Class: SoftLayer::BareMetalServerOrder
- Inherits:
-
Object
- Object
- SoftLayer::BareMetalServerOrder
- 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
-
#cores ⇒ Object
Integer, The number of cpu cores to include in the instance Corresponds to
processorCoreAmountin the documentation forcreateObject. -
#datacenter ⇒ Object
String, short name of the data center that will house the new Bare Metal Instance (e.g. “dal05” or “sea01”) Corresponds to
datacenter.namein the documentation forcreateObject. -
#disks ⇒ Object
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
hardDrivesfield in thecreateObjectdocumentation. -
#domain ⇒ Object
String, The domain (i.e. softlayer.com) for the new server.
-
#hostname ⇒ Object
String, The hostname to assign to the new server.
-
#hourly ⇒ Object
Boolean, If true, an hourly server will be ordered, otherwise a monthly server will be ordered Corresponds to
hourlyBillingFlagin thecreateObjectdocumentation. -
#max_port_speed ⇒ Object
Integer (Should be 10, 100, or 1000), The maximum network interface card speed (in Mbps) for the new instance Corresponds to
networkComponents.maxSpeedin thecreateObjectdocumentation. -
#memory ⇒ Object
Integer, The amount of RAM for the new server (specified in Gigabytes so a value of 4 is 4GB) Corresponds to
memoryCapacityin the documentation forcreateObject. -
#os_reference_code ⇒ Object
String, An OS reference code for the operating system to install on the server Corresponds to
operatingSystemReferenceCodein thecreateObjectdocumentation. -
#private_network_only ⇒ Object
Boolean, If true then the server will only have a private network interface (and no public network interface) Corresponds to
privateNetworkOnlyFlagin thecreateObjectdocumentation. -
#private_vlan_id ⇒ Object
Integer, The id of the private VLAN this server should join Corresponds to
primaryBackendNetworkComponent.networkVlan.idin thecreateObjectdocumentation. -
#provision_script_URI ⇒ Object
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.
-
#public_vlan_id ⇒ Object
Integer, The id of the public VLAN this server should join Corresponds to
primaryNetworkComponent.networkVlan.idin thecreateObjectdocumentation. -
#ssh_key_ids ⇒ Object
Array of Strings, SSH keys to add to the root user’s account.
-
#user_metadata ⇒ Object
String, User metadata associated with the instance Corresponds to
userData.valuein thecreateObjectdocumentation.
Instance Method Summary collapse
-
#initialize(client = nil) ⇒ BareMetalServerOrder
constructor
Create a new order that works thorugh the given client connection.
-
#place_order! ⇒ Object
Calls the SoftLayer API to place an order for a new server based on the template in this order.
-
#verify ⇒ Object
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.
Constructor Details
#initialize(client = nil) ⇒ BareMetalServerOrder
Create a new order that works thorugh the given client connection
114 115 116 117 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 114 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
#cores ⇒ Object
Integer, The number of cpu cores to include in the instance Corresponds to processorCoreAmount in the documentation for createObject
61 62 63 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 61 def cores @cores end |
#datacenter ⇒ Object
String, short name of the data center that will house the new Bare Metal Instance (e.g. “dal05” or “sea01”) Corresponds to datacenter.name in the documentation for createObject.
51 52 53 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 51 def datacenter @datacenter end |
#disks ⇒ Object
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.
89 90 91 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 89 def disks @disks end |
#domain ⇒ Object
String, The domain (i.e. softlayer.com) for the new server
57 58 59 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 57 def domain @domain end |
#hostname ⇒ Object
String, The hostname to assign to the new server
54 55 56 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 54 def hostname @hostname end |
#hourly ⇒ Object
Boolean, If true, an hourly server will be ordered, otherwise a monthly server will be ordered Corresponds to hourlyBillingFlag in the createObject documentation
77 78 79 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 77 def hourly @hourly end |
#max_port_speed ⇒ Object
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
110 111 112 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 110 def max_port_speed @max_port_speed end |
#memory ⇒ Object
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
65 66 67 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 65 def memory @memory end |
#os_reference_code ⇒ Object
String, An OS reference code for the operating system to install on the server Corresponds to operatingSystemReferenceCode in the createObject documentation
69 70 71 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 69 def os_reference_code @os_reference_code end |
#private_network_only ⇒ Object
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
102 103 104 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 102 def private_network_only @private_network_only end |
#private_vlan_id ⇒ Object
Integer, The id of the private VLAN this server should join Corresponds to primaryBackendNetworkComponent.networkVlan.id in the createObject documentation
85 86 87 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 85 def private_vlan_id @private_vlan_id end |
#provision_script_URI ⇒ Object
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
98 99 100 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 98 def provision_script_URI @provision_script_URI end |
#public_vlan_id ⇒ Object
Integer, The id of the public VLAN this server should join Corresponds to primaryNetworkComponent.networkVlan.id in the createObject documentation
81 82 83 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 81 def public_vlan_id @public_vlan_id end |
#ssh_key_ids ⇒ Object
Array of Strings, SSH keys to add to the root user’s account. Corresponds to sshKeys in the createObject documentation
93 94 95 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 93 def ssh_key_ids @ssh_key_ids end |
#user_metadata ⇒ Object
String, User metadata associated with the instance Corresponds to userData.value in the createObject documentation
106 107 108 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 106 def 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.
140 141 142 143 144 145 146 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 140 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 |
#verify ⇒ Object
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.
127 128 129 130 131 132 |
# File 'lib/softlayer/BareMetalServerOrder.rb', line 127 def verify() order_template = hardware_instance_template order_template = yield order_template if block_given? @softlayer_client["Hardware"].generateOrderTemplate(order_template) end |