Class: SoftLayer::BareMetalServerOrder

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

Overview

This class allows you to order a Bare Metal Server by providing a simple set of attributes for the newly created server. The SoftLayer system will select a server that matches the attributes provided and provision it or will report an error.

If you wish to have more exacting control over the set of options that go into configuring the server, please see the BareMetalServerOrder_Package class.

This class creates the server with the SoftLayer_Hardware::createObject method.

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

Reading that documentation may help you understand the options presented here.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client = nil) ⇒ BareMetalServerOrder

Create a new order that works thorugh the given client connection


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

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 cpu cores to include in the instance Corresponds to processorCoreAmount in the documentation for createObject


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

def cores
  @cores
end

#datacenterObject

An instance of SoftLayer::Datacenter. The server will be provisioned in this data center


34
35
36
# File 'lib/softlayer/BareMetalServerOrder.rb', line 34

def datacenter
  @datacenter
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 hardDrives field in the createObject documentation.


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

def disks
  @disks
end

#domainObject

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


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

def domain
  @domain
end

#hostnameObject

String, The hostname to assign to the new server


37
38
39
# File 'lib/softlayer/BareMetalServerOrder.rb', line 37

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


60
61
62
# File 'lib/softlayer/BareMetalServerOrder.rb', line 60

def hourly
  @hourly
end

#max_port_speedObject

Integer (Should be 10, 100, or 1000), 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/BareMetalServerOrder.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 memoryCapacity in the documentation for createObject


48
49
50
# File 'lib/softlayer/BareMetalServerOrder.rb', line 48

def memory
  @memory
end

#os_reference_codeObject

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


52
53
54
# File 'lib/softlayer/BareMetalServerOrder.rb', line 52

def os_reference_code
  @os_reference_code
end

#private_network_onlyObject

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


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

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


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

def private_vlan_id
  @private_vlan_id
end

#provision_script_URIObject

Object responding to to_s and providing a valid URI, The URI of a post provisioning script to run on this server once it is created. Corresponds to postInstallScriptUri in the createObject documentation


81
82
83
# File 'lib/softlayer/BareMetalServerOrder.rb', line 81

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


64
65
66
# File 'lib/softlayer/BareMetalServerOrder.rb', line 64

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


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

def ssh_key_ids
  @ssh_key_ids
end

#user_metadataObject

String, User metadata associated with the instance Corresponds to userData.value in the createObject documentation


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

def 
  @user_metadata
end

Instance Method Details

#place_order!Object

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

If you provide a block, it will receive the order template as a parameter and the block may make changes to the template before it is submitted.


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

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

  server_hash = @softlayer_client[:Hardware].createObject(order_template)
  SoftLayer::BareMetalServer.server_with_id(server_hash['id'], :client => @softlayer_client) if 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 Bare Metal Instance and will not affect billing.

If you provide a block, it will receive the order template as a parameter and the block may make changes to the template before it is submitted.


110
111
112
113
114
115
# File 'lib/softlayer/BareMetalServerOrder.rb', line 110

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

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