Class: SoftLayer::VirtualServerOrder_Package

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

Overview

This class is used to order a virtual 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 VirtualServerServerOrder 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 of the server as well as the set of configuration options available for that server. To fully configure the server you must select the value for each configuration option.

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

sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Virtual_Guest

Instance Attribute Summary collapse

Attributes inherited from ModelBase

#softlayer_client

Instance Method Summary collapse

Methods inherited from Server

#change_port_speed, #firewall_port_speed, #fullyQualifiedDomainName, #notes, #notes=, #primary_private_ip, #primary_public_ip, #reboot!, #reload_os!, #set_domain!, #set_hostname!, #softlayer_properties, #software, #to_s

Methods included from DynamicAttribute

included

Methods inherited from ModelBase

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

Constructor Details

#initialize(client = nil) ⇒ VirtualServerOrder_Package

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


84
85
86
87
88
89
90
# File 'lib/softlayer/VirtualServerOrder_Package.rb', line 84

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

  @configuration_options = []
  @package               = SoftLayer::ProductPackage.virtual_server_package(@softlayer_client)
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)


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

def configuration_options
  @configuration_options
end

#datacenterObject

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.


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

def datacenter
  @datacenter
end

#domainObject

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


43
44
45
# File 'lib/softlayer/VirtualServerOrder_Package.rb', line 43

def domain
  @domain
end

#hostnameObject

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


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

def hostname
  @hostname
end

#hourlyObject

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_Virtual_Guest container documentation


62
63
64
# File 'lib/softlayer/VirtualServerOrder_Package.rb', line 62

def hourly
  @hourly
end

#image_templateObject

An instance of the SoftLayer::ImageTemplate class. Represents the image template that should be installed on the server.


66
67
68
# File 'lib/softlayer/VirtualServerOrder_Package.rb', line 66

def image_template
  @image_template
end

#packageObject (readonly)

The product package object (an instance of SoftLayer::ProductPackage) identifying the base configuration for the server. A Virtual Server product package is returned by SoftLayer::ProductPackage.virtual_server_package


32
33
34
# File 'lib/softlayer/VirtualServerOrder_Package.rb', line 32

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.


70
71
72
# File 'lib/softlayer/VirtualServerOrder_Package.rb', line 70

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()

75
76
77
# File 'lib/softlayer/VirtualServerOrder_Package.rb', line 75

def ssh_key_ids
  @ssh_key_ids
end

#user_metadataObject

String, User metadata associated with the instance Corresponds to userData in the SoftLayer_Virtual_Guest documentation


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

def 
  @user_metadata
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.


119
120
121
122
123
# File 'lib/softlayer/VirtualServerOrder_Package.rb', line 119

def place_order!
  product_order = virtual_server_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.


101
102
103
104
105
# File 'lib/softlayer/VirtualServerOrder_Package.rb', line 101

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