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

add new method to Slicehost - get_zones (not debugged yet)

have added new parser and request for get_zones.  As slicehost docs are sparse, parser has not been updated.  Will do so once I analyze xml that comes back from request (ie next checkin should have working parser)
This commit is contained in:
Athir Nuaimi 2010-12-09 11:51:17 -05:00
parent 0b5e0d9e19
commit 9d4b6a8bfb
3 changed files with 79 additions and 0 deletions

View file

@ -24,6 +24,7 @@ module Fog
request :get_slice
request :get_slices
request :reboot_slice
request :get_zones
class Mock

View file

@ -0,0 +1,35 @@
module Fog
module Parsers
module Slicehost
module Compute
class GetZones < Fog::Parsers::Base
def reset
@zone = {}
@response = { 'zones' => [] }
end
def end_element(name)
case name
when 'address'
@slice['addresses'] ||= []
@slice['addresses'] << @value
when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress'
@slice[name] = @value.to_i
when 'bw-in', 'bw-out'
@slice[name] = @value.to_f
when 'name', 'status'
@slice[name] = @value
when 'slice'
@response['slices'] << @slice
@slice = {}
end
end
end
end
end
end
end

View file

@ -0,0 +1,43 @@
module Fog
module Slicehost
class Compute
class Real
require 'fog/slicehost/parsers/compute/get_zones'
# Get list of DNS zones
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'addresses'<~Array> - Ip addresses for the slice
# * 'backup-id'<~Integer> - Id of backup slice was booted from
# * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes
# * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
# * 'id'<~Integer> - Id of the slice
# * 'image-id'<~Integer> - Id of image slice was booted from
# * 'name'<~String> - Name of the slice
# * 'progress'<~Integer> - Progress of current action, in percentage
# * 'status'<~String> - Current status of the slice
def get_zones
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Slicehost::Compute::GetZones.new,
:path => 'zones.xml'
)
end
end
class Mock
def get_zones
Fog::Mock.not_implemented
end
end
end
end
end