Class: SoftLayer::VirtualServerOrder

Inherits:
Object
  • Object
show all
Defined in:
lib/softlayer/VirtualServerOrder.rb

Overview

VirtualServerOrder orders virtual servers using SoftLayer_Virtual_Guest::createObject.

sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject

createObject allows you to order a virtual server by providing a simple set of attributes and allows you to avoid much of the complexity of the SoftLayer ordering system (see ProductPackage)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client = nil) ⇒ VirtualServerOrder

Create a new order that works through the given client connection



112
113
114
115
# File 'lib/softlayer/VirtualServerOrder.rb', line 112

def initialize (client = nil)
  @softlayer_client = client || Client.default_client
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !@softlayer_client
end

Instance Attribute Details

#coresObject

Integer, The number of virtual CPU cores to include in the instance Corresponds to startCpus in the documentation for createObject



36
37
38
# File 'lib/softlayer/VirtualServerOrder.rb', line 36

def cores
  @cores
end

#datacenterObject

An instance of SoftLayer::Datacenter. The server will be provisioned in that Datacenter.



26
27
28
# File 'lib/softlayer/VirtualServerOrder.rb', line 26

def datacenter
  @datacenter
end

#dedicated_host_onlyObject

Boolean, If true, the virtual server will reside only on hosts with instances from this same account Corresponds to dedicatedAccountHostOnlyFlag in the createObject documentation



62
63
64
# File 'lib/softlayer/VirtualServerOrder.rb', line 62

def dedicated_host_only
  @dedicated_host_only
end

#disksObject

Array of Integer, Sizes (in gigabytes… so use 25 to get a 25GB disk) of disks to attach to this server This roughly Corresponds to blockDevices field in the createObject documentation. This attribute only allows you to configure the size of disks while blockDevices allows more configuration options



68
69
70
# File 'lib/softlayer/VirtualServerOrder.rb', line 68

def disks
  @disks
end

#domainObject

String, The domain (i.e. softlayer.com) for the new server



32
33
34
# File 'lib/softlayer/VirtualServerOrder.rb', line 32

def domain
  @domain
end

#hostnameObject

String, The hostname to assign to the new server



29
30
31
# File 'lib/softlayer/VirtualServerOrder.rb', line 29

def hostname
  @hostname
end

#hourlyObject

Boolean, If true, an hourly server will be ordered, otherwise a monthly server will be ordered Corresponds to hourlyBillingFlag in the createObject documentation



72
73
74
# File 'lib/softlayer/VirtualServerOrder.rb', line 72

def hourly
  @hourly
end

#image_templateObject

An instance of the SoftLayer::ImageTemplate class. Represents the image template that should be installed on the server.



54
55
56
# File 'lib/softlayer/VirtualServerOrder.rb', line 54

def image_template
  @image_template
end

#max_port_speedObject

Integer, The maximum network interface card speed (in Mbps) for the new instance Corresponds to networkComponents.maxSpeed in the createObject documentation



76
77
78
# File 'lib/softlayer/VirtualServerOrder.rb', line 76

def max_port_speed
  @max_port_speed
end

#memoryObject

Integer, The amount of RAM for the new server (specified in Gigabytes so a value of 4 is 4GB) Corresponds to maxMemory in the documentation for createObject



40
41
42
# File 'lib/softlayer/VirtualServerOrder.rb', line 40

def memory
  @memory
end

#os_reference_codeObject

String, An OS reference code for the operating system to install on the virtual server Corresponds to operatingSystemReferenceCode in the createObject documentation



50
51
52
# File 'lib/softlayer/VirtualServerOrder.rb', line 50

def os_reference_code
  @os_reference_code
end

#private_network_onlyObject

Boolean, If true then the virtual server will only have a private network interface (and no public network interface) Corresponds to userData.value in the createObject documentation



80
81
82
# File 'lib/softlayer/VirtualServerOrder.rb', line 80

def private_network_only
  @private_network_only
end

#private_vlan_idObject

Integer, The id of the private VLAN this server should join Corresponds to primaryBackendNetworkComponent.networkVlan.id in the createObject documentation



84
85
86
# File 'lib/softlayer/VirtualServerOrder.rb', line 84

def private_vlan_id
  @private_vlan_id
end

#provision_script_uriObject

String, The URI of a post provisioning script to run on this server once it is created



87
88
89
# File 'lib/softlayer/VirtualServerOrder.rb', line 87

def provision_script_uri
  @provision_script_uri
end

#provision_script_URIObject

String, The URI of a post provisioning script to run on this server once it is created

DEPRECATION WARNING: This attribute is deprecated in favor of provision_script_uri and will be removed in the next major release.



93
94
95
# File 'lib/softlayer/VirtualServerOrder.rb', line 93

def provision_script_URI
  @provision_script_URI
end

#public_vlan_idObject

Integer, The id of the public VLAN this server should join Corresponds to primaryNetworkComponent.networkVlan.id in the createObject documentation



97
98
99
# File 'lib/softlayer/VirtualServerOrder.rb', line 97

def public_vlan_id
  @public_vlan_id
end

#ssh_key_idsObject

Array of Strings, SSH keys to add to the root user’s account. Corresponds to sshKeys in the createObject documentation



101
102
103
# File 'lib/softlayer/VirtualServerOrder.rb', line 101

def ssh_key_ids
  @ssh_key_ids
end

#use_local_diskObject

Boolean, If true the server will use a virtual hard drive, if false, data will be stored on a SAN disk Corresponds to localDiskFlag in the createObject documentation



105
106
107
# File 'lib/softlayer/VirtualServerOrder.rb', line 105

def use_local_disk
  @use_local_disk
end

#user_metadataObject

String, User metadata associated with the instance Corresponds to primaryBackendNetworkComponent.networkVlan.id in the createObject documentation



109
110
111
# File 'lib/softlayer/VirtualServerOrder.rb', line 109

def 
  @user_metadata
end

Instance Method Details

#place_order!Object

Calls the SoftLayer API to place an order for a new virtual server based on the template in this order. If this succeeds then you will be billed for the new Virtual Server.

If you provide a block, it will receive the order template as a parameter and should return an order template, carefully modified, that will be sent to create the server



137
138
139
140
141
142
143
# File 'lib/softlayer/VirtualServerOrder.rb', line 137

def place_order!()
  order_template = virtual_guest_template
  order_template = yield order_template if block_given?

  virtual_server_hash = @softlayer_client[:Virtual_Guest].createObject(order_template)
  SoftLayer::VirtualServer.server_with_id(virtual_server_hash['id'], :client => @softlayer_client) if virtual_server_hash
end

#verifyObject

Calls the SoftLayer API to verify that the template provided by this order is valid This routine will return the order template generated by the API or will throw an exception

This routine will not actually create a Virtual Server and will not affect billing.

If you provide a block, it will receive the order template as a parameter and it should return the order template you wish to forward to the server.



124
125
126
127
128
129
# File 'lib/softlayer/VirtualServerOrder.rb', line 124

def verify()
  order_template = virtual_guest_template
  order_template = yield order_template if block_given?

  @softlayer_client[:Virtual_Guest].generateOrderTemplate(order_template)
end