Exemplo n.º 1
0
def get_deployments_list(api_key, options_file, **filters):
    del_if_value_is_none(filters)
    command = deployments_commands.ListDeploymentsCommand(api_key=api_key)
    try:
        command.execute(**filters)
    except exceptions.ApplicationError as e:
        clilogger.CliLogger().error(e)
Exemplo n.º 2
0
def get_workspace_handler(api_key):
    logger_ = clilogger.CliLogger()
    workspace_handler = workspace.S3WorkspaceHandlerWithProgressbar(
        api_key=api_key,
        logger_=logger_,
        uploader_cls=DeploymentWorkspaceDirectoryUploader,
        client_name=CLI_PS_CLIENT_NAME)
    return workspace_handler
Exemplo n.º 3
0
def list_machines(api_key, params, options_file, **kwargs):
    del_if_value_is_none(kwargs)
    params = params or {}
    kwargs = kwargs or {}
    validate_mutually_exclusive(params.values(), kwargs.values(),
                                "You can use either --params dictionary or single filter arguments")

    command = machines_commands.ListMachinesCommand(api_key=api_key, logger=clilogger.CliLogger())
    filters = params or kwargs
    command.execute(**filters)
Exemplo n.º 4
0
def create_machine(api_key, options_file, **kwargs):
    kwargs["tags"] = validate_comma_split_option(kwargs.pop("tags_comma"), kwargs.pop("tags"))
    del_if_value_is_none(kwargs)

    assign_public_ip = kwargs.get("assign_public_ip")
    dynamic_public_ip = kwargs.get("dynamic_public_ip")
    validate_mutually_exclusive([assign_public_ip], [dynamic_public_ip],
                                "--assignPublicIp cannot be used with --dynamicPublicIp")

    user_id = kwargs.get("user_id")
    email = kwargs.get("email")
    password = kwargs.get("password")
    first_name = kwargs.get("first_name")
    last_name = kwargs.get("last_name")
    validate_mutually_exclusive([user_id], [email, password, first_name, last_name],
                                "--userId is mutually exclusive with --email, --password, --firstName and --lastName")

    command = machines_commands.CreateMachineCommand(api_key=api_key, logger=clilogger.CliLogger())
    command.execute(kwargs)
Exemplo n.º 5
0
def validate_autoscaling_metric_or_resource(ctx, param, value, metric_type):
    """
    value in = ("cpu/targetAverage:10")
    value out = ({"type": instance,
                  "name": "cpu",
                  "value_type": "targetAverage",
                  "value": 10})
    """

    if value is None:
        return None

    old_values = value
    new_values = []

    for old_value in old_values:
        try:
            name, values = old_value.split("/", 1)
            value_type, value = values.split(":", 1)
            value = float(value)
        except Exception as e:
            debug_msg = "Error occurred while validating autoscaling {} with value {}: {}" \
                .format(metric_type, old_value, e)
            clilogger.CliLogger().debug(debug_msg)

            msg = "value need to be in format resource_name/value_type:value for example cpu/targetAverage:60" \
                .format(old_value)
            raise click.BadParameter(msg)

        new_value = {
            "type": metric_type,
            "name": name,
            "value_type": value_type,
            "value": value
        }
        new_values.append(new_value)

    return tuple(new_values)
Exemplo n.º 6
0
 def __init__(self, api=None, logger_=clilogger.CliLogger()):
     self.api = api
     self.logger = logger_
Exemplo n.º 7
0
def get_workspace_handler(api_key):
    logger_ = clilogger.CliLogger()
    workspace_handler = workspace.S3WorkspaceHandlerWithProgressbar(api_key=api_key, logger_=logger_,
                                                                    client_name=CLI_PS_CLIENT_NAME)
    return workspace_handler
Exemplo n.º 8
0
def get_workspace_handler():
    logger_ = clilogger.CliLogger()
    workspace_handler = WorkspaceHandler(logger_=logger_)
    return workspace_handler
Exemplo n.º 9
0
def restart_machine(machine_id, api_key, options_file):
    command = machines_commands.RestartMachineCommand(api_key=api_key, logger=clilogger.CliLogger())
    command.execute(machine_id)
Exemplo n.º 10
0
def destroy_machine(machine_id, release_public_ip, api_key, options_file):
    command = machines_commands.DestroyMachineCommand(api_key=api_key, logger=clilogger.CliLogger())
    command.execute(machine_id, release_public_ip)