Class: Fog::Compute::IBM::Address
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::IBM::Address
- 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
- #destroy ⇒ Object
-
#initialize(new_attributes = {}) ⇒ Address
constructor
A new instance of Address.
- #ready? ⇒ Boolean
- #save ⇒ Object
- #state ⇒ Object
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
#destroy ⇒ Object
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
50 51 52 |
# File 'lib/fog/ibm/models/compute/address.rb', line 50 def ready? state == 'Free' || state == 'Released' end |
#save ⇒ Object
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 |
#state ⇒ Object
46 47 48 |
# File 'lib/fog/ibm/models/compute/address.rb', line 46 def state STATES[attributes[:state]] end |