def virtual_guest_template
      template = {
        "startCpus" => @cores.to_i,
        "maxMemory" => @memory.to_i * 1024,  # we let the user specify memory in GB, but the API expects maxMemory in MB.
        "hostname" => @hostname,
        "domain" => @domain,

        # Note : for the values below, we want to use the constants "true" and "false" not nil
        # the nil value (while false to Ruby) will not translate to XML properly
        "localDiskFlag" => !!@use_local_disk,
        "hourlyBillingFlag" => !!@hourly
      }

      template['dedicatedAccountHostOnlyFlag'] = true if @dedicated_host_only
      template['privateNetworkOnlyFlag'] = true if @private_network_only

      template['datacenter']                     = {"name" => @datacenter.name}     if @datacenter
      template['userData']                       = [{'value' => @user_metadata}]    if @user_metadata
      template['networkComponents']              = [{'maxSpeed'=> @max_port_speed}] if @max_port_speed
      template['postInstallScriptUri']           = @provision_script_URI.to_s       if @provision_script_URI
      template['postInstallScriptUri']           = @provision_script_uri.to_s       if @provision_script_uri
      template['primaryNetworkComponent']        = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id
      template['primaryBackendNetworkComponent'] = { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id
      template['sshKeys']                        = @ssh_key_ids.collect { |ssh_key_id| {'id'=> ssh_key_id.to_i } } if @ssh_key_ids
      template['supplementalCreateObjectOptions'] = @supplementalCreateObjectOptions if @supplementalCreateObjectOptions

      if @image_template
        template['blockDeviceTemplateGroup'] = {"globalIdentifier" => @image_template.global_id}
      elsif @os_reference_code
        template['operatingSystemReferenceCode'] = @os_reference_code
      end

      if @disks && !@disks.empty?
        template['blockDevices'] = []

        # According to the documentation for +createObject+,
        # device number 1 is reserved for the SWAP disk of the computing instance.
        # So we assign device 0 and then assign the rest starting at index 2.
        @disks.each_with_index do |disk, index|
          device_id = (index >= 1) ? index + 1 : index
          template['blockDevices'].push({"device" => "#{device_id}", "diskImage" => {"capacity" => disk}})
        end
      end

      template
    end
def virtual_guest_template
      template = {
        "startCpus" => @cores.to_i,
        "maxMemory" => @memory.to_i * 1024,  # we let the user specify memory in GB, but the API expects maxMemory in MB.
        "hostname" => @hostname,
        "domain" => @domain,

        # Note : for the values below, we want to use the constants "true" and "false" not nil
        # the nil value (while false to Ruby) will not translate to XML properly
        "localDiskFlag" => !!@use_local_disk,
        "hourlyBillingFlag" => !!@hourly
      }

      template['dedicatedAccountHostOnlyFlag'] = true if @dedicated_host_only
      template['privateNetworkOnlyFlag'] = true if @private_network_only

      template['datacenter']                     = {"name" => @datacenter.name}     if @datacenter
      template['userData']                       = [{'value' => @user_metadata}]    if @user_metadata
      template['networkComponents']              = [{'maxSpeed'=> @max_port_speed}] if @max_port_speed
      template['postInstallScriptUri']           = @provision_script_URI.to_s       if @provision_script_URI
      template['postInstallScriptUri']           = @provision_script_uri.to_s       if @provision_script_uri
      template['primaryNetworkComponent']        = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id
      template['primaryBackendNetworkComponent'] = { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id
      template['sshKeys']                        = @ssh_key_ids.collect { |ssh_key_id| {'id'=> ssh_key_id.to_i } } if @ssh_key_ids
      template['supplementalCreateObjectOptions'] = @supplementalCreateObjectOptions if @supplementalCreateObjectOptions

      if @image_template
        template['blockDeviceTemplateGroup'] = {"globalIdentifier" => @image_template.global_id}
      elsif @os_reference_code
        template['operatingSystemReferenceCode'] = @os_reference_code
      end

      if @disks && !@disks.empty?
        template['blockDevices'] = []

        # According to the documentation for +createObject+,
        # device number 1 is reserved for the SWAP disk of the computing instance.
        # So we assign device 0 and then assign the rest starting at index 2.
        @disks.each_with_index do |disk, index|
          device_id = (index >= 1) ? index + 1 : index
          template['blockDevices'].push({"device" => "#{device_id}", "diskImage" => {"capacity" => disk}})
        end
      end

      template
    end
Returns a hash of the creation options formatted to be sent to
 the SoftLayer API for either verification or completion