Files
python-saharaclient/doc/source/reference/pythonclient.rst
Jeremy Freudberg 45088c61f0 APIv2 support in client
* Support of all APIv2 features carried from APIv1 ("feature parity")
* Minimum amount of docs to pass the gate
* Endpoint manipulation and version discovery handled by keystoneauth
* APIv2 feature: decommision of specific instances (doc change only)
* APIv2 feature: force delete (new method)

Unit tests will arrive in a future patch.

bp v2-api-experimental-impl

Co-Authored-By: Monty Taylor <mordred@inaugust.com>
Change-Id: I32178439fe85cc6d5faf4ac2e33ae80c08619de5
2018-01-25 05:47:33 +00:00

4.0 KiB

Python Sahara client

Overview

Sahara Client provides a list of Python interfaces to communicate with the Sahara REST API. Sahara Client enables users to perform most of the existing operations like retrieving template lists, creating Clusters, submitting EDP Jobs, etc.

Instantiating a Client

To start using the Sahara Client users have to create an instance of the Client class. The client constructor has a list of parameters to authenticate and locate Sahara endpoint.

saharaclient.api.client.Client

Important!

It is not a mandatory rule to provide all of the parameters above. The minimum number should be enough to determine Sahara endpoint, check user authentication and tenant to operate in.

Authentication check

Passing authentication parameters to Sahara Client is deprecated. Keystone Session object should be used for this purpose. For example:

from keystoneauth1.identity import v2
from keystoneauth1 import session
from saharaclient import client

auth = v2.Password(auth_url=AUTH_URL,
                   username=USERNAME,
                   password=PASSWORD,
                   tenant_name=PROJECT_ID)

ses = session.Session(auth=auth)

sahara = client.Client('1.1', session=ses)

For more information about Keystone Sessions, see Using Sessions.

Sahara endpoint discovery

If user has a direct URL pointing to Sahara REST API, it may be specified as sahara_url. If this parameter is missing, Sahara client will use Keystone Service Catalog to find the endpoint. There are two parameters: service_type and endpoint_type to configure endpoint search. Both parameters have default values.

from keystoneauth1.identity import v2
from keystoneauth1 import session
from saharaclient import client

auth = v2.Password(auth_url=AUTH_URL,
                   username=USERNAME,
                   password=PASSWORD,
                   tenant_name=PROJECT_ID)

ses = session.Session(auth=auth)

sahara = client.Client('1.1', session=ses,
                       service_type="non-default-service-type",
                       endpoint_type="internalURL")

Object managers

Sahara Client has a list of fields to operate with:

  • plugins
  • clusters
  • cluster_templates
  • node_group_templates
  • images
  • data_sources
  • job_binaries
  • job_binary_internals
  • job_executions
  • job_types

Each of this fields is a reference to a Manager for a corresponding group of REST calls.

Supported operations

Plugin ops

saharaclient.api.plugins.PluginManagerV1

Image Registry ops

saharaclient.api.images.ImageManagerV1

Node Group Template ops

saharaclient.api.node_group_templates.NodeGroupTemplateManagerV1

Cluster Template ops

saharaclient.api.cluster_templates.ClusterTemplateManagerV1

Cluster ops

saharaclient.api.clusters.ClusterManagerV1

Data Source ops

saharaclient.api.data_sources.DataSourceManagerV1

Job Binary Internal ops

saharaclient.api.job_binary_internals.JobBinaryInternalsManager

Job Binary ops

saharaclient.api.job_binaries.JobBinariesManagerV1

Job ops

saharaclient.api.jobs.JobsManagerV1

Job Execution ops

saharaclient.api.job_executions.JobExecutionsManager

Job Types ops

saharaclient.api.job_types.JobTypesManager