mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[terremark] Mock get_public_ips
This commit is contained in:
parent
62a39a8eca
commit
f95a2ddad8
2 changed files with 48 additions and 1 deletions
|
@ -32,7 +32,38 @@ module Fog
|
|||
module Mock
|
||||
|
||||
def get_public_ips(vdc_id)
|
||||
raise MockNotImplemented.new("Contributions welcome!")
|
||||
vdc_id = vdc_id.to_i
|
||||
response = Excon::Response.new
|
||||
|
||||
if vdc = @data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:id] == vdc_id }
|
||||
body = { "PublicIpAddresses" => [] }
|
||||
vdc[:public_ips].each do |ip|
|
||||
ip = { "name" => ip[:name],
|
||||
"href" => case self
|
||||
when Fog::Terremark::Ecloud::Mock
|
||||
"#{@base_url}/extensions/publicIp/#{ip[:id]}"
|
||||
when Fog::Terremark::Vcloud::Mock
|
||||
"#{@base_url}/PublicIps/#{ip[:id]}"
|
||||
end,
|
||||
"id" => ip[:id].to_s }
|
||||
body["PublicIpAddresses"] << ip
|
||||
end
|
||||
response.status = 200
|
||||
response.body = body
|
||||
response.headers = Fog::Terremark::Shared::Mock.headers(response.body,
|
||||
case self
|
||||
when Fog::Terremark::Ecloud::Mock
|
||||
"application/vnd.tmrk.ecloud.publicIpsList+xml"
|
||||
when Fog::Terremark::Vcloud::Mock
|
||||
"application/xml; charset=utf-8"
|
||||
end
|
||||
)
|
||||
else
|
||||
response.status = Fog::Terremark::Shared::Mock.unathorized_status
|
||||
response.headers = Fog::Terremark::Shared::Mock.error_headers
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -99,6 +99,17 @@ module Fog
|
|||
{ :id => 43,
|
||||
:name => "Email!"
|
||||
}
|
||||
],
|
||||
:public_ips => [
|
||||
{ :id => 51,
|
||||
:name => "99.1.2.3"
|
||||
},
|
||||
{ :id => 52,
|
||||
:name => "99.1.2.4"
|
||||
},
|
||||
{ :id => 53,
|
||||
:name => "99.1.9.7"
|
||||
}
|
||||
]
|
||||
},
|
||||
{ :id => 22,
|
||||
|
@ -119,6 +130,11 @@ module Fog
|
|||
{ :id => 44,
|
||||
:name => "Master Blaster"
|
||||
}
|
||||
],
|
||||
:public_ips => [
|
||||
{ :id => 54,
|
||||
:name => "99.99.99.99"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue