Class: 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 Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(new_attributes = {}) ⇒ Address
constructor
A new instance of Address.
- #ready? ⇒ Boolean
- #save ⇒ Object
- #state ⇒ Object
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Fog::Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
#initialize(new_attributes = {}) ⇒ Address
Returns a new instance of Address.
32 33 34 35 36 |
# File 'lib/fog/ibm/models/compute/address.rb', line 32 def initialize(new_attributes={}) super(new_attributes) self.offering_id ||= '20001223' self.location ||= '82' end |
Instance Method Details
#destroy ⇒ Object
55 56 57 58 |
# File 'lib/fog/ibm/models/compute/address.rb', line 55 def destroy requires :id service.delete_address(id).body['success'] end |
#ready? ⇒ Boolean
51 52 53 |
# File 'lib/fog/ibm/models/compute/address.rb', line 51 def ready? state == 'Free' || state == 'Released' end |
#save ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/fog/ibm/models/compute/address.rb', line 38 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
47 48 49 |
# File 'lib/fog/ibm/models/compute/address.rb', line 47 def state STATES[attributes[:state]] end |