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))
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))
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))
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))
def remove(id): """Remove a website""" try: job = client().websites.delete(id) handle_job(job) except Exception as e: raise CLIException(str(e))
def install(name): """Install system package(s)""" try: job = client().packages.install(name) handle_job(job) except Exception as e: raise CLIException(str(e))
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))
def install(name): """Install system package(s)""" try: job = client().packages.install(name) handle_job(job) except Exception as e: raise CLIException(str(e))
def remove(id): """Remove a website""" try: job = client().websites.delete(id) handle_job(job) except Exception as e: raise CLIException(str(e))
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))
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))
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")
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")
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))
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))
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))
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))
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))
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))
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))
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))
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))