def ui_command_delete(self, tag): ''' Deletes the Target Portal Group with TPG I{tag} from the target. The I{tag} must be a positive integer matching an existing TPG. SEE ALSO ======== B{create} ''' self.assert_root() tpg = TPG(self.rtsnode, tag, mode='lookup') tpg.delete() self.shell.log.info("Deleted TPG %s." % tag) self.refresh()
def ui_command_delete(self, tag): """ Deletes the Target Portal Group with TPGT I{tag} from the target. The I{tag} must be a positive integer matching an existing TPGT. SEE ALSO ======== B{create} """ self.assert_root() if tag.startswith("tpg"): tag = tag[3:] tpg = TPG(self.rtsnode, int(tag), mode="lookup") tpg.delete() self.shell.log.info("Deleted TPGT %s." % tag) self.refresh()
def ui_command_delete(self, tag): ''' Deletes the Target Portal Group with TPGT I{tag} from the target. The I{tag} must be a positive integer matching an existing TPGT. SEE ALSO ======== B{create} ''' self.assert_root() if tag.startswith("tpg"): tag = tag[3:] tpg = TPG(self.rtsnode, int(tag), mode='lookup') tpg.delete() self.shell.log.info("Deleted TPGT %s." % tag) self.refresh()
def apply_delete_obj(obj): ''' Deletes an object from the live system. ''' # TODO Factorize this when stable # TODO storage fabric cannot be deleted from the system, find a way to # handle this when i.e. path 'storage fileio' is in current config, but # no objects are hanging under it. root = get_root() log.debug("apply_delete(%s)" % obj.data) if obj.key[0] == 'mapped_lun': acl = obj.parent if acl.parent.key[0] == 'tpgt': tpg = acl.parent target = tpg.parent else: tpg = None target = acl.parent fabric = target.parent lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=target.key[1], mode='lookup') if tpg is None: tpgt = 1 else: tpgt = int(tpg.key[1]) lio_tpg = TPG(lio_target, tpgt, mode='lookup') node_wwn = acl.key[1] lio_acl = NodeACL(lio_tpg, node_wwn, mode='lookup') mlun = int(obj.key[1]) lio_mlun = MappedLUN(lio_acl, mlun) lio_mlun.delete() elif obj.key[0] == 'acl': if obj.parent.key[0] == 'tpgt': tpg = obj.parent target = tpg.parent else: tpg = None target = obj.parent fabric = target.parent lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=target.key[1], mode='lookup') if tpg is None: tpgt = 1 else: tpgt = int(tpg.key[1]) lio_tpg = TPG(lio_target, tpgt, mode='lookup') node_wwn = obj.key[1] lio_acl = NodeACL(lio_tpg, node_wwn, mode='lookup') lio_acl.delete() elif obj.key[0] == 'portal': if obj.parent.key[0] == 'tpgt': tpg = obj.parent target = tpg.parent else: tpg = None target = obj.parent fabric = target.parent lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=target.key[1], mode='lookup') if tpg is None: tpgt = 1 else: tpgt = int(tpg.key[1]) lio_tpg = TPG(lio_target, tpgt, mode='lookup') (address, _, port) = obj.key[1].partition(':') port = int(port) lio_portal = NetworkPortal(lio_tpg, address, port, mode='lookup') lio_portal.delete() elif obj.key[0] == 'lun': if obj.parent.key[0] == 'tpgt': tpg = obj.parent target = tpg.parent else: tpg = None target = obj.parent fabric = target.parent lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=target.key[1], mode='lookup') if tpg is None: tpgt = 1 else: tpgt = int(tpg.key[1]) lio_tpg = TPG(lio_target, tpgt, mode='lookup') lun = int(obj.key[1]) lio_lun = LUN(lio_tpg, lun) lio_lun.delete() elif obj.key[0] == 'tpgt': target = obj.parent fabric = target.parent lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=target.key[1], mode='lookup') tpgt = int(obj.key[1]) lio_tpg = TPG(lio_target, tpgt, mode='lookup') # FIXME IS this really needed ? lio_tpg.enable = True lio_tpg.delete() elif obj.key[0] == 'target': fabric = obj.parent wwn = obj.key[1] lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=wwn, mode='lookup') lio_target.delete() elif obj.key[0] == 'disk': plugin = obj.parent.key[1] name = obj.key[1] matching_lio_so = [ so for so in root.storage_objects if so.backstore.plugin == plugin and so.name == name ] log.debug("Looking for storage object %s in %s" % (obj.path_str, str([ "%s/%s" % (so.backstore.plugin, so.name) for so in root.storage_objects ]))) if len(matching_lio_so) > 1: raise ConfigError("Detected unsupported configfs storage objects " "allocation schema for storage object '%s'" % obj.path_str) elif len(matching_lio_so) == 0: raise ConfigError("Could not find storage object '%s'" % obj.path_str) else: lio_so = matching_lio_so[0] lio_so.delete()
def apply_delete_obj(obj): ''' Deletes an object from the live system. ''' # TODO Factorize this when stable # TODO storage fabric cannot be deleted from the system, find a way to # handle this when i.e. path 'storage fileio' is in current config, but # no objects are hanging under it. root = get_root() log.debug("apply_delete(%s)" % obj.data) if obj.key[0] == 'mapped_lun': acl = obj.parent if acl.parent.key[0] == 'tpgt': tpg = acl.parent target = tpg.parent else: tpg = None target = acl.parent fabric = target.parent lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=target.key[1], mode='lookup') if tpg is None: tpgt = 1 else: tpgt = int(tpg.key[1]) lio_tpg = TPG(lio_target, tpgt, mode='lookup') node_wwn = acl.key[1] lio_acl = NodeACL(lio_tpg, node_wwn, mode='lookup') mlun = int(obj.key[1]) lio_mlun = MappedLUN(lio_acl, mlun) lio_mlun.delete() elif obj.key[0] == 'acl': if obj.parent.key[0] == 'tpgt': tpg = obj.parent target = tpg.parent else: tpg = None target = obj.parent fabric = target.parent lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=target.key[1], mode='lookup') if tpg is None: tpgt = 1 else: tpgt = int(tpg.key[1]) lio_tpg = TPG(lio_target, tpgt, mode='lookup') node_wwn = obj.key[1] lio_acl = NodeACL(lio_tpg, node_wwn, mode='lookup') lio_acl.delete() elif obj.key[0] == 'portal': if obj.parent.key[0] == 'tpgt': tpg = obj.parent target = tpg.parent else: tpg = None target = obj.parent fabric = target.parent lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=target.key[1], mode='lookup') if tpg is None: tpgt = 1 else: tpgt = int(tpg.key[1]) lio_tpg = TPG(lio_target, tpgt, mode='lookup') (address, _, port) = obj.key[1].partition(':') port = int(port) lio_portal = NetworkPortal(lio_tpg, address, port, mode='lookup') lio_portal.delete() elif obj.key[0] == 'lun': if obj.parent.key[0] == 'tpgt': tpg = obj.parent target = tpg.parent else: tpg = None target = obj.parent fabric = target.parent lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=target.key[1], mode='lookup') if tpg is None: tpgt = 1 else: tpgt = int(tpg.key[1]) lio_tpg = TPG(lio_target, tpgt, mode='lookup') lun = int(obj.key[1]) lio_lun = LUN(lio_tpg, lun) lio_lun.delete() elif obj.key[0] == 'tpgt': target = obj.parent fabric = target.parent lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=target.key[1], mode='lookup') tpgt = int(obj.key[1]) lio_tpg = TPG(lio_target, tpgt, mode='lookup') # FIXME IS this really needed ? lio_tpg.enable = True lio_tpg.delete() elif obj.key[0] == 'target': fabric = obj.parent wwn = obj.key[1] lio_fabric = FabricModule(fabric.key[1]) lio_target = Target(lio_fabric, wwn=wwn, mode='lookup') lio_target.delete() elif obj.key[0] == 'disk': plugin = obj.parent.key[1] name = obj.key[1] matching_lio_so = [so for so in root.storage_objects if so.backstore.plugin == plugin and so.name == name] log.debug("Looking for storage object %s in %s" % (obj.path_str, str(["%s/%s" % (so.backstore.plugin, so.name) for so in root.storage_objects]))) if len(matching_lio_so) > 1: raise ConfigError("Detected unsupported configfs storage objects " "allocation schema for storage object '%s'" % obj.path_str) elif len(matching_lio_so) == 0: raise ConfigError("Could not find storage object '%s'" % obj.path_str) else: lio_so = matching_lio_so[0] lio_so.delete()