Persistent Volumes

Applications running on the cloud de-allocate any resources consumed when they stop, scale down, or fail. This implies that the working storage associated with them is ephemeral. To get around this problem rapyuta.io provides a mechanism to consume persistent block storage for your applications running in the cloud. This storage can be associated with at most one running deployment at any given point of time. A user is typically required to manage the lifecycle of the application code independently from the associated storage.

The Rapyuta IO Persistent Volume is a storage package. A storage package is a public package which is available to all users out of the box. You cannot delete or modify storage packages, and they are available to every user.

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_persistent_volume(retry_limit=0)

Get persistent volume class

Parameters

retry_limit (int) – Number of retry attempts to be carried out if any failures occurs during the API call.

Returns

PersistentVolumes class.

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 a persistent volume

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> persistent_volume = client.get_persistent_volume()
get_volume_instance(instance_id, retry_limit=0)

Get a volume instance

Parameters
  • instance_id (string) – Volume instance 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 VolumeInstance:

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 a volume instance.

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> deployments = client.get_volume_instance('instance_id')

Persistent Volumes Module

class DiskCapacity(value)

Enumeration variables for disk capacity. The type may be one of the following

DiskCapacity.GiB_4

DiskCapacity.GiB_8

DiskCapacity.GiB_16

DiskCapacity.GiB_32

DiskCapacity.GiB_64

DiskCapacity.GiB_128

DiskCapacity.GiB_256

DiskCapacity.GiB_512

class DiskType(value)

Enumeration variables for the Volume Type. The type may be ‘Default’ or ‘SSD’

DiskType.DEFAULT

DiskType.SSD

class PersistentVolumes(*args, **kwargs)

PersistentVolumes class represents a a persistent volume package. It contains methods to create persistent volume instance and listing all the instances.

Variables
  • packageId – Id of the package.

  • packageName – Package name.

  • packageVersion – Version of the package.

  • apiVersion – Package API Version.

  • bindable – Package is bindable or not.

  • description – Description of the package.

  • category – Package category.

  • plans (list(Plan)) – List of plans associated with the package.

  • isPublic – Boolean denoting whether the package is public or not.

  • status – Status of the package.

  • tags – Tags associated with the package.

  • buildGeneration – Build generation.

  • ownerProject – Owner project guid.

  • creator – Creator user guid.

  • CreatedAt – Date of creation.

  • UpdatedAt – Date of updation.

  • DeletedAt – Date of deletion.

create_volume_instance(name, capacity, disk_type=DiskType.SSD, retry_limit=0)

Create a volume instance

Parameters
  • name (str) – name of the volume instance

  • capacity (enum DiskCapacity) – disk capacity of the volume instance

  • disk_type (enum DiskType) – Type of disk to be deployed. Allowed values are - default or ssd

  • 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

volume instance

Raises

InvalidParameterException: If the disk type and volume capacity parameters are missing or invalid.

Raises

APIError: If the api return an error, the status code is anything other than 200/201

Following example demonstrates how to create a volume instance

>>> from rapyuta_io import Client
>>> from rapyuta_io.clients.persistent_volumes import DiskType, DiskCapacity
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> pv = client.get_persistent_volume()
>>> pv.create_volume_instance(name='myVolume', capacity=DiskCapacity.GiB_32, disk_type=DiskType.SSD)
get_all_volume_instances(phases=None, retry_limit=0, deploymentGUIDs=None)

Get all persistent volume instances

Parameters
  • phases (list(DeploymentPhaseConstants)) – optional parameter to filter out the deployments based on current deployment

  • 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 volume instances

Raises

APIError: If the api return an error, the status code is anything other than 200/201

Following example demonstrates how to create a volume instance

>>> from rapyuta_io import Client, DeploymentPhaseConstants
>>> client = Client(auth_token='auth_token', project="project_guid")
>>> pv = client.get_persistent_volume()
>>> pv.get_all_volume_instances()
>>> volume_deployments_list_filtered_by_phase = pv.get_all_volume_instances(phases=
>>>   [DeploymentPhaseConstants.SUCCEEDED, DeploymentPhaseConstants.PROVISIONING])
get_volume_instance(volume_instance_id, retry_limit=0)

Get a volume instance

Parameters
  • volume_instance_id (string) – Volume instance 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

return instance of class VolumeInstance:

Raises

APIError: If the api return an error, the status code is anything other than 200/201

Following example demonstrates how to a volume instance

>>> from rapyuta_io import Client
>>> client = Client(auth_token='auth_token', project="project_guid")
>>> persistent_volume = client.get_persistent_volume()
>>> volume_instance = persistent_volume.get_volume_instance('instance_id')
class VolumeInstance(*args, **kwargs)

VolumeInstance class represents a running Persistent Volume.

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.

destroy_volume_instance(retry_limit=0)

Destroy a volume instance

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

True if volume is destroyed is successfully, False otherwise

Raises

APIError: If the api return an error, the status code is anything other than 200/201

get_status(retry_limit=0)

Get the status of volume instance

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 api return 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")
>>> persistent_volume = client.get_persistent_volume()
>>> volume_instance = persistent_volume.get_volume_instance('instance_id')
>>> volume_instance.get_status()
poll_deployment_till_ready(retry_count=50, sleep_interval=6)

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 VolumeInstanceStatus:

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.

>>> from rapyuta_io import Client
>>> from rapyuta_io.utils.error import (DeploymentNotRunningException,
...     RetriesExhausted)
>>> client = Client(auth_token='auth_token', project="project_guid")
>>> persistent_volume = client.get_persistent_volume()
>>> volume_instance = persistent_volume.get_volume_instance('instance_id')
>>> try:
...     vol_status = volume_instance.poll_deployment_till_ready(sleep_interval=20)
...     print vol_status
... except RetriesExhausted as e:
...     print e, 'Retry again?'
... except DeploymentNotRunningException as e:
...     print e, e.deployment_status
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 VolumeInstanceStatus(*args, **kwargs)

VolumeInstanceStatus class

Variables
  • deploymentId – Deployment Id.

  • name – Volume instance 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.