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 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.

  • description – Description of the package.

  • plans – List of plans associated with the package. binding of 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.

create_volume_instance(name, capacity, disk_type=<DiskType.SSD: 'ssd'>, retry_limit=0)

Create a volume instance

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

  • capacity (int) – capacity of volume instance in GB. Permissible values: 32, 64, 128, 256, 512

  • 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
>>> client = Client(auth_token='auth_token', project='project_guid')
>>> pv = client.get_persistent_volume()
>>> pv.create_volume_instance(name='myVolume', capacity=32, disk_type=DiskType.SSD)
get_all_volume_instances(phases=None, retry_limit=0)

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)
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=15, 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
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.