Since nobody got nothing I am asking you what do you think of this solution. I still have lots of testing to do, but so far it works:
1. I have created /etc/iscsi/persistent.names.conf. It looks like this:
iqn.2100-05.si.ozs:diski.sas;0;iscsi/win_portal
iqn.2100-05.si.ozs:diski.sas;1;iscsi/dns1
iqn.2100-05.si.ozs:diski.sas;2;iscsi/dns2
2. I have created /etc/udev/rules.d/60-persistent-iscsi.rules. It looks like this:
# This file maintains persistent names for iscsi disks.
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", IMPORT{program}="path_id %p"
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", PROGRAM="/usr/bin/persistent_iscsi.rb $env{ID_PATH}", SYMLINK+="%c"
3. And finaly I have created this Ruby script, since I do almost all my programing in Ruby.
#!/usr/bin/ruby
# id looks like this: ip-192.168.1.221:3260-iscsi-iqn.2100-05.si.ozs:diski.sas-lun-0
device = nil
id = ARGV.first
# parse id on - sign
a = id.split('-')
# get lun and iqn
id_iqn = a[3] + '-' + a[4]
id_lun = a[6]
# third part should be iscsi
exit 1 unless a[2] == 'iscsi'
# read my configuration file /etc/iscsi/persistent.names.conf
File.new('/etc/iscsi/persistent.names.conf').readlines.each do |line|
# config line looks like this: iqn.2100-05.si.ozs:diski.sas;2;iscsi/dns1
iqn, lun, dev = line.chomp.split(';')
if iqn == id_iqn and lun == id_lun
device = dev
break
end
end
# Error if not found
exit 1 if device.nil?
# out device name on stdout
puts device
by
TheR
Last edited by TheR_; 09-09-2009 at 07:51 AM.
|