class SoftLayer::BareMetalServerOrder_Package
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
Attributes
The value of this property should be a hash. The keys of the hash are ProductItemCategory 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 #configuration_options should include entries for each of the categories required by the package (i.e. those returned from SoftLayer::ProductPackage#required_categories)
An instance of SoftLayer::Datacenter. The server will be provisioned in this data center. The set of datacenters available is determined by the package and may be obtained from the SoftLayer::ProductPackage object using the datacenter_options method.
The domain of the server being created (i.e. 'softlayer.com' is the domain of sldn.softlayer.com)
The hostname of the server being created (i.e. 'sldn' is the hostname of sldn.softlayer.com).
Boolean, If true, an hourly server will be ordered, otherwise a monthly
server will be ordered Corresponds to useHourlyPricing
in the
SoftLayer_Container_Product_Order_Hardware_Server container documentation
An instance of the SoftLayer::ImageTemplate class. Represents the image template that should be installed on the server.
The product package object (an instance of SoftLayer::ProductPackage) identifying the base configuration for the server. A list of Bare Metal Server product packages is returned by SoftLayer::ProductPackage.bare_metal_server_packages
Integer, The id of the private VLAN this server should join Corresponds to
primaryBackendNetworkComponent.networkVlan.id
in the
createObject
documentation
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.
DEPRECATION WARNING: This attribute is deprecated in favor of #provision_script_uri and will be removed in the next major release.
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.
Integer, The id of the public VLAN this server should join Corresponds to
primaryNetworkComponent.networkVlan.id
in the
createObject
documentation
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()
String, User metadata associated with the
instance Corresponds to userData
in the
SoftLayer_Hardware_Server
documentation
Public Class Methods
You initialize a BareMetalServerOrder_Package by passing in the package that you are ordering from.
# File lib/softlayer/BareMetalServerOrder_Package.rb, line 99 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
Public Instance Methods
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.
# File lib/softlayer/BareMetalServerOrder_Package.rb, line 134 def place_order! product_order = hardware_order product_order = yield product_order if block_given? softlayer_client[:Product_Order].placeOrder(product_order) end
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.
# File lib/softlayer/BareMetalServerOrder_Package.rb, line 116 def verify product_order = hardware_order product_order = yield product_order if block_given? softlayer_client[:Product_Order].verifyOrder(product_order) end
Protected Instance Methods
Construct and return a hash representing a
SoftLayer_Container_Product_Order_Hardware_Server
based on the
configuration options given.
# File lib/softlayer/BareMetalServerOrder_Package.rb, line 145 def hardware_order product_order = { 'packageId' => @package.id, 'hardware' => [{ 'domain' => @domain, 'hostname' => @hostname }], 'useHourlyPricing' => !!@hourly } #Note that the use of image_template and SoftLayer::ProductPackage os/guest_diskX configuration category #item prices is mutually exclusive. product_order['hardware'][0]['userData'] = @user_metadata if @user_metadata product_order['imageTemplateGlobalIdentifier'] = @image_template.global_id if @image_template product_order['location'] = @datacenter.id if @datacenter product_order['provisionScripts'] = [@provision_script_URI.to_s] if @provision_script_URI product_order['provisionScripts'] = [@provision_script_uri.to_s] if @provision_script_uri product_order['sshKeys'] = [{ 'sshKeyIds' => @ssh_key_ids }] if @ssh_key_ids product_order['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id product_order['primaryBackendNetworkComponent'] = { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id product_order['prices'] = @configuration_options.collect do |key, value| if value.respond_to?(:price_id) price_id = value.price_id else price_id = value.to_i end { 'id' => price_id } end product_order end