Beispiel #1
0
def v1_compose_finished():
    """Return the list of finished composes

    **/api/v1/compose/finished**

      Return the details on all of the finished composes on the system.

      Example::

          {
            "finished": [
              {
                "id": "70b84195-9817-4b8a-af92-45e380f39894",
                "blueprint": "glusterfs",
                "queue_status": "FINISHED",
                "job_created": 1517351003.8210032,
                "job_started": 1517351003.8230415,
                "job_finished": 1517359234.1003145,
                "version": "0.0.6"
              },
              {
                "id": "e695affd-397f-4af9-9022-add2636e7459",
                "blueprint": "glusterfs",
                "queue_status": "FINISHED",
                "job_created": 1517362289.7193348,
                "job_started": 1517362289.9751132,
                "job_finished": 1517363500.1234567,
                "version": "0.0.6",
                "uploads": [
                    {
                        "creation_time": 1568150660.524401,
                        "image_name": "glusterfs server",
                        "image_path": "/var/lib/lorax/composer/results/e695affd-397f-4af9-9022-add2636e7459/disk.vhd",
                        "provider_name": "azure",
                        "settings": {
                            "client_id": "need",
                            "location": "need",
                            "resource_group": "group",
                            "secret": "need",
                            "storage_account_name": "need",
                            "storage_container": "need",
                            "subscription_id": "need",
                            "tenant": "need"
                        },
                        "status": "WAITING",
                        "uuid": "21898dfd-9ac9-4e22-bb1d-7f12d0129e65"
                    }
                ]
              }
            ]
          }
    """
    return jsonify(
        finished=build_status(api.config["COMPOSER_CFG"], "FINISHED", api=1))
Beispiel #2
0
def v1_compose_failed():
    """Return the list of failed composes

    **/api/v1/compose/failed**

      Return the details on all of the failed composes on the system.

      Example::

          {
            "failed": [
               {
                "id": "8c8435ef-d6bd-4c68-9bf1-a2ef832e6b1a",
                "blueprint": "http-server",
                "queue_status": "FAILED",
                "job_created": 1517523249.9301329,
                "job_started": 1517523249.9314211,
                "job_finished": 1517523255.5623411,
                "version": "0.0.2",
                "uploads": [
                    {
                        "creation_time": 1568150660.524401,
                        "image_name": "http-server",
                        "image_path": null,
                        "provider_name": "azure",
                        "settings": {
                            "client_id": "need",
                            "location": "need",
                            "resource_group": "group",
                            "secret": "need",
                            "storage_account_name": "need",
                            "storage_container": "need",
                            "subscription_id": "need",
                            "tenant": "need"
                        },
                        "status": "WAITING",
                        "uuid": "21898dfd-9ac9-4e22-bb1d-7f12d0129e65"
                    }
                ]
              }
            ]
          }
    """
    return jsonify(
        failed=build_status(api.config["COMPOSER_CFG"], "FAILED", api=1))
Beispiel #3
0
def v1_compose_status(uuids):
    """Return the status of the listed uuids

    **/api/v1/compose/status/<uuids>[?blueprint=<blueprint_name>&status=<compose_status>&type=<compose_type>]**

      Return the details for each of the comma-separated list of uuids. A uuid of '*' will return
      details for all composes.

      Example::

          {
            "uuids": [
              {
                "id": "8c8435ef-d6bd-4c68-9bf1-a2ef832e6b1a",
                "blueprint": "http-server",
                "queue_status": "FINISHED",
                "job_created": 1517523644.2384307,
                "job_started": 1517523644.2551234,
                "job_finished": 1517523689.9864314,
                "version": "0.0.2"
              },
              {
                "id": "45502a6d-06e8-48a5-a215-2b4174b3614b",
                "blueprint": "glusterfs",
                "queue_status": "FINISHED",
                "job_created": 1517363442.188399,
                "job_started": 1517363442.325324,
                "job_finished": 1517363451.653621,
                "version": "0.0.6",
                "uploads": [
                    {
                        "creation_time": 1568150660.524401,
                        "image_name": "glusterfs server",
                        "image_path": null,
                        "provider_name": "azure",
                        "settings": {
                            "client_id": "need",
                            "location": "need",
                            "resource_group": "group",
                            "secret": "need",
                            "storage_account_name": "need",
                            "storage_container": "need",
                            "subscription_id": "need",
                            "tenant": "need"
                        },
                        "status": "WAITING",
                        "uuid": "21898dfd-9ac9-4e22-bb1d-7f12d0129e65"
                    }
                ]
              }
            ]
          }
    """
    if VALID_API_STRING.match(uuids) is None:
        return jsonify(status=False,
                       errors=[{
                           "id": INVALID_CHARS,
                           "msg": "Invalid characters in API path"
                       }]), 400

    blueprint = request.args.get("blueprint", None)
    status = request.args.get("status", None)
    compose_type = request.args.get("type", None)

    results = []
    errors = []

    if uuids.strip() == '*':
        queue_status_dict = queue_status(api.config["COMPOSER_CFG"], api=1)
        queue_new = queue_status_dict["new"]
        queue_running = queue_status_dict["run"]
        candidates = queue_new + queue_running + build_status(
            api.config["COMPOSER_CFG"], api=1)
    else:
        candidates = []
        for uuid in [n.strip().lower() for n in uuids.split(",")]:
            details = uuid_status(api.config["COMPOSER_CFG"], uuid, api=1)
            if details is None:
                errors.append({
                    "id": UNKNOWN_UUID,
                    "msg": "%s is not a valid build uuid" % uuid
                })
            else:
                candidates.append(details)

    for details in candidates:
        if blueprint is not None and details['blueprint'] != blueprint:
            continue

        if status is not None and details['queue_status'] != status:
            continue

        if compose_type is not None and details['compose_type'] != compose_type:
            continue

        results.append(details)

    return jsonify(uuids=results, errors=errors)