Skip to content

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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jul 28, 2020
335156e · Jul 28, 2020
Jul 28, 2020
Jun 15, 2020
Jul 27, 2020
Jul 17, 2020
Jul 28, 2020
Jul 26, 2020
Jun 4, 2020
Jun 16, 2020
Jul 16, 2020
Jun 6, 2020
Jun 14, 2020
Jun 4, 2020
Jun 15, 2020
Jul 26, 2020
Jun 4, 2020
Jul 25, 2020
Jun 17, 2020
Jul 20, 2020
Jul 27, 2020
May 18, 2020
Jul 26, 2020
Jul 27, 2020
Jul 25, 2020
Jun 17, 2020
Jun 15, 2020
Jul 28, 2020
Jul 25, 2020

Repository files navigation

Build & Test Code Checks Issues Coverage Status Pyversions MIT license Code Style

Gitpod Ready-to-Code Good first issues open


- This project is under active development.
- Method APIs may change between commits.
- Not all HPE CP APIs have been implemented.
- Help Wanted - please consider contributing!

Documentation

See here for User Documentation.

Contributing

See:

Installation

# ensure you have an up-to-date pip
pip3 install -U pip

# install hpecp directly from git
pip3 install --upgrade git+https://github.com/hpe-container-platform-community/hpecp-client@master

If you are installing on Centos 7.7 with only Python 2.7 see here for a workaround

CLI examples

CLI is installed with pip (as above)

First you 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.1
api_port = 8080
use_ssl = True
verify_ssl = False
warn_ssl = False
username = admin
password = admin123

[tenant1]
tenant = /api/v1/tenant/15
admin = ad_admin1
password = pass123
EOF

Setup bash autocomplete:

source <(hpecp autocomplete bash)

Autocompletion:

hpecp TAB

K8s versions:

hpecp k8scluster k8s-supported-versions --major-filter 1 --minor-filter 17

Create k8s cluster:

hpecp k8scluster create --name myclus1 --k8shosts-config /api/v2/worker/k8shost/1:master --k8s_version=1.17.0

List with columns parameter:

hpecp k8scluster list --columns [id,description,status]

List with (jmespath) query parameter:

hpecp catalog list --query "[?state!='installed' && state!='installing'] | [*].[_links.self.href] | []"  --output text

List --query examples:

hpecp tenant examples

Tenant kube config:

PROFILE=tenant1 hpecp tenant k8skubeconfig > tenant1_kube.conf

Http call:

hpecp httpclient get /some/uri

Logging with HTTP tracing:

export LOG_LEVEL=DEBUG
hpecp do-something

More sophisticated CLI examples here

Basic Library Usage

See docs: https://hpe-container-platform-community.github.io/hpecp-python-library/index.html

Example:

from hpecp import ContainerPlatformClient

client = 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 |
+-------------+-----------------------+