November 23, 2017

Create an flex image from a Server

The script makes a single call to the SoftLayer_Hardware_Server::captureTemplate
method in order to create a flex image from the bare metal server.
For more information please see below.

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 page:

Author: SoftLayer Technologies, Inc. <>
import SoftLayer

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

# Generate one at
API_KEY = 'set me'

# The hardware server ID of the machine you wish to create the image template
hardwareServerId = 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)
hardwareServerService = client['SoftLayer_Hardware_Server']

    # calling the captureImage method along with our captureTemplate to create the flexImage
    result = hardwareServerService.captureImage(captureTemplate, id=hardwareServerId)
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