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 thorugh the given client connection



123
124
125
126
# File 'lib/softlayer/VirtualServerOrder.rb', line 123

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



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

def cores
  @cores
end

#datacenterObject

String, short name of the data center that will house the new virtual server (e.g. “dal05” or “sea01”) Corresponds to datacenter.name in the documentation for createObject. If not provided, the server will be provisioned in the first available data center.



44
45
46
# File 'lib/softlayer/VirtualServerOrder.rb', line 44

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



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

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



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

def disks
  @disks
end

#domainObject

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



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

def domain
  @domain
end

#hostnameObject

String, The hostname to assign to the new server



47
48
49
# File 'lib/softlayer/VirtualServerOrder.rb', line 47

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



89
90
91
# File 'lib/softlayer/VirtualServerOrder.rb', line 89

def hourly
  @hourly
end

#image_global_idObject

String, The globalIdentifier of a disk image to put on the newly created server Corresponds to blockDeviceTemplateGroup.globalIdentifier in the createObject documentation



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

def image_global_id
  @image_global_id
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



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

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



58
59
60
# File 'lib/softlayer/VirtualServerOrder.rb', line 58

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



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

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



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

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



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

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



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

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



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

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



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

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



116
117
118
# File 'lib/softlayer/VirtualServerOrder.rb', line 116

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



120
121
122
# File 'lib/softlayer/VirtualServerOrder.rb', line 120

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



148
149
150
151
152
153
154
# File 'lib/softlayer/VirtualServerOrder.rb', line 148

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.



135
136
137
138
139
140
# File 'lib/softlayer/VirtualServerOrder.rb', line 135

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

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