Create a virtual server from an existing image template
Provide an image template with a virtual machine order instead of an OS code.
Hey, listen!
This example contains deprecated methods or syntax and needs to be updated. Please use caution when using.
require'softlayer_api'require'pp'IMAGE_ID='foobar'# change me. Image template global ID.# Credentials to the API are read from a configuration file by default.# See https://github.com/softlayer/softlayer-ruby/blob/master/lib/softlayer/Config.rb#L11-L44SoftLayer::Client.default_client=SoftLayer::Client.neworder_template={hostname:'test',domain:'example.com',datacenter:'hou02',cores:2,# 2 x 2.0 GHz Coresmemory:4,# 4GB RAMprivate_network_only:false,dedicated_host_only:false,#os_reference_code: 'CENTOS_6_64', # CentOS 6.latest minimal (64 bit)image_template:SoftLayer::ImageTemplate.template_with_global_id(IMAGE_ID),use_local_disk:false,# Use a SAN diskhourly:true# Charge me for hourly use, rather than monthly.}# Set order template in our order instance,# Otherwise, you can skip using an order template hash, and just# set values directly in the order instance like `order.cores = 2`.order=SoftLayer::VirtualServerOrder.neworder_template.keys.eachdo|k|order.send("#{k}=",order_template[k])endpporder.verify# Uncomment to place the order.# server = order.place_order!# pp server