Example #1
0
def unregister_targets_direct(options, config):
    """ unregister a given configured at SCST. This
	function bypasses the information given by the monitor. Therefore
	this function can be used to unregister a target if dedupv1d is not
	available
    """
    try:
        for (tid, t) in iscsi_scst.get_targets().items():
            try:
                log_verbose(options, "Remove target %s" % (t.name()))
                iscsi_scst.unregister_target(t)
            except scst.ScstException as e:
                log_warning(options, "Failed to unregister target %s: %s" % (t.name(), str(e)))
    except scst.ScstException as e:
        log_warning("Failed to unregister targets: %s" % (str(e)))
Example #2
0
def unregister_targets(monitor, options, config):
    """ unregisters the targets configured at SCST. This
	function bypasses the information given by the monitor. Therefore
	this function can be used to unregister the targets if dedupv1d is not
	available
    """
    try:
        for (tid, t) in target.read_all_targets(monitor).items():
            try:
                if iscsi_scst.is_target_registered(t):
                    iscsi_scst.unregister_target(t)

                group_name = "Default_" + t.name()
                if len(t.volumes()) > 0 and scst.exists_group(group_name):
                    scst.rm_group(group_name)

                log_verbose(options, "Target %s unregistered" % t.name())
            except scst.ScstException as e:
                if options.force:
                    log_warning("Failed to unregister target %s: %s" % (t.name(), str(e)))
                else:
                    raise scst.ScstException("Failed to unregister target %s" % (t.name()), e)
    except IOError as e:
        handle_exception(options, e)