hpe-container-platform-community/hpecp-python-library

Implement /api/v1/config/

snowch opened this issue · 3 comments

GET /api/v1/config/ HTTP/1.1
Host: 127.0.0.1:8080
Accept-Encoding: gzip, deflate
REMOTE_ADDR: 86.138.132.112
Accept: */*
User-Agent: python-requests/2.6.0 CPython/2.7.5 Linux/3.10.0-1127.13.1.el7.x86_64
Connection: keep-alive
X-BDS-SESSION: /api/v2/session/5a1cec10-f62e-44dc-9692-e3f52a2dcc7c
Authorization: /api/v2/session/5a1cec10-f62e-44dc-9692-e3f52a2dcc7c

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Length: 4466
Content-Type: application/json
Date: Tue, 21 Jul 2020 14:11:29 GMT
Server: HPE Ezmeral Container Platform 5.1

{
  "result": "Success",
  "objects": {
    "timezone": "UTC",
    "total_tenant_storage": 3072,
    "auth_types": [
      "LDAP",
      "Active Directory"
    ],
    "cpu_allocation_ratio": 1,
    "ram_allocation_ratio": 1,
    "proxy_port_map_ranges": [
      {
        "start_port": 10000,
        "end_port": 50000
      }
    ],
    "external_auth": "Active Directory",
    "gateway_ssl_cert_info": [],
    "tenant_storage_root": {
      "bdfs_root": {
        "path_from_endpoint": "/hcp"
      },
      "endpoint": {
        "cluster_name": "hcp.mapr.cluster",
        "ticket": "hcp-service-ticket",
        "type": "mapr",
        "secure": true,
        "cldb": [
          "ip-10-1-0-210.us-west-2.compute.internal"
        ]
      },
      "label": {
        "name": "TenantStorage",
        "description": "Protected DataTap for a tenant-specific sandboxed storage space."
      }
    },
    "tmp_defaultfs_root": {
      "bdfs_root": {
        "path_from_endpoint": "/hcp"
      },
      "endpoint": {
        "cluster_name": "hcp.mapr.cluster",
        "ticket": "hcp-service-ticket",
        "type": "mapr",
        "secure": true,
        "cldb": [
          "ip-10-1-0-210.us-west-2.compute.internal"
        ]
      },
      "label": {
        "name": "TenantStorage",
        "description": "Protected DataTap for a tenant-specific sandboxed storage space."
      }
    },
    "external_auth_params": {
      "type": "Active Directory",
      "ldap_protocol": "ldaps",
      "user_attr": "sAMAccountName",
      "bind_type": "search_bind",
      "tls_enabled": false,
      "saml_available": true,
      "host": "10.1.0.132",
      "port": 636,
      "base_dn": "CN=Users,DC=samdom,DC=example,DC=com",
      "bind_dn": "cn=Administrator,CN=Users,DC=samdom,DC=example,DC=com",
      "tls_verify_peer": false
    },
    "tenant_types": [
      {
        "tenant_type": "k8s",
        "quota_support": {
          "cores": true,
          "gpus": true,
          "memory_gb": true,
          "disk_gb": true,
          "tenant_storage_gb": true,
          "persistent_storage_size_gb": true
        },
        "label": {
          "name": "K8S",
          "description": "Tenant type for managing vclusters in Kubernetes."
        },
        "fields": [
          {
            "id": "specified_namespace_name",
            "name": "Specified Namespace Name",
            "tooltip": "A name for the namespace that will be created or adopted. If this is omitted in the case of creating a namespace, a unique name will be autogenerated.",
            "type": "string",
            "required": false,
            "message": "Optionally enter a specified namespace name",
            "editable": false
          },
          {
            "id": "adopt_existing_namespace",
            "name": "Adopt Existing Namespace",
            "tooltip": "Whether to attach the tenant to an existing namespace. If true, a namespace name must also be specified. If false, a namespace will be created.",
            "type": "boolean",
            "required": false,
            "message": "Choose whether to adopt an existing namespace",
            "default": false,
            "editable": false
          },
          {
            "id": "is_namespace_owner",
            "name": "Is Namespace Owner",
            "tooltip": "Whether the namespace (and all its contents) should be deleted on tenant deletion.",
            "type": "boolean",
            "required": false,
            "message": "Choose whether the tenant will own the namespace",
            "default": true
          },
          {
            "id": "map_services_to_gateway",
            "name": "Map Services To Gateway",
            "tooltip": "Whether NodePort services in this tenant's namespace will automatically be plumbed to a gateway port.",
            "type": "boolean",
            "required": false,
            "message": "Choose whether to auto-map NodePort services to gateway",
            "default": true
          },
          {
            "id": "enable_service_mesh",
            "name": "Enable Istio Service Mesh",
            "tooltip": "Whether Istio Envoy sidecar proxy injection will be enabled for this namespace.",
            "type": "boolean",
            "required": false,
            "message": "Choose whether to enable service mesh on this namespace.",
            "default": false
          }
        ]
      },
      {
        "tenant_type": "docker",
        "quota_support": {
          "cores": true,
          "gpus": true,
          "memory_gb": true,
          "disk_gb": true,
          "tenant_storage_gb": true,
          "persistent_storage_size_gb": true
        },
        "label": {
          "name": "On-Prem",
          "description": "Tenant type for managing clusters locally."
        },
        "fields": [
          {
            "id": "qos_multiplier",
            "name": "QOS Multiplier",
            "tooltip": "Input an integer (between 1 and 32) to prioritize the cluster performance in this tenant relative to other tenants. Higher integer value results in allocation of proportionately larger \"CPU\" shares.",
            "type": "integer",
            "required": true,
            "message": "Please enter a valid QOS Multiplier",
            "default": 1,
            "min": 1,
            "max": 32,
            "editable": true
          }
        ]
      }
    ],
    "system_quota": [
      {
        "tenant_type": "docker",
        "cores": 0,
        "memory": 0,
        "swap": 0,
        "disk": 0,
        "nodes": 0,
        "gpus": 0
      },
      {
        "tenant_type": "k8s",
        "cores": 24,
        "memory_gb": 183,
        "gpus": 0,
        "persistent_storage_size_gb": 3072,
        "ephemeral_storage_size_gb": 3072
      }
    ],
    "upload_image_settings_fields": [
      {
        "tenant_type": "docker"
      },
      {
        "tenant_type": "k8s"
      }
    ],
    "bds_network_publicinterface": "ens5",
    "bds_install_workerreboot": "false",
    "bdshared_install_agent": "false",
    "bds_global_bundleflavor": "minimal",
    "bds_global_version": "5.1",
    "bds_global_buildnumber": "2055",
    "bds_ha_enabled": "No",
    "bds_global_user": "centos",
    "bdshared_global_bddomain": "demo.bdlocal",
    "bdshared_global_bdprefix": "bluedata-",
    "bds_storage_cstorevg": "VolBDSCStore",
    "bdshared_ha_clusterip": "",
    "cluster_dns_name": ""
  }
}

support jmespath query, e.g.

objects.[bds_global_version, bds_global_buildnumber]

also ...

            data = list_instance.json
            if output == "json-pp":
                print(
                    json.dumps(
                        jmespath.search(str(query), data),
                        indent=4,
                        sort_keys=True,
                    )
                )
            elif output == "text":
                obj = jmespath.search(str(query), data)
                print(TextOutput.dump(obj))
            else:
                print(
                    json.dumps(
                        jmespath.search(str(query), data),
                    )
                )

Done.