Deployment module¶
A deployment is a rapyuta.io resource that represents a unique instantiation of a rapyuta.io package. It holds information about the package deployed, the configuration used, and interfaces exposed. It possesses a unique identifier and provides a mechanism to introspect its phase and state that are needed to ascertain the state of a system.
Tooling such as logs, debug terminals and other automation leverage this uniquely identifiable resource to allow the operator to manage, debug and observe a particular running instance of their application.
Deployments support composition patterns to allow the user to combine multiple different applications to help realize a potentially more complex robotics solution.
Client Module¶
- class Client(auth_token, project=None)¶
Client class provides access to device, package, volume and deployment classes.
- __init__(auth_token, project=None)¶
Get new client object
- Parameters
auth_token (string) – Authentication token
project (string) – project_guid of the user
- get_all_deployments(phases=None, device_id='', retry_limit=0)¶
Get all deployments created by the user.
- Parameters
phases (list(DeploymentPhaseConstants)) – optional parameter to filter out the deployments based on current deployment
device_id (str) – optional parameter to filter out the deployments based on uid of the corresponding device
retry_limit (int) – Optional parameter to specify the number of retry attempts to be carried out if any failures occurs during the API call.
- Returns
list of instances of class
Deployment
:- Raises
APIError
: If the API returns an error, a status code of anything other than 200/201 is returned.
Following example demonstrates how to get all the deployments.
>>> from rapyuta_io import Client, DeploymentPhaseConstants >>> client = Client(auth_token='auth_token', project='project_guid') >>> deployments = client.get_all_deployments() >>> deployments_list_filtered_by_phase = client.get_all_deployments(phases= >>> [DeploymentPhaseConstants.SUCCEEDED, DeploymentPhaseConstants.PROVISIONING]) >>> deployments_list_filtered_by_device_id = client.get_all_deployments( >>> device_id='<device_id>')
- get_deployment(deployment_id, retry_limit=0)¶
Get a deployment
- Parameters
deployment_id (string) – Deployment ID
retry_limit (int) – Optional parameter to specify the number of retry attempts to be carried out if any failures occurs during the API call.
- Returns
instance of class
Deployment
:- Raises
APIError
: If the API returns an error, a status code of anything other than 200/201 is returned.
Following example demonstrates how to get all the deployments.
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> deployment = client.get_deployment('deployment_id')
- update_deployment(payload, retry_limit=0)¶
Update a deployment
- Returns
list of instances of class
Deployment
:- Raises
APIError
: If the API returns an error, a status code of anything other than 200/201 is returned.
The following example demonstrates how to update a deployment
>>> from rapyuta_io import Client, DeploymentPhaseConstants >>> client = Client(auth_token='auth_token', project='project_guid') >>> status = client.update_deployment(payload)
Deployments Module¶
- class Deployment(*args, **kwargs)¶
Deployment class represents a running deployment. Member variables of the class represent the properties of the deployment.
Variables marked as (full-only) are only available on a full object. Use refresh() to convert a partial object into a full one.
- Variables
deploymentId – Deployment Id.
name – Deployment name.
packageId – Package Id.
packageName – Package Name.
packageAPIVersion – Package API Version.
planId – Plan Id.
bindable – Deployment is bindable or not.
labels – (full-only) Labels associated with the deployment.
parameters – (full-only) Deployment parameters.
componentInfo – (full-only) List of component details.
componentInstanceIds – (full-only) List of component instance ids.
dependentDeployments – (full-only) List of dependent deployments.
dependentDeploymentStatus – (full-only) Dependent deployments status details.
packageDependencyStatus – (full-only) Package dependency status details.
coreNetworks – (full-only) Routed and Native network details.
phase (
DeploymentPhaseConstants
) – Phase of the deployment.status (
DeploymentStatusConstants
) – (full-only) Status of the deployment.provisionContext – (full-only) Context set during provisioning.
currentGeneration – (full-only) Build generation number.
errors – (full-only) List of errors.
inUse – Deployment is in use or not.
ownerProject – Owner project guid.
creator – Creator user guid.
CreatedAt – Date of creation.
UpdatedAt – Date of updation.
DeletedAt – Date of deletion.
- deprovision(retry_limit=0)¶
Deprovision the deployment instance represented by the corresponding
Deployment
: class.- Parameters
retry_limit –
- Returns
True if de-provision is successful, False otherwise
- Raises
ParameterMissingException
: If the planId or deploymentId is missing in the request.- Raises
APIError
: If the deprovision-api returns an error, the status code is anything other than 200/201
Following example demonstrates how to deprovision a deployment
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project="project_guid") >>> deployment = client.get_deployment('test_deployment_id') >>> deployment.deprovision()
- get_service_binding(binding_id=None, retry_limit=0)¶
Get the service bindings of the deployment. Service Bindings contain the credentials that can be used to communicate with the deployment.
- Parameters
binding_id (string) – Optional parameter Binding Id
retry_limit (int) – Optional parameter to specify the number of retry attempts to be carried out if any failures occurs during the API call.
- Returns
Service binding dictionary containing credentials.
- Raises
ServiceBindingError
: If the request failed to get the service binding.- Raises
APIError
: If service binding api return an error, the status code is anything other than 200/201
Following example demonstrates how to get the service binding
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project="project_guid") >>> deployment = client.get_deployment('test_deployment_id') >>> deployment.get_service_binding()
- get_status(retry_limit=0)¶
Get the deployment status
- Parameters
retry_limit (int) – Optional parameter to specify the number of retry attempts to be carried out if any failures occurs during the API call.
- Returns
instance of class
DeploymentStatus
:- Raises
APIError
: If the get deployment status api returns an error, the status code is anything other than 200/201
Following example demonstrates how to get a deployment status
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project="project_guid") >>> deployment = client.get_deployment('test_deployment_id') >>> deployment.get_status()
- poll_deployment_till_ready(retry_count=50, sleep_interval=6, ready_phases=None)¶
Wait for the deployment to be ready
- Parameters
retry_count – Optional parameter to specify the retries. Default value is 15
sleep_interval – Optional parameter to specify the interval between retries. Default value is 6 Sec.
- Returns
instance of class
DeploymentStatus
:- Raises
APIError
: If service binding api return an error, the status code is anything other than 200/201- Raises
DeploymentNotRunningException
: If the deployment’s state might not progress due to errors.- Raises
RetriesExhausted
: If number of polling retries exhausted before the deployment could succeed or fail.
Following example demonstrates use of poll_deployment_till_ready, and in case of deployment failure uses error codes to check whether it was due to device being offline. Read more on error codes: https://userdocs.rapyuta.io/6_troubleshoot/611_deployment-error-codes/
>>> from rapyuta_io import Client >>> from rapyuta_io.utils.error import (DeploymentNotRunningException, ... RetriesExhausted) >>> client = Client(auth_token='auth_token', project="project_guid") >>> deployment = client.get_deployment('test_deployment_id') >>> try: ... dep_status = deployment.poll_deployment_till_ready() ... print dep_status ... except RetriesExhausted as e: ... print e, 'Retry again?' ... except DeploymentNotRunningException as e: ... print e ... if 'DEP_E151' in e.deployment_status.errors: ... print 'Device is either offline or not reachable'
- refresh()¶
Fetches the updated resource from the server, and adds/updates object attributes based on it.
- Raises
APIError
: If the api returns an error, the status code is anything other than 200/201
- class DeploymentPhaseConstants(value)¶
Enumeration variables for the deployment phase
Deployment phase can be any of the following types
DeploymentPhaseConstants.INPROGRESS
DeploymentPhaseConstants.PROVISIONING
DeploymentPhaseConstants.SUCCEEDED
DeploymentPhaseConstants.FAILED_TO_START
DeploymentPhaseConstants.PARTIALLY_DEPROVISIONED
DeploymentPhaseConstants.DEPLOYMENT_STOPPED
- class DeploymentStatus(*args, **kwargs)¶
DeploymentStatus class
- Variables
deploymentId – Deployment Id.
name – Deployment name.
packageId – Package Id.
status – Deployment status
phase – Deployment phase
errors – Deployment errors
componentInfo – List containing the deployment components and their status.
dependentDeploymentStatus – Dependent deployment status.
packageDependencyStatus – Package dependency status.
- class DeploymentStatusConstants(value)¶
Enumeration variables for the deployment status
Deployment status can be any of the following types
DeploymentStatusConstants.RUNNING
DeploymentStatusConstants.PENDING
DeploymentStatusConstants.ERROR
DeploymentStatusConstants.UNKNOWN
DeploymentStatusConstants.STOPPED