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 manual page:
# License:
# Author: SoftLayer Technologies, Inc. <>

use lib 'C:/softlayerApis/perl/softlayer-api-perl-client-master/';
use SoftLayer::API::SOAP;
use Data::Dumper;

# Your SoftLayer API username and key.
my $username = 'set me';
my $key = 'set me';

# The virtual guest Id of the machine you wish to create the image template
my $hardware_server_id = 7438972;

# Creating an SoftLayer_Container_Disk_Image_Capture_Template Skeleton
# wich contains the information for our flex image
my $capture_template = bless({
    "description" => "test",
    "name" => "reloadFlexImage",
    "summary" => "test summary",
}, 'slapi:SoftLayer_Container_Disk_Image_Capture_Template');

# Creating a SoftLayer API client object
my $hardware_server_service = SoftLayer::API::SOAP->new('SoftLayer_Hardware_Server', undef, $username, $key);

# Setting the init parameter

# Calling the captureImage method along with our captureTemplate to create the flexImage
my $result = $hardware_server_service->captureImage($capture_template);
if ($result->fault) {
    die 'Unable to create the flex image. ' . $result->faultstring;
print Dumper($result->result);
print ("The flex image has been created succesfully. ");


If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue