Class: Fog::Compute::IBM::Address
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::IBM::Address
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 Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(new_attributes = {}) ⇒ 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
connection.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 = connection.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
|