def run(self, args):
        # Regenerate if secret.pem.pub not exists
        if not os.path.exists(SECRET_PEM + ".pub"):
            # Cleanup old files
            for f in glob.glob(SECRET_PEM + "*"):
                os.remove(f)

            execute(["ssh-keygen", "-N", "", "-f", SECRET_PEM])

        # Regenerate if ssh_tar.pem.pub not exists
        if not os.path.exists(TAR_SSH_PEM + ".pub"):
            # Cleanup old files
            for f in glob.glob(TAR_SSH_PEM + "*"):
                os.remove(f)

            execute(["ssh-keygen", "-N", "", "-f", TAR_SSH_PEM])

        # Add required prefixes if prefix is not "container"
        prefix_secret_pem_pub = ""
        prefix_tar_ssh_pem_pub = ""
        if args.no_prefix != "no-prefix":
            prefix_secret_pem_pub = GSYNCD_CMD
            prefix_tar_ssh_pem_pub = TAR_CMD

        data = {"default_pub": "", "tar_pub": ""}
        with open(SECRET_PEM + ".pub") as f:
            data["default_pub"] = prefix_secret_pem_pub + f.read().strip()

        with open(TAR_SSH_PEM + ".pub") as f:
            data["tar_pub"] = prefix_tar_ssh_pem_pub + f.read().strip()

        node_output_ok(data)
コード例 #2
0
def stop_service(service):
    rc, out, err = disable_service(service)
    if rc != 0:
        return (rc, out, err)

    cmd = ["systemctl", "stop", service]
    return execute(cmd)
コード例 #3
0
def start_service(service):
    rc, out, err = enable_service(service)
    if rc != 0:
        return (rc, out, err)

    cmd = ["systemctl", "start", service]
    return execute(cmd)
コード例 #4
0
ファイル: peer_eventsapi.py プロジェクト: Junsu/glusterfs
def stop_service(service):
    rc, out, err = disable_service(service)
    if rc != 0:
        return (rc, out, err)

    cmd = ["systemctl", "stop", service]
    return execute(cmd)
コード例 #5
0
ファイル: peer_eventsapi.py プロジェクト: Junsu/glusterfs
def start_service(service):
    rc, out, err = enable_service(service)
    if rc != 0:
        return (rc, out, err)

    cmd = ["systemctl", "start", service]
    return execute(cmd)
コード例 #6
0
    def run(self, args):
        m = MountbrokerUserMgmt(GLUSTERD_VOLFILE)
        data = m.info()
        data["group_exists"] = False
        data["path_exists"] = False

        rc, out, err = execute(
            ["getent", "group", data["geo-replication-log-group"]])

        if rc == 0:
            data["group_exists"] = True

        if os.path.exists(data["mountbroker-root"]):
            data["path_exists"] = True

        node_output_ok(data)
コード例 #7
0
def disable_service(service):
    if is_enabled(service):
        cmd = ["systemctl", "disable", service]
        return execute(cmd)

    return (0, "", "")
コード例 #8
0
def is_active(service):
    rc, out, err = execute(["systemctl", "is-active", service])
    return rc == 0
コード例 #9
0
def is_enabled(service):
    rc, out, err = execute(["systemctl", "is-enabled", service])
    return rc == 0
コード例 #10
0
def reload_service(service):
    if is_active(service):
        cmd = ["systemctl", "reload", service]
        return execute(cmd)

    return (0, "", "")
コード例 #11
0
    def run(self, args):
        m = MountbrokerUserMgmt(GLUSTERD_VOLFILE)

        try:
            os.makedirs(args.mount_root)
        except OSError as e:
            if e.errno == EEXIST:
                pass
            else:
                node_output_notok("Unable to Create {0}".format(
                    args.mount_root))

        execute(["chmod", "0711", args.mount_root])
        try:
            execute(
                ["semanage", "fcontext", "-a", "-e", "/home", args.mount_root])
        except OSError as e:
            if e.errno == ENOENT:
                pass
            else:
                node_output_notok("Unable to run semanage: {0}".format(e))

        try:
            execute(["restorecon", "-Rv", args.mount_root])
        except OSError as e:
            if e.errno == ENOENT:
                pass
            else:
                node_output_notok("Unable to run restorecon: {0}".format(e))

        rc, out, err = execute(["getent", "group", args.group])
        if rc != 0:
            node_output_notok("User Group not exists")

        execute(["chgrp", "-R", args.group, GEOREP_DIR])
        execute(["chgrp", "-R", args.group, LOG_DIR])
        execute(["chmod", "-R", "770", GEOREP_DIR])
        execute(["chmod", "-R", "770", args.group, LOG_DIR])

        m.set_mount_root_and_group(args.mount_root, args.group)
        m.save()

        node_output_ok()
コード例 #12
0
ファイル: peer_eventsapi.py プロジェクト: Junsu/glusterfs
def disable_service(service):
    if is_enabled(service):
        cmd = ["systemctl", "disable", service]
        return execute(cmd)

    return (0, "", "")
コード例 #13
0
ファイル: peer_eventsapi.py プロジェクト: Junsu/glusterfs
def is_active(service):
    rc, out, err = execute(["systemctl", "is-active", service])
    return rc == 0
コード例 #14
0
ファイル: peer_eventsapi.py プロジェクト: Junsu/glusterfs
def is_enabled(service):
    rc, out, err = execute(["systemctl", "is-enabled", service])
    return rc == 0
コード例 #15
0
ファイル: peer_eventsapi.py プロジェクト: Junsu/glusterfs
def reload_service(service):
    if is_active(service):
        cmd = ["systemctl", "reload", service]
        return execute(cmd)

    return (0, "", "")