def initiator_set_auth(req, initiator_wwn, in_user, in_pass, out_user, out_pass): fm = FabricModule('iscsi') t = Target(fm, target_name) tpg = TPG(t, 1) na = NodeACL(tpg, initiator_wwn) if not in_user or not in_pass: # rtslib treats '' as its NULL value for these in_user = in_pass = '' if not out_user or not out_pass: out_user = out_pass = '' na.chap_userid = in_user na.chap_password = in_pass na.chap_mutual_userid = out_user na.chap_mutual_password = out_pass RTSRoot().save_to_file()
def export_destroy(req, pool, vol, initiator_wwn): mod = pool_module(pool) fm = FabricModule('iscsi') t = Target(fm, target_name) tpg = TPG(t, 1) na = NodeACL(tpg, initiator_wwn) pool_dev_name = mod.pool2dev_name(pool) for mlun in na.mapped_luns: # all SOs are Block so we can access udev_path safely if mod.has_udev_path(mlun.tpg_lun.storage_object.udev_path): mlun_vg, mlun_name = \ mod.split_udev_path(mlun.tpg_lun.storage_object.udev_path) if mlun_vg == pool_dev_name and mlun_name == vol: tpg_lun = mlun.tpg_lun mlun.delete() # be tidy and delete unused tpg lun mappings? if not any(tpg_lun.mapped_luns): so = tpg_lun.storage_object tpg_lun.delete() so.delete() break else: raise TargetdError(TargetdError.NOT_FOUND_VOLUME_EXPORT, "Volume '%s' not found in %s exports" % (vol, initiator_wwn)) # Clean up tree if branch has no leaf if not any(na.mapped_luns): na.delete() if not any(tpg.node_acls): tpg.delete() if not any(t.tpgs): t.delete() RTSRoot().save_to_file()
def create_acl(self, tpg, initiator_name): acl = None wwn = tpg.parent_target.wwn acl_list = self.target[wwn]['tpg'][tpg.tag]['acl'] if initiator_name in acl_list: Log.info('acl (%s, %s) already exists, not creating' % (tpg, initiator_name)) acl = acl_list[initiator_name] else: Log.info('creating acl (%s, %s)' % (tpg, initiator_name)) acl = NodeACL(tpg, initiator_name) acl_list[initiator_name] = acl return acl
def export_destroy(req, pool, vol, initiator_wwn): pool_check(pool) fm = FabricModule('iscsi') t = Target(fm, target_name) tpg = TPG(t, 1) na = NodeACL(tpg, initiator_wwn) vg_name, thin_pool = get_vg_lv(pool) for mlun in na.mapped_luns: # all SOs are Block so we can access udev_path safely mlun_vg, mlun_name = \ mlun.tpg_lun.storage_object.udev_path.split("/")[2:] if mlun_vg == vg_name and mlun_name == vol: tpg_lun = mlun.tpg_lun mlun.delete() # be tidy and delete unused tpg lun mappings? if not any(tpg_lun.mapped_luns): so = tpg_lun.storage_object tpg_lun.delete() so.delete() break else: raise TargetdError(-151, "Volume '%s' not found in %s exports" % (vol, initiator_wwn)) # Clean up tree if branch has no leaf if not any(na.mapped_luns): na.delete() if not any(tpg.node_acls): tpg.delete() if not any(t.tpgs): t.delete() RTSRoot().save_to_file()
def export_destroy(req, pool, vol, initiator_wwn): pool_check(pool) fm = FabricModule('iscsi') t = Target(fm, target_name) tpg = TPG(t, 1) na = NodeACL(tpg, initiator_wwn) vg_name, thin_pool = get_vg_lv(pool) for mlun in na.mapped_luns: # all SOs are Block so we can access udev_path safely mlun_vg, mlun_name = \ mlun.tpg_lun.storage_object.udev_path.split("/")[2:] if mlun_vg == vg_name and mlun_name == vol: tpg_lun = mlun.tpg_lun mlun.delete() # be tidy and delete unused tpg lun mappings? if not any(tpg_lun.mapped_luns): so = tpg_lun.storage_object tpg_lun.delete() so.delete() break else: raise TargetdError( -151, "Volume '%s' not found in %s exports" % (vol, initiator_wwn)) # Clean up tree if branch has no leaf if not any(na.mapped_luns): na.delete() if not any(tpg.node_acls): tpg.delete() if not any(t.tpgs): t.delete() RTSRoot().save_to_file()
def export_create(req, pool, vol, initiator_wwn, lun): fm = FabricModule('iscsi') t = Target(fm, target_name) tpg = TPG(t, 1) tpg.enable = True tpg.set_attribute("authentication", '0') NetworkPortal(tpg, "0.0.0.0") na = NodeACL(tpg, initiator_wwn) tpg_lun = _tpg_lun_of(tpg, pool, vol) # only add mapped lun if it doesn't exist for tmp_mlun in tpg_lun.mapped_luns: if tmp_mlun.mapped_lun == lun and tmp_mlun.parent_nodeacl == na: break else: MappedLUN(na, lun, tpg_lun) RTSRoot().save_to_file()