Package: hpecp
DocumentationSeeherefor User Documentation.ContributingSee:Developing GuideContribution GuideInstallationpip3install-UhpecpIf you encounter an issue installing on Centos 7.7 with Python 2.7 seeherefor a workaroundCLI examplesYou need to create a config file with your endpoint details - note that you can have multiple profiles:cat > ~/.hpecp.conf <<EOF[default]api_host=127.0.0.1api_port=8080use_ssl=Trueverify_ssl=Falsewarn_ssl=Falseusername=adminpassword=admin123[tenant1]tenant=/api/v1/tenant/15admin=ad_admin1password=pass123EOFSetup bash autocomplete:source<(hpecpautocompletebash)Autocompletion:hpecpTABAdd gateway:hpecplockcreate"Install Gateway"hpecpgatewaycreate-with-ssh-key--ip10.1.0.5--proxy-node-hostnamemy.gateway.local--ssh-key-filecontroller_private.key
hpecpgatewaywait-for-state${GATEWAY_ID}--states[installed]--timeout-secs1200hpecplockdelete-allAdd K8s worker host:hpecpk8sworkercreate-with-ssh-key\--ip10.1.0.10\--ssh-key-filecontroller_private.key\--persistent-disks/dev/nvme1n1\--ephemeral-disks/dev/nvme2n1\--wait-for-operation-secs600K8s versions:hpecpk8sclusterk8s-supported-versions--major-filter1--minor-filter17Create k8s cluster:hpecpk8sclustercreate--namemyclus1--k8shosts-config/api/v2/worker/k8shost/1:master--k8s_version=1.17.0Get k8s available addons:hpecpk8sclusterget-available-addons--id$CLUSTER_IDAdd k8s cluster addons:hpecpk8sclusteradd-addons--id$CLUSTER_ID--addons[istio,harbor]List with columns parameter:hpecpk8sclusterlist--columns[id,description,status]List with (jmespath) query parameter:hpecpcataloglist--query"[?state!='installed' && state!='installing'] | [*].[_links.self.href] | []"--outputtextList --query examples:hpecptenantexamplesTenant create:TENANT_ID=$(hpecptenantcreate--nametenant1--description"dev tenant"--k8s-cluster-id$CLUSTER_ID--tenant-typek8s)hpecptenantwait-for-status--id$TENANT_ID--status[ready]--timeout-secs600Add LDAP role to Tenant:ADMIN_GROUP="CN=DemoTenantAdmins,CN=Users,DC=samdom,DC=example,DC=com"ADMIN_ROLE=$(hpecprolelist--query"[?label.name == 'Admin'][_links.self.href]"--outputtext)hpecptenantadd-external-user-group--tenant-id$TENANT_ID--group$ADMIN_GROUP--role-id$ADMIN_ROLEAdd internal user to Tenant:ADMIN_USER_ID=$(hpecpuserlist--query"[?label.name == 'admin'][_links.self.href]"--outputtext)ADMIN_ROLE=$(hpecprolelist--query"[?label.name == 'Admin'][_links.self.href]"--outputtext)hpecptenantassign-user-to-role--tenant-id$TENANT_ID--role-id$ADMIN_ROLE--user-id$ADMIN_USER_IDTenant kube config:PROFILE=tenant1hpecptenantk8skubeconfig>tenant1_kube.conf# get available Kubedirector appskubectl--kubeconfigtenant1_kube.conf-nt1getkubedirectorapps# list running applicationskubectl--kubeconfigtenant1_kube.conf-nt1describekubedirectorclustersHttp call:hpecphttpclientget/some/uriUse a different config file:HPECP_CONFIG_FILE=myclus.confhpecpdo-somethingLogging with HTTP tracing:exportLOG_LEVEL=DEBUG
hpecpdo-somethingMore sophisticated CLI examplesherePython Library ExamplesSee docs:https://hpe-container-platform-community.github.io/hpecp-python-library/index.htmlExample:fromhpecpimportContainerPlatformClientclient=ContainerPlatformClient(username='admin',password='admin123',api_host='127.0.0.1',api_port=8080,use_ssl=True,verify_ssl='/certs/hpecp-ca-cert.pem')client.create_session()# Login# Alternatively:# client = ContainerPlatformClient.create_from_config_file().create_session()print(client.k8s_cluster.list(columns=['description','id']))On my environment, this displays:+-------------+-----------------------+
| description |          id           |
+-------------+-----------------------+
| my cluster  | /api/v2/k8scluster/20 |
+-------------+-----------------------+