Esempio n. 1
0
def remove(name, purge):
    """Removes system package(s)"""
    try:
        job = client().packages.remove(name)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 2
0
def uninstall(id):
    """Uninstall an application."""
    try:
        job, data = client().applications.uninstall(id=id)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 3
0
def remove(name, purge):
    """Removes system package(s)"""
    try:
        job = client().packages.remove(name)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 4
0
def generate(name, domain, country, state, locale, email,
             keytype, keylength):
    """Generate an SSL/TLS certificate."""
    if not domain:
        logger.error(
            "ctl:info:generate", "Choose a fully-qualified domain name of the "
            "certificate. Must match a domain present on the system"
        )
        domain = click.prompt("Domain name")
    if not country:
        logger.info(
            "ctl:cert:generate",
            "Two-character country code (ex.: 'US' or 'CA')"
        )
        country = click.prompt("Country code")
    if not state:
        state = click.prompt("State/Province")
    if not locale:
        locale = click.prompt("City/Town/Locale")
    if not email:
        email = click.prompt("Contact email [optional]")
    try:
        cmd = client().certificates.generate
        job, data = cmd(
            name, domain, country, state, locale, email, keytype, keylength)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 5
0
def remove(id):
    """Remove a website"""
    try:
        job = client().websites.delete(id)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 6
0
def install(name):
    """Install system package(s)"""
    try:
        job = client().packages.install(name)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 7
0
def uninstall(id):
    """Uninstall an application."""
    try:
        job, data = client().applications.uninstall(id=id)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 8
0
def install(name):
    """Install system package(s)"""
    try:
        job = client().packages.install(name)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 9
0
def remove(id):
    """Remove a website"""
    try:
        job = client().websites.delete(id)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 10
0
def upload(name, certfile, keyfile, chainfile):
    """Upload an SSL/TLS certificate."""
    try:
        cmd = client().certificates.upload
        job, data = cmd(name, certfile, keyfile, chainfile)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 11
0
def upload(name, certfile, keyfile, chainfile):
    """Upload an SSL/TLS certificate."""
    try:
        cmd = client().certificates.upload
        job, data = cmd(name, certfile, keyfile, chainfile)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 12
0
def create(appid):
    """Create a backup."""
    try:
        job, data = client().backups.create(id=appid)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
    else:
        click.secho("Backup saved!", fg="yellow")
Esempio n. 13
0
def create(appid):
    """Create a backup."""
    try:
        job, data = client().backups.create(id=appid)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
    else:
        click.secho("Backup saved!", fg="yellow")
Esempio n. 14
0
def restore(id):
    """Restore a backup by ID."""
    if "/" not in id:
        raise CLIException("Requires full backup ID with app ID and timestamp")
    id, tsp = id.split("/")
    try:
        job, data = client().backups.restore(id=id, time=tsp)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 15
0
def restore(id):
    """Restore a backup by ID."""
    if "/" not in id:
        raise CLIException("Requires full backup ID with app ID and timestamp")
    id, tsp = id.split("/")
    try:
        job, data = client().backups.restore(id=id, time=tsp)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 16
0
def create(name, size, encrypt, password):
    """Create a virtual disk."""
    try:
        if encrypt and not password:
            password = click.prompt("Please choose a password for encryption",
                                    hide_input=True,
                                    confirmation_prompt=True)
        job, data = client().filesystems.create_virtual(
            name, size * 1048576, encrypt, password)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 17
0
def create(name, size, encrypt, password):
    """Create a virtual disk."""
    try:
        if encrypt and not password:
            password = click.prompt(
                "Please choose a password for encryption",
                hide_input=True, confirmation_prompt=True)
        job, data = client().filesystems.create_virtual(
            name, size * 1048576, encrypt, password)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 18
0
def upgrade(yes):
    """Upgrades all system packages"""
    try:
        pkgs = client().packages.get(refresh=False)
        pkgs = [x["id"] for x in pkgs if x["upgradable"]]
        if not pkgs:
            logger.info('ctl:pkg:upgrade', 'System already up-to-date')
        else:
            logger.info('ctl:pkg:upgrade',
                        'The following packages will be upgraded:')
            click.echo(", ".join(pkgs))
            if yes or click.confirm("Are you sure you want to upgrade?"):
                job = client().packages.install(pkgs)
                handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 19
0
def upgrade(yes):
    """Upgrades all system packages"""
    try:
        pkgs = client().packages.get(refresh=False)
        pkgs = [x["id"] for x in pkgs if x["upgradable"]]
        if not pkgs:
            logger.info('ctl:pkg:upgrade', 'System already up-to-date')
        else:
            logger.info(
                'ctl:pkg:upgrade', 'The following packages will be upgraded:'
            )
            click.echo(", ".join(pkgs))
            if yes or click.confirm("Are you sure you want to upgrade?"):
                job = client().packages.install(pkgs)
                handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 20
0
def create(id, site_type, address, port, extra_data):
    """Create a website"""
    try:
        edata = {}
        if extra_data:
            for x in extra_data.split(","):
                edata[x.split("=")[0]] = x.split("=")[1]
        stype = client().applications.get(id=site_type.lower())
        if stype.get("website_options") and not extra_data:
            for x in stype["website_options"]:
                if x == "messages":
                    continue
                for y in stype["website_options"][x]:
                    edata[y["id"]] = click.prompt(y["label"])
        job, data = client().websites.create(id, site_type.lower(), address,
                                             port, edata)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 21
0
def create(id, site_type, address, port, extra_data):
    """Create a website"""
    try:
        edata = {}
        if extra_data:
            for x in extra_data.split(","):
                edata[x.split("=")[0]] = x.split("=")[1]
        stype = client().applications.get(id=site_type.lower())
        if stype.get("website_options") and not extra_data:
            for x in stype["website_options"]:
                if x == "messages":
                    continue
                for y in stype["website_options"][x]:
                    edata[y["id"]] = click.prompt(y["label"])
        job, data = client().websites.create(
            id, site_type.lower(), address, port, edata)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))
Esempio n. 22
0
def generate(name, domain, country, state, locale, email, keytype, keylength):
    """Generate an SSL/TLS certificate."""
    if not domain:
        logger.error(
            "ctl:info:generate", "Choose a fully-qualified domain name of the "
            "certificate. Must match a domain present on the system")
        domain = click.prompt("Domain name")
    if not country:
        logger.info("ctl:cert:generate",
                    "Two-character country code (ex.: 'US' or 'CA')")
        country = click.prompt("Country code")
    if not state:
        state = click.prompt("State/Province")
    if not locale:
        locale = click.prompt("City/Town/Locale")
    if not email:
        email = click.prompt("Contact email [optional]")
    try:
        cmd = client().certificates.generate
        job, data = cmd(name, domain, country, state, locale, email, keytype,
                        keylength)
        handle_job(job)
    except Exception as e:
        raise CLIException(str(e))