Orpy API bindings

You can use this library to interact with the INDIGO PaaS Orchestrator:

>>> from orpy.client import client
>>> orpy = client.OrpyClient(
...     url=ORCHESTRATOR_URL,
...     token=ORCHESTRATOR_TOKEN)
>>> deployments = orpy.deployments.list()
>>> deployments[0]
<Deployment cloudProviderName=provider-BARI, createdBy={u'subject': u'de28e179-ec86-4915-a748-7a37f8d80311', u'issuer': u'https://iam.deep-hybrid-datacloud.eu/'}, creationTime=2019-05-27T11:31+0000, links=[{u'href': u'https://paas.cloud.cnaf.infn.it/orchestrator/deployments/11e98073-06f3-6797-9258-0242ac140005', u'rel': u'self'}, {u'href': u'https://paas.cloud.cnaf.infn.it/orchestrator/deployments/11e98073-06f3-6797-9258-0242ac140005/resources', u'rel': u'resources'}, {u'href': u'https://paas.cloud.cnaf.infn.it/orchestrator/deployments/11e98073-06f3-6797-9258-0242ac140005/template', u'rel': u'template'}], outputs={}, physicalId=11e98073-06f3-6797-9258-0242ac140005, status=CREATE_FAILED, statusReason=Error while checking the deployment status; nested exception is feign.RetryableException: mesos.ui.sav.sk executing GET https://mesos.ui.sav.sk/marathon/v2/groups/11e98073-06f3-6797-9258-0242ac140005, task=NONE, updateTime=2019-05-29T02:05+0000, uuid=11e98073-06f3-6797-9258-0242ac140005>
>>> deployments[0].status
CREATE_FAILED

Orpy Client

Use this to interact with the INDIGO-DatatCloud orchestrator.

class orpy.client.client.OrpyClient(url, oidc_agent=None, token=None, debug=False)

An INDIGO-DataCloud PaaS orchestrator client class.

delete(url, **kwargs)

Perform a DELETE request.

This calls request() with method set to DELETE.

deployments

Interface to query for deployments.

Returns:Deployments interface.
Return type:orpy.client.deployments.Deployments
get(url, **kwargs)

Perform a GET request.

This calls request() with method set to GET.

head(url, **kwargs)

Perform a HEAD request.

This calls request() with method set to HEAD.

info

Interface to query for Orchestrator information.

Returns:Information interface.
Return type:orpy.info.Info
patch(url, **kwargs)

Perform a PATCH request.

This calls request() with method set to PATCH.

post(url, **kwargs)

Perform a POST request.

This calls request() with method set to POST.

put(url, **kwargs)

Perform a PUT request.

This calls request() with method set to PUT.

request(url, method, json=None, **kwargs)

Send an HTTP request with the specified characteristics.

Wrapper around requests.Session.request to handle tasks such as setting headers, JSON encoding/decoding, and error handling.

Arguments that are not handled are passed through to the requests library.

Parameters:
  • url (str) – Path or fully qualified URL of the HTTP request. If only a path is provided then the URL will be prefixed with the attribute self.url. If a fully qualified URL is provided then self.url will be ignored.
  • method (str) – The http method to use. (e.g. ‘GET’, ‘POST’)
  • json – Some data to be represented as JSON. (optional)
  • kwargs

    any other parameter that can be passed to requests.Session.request() (such as headers). Except:

    • data will be overwritten by the data in the json param.
    • allow_redirects is ignored as redirects are handled by the session.
Returns:

The response to the request.

resources

Interface to query for resources.

Returns:Resources interface.
Return type:orpy.client.resources.Resources

Deployments interface

class orpy.client.deployments.Deployments(client)

Manage Orchestrator deployments.

create(template, callback_url=None, max_providers_retry=None, keep_last_attemp=True, parameters={})

Create a deployment.

Parameters:
  • template (str) – The TOSCA template to use.
  • callback_url (str) – The orchestrator callback url.
  • max_providers_retry (int) – Maximum number of providers to retry.
  • keep_last_attemp (bool) – Whether to keep the allocated resources in case of failure.
Returns:

The created deployment

Return type:

orpy.client.base.Deployment

delete(uuid)

Delete a deployment.

Parameters:uuid (str) – The UUID of the deployment to delete.
Returns:None
Return type:None
get_template(uuid)

Get the TOSCA template of a deployment.

Parameters:uuid (str) – The UUID of the deployment.
Returns:The TOSCA template for the deployment
Return type:orpy.client.base.TOSCATemplate
list()

List existing deployments.

Returns:List of orpy.client.base.Deployment
Return type:list
show(uuid)

Show details about a deployment.

Parameters:uuid (str) – The UUID of the deployment to show.
Returns:The deployment requested
Return type:orpy.client.base.Deployment
update(uuid, template, callback_url=None, max_providers_retry=None, keep_last_attemp=True, parameters={})

Update a deployment.

Parameters:
  • uuid (str) – The UUID of the deployment.
  • template (str) – The TOSCA template to use.
  • callback_url (str) – The orchestrator callback url.
  • max_providers_retry (int) – Maximum number of providers to retry.
  • keep_last_attemp (bool) – Whether to keep the allocated resources in case of failure.
Returns:

The updated deployment

Return type:

orpy.client.base.Deployment

Resources interface

class orpy.client.resources.Resources(client)

Manage Orchestrator deployment resources.

list(uuid)

List resources for a deployment.

Parameters:uuid (str) – The UUID of the deployment get the resources.
Returns:A list of orpy.client.base.Resource
Return type:list
show(deployment_uuid, resource_uuid)

Show details about a resource on a deployment.

Parameters:
  • resource_uuid (str) – The UUID of the deployment get the resource.
  • deployment_uuid (str) – The UUID of the resource.
Returns:

The resource requested

Return type:

orpy.client.base.Resource

Information interface

class orpy.client.info.Info(client)

Get information about the Orchestrator.

get()

Get information about the Orchestrator.

Returns:Information about the orchestrator.
Return type:orpy.client.base.OrchestratorInfo

Orchestrator resources objects

class orpy.client.base.BaseObject(info)

Base class for all objects that represents orchestrator resoruces.

set_info(key, value)

Set an objects information with key, value.

Parameters:
  • key – the element to set
  • value – the value for the element
to_dict()

Translate the object into a dictionary.

Returns:A dictionary contaning the object representation
Return type:dict
class orpy.client.base.Deployment(info)

Object that represents a deployment.

set_info(key, value)

Set an objects information with key, value.

Parameters:
  • key – the element to set
  • value – the value for the element
to_dict()

Translate the object into a dictionary.

Returns:A dictionary contaning the object representation
Return type:dict
class orpy.client.base.OrchestratorInfo(info)

Object that represents the Orchestrtor information.

set_info(key, value)

Set an objects information with key, value.

Parameters:
  • key – the element to set
  • value – the value for the element
to_dict()

Translate the object into a dictionary.

Returns:A dictionary contaning the object representation
Return type:dict
class orpy.client.base.Resource(info)

Object that represents a Resource.

set_info(key, value)

Set an objects information with key, value.

Parameters:
  • key – the element to set
  • value – the value for the element
to_dict()

Translate the object into a dictionary.

Returns:A dictionary contaning the object representation
Return type:dict
class orpy.client.base.TOSCATemplate(info)

Object that repesents a TOSCA template.

set_info(key, value)

Set an objects information with key, value.

Parameters:
  • key – the element to set
  • value – the value for the element
to_dict()

Translate the object into a dictionary.

Returns:A dictionary contaning the object representation
Return type:dict