Example #1
0
def unregister_groups(monitor, options, config):
    """ unregisters the groups of the dedupv1d
    """
    for (group_name, g) in group.read_all_groups(monitor).items():
        try:
            for pattern in g.initiator_pattern():
                scst.rm_initiator_pattern_from_group(pattern, group_name)
            if not group_name == "Default" and scst.exists_group(group_name):
                # The Default group cannot be deleted
                scst.rm_group(group_name)

            log_verbose(options, "Group %s unregistered" % group_name)
        except scst.ScstException as e:
            handle_exception(options, e)
Example #2
0
def unregister_group_direct(option, config, groups):
    try:
        all_groups = scst.get_scst_groups()
        for (group_name) in groups:
            try:
                if options.verbose:
                    log_verbose(options, "Remove group %s" % (group_name))

                if not group_name in all_groups:
                    raise scst.ScstException("Group %s not existing" % (group_name))
                for ip in scst.get_initiator_pattern_in_group(group_name):
                    scst.rm_initiator_pattern_from_group(ip, group_name)

                if group_name != "Default":
                    scst.rm_group(group_name)
            except scst.ScstException as e:
                log_error(options, "Failed to remove group %s: %s" % (group_name, e))
    except scst.ScstException as e:
        log_error("Failed to remove groups: %s" % (e))
Example #3
0
def unregister_groups_direct(options, config):
    """ unregisters the groups configured at SCST. This
	function bypasses the information given by the monitor. Therefore
	this function can be used to unregister the groups if dedupv1d is not
	available
    """
    try:
        for (group_name) in scst.get_scst_groups():
            try:
                if options.verbose:
                    log_info(options, "Remove group %s" % (group_name))
                for ip in scst.get_initiator_pattern_in_group(group_name):
                    scst.rm_initiator_pattern_from_group(ip, group_name)

                for device_name in scst.get_devices_in_group(group_name):
                    scst.rm_from_group(device_name, group_name)

                if group_name != "Default":
                    scst.rm_group(group_name)
            except scst.ScstException as e:
                log_error(options,  "Failed to remove group %s: %s" % (group_name, e))
    except scst.ScstException as e:
        log_error(options, "Failed to remove groups: %s" % (e))
Example #4
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)