Class: Dcmgr::Drivers::LinuxIscsi
Constant Summary
collapse
- IQN_PREFIX =
"iqn.2010-09.jp.wakame".freeze
Instance Attribute Summary
Attributes inherited from IscsiTarget
#node
Instance Method Summary
collapse
#sh, #tryagain
Methods included from Logger
create, default_logdev, included
Methods inherited from IscsiTarget
select_iscsi_target
Instance Method Details
#create(ctx) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/dcmgr/drivers/linux_iscsi.rb', line 11
def create(ctx)
@volume = ctx.volume
@volume_id = ctx.volume_id
@node = ctx.node
vol_path = File.join(@volume[:storage_node][:export_path], @volume[:account_id], @volume[:uuid])
@volume[:transport_information] = iscsi = {}
iscsi[:iqn] = "#{IQN_PREFIX}:#{@volume[:account_id]}.#{@volume[:uuid]}"
iscsi[:tid] = pick_next_tid
iscsi[:lun] = 1
iscsi[:backing_store] = vol_path
register(@volume)
opt = { :iqn => iscsi[:iqn], :lun => iscsi[:lun], :tid => iscsi[:tid], :backing_store => iscsi[:backing_store] }
end
|
#delete(ctx) ⇒ Object
29
30
31
32
|
# File 'lib/dcmgr/drivers/linux_iscsi.rb', line 29
def delete(ctx)
@volume = ctx.volume
sh("/usr/sbin/tgt-admin --delete #{@volume[:transport_information][:iqn]}")
end
|
#register(volume) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/dcmgr/drivers/linux_iscsi.rb', line 34
def register(volume)
tinfo = volume[:transport_information]
sh("/usr/sbin/tgtadm --lld iscsi --op new --mode=target --tid=%s --targetname %s", [tinfo[:tid], tinfo[:iqn]])
sh("/usr/sbin/tgtadm --lld iscsi --op new --mode=logicalunit --tid=%s --lun=%s -b %s",
[tinfo[:tid], tinfo[:lun], tinfo[:backing_store]])
sh("/usr/sbin/tgtadm --lld iscsi --op bind --mode=target --tid=%s --initiator-address=%s",
[tinfo[:tid], node.manifest.config.initiator_address])
end
|