hpecp.client module¶
HPE Container Platform Client.
- class hpecp.client.ContainerPlatformClient(username=None, password=None, api_host=None, api_port=8080, use_ssl=True, verify_ssl=True, warn_ssl=False, tenant=None)[source]¶
Client object for HPE Container Platform.
This is the central object that users of this library work with.
- usernamestr
HPECP username
- passwordstr
HPECP password
- api_hoststr
HPECP api_host
- api_portint
HPECP api_port
- use_sslbool:
Connect to HPECP using SSL: True|False
- verify_sslbool|str
See “https://requests.readthedocs.io/en/master/user/advanced/ #ssl-cert-verification”
- warn_sslbool
Disable ssl warnings
- tenantstr (optional)
The tenant ID, e.g. /api/v1/tenant/2
- ContainerPlatformClient:
An instance of ContainerPlatformClient
Instantiating the ContainerPlatformClient does not make any connection to the HPE Container Platform API. The initial connection would be made by calling the method
create_session()
.create_from_config_file()
for an alternative way to create a ContainerPlatformClient instancecreate_from_env()
for an alternative way to create a ContainerPlatformClient instance- classmethod create_from_config_file(config_file='~/.hpecp.conf', profile=None)[source]¶
Create a ContainerPlatformClient object from a configuration file.
- config_filestr
The configuration filename and path
- profilestr
If the configuration file has multiple profile sections, you can select the profile to use.
- ContainerPlatformClient:
An instance of ContainerPlatformClient is returned.
Below is an example configuration file.
[default] api_host = 127.0.0.1 api_port = 8080 use_ssl = True verify_ssl = False warn_ssl = False
[demoserver] username = admin password = admin123 tenant = /api/v1/tenant/2
- classmethod create_from_env()[source]¶
Create an instance of ContainerPlatformClient from environment variables.
HPECP_USERNAME HPECP_PASSWORD HPECP_API_HOST HPECP_API_PORT HPECP_USE_SSL HPECP_VERIFY_SSL HPECP_WARN_SSL HPECP_TENANT
See ContainerPlatformClient
constructor
for the paramaeter definitions.
- create_session()[source]¶
Create a session with the HPE CP controller.
- ContainerPlatformClient
An instance of ContainerPlatformClient is returned.
- APIException
for connection error to the HPE CP controller requests.exceptions.RequestException for exceptions that are not a connection error
- property tenant¶
Retrieve a reference to .tenant.TenantController object.
See the class
tenant.TenantController
for the methods available.This example calls the method
list()
intenant.TenantController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.tenant.list()
- property config¶
Retrieve a reference to .config.ConfigController object.
See the class
config.ConfigController
for the methods available.This example calls the method
auth()
inconfig.ConfigController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.config.auth( ... { ... "external_identity_server": { ... "bind_pwd":"5ambaPwd@", ... "user_attribute":"sAMAccountName", ... "bind_type":"search_bind", ... "bind_dn": ( ... "cn=Administrator,CN=Users,DC=samdom," ... "DC=example,DC=com" ... ), ... "host":"10.1.0.77", ... "security_protocol":"ldaps", ... "base_dn":"CN=Users,DC=samdom,DC=example,DC=com", ... "verify_peer": False, ... "type":"Active Directory", ... "port":636 ... } ... } ... )
- property install¶
Retrieve a reference to .install.InstallController object.
See the class
install.InstallController
for the methods available.This example calls the method
get()
ininstall.InstallController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.install.get()
- property k8s_cluster¶
Retrieve a reference to .k8s_cluster.K8sClusterController object.
See the class
k8s_cluster.K8sClusterController
for the methods available.This example calls the method
list()
ink8s_cluster.K8sClusterController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.k8s_cluster.list()
- property k8s_worker¶
Retrieve a reference to .k8s_worker.K8sWorkerController object.
See the class
k8s_worker.K8sWorkerController
for the methods available.This example calls the method
list()
ink8s_worker.K8sWorkerController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.k8s_worker.list()
- property epic_worker¶
Retrieve a reference to .epic_worker.EpicWorkerController object.
See the class
epic_worker.EpicWorkerController
for the methods available.This example calls the method
list()
inepic_worker.EpicWorkerController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.epic_worker.list()
- property gateway¶
Retrieve a reference to .gateway.GatewayController object.
See the class
gateway.GatewayController
for the methods available.This example calls the method
list()
ingateway.GatewayController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.gateway.list()
- property license¶
Retrieve a reference to a .license.LicenseController object.
See the class
license.LicenseController
for the methods available.This example calls the method
list()
inlicense.LicenseController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.license.list()
- property lock¶
Retrieve a reference to a .lock.LockController object.
See the class
lock.LockController
for the methods available.This example calls the method
get()
inlock.LockController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.lock.get()
- property log¶
Retrieve a reference to a :py:class:.logger.Logger`.
The log function can be called from controller objects via the client parameter passed in during instantiation of the controller.
- class K8sClusterController:
…
- def __init__(self, client):
self.client = client
- def some_method(self):
… self.client.log.error(“Some Error”)
- property user¶
Retrieve a reference to a .lock.LockController object.
See the class
lock.UserController
for the methods available.This example calls the method
get()
inuser.UserController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.user.get()
- property catalog¶
Retrieve a reference to a .catalog.CatalogController object.
See the class
catalog.CatalogController
for the methods available.This example calls the method
create()
incatalog.CatalogController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.catalog.create()
- property role¶
Retrieve a reference to a .role.RoleController object.
See the class
role.RoleController
for the methods available.This example calls the method
get()
inrole.RoleController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.role.get()
- property datatap¶
Retrieve a reference to a .datatap.DatatapController object.
See the class
role.DatatapController
for the methods available.This example calls the method
get()
indatatap.DatatapController
.>>> client = ContainerPlatformClient(...) >>> client.create_session() >>> client.datatap.get()