Beispiel #1
0
def unregister_users_direct(options, config):
    """ unregisters the users configured at SCST. This
	function bypasses the information given by the monitor. Therefore
	this function can be used to unregister the users if dedupv1d is not
	available
    """
    try:
        for (tid, t) in iscsi_scst.get_targets().items():
            target_users = iscsi_scst.get_users_in_target(t)
            for u in target_users:
                try:
                    log_verbose(options, "Remove user %s from %s" % (u.name, t.name()))
                    iscsi_scst.rm_user_from_target(u, t)
                except scst.ScstException as e:
                    log_error(options, "Failed to remove user %s from %s: %s" % (u.name, t.name(), str(e)))
    except scst.ScstException as e:
        log_error(options, "Failed to remove users: %s" % (str(e)))
Beispiel #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))
Beispiel #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))
Beispiel #4
0
def bootstrap_system(dedupv1_root, monitor, options, config):
    """ bootstraps the SCST system
    """
    if not check_root():
        log_error(options, "Permission denied")
        sys.exit(1)

    if is_running(config):
        if options.force:
            log_info(options, "Lock file exists. Forcing start")
            lock_filename = config.get("daemon.lockfile")
            if os.path.exists(lock_filename):
                os.unlink(lock_filename)
        else:
            raise Exception("dedupv1d running")

    daemon_user = config.get("daemon.user")
    daemon_group = config.get("daemon.group")
    daemon_port = config.get("iscsi.port", None)
    daemon_host = config.get("iscsi.host", None)

    check_iscsi = True
    no_iscsi = config.get("daemon.no-iscsi", "False")
    if no_iscsi == "True" or no_iscsi == "true":
        check_iscsi = False

    validate_dedupv1(dedupv1_root, daemon_user, daemon_group)
    scst.check_scst(group_name = daemon_group)
    scst.validate_scst(group_name = daemon_group)
    if check_iscsi:
        # In root mode, use the root group
        if not daemon_group:
            daemon_group = "root"
        iscsi_scst.start_iscsi(group_name = daemon_group,
                port = daemon_port,
                host = daemon_host)
        iscsi_scst.validate_iscsi()