A CloudSigma Python Script to automate the conversion of a drive snapshot into a full drive

A robust cloud deployment means having a well thought out data management strategy. At CloudSigma we offer free functionality such as snapshotting as well as tiered storage. It’s therefore possible to implement a great data management framework to ensure strong protection for the availability and integrity of the data you store in the cloud.

In this post we share with you a script that allows you to automate promoting a snapshot of a drive into a full drive. This is great for backing up various restore points you have created with the drive backup functionality. This functionality is achieved using a python script, which in turn leverages the free CloudSigma Python Library (you can download this from here).

So let’s get started!

First you have to install python on your local machine or server if you don’t have that already. Installing Python is generally easy, and nowadays many Linux and UNIX distributions include a recent Python version by default. Even some Windows computers now come with Python already installed. Here is a brief overview of installing Python for various operating systems.

Installation by OS

Mac OS X
Ubuntu
CentOS / RHEL

In order to install the CloudSigma module, you first need to install the EPEL repository, in order to install PIP. The instructions below are for RHEL 6.x / CentOS 6.x. For further details on installing the repository, please visit the EPEL site at here.

Python and Script Configuration

Now let’s verify the python is installed correctly with this simple command:

The output version of the above command should be similar to: Python 2.7.10
Once, you have python installed on your machine, we can proceed with py-cloudsigma configuration.

In order for the CloudSigma library to interact with the API, you need to provide your credentials.

These are set in the file ~/.cloudsigma.conf.

Here’s a sample version of the file that “communicates” to the San Jose data center. If you want instead to use the Zürich datacenter, simply replace sjc with zrh in the api_endpoint and ws_endpoint.

Since this file includes credentials, it’s highly recommended you set the permission of the file to chmod 600 so that this file can only be read by the owner:

Now we are ready to create and execute the python script. We include the full source code below so just open your favourite text-editor and paste it there or use the download link here

Please be aware that the extension of the file must be .py when you come to save the file.

Execute the script through the following command:

The main goal of this script is to make things as convenient and easy as possible on the storage management side of things, especially for new users and for those who like the console more than GUI 🙂

Share this Post

About Viktor Stankov

Technical Support Representative @ CloudSigma. He is interested in computers, new technologies and sports. Addicted to learning Linux and Scripting languages.

Leave a Reply