class SoftLayer::VirtualServerUpgradeOrder
This class is used to order changes to a virtual server. Although the class is named “upgrade” this class can also be used for “downgrades” (i.e. changing attributes to a smaller, or slower, value)
The class can also be used to discover what upgrades are available for a given virtual server.
Attributes
The number of cores the server should have after the upgrade. If this is nil, the the number of cores will not change
The port speed (in Mega bits per second) that the server should have after the upgrade. This is typically a value like 100, or 1000 If this is nil, the port speeds will not change
The amount of RAM (in GB) that the server should have after the upgrade If this is nil, the ram will not change
The date and time when you would like the upgrade to be processed. This should simply be a Time object. If nil then the upgrade will be performed immediately
The virtual server that this order is designed to upgrade.
Public Class Methods
Create an upgrade order for the virtual server provided.
# File lib/softlayer/VirtualServerUpgradeOrder.rb, line 40 def initialize(virtual_server) raise "A virtual server must be provided at the time a virtual server order is created" if !virtual_server || !virtual_server.kind_of?(SoftLayer::VirtualServer) @virtual_server = virtual_server end
Public Instance Methods
Return a list of values that are valid for the :cores attribute
# File lib/softlayer/VirtualServerUpgradeOrder.rb, line 78 def core_options() self._item_prices_in_category("guest_core").map { |item_price| item_price['item']['capacity'].to_i}.sort.uniq end
Returns a list of valid values for #max_port_speed
# File lib/softlayer/VirtualServerUpgradeOrder.rb, line 90 def max_port_speed_options(client = nil) self._item_prices_in_category("port_speed").map { |item_price| item_price['item']['capacity'].to_i}.sort.uniq end
Return a list of values that are valid for the :memory attribute
# File lib/softlayer/VirtualServerUpgradeOrder.rb, line 84 def memory_options() self._item_prices_in_category("ram").map { |item_price| item_price['item']['capacity'].to_i}.sort.uniq end
Places the order represented by this object. This is likely to involve a change to the charges on an account.
If a block is passed to this routine, the code will send the order template being constructed to that block before the order is sent
# File lib/softlayer/VirtualServerUpgradeOrder.rb, line 67 def place_order!() if has_order_items? order_template = order_object order_template = yield order_object if block_given? @virtual_server.softlayer_client[:Product_Order].placeOrder(order_template) end end
Sends the order represented by this object to SoftLayer for validation.
If a block is passed to verify, the code will send the order template being constructed to the block before the order is actually sent for validation.
# File lib/softlayer/VirtualServerUpgradeOrder.rb, line 52 def verify() if has_order_items? order_template = order_object order_template = yield order_object if block_given? @virtual_server.softlayer_client[:Product_Order].verifyOrder(order_template) end end