November 23, 2017


Copy to external source

This script creates a transaction to export/copy a template to an external source.
Flex Images cannot be copied to external sources.

Important manual pages:

Author: SoftLayer Technologies, Inc. <>
package main

import (

func main() {
	// SoftLayer API username and key.
	username  := "set me"
	apikey    := "set me"

	// The image id you wish to copy to external source. Take account that Flex Images are not
	// supported.
	imageId := 879951

	// Declare storage, cluster, container and filename used to create the URL where image
	// will be copied.
	storageName   := "SLOS307608-40"
	clusterName   := "sao01"
	containerName := "softlayer_container"
	fileName      := "centos6test.vhd"

	// Create URL where image will be copied
	swift := fmt.Sprintf("swift://%s@%s/%s/%s", storageName, clusterName, containerName, fileName )

	// Build the Container_Virtual_Guest_Block_Device_Template_Configuration object
	configuration := datatypes.Container_Virtual_Guest_Block_Device_Template_Configuration{
		Uri: sl.String(swift),

	// Create session
	sess := session.New(username, apikey)

	// Get SoftLayer_Virtual_Guest_Block_Device_Template_Group service.
	service := services.GetVirtualGuestBlockDeviceTemplateGroupService(sess)

	// Copy the standard image to an external source.
	result, err := service.Id(imageId).CopyToExternalSource(&configuration)
	if err != nil {
		fmt.Printf("\n Unable to copy image to external source:\n - %s\n", err)

	// Print result


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