Building virtual images in a scripting environment with IBM Smart Cloud Provisioning
marcese 11000065AG Visits (3703)
In this new post I would like to describe how you can script the building of virtual images using the Image Construction and Composition Tool provided by IBM Smart Cloud Provisioning.
The upcoming release of IBM Smart Cloud Provisioning 2.1 embeds, among other things, a new version of the Image Construction and Composition Tool. Image Construction and Composition Tool allows to build virtual images that are self-descriptive, customizable and manageable; at the end it produces Open Virtualization Appliance (OVA) images that can be deployed into a cloud environment.
One of the new features of this tool is the capability of performing image management operations directly through a command-line interface. This capability enables a set of new use cases through a scripting environment.
The command-line interface of Image Construction and Composition Tool provides a scripting environment based on Jython (i.e. the Java-based implementation of Python) and in addition to issuing commands specific to the Image Construction and Composition Tool, you can also issue Python commands at the command prompt.
Using such interface, you can manage the Image Construction and Composition Tool remotely since you can download it to any machine and then point to the system where the tool is running: it communicates with the server using the HTTPS protocol so that all the communications are encrypted. The command-line interface can be installed on both Linux and Windows operating systems and can run in both interactive and batch modes.
Anything that can be managed in the Image Construction and Composition Tool is modelled by a resource object on the command-line interface that exposes a set of methods for performing the related management actions. The following objects are available: software bundles references (for defining software configurations to be deployed on a virtual machine), cloud providers references (for defining the hypervisors used by Image Construction and Composition Tool to build and capture images), images references (for handling virtual machine images to be used for import, extend, capture and export operations) and users references (for administering the user of Image Construction and Composition Tool ).
Once you have downloaded and configured the command-line to start a new session in interactive mode you can issue the following command from a shell prompt:
One you get the interactive shell you can start issuing commands.
Here are a few examples.
To get a list of all the images for a cloud provider, you can use a command like the following:
To import a software bundle and wait for the import to complete, you can use a set of commands like the following:
... print 'Bundle import failed!'
To get a list of all the images, you can use a command like the following:
>>> allImages = icct.images
And so on.
You can also use the Image Construction and Composition Tool command-line interface in batch mode, by creating your own script and then launching it. For example, to run a script called myScript.py you can issue the following command:
icct -h <icct server> -u username -p password -f myScript.py arg1 arg2 arg3
A few samples come directly with Image Construction and Composition Tool. They are located under the following directory:
They cover some of the Image Construction and Composition Tool basic flows, such as creating a new cloud provider configuration, importing an image, extending an image, etc..
You can use them as a starting point for creating your own workflows.
That's all for now.
We have just provided a quick introduction of all the capabilities of the Image Construction and Composition Tool command-line interface. If you are interested in discovering more about Image Construction and Composition Tool, its command-line interface and SCP 2.1, you can have a look at what is included in IBM Smart Cloud Provisioning beta code: