Class: SoftLayer::VirtualServerUpgradeOrder

Inherits:
Object
  • Object
show all
Defined in:
lib/softlayer/VirtualServerUpgradeOrder.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(virtual_server) ⇒ VirtualServerUpgradeOrder

Create an upgrade order for the virtual server provided.


40
41
42
43
# 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

Instance Attribute Details

#coresObject

The number of cores the server should have after the upgrade. If this is nil, the the number of cores will not change


21
22
23
# File 'lib/softlayer/VirtualServerUpgradeOrder.rb', line 21

def cores
  @cores
end

#max_port_speedObject

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


30
31
32
# File 'lib/softlayer/VirtualServerUpgradeOrder.rb', line 30

def max_port_speed
  @max_port_speed
end

#ramObject

The amount of RAM (in GB) that the server should have after the upgrade If this is nil, the ram will not change


25
26
27
# File 'lib/softlayer/VirtualServerUpgradeOrder.rb', line 25

def ram
  @ram
end

#upgrade_atObject

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


35
36
37
# File 'lib/softlayer/VirtualServerUpgradeOrder.rb', line 35

def upgrade_at
  @upgrade_at
end

#virtual_serverObject (readonly)

The virtual server that this order is designed to upgrade.


17
18
19
# File 'lib/softlayer/VirtualServerUpgradeOrder.rb', line 17

def virtual_server
  @virtual_server
end

Instance Method Details

#core_optionsObject

Return a list of values that are valid for the :cores attribute


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

def core_options()
  self._item_prices_in_category("guest_core").map { |item_price| item_price['item']['capacity'].to_i}.sort.uniq
end

#max_port_speed_options(client = nil) ⇒ Object

Returns a list of valid values for max_port_speed


91
92
93
# File 'lib/softlayer/VirtualServerUpgradeOrder.rb', line 91

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

#memory_optionsObject

Return a list of values that are valid for the :memory attribute


85
86
87
# File 'lib/softlayer/VirtualServerUpgradeOrder.rb', line 85

def memory_options()
  self._item_prices_in_category("ram").map { |item_price| item_price['item']['capacity'].to_i}.sort.uniq
end

#place_order!Object

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


68
69
70
71
72
73
74
75
# File 'lib/softlayer/VirtualServerUpgradeOrder.rb', line 68

def place_order!()
  if has_order_items?
    order_object = self.order_object
    order_object = yield order_object if block_given?

    @virtual_server.softlayer_client[:Product_Order].placeOrder(order_object)
  end
end

#verifyObject

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.


52
53
54
55
56
57
58
59
# File 'lib/softlayer/VirtualServerUpgradeOrder.rb', line 52

def verify()
  if has_order_items?
    order_object = self.order_object
    order_object = yield order_object if block_given?

    @virtual_server.softlayer_client[:Product_Order].verifyOrder(order_object)
  end
end