Class: Fog::Compute::IBM::Address

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/ibm/models/compute/address.rb

Constant Summary collapse

STATES =
{
  0 => 'New',
  1 => 'Allocating',
  2 => 'Free',
  3 => 'Attached',
  4 => 'Releasing',
  5 => 'Released',
  6 => 'Failed',
  7 => 'Release pending',
}

Instance Method Summary collapse

Constructor Details

#initialize(new_attributes = {}) ⇒ Address

Returns a new instance of Address.



31
32
33
34
35
# File 'lib/fog/ibm/models/compute/address.rb', line 31

def initialize(new_attributes={})
  super(new_attributes)
  self.offering_id ||= '20001223'
  self.location ||= '82'
end

Instance Method Details

#destroyObject



54
55
56
57
# File 'lib/fog/ibm/models/compute/address.rb', line 54

def destroy
  requires :id
  service.delete_address(id).body['success']
end

#ready?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/fog/ibm/models/compute/address.rb', line 50

def ready?
  state == 'Free' || state == 'Released'
end

#saveObject



37
38
39
40
41
42
43
44
# File 'lib/fog/ibm/models/compute/address.rb', line 37

def save
  requires :offering_id, :location
  data = service.create_address(location, offering_id,
                                   :vlan_id => vlan_id,
                                   :ip => ip)
  merge_attributes(data.body)
  true
end

#stateObject



46
47
48
# File 'lib/fog/ibm/models/compute/address.rb', line 46

def state
  STATES[attributes[:state]]
end