Class: SoftLayer::BareMetalServerOrder_Package

Inherits:
Server show all
Defined in:
lib/softlayer/BareMetalServerOrder_Package.rb

Overview

This class is used to order a hardware server using a product package.

Ordering a server using a product package is a more complex process than ordering with simple attributes (as is done by the BareMetalServerOrder class). However with that complexity comes the the ability to specify the configuration of the server in exacting detail.

To use this class, you first select a product package. The product package defines the base configuration, the chassis, of the server as well as the set of configuration options available for that chassis. To fully configure the server you must select the value for each configuration option.

This class roughly Corresponds to the SoftLayer_Container_Product_Order_Hardware_Server data type in the SoftLayer API

sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Hardware_Server

Instance Attribute Summary collapse

Attributes inherited from ModelBase

#softlayer_client

Instance Method Summary collapse

Methods inherited from Server

#change_port_speed, #fullyQualifiedDomainName, #notes, #notes=, #primary_private_ip, #primary_public_ip, #reload_os!, #set_domain!, #set_hostname!, #softlayer_properties, #to_s, #user_metadata=

Methods inherited from ModelBase

#[], #has_sl_property?, #refresh_details, #service, sl_attr, #to_ary

Constructor Details

#initialize(package, client = nil) ⇒ BareMetalServerOrder_Package

You initialize a BareMetalServerOrder_Package by passing in the package that you are ordering from.



86
87
88
89
90
91
92
# File 'lib/softlayer/BareMetalServerOrder_Package.rb', line 86

def initialize(package, 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

  @package = package
  @configuration_options = []
end

Instance Attribute Details

#configuration_optionsObject

The value of this property should be a hash. The keys of the hash are ProdcutItemCategory codes (like ‘os’ and ‘ram’) while the values may be Integers or Objects. The Integer values should be the id of a SoftLayer_Product_Item_Price representing the configuration option chosen for that category. Objects must respond to the price_id message and return an integer that is the id of a SoftLayer_Product_Item_Price. Instances of the ProductConfigurationOption class behave this way.

At a minimum, the configuation_options should include entries for each of the categories required by the package (i.e. those returned from ProductPackage#required_categories)



69
70
71
# File 'lib/softlayer/BareMetalServerOrder_Package.rb', line 69

def configuration_options
  @configuration_options
end

#datacenterObject

String, short name of the data center that will house the new virtual server (e.g. “dal05” or “sea01”) A list of valid data centers can be found in ProductPackage#datacenter_options



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

def datacenter
  @datacenter
end

#domainObject

The domain of the server being created (i.e. ‘softlayer.com’ is the domain of sldn.softlayer.com)



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

def domain
  @domain
end

#hostnameObject

The hostname of the server being created (i.e. ‘sldn’ is the hostname of sldn.softlayer.com).



55
56
57
# File 'lib/softlayer/BareMetalServerOrder_Package.rb', line 55

def hostname
  @hostname
end

#packageObject (readonly)

The product package identifying the base configuration for the server. a list of Bare Metal Server product packages is returned by SoftLayer::ProductPackage.bare_metal_server_packages



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

def package
  @package
end

#provision_script_URIObject

The URI of a script to execute on the server after it has been provisioned. This may be any object which accepts the to_s message. The resulting string will be passed to SoftLayer API.



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

def provision_script_URI
  @provision_script_URI
end

#ssh_key_idsObject

An array of the ids of SSH keys to install on the server upon provisioning To obtain a list of existing SSH keys, call getSshKeys on the SoftLayer_Account service:

client['Account'].getSshKeys()


77
78
79
# File 'lib/softlayer/BareMetalServerOrder_Package.rb', line 77

def ssh_key_ids
  @ssh_key_ids
end

Instance Method Details

#place_order!Object

Submit the order to be executed by the SoftLayer ordering system. If successful this will probably result in additional billing items applied to your account!

If you add a block to the method call, it will receive the product order template before it is sent to the API. You may carefully make changes to the template to provide specialized configuration.

The return value of this call is a product order receipt. After submitting the order, it will proceed to Sales for authorization.



121
122
123
124
125
# File 'lib/softlayer/BareMetalServerOrder_Package.rb', line 121

def place_order!
  product_order = hardware_order
  product_order = yield product_order if block_given?
  softlayer_client["Product_Order"].placeOrder(product_order)
end

#verifyObject

Present the order for verification by the SoftLayer ordering system. The order is verified, but not executed. This should not change the billing of your account.

If you add a block to the method call, it will receive the product order template before it is sent to the API. You may carefully make changes to the template to provide specialized configuration.



103
104
105
106
107
# File 'lib/softlayer/BareMetalServerOrder_Package.rb', line 103

def verify
  product_order = hardware_order
  product_order = yield product_order if block_given?
  softlayer_client["Product_Order"].verifyOrder(product_order)
end