Beispiel #1
0
def remove_share(id):
    """Disable a fileshare link."""
    try:
        client().files.remove_share(id)
        logger.success('ctl:links:delete', 'Deleted share {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #2
0
def remove_share(id):
    """Disable a fileshare link."""
    try:
        client().files.remove_share(id)
        logger.success('ctl:links:delete', 'Deleted share {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #3
0
def add(name, type_id):
    """Add a database."""
    try:
        client().databases.add(name, "db-" + type_id)
        logger.success('ctl:db:create', 'Added {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #4
0
def delete(id):
    """Delete a network connection"""
    try:
        client().networks.delete(id)
        logger.success('ctl:net:delete', 'Deleted {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #5
0
def add_user(name, type_id):
    """Add a database user."""
    try:
        client().databases.add_user(name, type_id)
        logger.success('ctl:dbusr:add', 'Added user {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #6
0
def add_domain(name):
    """Add a domain to arkOS LDAP"""
    try:
        client().roles.add_domain(name)
        logger.success('ctl:dom:add', 'Added {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #7
0
def delete_domain(name):
    """Delete an arkOS LDAP domain"""
    try:
        client().roles.delete_domain(name)
        logger.success('ctl:dom:delete', 'Deleted {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #8
0
def update_share(id, expires):
    """Update a fileshare link's expiration."""
    try:
        client().files.update_share(id, expires)
        logger.success('ctl:links:update', 'Updated share {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #9
0
def update_share(id, expires):
    """Update a fileshare link's expiration."""
    try:
        client().files.update_share(id, expires)
        logger.success('ctl:links:update', 'Updated share {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #10
0
def disable(id):
    """Disable mounting a filesystem on boot"""
    try:
        client().filesystems.disable(id)
        logger.success('ctl:fs:disable', 'Disabled {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #11
0
def local(id):
    """Allow local network access only to service"""
    try:
        client().security.update_policy(id, "local")
        logger.success('ctl:sec:local', 'Access to {0} restricted'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #12
0
def block(id):
    """Block all network access to service"""
    try:
        client().security.update_policy(id, "block")
        logger.success('ctl:sec:block', 'Access to {0} blocked'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #13
0
def block(id):
    """Block all network access to service"""
    try:
        client().security.update_policy(id, "block")
        logger.success('ctl:sec:block', 'Access to {0} blocked'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #14
0
def allow(id):
    """Allow all access to service"""
    try:
        client().security.update_policy(id, "allow")
        logger.success('ctl:sec:allow', 'Access to {0} allowed'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #15
0
def allow(id):
    """Allow all access to service"""
    try:
        client().security.update_policy(id, "allow")
        logger.success('ctl:sec:allow', 'Access to {0} allowed'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #16
0
def local(id):
    """Allow local network access only to service"""
    try:
        client().security.update_policy(id, "local")
        logger.success('ctl:sec:local', 'Access to {0} restricted'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #17
0
def update():
    """Updates system package index"""
    try:
        client().packages.get(refresh=True)
        logger.success('ctl:pkg:update', 'Index updated')
    except Exception as e:
        raise CLIException(str(e))
Beispiel #18
0
def edit(id, address, port, new_name):
    """Edit a website"""
    try:
        client().websites.edit(id, new_name, address, port)
        logger.success('ctl:site:edit', 'Edited {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #19
0
def update(id):
    """Update a website"""
    try:
        client().websites.update(id)
        logger.success('ctl:site:update', 'Updated {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #20
0
def delete(id):
    """Delete a certificate."""
    try:
        client().certificates.delete(id=id)
        logger.success('ctl:cert:delete', 'Deleted {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #21
0
def drop_user(name):
    """Delete a database user."""
    try:
        client().databases.delete_user(name)
        logger.success('ctl:dbusr:drop', 'Dropped {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #22
0
def connect(id):
    """Connect to a network"""
    try:
        client().networks.connect(id)
        logger.success('ctl:net:connect', 'Connected {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #23
0
def enable(id):
    """Mount a filesystem on boot"""
    try:
        client().filesystems.enable(id)
        logger.success('ctl:fs:enable', 'Enabled {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #24
0
def add_user(name, type_id):
    """Add a database user."""
    try:
        client().databases.add_user(name, type_id)
        logger.success('ctl:dbusr:add', 'Added user {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #25
0
def add(name, type_id):
    """Add a database."""
    try:
        client().databases.add(name, "db-" + type_id)
        logger.success('ctl:db:create', 'Added {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #26
0
def drop_user(name):
    """Delete a database user."""
    try:
        client().databases.delete_user(name)
        logger.success('ctl:dbusr:drop', 'Dropped {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #27
0
def delete(id):
    """Delete a virtual disk"""
    try:
        client().filesystems.delete(id)
        logger.success('ctl:fs:delete', 'Deleted {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #28
0
def add_group(name, users):
    """Add a group to arkOS LDAP"""
    try:
        client().roles.add_group(name, users)
        logger.success('ctl:grp:add', 'Added {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #29
0
def update(id):
    """Update a website"""
    try:
        client().websites.update(id)
        logger.success('ctl:site:update', 'Updated {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #30
0
def delete(id):
    """Delete a certificate."""
    try:
        client().certificates.delete(id=id)
        logger.success('ctl:cert:delete', 'Deleted {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #31
0
def enable(id):
    """Enable connection to a network on boot"""
    try:
        client().networks.enable(id)
        logger.success('ctl:net:enable', 'Enabled {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #32
0
def disconnect(id):
    """Disconnect from a network"""
    try:
        client().networks.disconnect(id)
        logger.success('ctl:net:disconnect', 'Disconnected {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #33
0
def add_group(name, users):
    """Add a group to arkOS LDAP"""
    try:
        client().roles.add_group(name, users)
        logger.success('ctl:grp:add', 'Added {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #34
0
def edit(id, address, port, new_name):
    """Edit a website"""
    try:
        client().websites.edit(id, new_name, address, port)
        logger.success('ctl:site:edit', 'Edited {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #35
0
def umount(id):
    """Unmount a filesystem"""
    try:
        client().filesystems.umount(id)
        logger.success('ctl:fs:umount', 'Unmounted {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #36
0
def add_domain(name):
    """Add a domain to arkOS LDAP"""
    try:
        client().roles.add_domain(name)
        logger.success('ctl:dom:add', 'Added {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #37
0
def disable(id):
    """Disable a website"""
    try:
        client().websites.disable(id)
        logger.success('ctl:site:disable', 'Disabled {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #38
0
def umount(id):
    """Unmount a filesystem"""
    try:
        client().filesystems.umount(id)
        logger.success('ctl:fs:umount', 'Unmounted {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #39
0
def enable(id):
    """Mount a filesystem on boot"""
    try:
        client().filesystems.enable(id)
        logger.success('ctl:fs:enable', 'Enabled {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #40
0
def disable(id):
    """Disable mounting a filesystem on boot"""
    try:
        client().filesystems.disable(id)
        logger.success('ctl:fs:disable', 'Disabled {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #41
0
def delete(id):
    """Delete a virtual disk"""
    try:
        client().filesystems.delete(id)
        logger.success('ctl:fs:delete', 'Deleted {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #42
0
def disable(name):
    """Disable a service on boot"""
    try:
        client().services.disable(name)
        logger.success('ctl:svc:disable', 'Disabled {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #43
0
def update():
    """Updates system package index"""
    try:
        client().packages.get(refresh=True)
        logger.success('ctl:pkg:update', 'Index updated')
    except Exception as e:
        raise CLIException(str(e))
Beispiel #44
0
def stop(name):
    """Stop a service"""
    try:
        client().services.stop(name)
        logger.success('ctl:svc:stop', 'Stopped {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #45
0
def disable(id):
    """Disable a website"""
    try:
        client().websites.disable(id)
        logger.success('ctl:site:disable', 'Disabled {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #46
0
def delete_domain(name):
    """Delete an arkOS LDAP domain"""
    try:
        client().roles.delete_domain(name)
        logger.success('ctl:dom:delete', 'Deleted {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #47
0
def dump(name, path):
    """Export database to SQL file."""
    try:
        data = client().databases.dump(name)
        path.write(data)
        logger.success('ctl:db:dump', 'Database dumped to {0}'.format(path))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #48
0
def add_user(name, password, domain, first_name, last_name, admin, sudo):
    """Add a user to arkOS LDAP"""
    try:
        client().roles.add_user(
            name, password, domain, first_name, last_name, admin, sudo)
        logger.success('ctl:usr:add', 'Added {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #49
0
def chmod(user_name, db_name, grant):
    """Get or set database user permissions."""
    try:
        cmd = client().databases.user_chmod
        cmd(user_name, "grant" if grant else "revoke")
        logger.success('ctl:dbusr:chmod', 'Permissions set')
    except Exception as e:
        raise CLIException(str(e))
Beispiel #50
0
def add_user(name, password, domain, first_name, last_name, admin, sudo):
    """Add a user to arkOS LDAP"""
    try:
        client().roles.add_user(name, password, domain, first_name, last_name,
                                admin, sudo)
        logger.success('ctl:usr:add', 'Added {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #51
0
def dump(name, path):
    """Export database to SQL file."""
    try:
        data = client().databases.dump(name)
        path.write(data)
        logger.success('ctl:db:dump', 'Database dumped to {0}'.format(path))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #52
0
def chmod(user_name, db_name, grant):
    """Get or set database user permissions."""
    try:
        cmd = client().databases.user_chmod
        cmd(user_name, "grant" if grant else "revoke")
        logger.success('ctl:dbusr:chmod', 'Permissions set')
    except Exception as e:
        raise CLIException(str(e))
Beispiel #53
0
def add_share(path, expires):
    """Create a fileshare link."""
    try:
        data = client().files.share(path, expires)
        logger.success('ctl:links:create', 'Created link')
        smsg = "Link is your external server address, plus: /shared/{0}"
        logger.info('ctl:links:create', smsg.format(data["id"]))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #54
0
def add_share(path, expires):
    """Create a fileshare link."""
    try:
        data = client().files.share(path, expires)
        logger.success('ctl:links:create', 'Created link')
        smsg = "Link is your external server address, plus: /shared/{0}"
        logger.info('ctl:links:create', smsg.format(data["id"]))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #55
0
def delete_user(name):
    """Delete an arkOS LDAP user"""
    try:
        users = client().roles.get_users()
        uid = [y["id"] for y in users if y["name"] == name]
        if not uid:
            raise CLIException("No such user")
        uid = uid[0]
        client().roles.delete_user(uid)
        logger.success('ctl:usr:delete', 'Deleted {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #56
0
def delete_group(name):
    """Delete an arkOS LDAP group"""
    try:
        groups = client().roles.get_groups()
        gid = [y["id"] for y in groups if y["name"] == name]
        if not gid:
            raise CLIException("No such group")
        gid = gid[0]
        client().roles.delete_group(gid)
        logger.success('ctl:grp:delete', 'Deleted {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #57
0
def start(name):
    """Start a service"""
    try:
        client().services.start(name)
        svc = client().services.get(id=name)
        state = svc["state"]
        if state == "running":
            logger.success('ctl:svc:start', 'Started {0}'.format(name))
        else:
            logger.error('ctl:svc:start', 'Failed to start {0}'.format(name))
    except Exception as e:
        raise CLIException(str(e))
Beispiel #58
0
def mount(id, password):
    """Mount a filesystem"""
    try:
        fs = client().filesystems.get(id=id)
        if fs["crypt"] and not password:
            password = click.prompt(
                "Please enter your password to mount this filesystem",
                hide_input=True)
        client().filesystems.mount(id, password or "")
        logger.success('ctl:fs:mount', 'Mounted {0}'.format(id))
    except Exception as e:
        raise CLIException(str(e))