Esempio n. 1
0
def blueprint(cmd_proc, operation, blueprint, blueprint_file, include_plan):
    """Operations with Blueprints"""
    scoreclient = None
    if 'validate' != operation:
        scoreclient = _authorize(cmd_proc)
    else:
        scoreclient = Score(cmd_proc.host_score)
        Log.debug(cmd_proc.logger, 'using host score: %s' %
                  cmd_proc.host_score)
    if 'validate' == operation:
        _validate(cmd_proc, blueprint_file, scoreclient)
    elif 'list' == operation:
        _list_blueprints(cmd_proc, scoreclient)
    elif 'upload' == operation:
        _upload(cmd_proc, blueprint, blueprint_file, scoreclient)
    elif 'delete' == operation:
        _delete_blueprint(cmd_proc, blueprint, scoreclient)
    elif 'info' == operation:
        _info_blueprint(cmd_proc, scoreclient,
                        include_plan=include_plan)
    elif 'status' == operation:
        try:
            scoreclient = _authorize(cmd_proc)
            status = scoreclient.get_status()
            print_utils.print_dict(json.loads(status))
        except exceptions.ClientException as e:
            utils.print_error("Unable to get blueprinting service status. "
                              "Reason: {0}"
                              .format(str(e)), cmd_proc)
Esempio n. 2
0
def _status(cmd_proc, operation, blueprint_id, blueprint_file, include_plan, scoreclient):
    try:
        status = scoreclient.get_status()
        print_utils.print_dict(json.loads(status))
    except exceptions.ClientException as e:
        utils.print_error(
            "Unable to get blueprinting service status. "
            "Reason: {0}, {1}".format(str(e), scoreclient.response.content),
            cmd_proc,
        )
Esempio n. 3
0
def _status(cmd_proc, operation,
            blueprint_id, blueprint_file,
            include_plan, scoreclient):
    try:
        status = scoreclient.get_status()
        print_utils.print_dict(json.loads(status))
    except exceptions.ClientException as e:
        utils.print_error("Unable to get blueprinting service status. "
                          "Reason: {0}, {1}"
                          .format(str(e), scoreclient.response.content),
                          cmd_proc)
Esempio n. 4
0
def _execute_workflow(cmd_proc, deployment_for_exection,
                      workflow, scoreclient):
    try:
        if not deployment_for_exection or not workflow:
            utils.print_error("Deployment ID or Workflow ID "
                              "was not specified.")
            return
        e = scoreclient.executions.start(
            deployment_for_exection, workflow)
        print_utils.print_dict(e) if e else utils.print_message(
            str(scoreclient.response.content), cmd_proc)
    except exceptions.ClientException as e:
            utils.print_error("Failed to execute workflow. Reasons: {0}."
                              .format(str(e)), cmd_proc)
Esempio n. 5
0
def _execute_workflow(cmd_proc, operation, deployment_id, blueprint_id,
                      input_file, workflow, show_events, execution_id,
                      force_cancel, force_delete, scoreclient):
    try:
        if not deployment_id or not workflow:
            utils.print_error("Deployment ID or Workflow ID "
                              "was not specified.")
            return
        e = scoreclient.executions.start(
            deployment_id, workflow)
        print_utils.print_dict(e) if e else utils.print_message(
            str(scoreclient.response.content), cmd_proc)
    except exceptions.ClientException as e:
            utils.print_error("Failed to execute workflow. Reasons: {0}, {1}"
                              .format(str(e), scoreclient.response.content),
                              cmd_proc)
Esempio n. 6
0
def _execute_workflow(
    cmd_proc,
    operation,
    deployment_id,
    blueprint_id,
    input_file,
    workflow,
    show_events,
    execution_id,
    force_cancel,
    force_delete,
    scoreclient,
):
    try:
        if not deployment_id or not workflow:
            utils.print_error("Deployment ID or Workflow ID " "was not specified.")
            return
        e = scoreclient.executions.start(deployment_id, workflow)
        print_utils.print_dict(e) if e else utils.print_message(str(scoreclient.response.content), cmd_proc)
    except exceptions.ClientException as e:
        utils.print_error(
            "Failed to execute workflow. Reasons: {0}, {1}".format(str(e), scoreclient.response.content), cmd_proc
        )