When you work with virtual machines in the cloud, one of the most critical functions that you’ll need to perform is to back up your virtual machines on a consistent basis. Since cloud vendors employ a hourly or monthy billing model for having the machines running, unless the machines are business critical and required to run 24×7, you’ll want them running for a set period of time, cancelled, and then re-provisioned when they are needed again. To faciliate this process, many cloud vendors allow you to create a template for the virtual machine to save a copy for future use. When you want to bring this machine online again, you just order the template instead of ordering a brand new virtual machine.

The SoftLayer Activity Library that I posted about a month ago provides the ability to create templates from the Cloud Computing Instances (CCIs) that you have running on your SoftLayer account. This article explains how to create templates from existing virtual machines as part of Workflow Studio workflows. To download the SoftLayer activity library and get started, view the setup instructions listed here. To view the full list of blogs within this blog series, refer to the bottom of this article.

Important Note – Download the SoftLayer Activity Library (Version 2.0) prior to beginning
As I was creating the workflow for this article, I noticed the original SoftLayer Activity Library that I created had a bug within the Create Template activity. When this activity executed, I kept getting the error – “Invalid block device supplied. Please be sure to not include the block device for a swap disk.” When talking with the lead developer at SoftLayer, it turned out they had changed the code slightly on how we should create templates from existing CCIs. I updated the Create Template activity to include the needed changes. So if you want to follow this workflow yourself, you’ll need to re-download the latest SoftLayer Activity Library for Citrix Workflow Studio.

First Step – Obtain the Instance ID for the instance
To create a template for an instance on SoftLayer, we need to know the Instance ID for the instance. In one of the previous blogs in this series, we used the SoftLayer Activity Library for displaying the instance details in a message box. The Instance ID was one of the details that we retrieved.

If you have experience in using the SoftLayer portal, you’ll notice that when they display the list of Cloud Computing Instances (CCIs) for your account on the web page, each link contains the Instance ID for that instance. This is another way you can retrieve the Instance ID for the instance that you want to create a template for.

Second Step – Create the workflow
Open the Workflow Studio Console and create a new workflow called CreateTemplate. Within the Workflow Studio Designer, drag the Connect To SoftLayer, Create Template, Message Box, and Disconnect From SoftLayer activities to the designer surface as shown below. The Message Box activity can be found within the Workflow Control activity library section. The other three activities are all part of the SoftLayer activity library section.

Configure the activities as noted in the table below:

Activity Configuration
Connect To SoftLayer
  • API Key – specify the API Key from your SoftLayer account
  • Username – specify your API Username from your SoftLayer account
Create Template
  • Connection – select the output of the Connect to SoftLayer activity
  • Instance ID – input the Instance ID for your instance that you want to create the template for
  • Template Name – input the name for the template to be created. A recommended practice is to include the version number of the template within the template name itself.
  • Template Notes – input notes for the template to be created (optional)
Message Box
  • Message Text – select the output of the Create Template activity as shown in the screen shot below
  • Window Title – specify a title for the message box such as Template Receipt
Disconnect From SoftLayer
  • Connection – select the output of the Connect to SoftLayer activity

The purpose of inserting the Message Box activity into this sample workflow is to allow us to view the status of the template request. If the template request went through successfully, a transaction id should be returned. In a true workflow, I would definitely recommend storing the transaction id into a SQL Server database or wherever you are storing data about this instance. The SQL Server Activity Library can be used for executing commands on a SQL database for storing this data. The key point is that the transaction id should be retained so that it can used for displaying within your applications.

Third Step – Run the workflow
Run the workflow within the Designer. Ensure that it succeeds properly. A message box should be displayed containing the transaction id for the template request. If you open the SoftLayer portal you should now see a transaction being performed on this instance which represents the template being created.

Next Steps
Once the template is created, you’ll want to keep track of the Template ID for the template. You can re-provision the template as a new Cloud Computing Instance (CCI) by using the Place Order activity within the SoftLayer activity library. When you configure this activity just be sure to include the Template ID. See this blog about how to use the Place Order activity.

This is the last blog in the series about how to use the SoftLayer Activity Library for Citrix Workflow Studio. If you have any requests on what else you would like to see with this library, just let me know. Stay tuned for more blogs on additional Workflow Studio topics.

Blogs in this series

Ed York – Architect – Worldwide Technical Readiness
Ask-the-Architect Site: http://community.citrix.com/p/product-automation#home
Follow Me on twitter: http://twitter.com/citrixedy