November 23, 2017

Create an flex image from a CCI

The script makes a single call to the  SoftLayer_Virtual_Guest::captureImage method
to create an flex image. please see below for more information.

IMPORTANT: This script will no longer work properly as of Monday August 7,
2017 IBM Cloud (formerly SoftLayer) has discontinued offering the Flex Image service.

Important manual pages:

Author: SoftLayer Technologies, Inc. <>
import SoftLayer

# Your SoftLayer API username and key.
API_USERNAME = 'set me'

# Generate one at
API_KEY = 'set me'

# The virtual guest ID of the machine you wish to create the image template
virtualGuestId = 7438972

Creating an SoftLayer_Container_Disk_Image_Capture_Template Skeleton
which contains the information for our flex image
captureTemplate = {
    "complexType": "SoftLayer_Container_Disk_Image_Capture_Template",
    "description": "test",
    "name": "reloadFlexImage",
    "summary": "test summary",

Declare the API client
client = SoftLayer.Client(endpoint_url=ENDPOINT, username=USERNAME,api_key=API_KEY)
client = SoftLayer.create_client_from_env(username=API_USERNAME, api_key=API_KEY)
virtualGuestService = client['SoftLayer_Virtual_Guest']

    # calling the captureImage method along with our captureTemplate to create the flexImage
    result = virtualGuestService.captureImage(captureTemplate, id=virtualGuestId)
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to create the image template. \nfaultCode= %s, \nfaultString= %s"
          % (e.faultCode, e.faultString))


We would love to hear it
Open an issue