From mboxrd@z Thu Jan 1 00:00:00 1970 From: Todd Deshane Date: Sun, 23 Jul 2006 04:49:33 +0000 Subject: mapping device name to iscsi target Message-Id: <1153630174.15463.45.camel@localhost> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org Hi, I know this topic has came up before on this list, but I still don't have a reliable solution. It was suggested to use the persistent device naming which comes with udev: http://www.kernel.org/git/?p=3Dlinux/hotplug/udev.git;a=3Dblob;f=3Detc/udev= /60-persistent-storage.rules (see: http://marc.theaimsgroup.com/?l=3Dlinux-hotplug-devel&m=115036155509938&w= =3D2 for details) since it gives the /dev/disk entries such as by-id,by-label and by-uuid, but i am not sure how to map the uuid back to the iscsi target. Has anyone done this successful or have any ideas? Also, the idea of using the bus id %b seems like a good idea, (see this thread: http://marc.theaimsgroup.com/?l=3Dlinux-hotplug-devel&m=106928672620090&w= =3D2 for details) but doesn't appear to be reliable enough: here is the code if have for it so far for it: I used the rule: BUS=3D"scsi", PROGRAM=3D"/lib/udev/iscsidev %b" NAME=3D"%c%n" SYMLINK=3D"= %k" with the /lib/udev/iscsidev script as follows: #!/usr/bin/python import sys import os import re arg =3D sys.argv[1] (targname,bus,targ,lun) =3D arg.split(':') for targets in os.popen('/sbin/iscsiadm -m session','r').readlines(): toMatch =3D re.compile('\[0*' + str(targname) + ':') isMatch =3D toMatch.search(targets) if(isMatch): (head,addr,target_name) =3D targets.split(); sys.stdout.write(target_name) script is based off of the perl version in: http://groups.google.com/group/open-iscsi/browse_thread/thread/bc050f805c8f= 85c/fb0ff969e8da7629?q=3Dudev&lnk=3Dgst&rnum=3D2#fb0ff969e8da7629 In most cases this seems to work perfectly... it prints out the target name and there is a nice mapping (targetname to actual device). However, the problem seems to be that the bus id %b in the udev rule above can get out of sync with targname in the script. targname refers to the 'xx' in the output of the command iscsiadm -m session for example: # iscsiadm -m session [xx:] :,1 targetname with a quick look at the source code the xx seems to refer to the session id, which is not necessarily the same as the bus id, hence the problem of out of sync. So, what is the recommended way to get this mapping that is reliable? Any experience with this? ideas/suggestions? Thanks in advance, Todd ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=DEVD= EV _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel