Building virtual images in a scripting environment with IBM SmartCloud Provisioning

In this post, I describe how you can script the building of virtual images by using the Image Construction and Composition Tool provided by IBM SmartCloud Provisioning.

The upcoming release of IBM SmartCloud Provisioning 2.1 embeds, among other things, a new version of the Image Construction and Composition Tool. With this tool, you can build virtual images that are self-descriptive, customizable, and manageable; at the end, it produces Open Virtualization Appliance (OVA) images that can be deployed to 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 (CLI). This capability enables a set of new use cases through a scripting environment.

The CLI of the Image Construction and Composition Tool provides a scripting environment based on Jython (the Java-based implementation of Python); in addition to issuing commands specific to the Image Construction and Composition Tool, you can also issue Python commands at the command prompt.

With the interface, you can manage the Image Construction and Composition Tool remotely because 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 CLI 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 CLI 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)
  • User references (for administering the user of Image Construction and Composition Tool).

After you download and configure the command-line to start a new session in interactive mode, you can issue the following command from a shell prompt:

<icct_cli-install-dir>/bin/icct -h <icct server> -u username -p password

When you get the interactive shell, you can start issuing commands.

Here are several examples:

Get a list of all the images for a cloud provider:

>>> icct.cloudproviders[0].getImages()

Import a software bundle and wait for the import to complete; use a set of commands:

>>> importingBundle = icct.bundles.import('http://localhost/myBundle.ras')

>>> importingBundle.waitFor()

>>> if importingBundle.currentState == 'import_failed':

... print 'Bundle import failed!'

Get a list of all the images:

>>> 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 named myScript.py, 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:

<icct_cli-install-dir>/samples

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, and more.

You can use them as a starting point for creating your own workflows.

That's all for now.

This is 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 this tool, its command-line interface, and SCP 2.1, see what is included in IBM SmartCloud Provisioning beta code:

Customer interaction program

Cloud Provisioning and Orchestration - Development Collaboration Community

Share
Comments: 2
Mauro Arcese

About Mauro Arcese

Mauro is an advisory software engineer in the IBM Software Group based in Italy with 12 years experience in the systems management area. Over the past years he has been working on the design and implementation of various products in that area (Tivoli Software Distribution, Tivoli Configuration Manager, Tivoli Provisioning Manager). He is currently member of the Smart Cloud Provisioning development team.
This entry was posted in Managing the Cloud and tagged , , , , , , , . Bookmark the permalink.