RE: Help with RTSLib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Everyone,

First time posting here.   I'm trying to write a script that automatically sets up targets at boot time.  I created it with python.  It reads in a list of target and initiator wwn's and tries to map them.  So far so good with a one to one mapping of wwn's.  I'm running into a problem when I have multiple initiators mapped to one target.  RTSLib says I can't have multiple initiator acl's.  The thing I don't understand is that the targetcli does this without issue.

Any help would be greatly appreciated!  Here's the snippet of code I am stuck on and the error message I'm receiving:

#acl_wwn is a list of wwn's.
def createTarget(lun_id,name,dev_path,acl_wwn,fabric_wwn):
                #acl_wwn[] could have multiple values.  Map each to the same lun
                print 'Creating target: "' + str(lun_id) + '" "' + name+ '" "' + dev_path + '" "' + acl_wwn[0].rstrip('\n') + '" "' + fabric_wwn + '"'
                backstore = IBlockBackstore(lun_id, mode='create')
                try:
                                so = IBlockStorageObject(backstore, name, dev=dev_path, gen_wwn=True)
                except:
                                backstore.delete()
                                raise

                # Create an FC target endpoint using a qla2xxx WWPN
                fabric = FabricModule('qla2xxx')
                target = Target(fabric, fabric_wwn)
                #tpg = TPG(target, lun_id)

                # Export LUN id# via the 'so' StorageObject class
                # Setup the NodeACL for an FC initiator, and create MappedLUN 0
                #map_lun = tpg.lun(lun_id, so, name)

                for a in acl_wwn:
                                tpg = TPG(target, lun_id)
                                map_lun = tpg.lun(lun_id, so, name)
                                a = a.rstrip('\n')
                                #node_acl = tpg.node_acl(a)
                                #mapped_lun = node_acl.mapped_lun(mapped_lun=map_lun.lun, tpg_lun=map_lun.lun, write_protect=False)
                                node_acl = NodeACL(tpg, a, mode="create")
                                MappedLUN(node_acl, map_lun.lun, map_lun.lun, write_protect=False)


And the output:
root@dlcephproxy01b:/etc/init.d# ./rbdmount -c /etc/ceph/mounts
Qlini mode is disabled.  Proceeding forward
mapping: dvmesx01_lun1
mapping: lwhyperv01_lun1
updating: /dev/rbd1
updating: /dev/rbd2
Creating target: "1" "dvmesx01_lun1" "/dev/rbd1" "10:00:00:00:c9:e0:4a:19" "21:00:00:1b:32:18:b4:0f"
Traceback (most recent call last):
  File "./rbdmount", line 131, in <module>
    main()
  File "./rbdmount", line 127, in main
    createTarget(m.rbd_id,m.image_name,m.device,m.initiator_wwn,m.target_wwn)
  File "./rbdmount", line 82, in createTarget
    map_lun = tpg.lun(lun_id, so, name)
  File "/usr/lib/python2.7/dist-packages/rtslib/target.py", line 1176, in lun
    return LUN(self, lun=lun, storage_object=storage_object, alias=alias)
  File "/usr/lib/python2.7/dist-packages/rtslib/target.py", line 399, in __init__
    self._create_in_cfs_ine('create')
  File "/usr/lib/python2.7/dist-packages/rtslib/target.py", line 409, in _create_in_cfs_ine
    super(LUN, self)._create_in_cfs_ine(mode)
  File "/usr/lib/python2.7/dist-packages/rtslib/node.py", line 66, in _create_in_cfs_ine
    % self.__class__.__name__)
rtslib.utils.RTSLibError: This LUN already exists in configFS.


Depending on how I rework the code I get something like this:

root@dlcephproxy01b:/etc/init.d# rbd showmapped
id pool image           snap device
3  csc  dvmesx01_lun1   -    /dev/rbd3
4  csc  lwhyperv01_lun1 -    /dev/rbd4
root@dlcephproxy01b:/etc/init.d# rbd unmap /dev/rbd3
root@dlcephproxy01b:/etc/init.d# rbd unmap /dev/rbd4
root@dlcephproxy01b:/etc/init.d# ./rbdmount -c /etc/ceph/mounts
Qlini mode is disabled.  Proceeding forward
mapping: dvmesx01_lun1
mapping: lwhyperv01_lun1
updating: /dev/rbd1
updating: /dev/rbd2
Creating target: "1" "dvmesx01_lun1" "/dev/rbd1" "10:00:00:00:c9:e0:4a:19" "21:00:00:1b:32:18:b4:0f"
Creating target: "2" "lwhyperv01_lun1" "/dev/rbd2" "10:00:00:00:c9:81:da:43" "21:00:00:1b:32:18:b4:0f"
Traceback (most recent call last):
  File "./rbdmount", line 129, in <module>
    main()
  File "./rbdmount", line 125, in main
    createTarget(m.rbd_id,m.image_name,m.device,m.initiator_wwn,m.target_wwn)
  File "./rbdmount", line 74, in createTarget
    tpg = TPG(target, lun_id)
  File "/usr/lib/python2.7/dist-packages/rtslib/target.py", line 999, in __init__
    raise RTSLibError("Target cannot have multiple TPGs.")
rtslib.utils.RTSLibError: Target cannot have multiple TPGs.


Thanks,
Chris Holcombe

________________________________

NOTICE: This e-mail and any attachments is intended only for use by the addressee(s) named herein and may contain legally privileged, proprietary or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this email, and any attachments thereto, is strictly prohibited. If you receive this email in error please immediately notify me via reply email or at (800) 927-9800 and permanently delete the original copy and any copy of any e-mail, and any printout.
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux