1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[ibm] Add state/ready? methods for Address

This commit is contained in:
Decklin Foster 2012-02-29 22:11:48 -05:00
parent 518bb3c7a0
commit 62886a41c0
2 changed files with 20 additions and 0 deletions

View file

@ -5,6 +5,17 @@ module Fog
class IBM
class Address < Fog::Model
STATES = {
0 => 'New',
1 => 'Allocating',
2 => 'Free',
3 => 'Attached',
4 => 'Releasing',
5 => 'Released',
6 => 'Failed',
7 => 'Release pending',
}
identity :id
attribute :type
@ -33,6 +44,14 @@ module Fog
true
end
def state
STATES[attributes[:state]]
end
def ready?
state == 'Free' || state == 'Released'
end
def destroy
requires :id
connection.delete_address(id).body['success']

View file

@ -35,6 +35,7 @@ Shindo.tests('Fog::Compute[:ibm] | address requests', ['ibm']) do
end
tests("#delete_address('#{@address_id}')") do
Fog::Compute[:ibm].addresses.get(@address_id).wait_for { ready? }
returns(true) { Fog::Compute[:ibm].delete_address(@address_id).body['success'] }
end