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

[stormondemand|compute] Add all Private IP APIs

This commit is contained in:
Eric Wong 2013-05-22 09:50:31 +08:00
parent 71af409b3d
commit 3d470a210a
8 changed files with 88 additions and 12 deletions

View file

@ -71,7 +71,11 @@ module Fog
request :get_stats request :get_stats
request :get_stats_graph request :get_stats_graph
request :list_private_ips request :list_private_ips
request :get_private_ip
request :attach_server_to_private_ip
request :detach_server_from_private_ip
request :check_server_attached
class Mock class Mock

View file

@ -5,8 +5,7 @@ module Fog
class StormOnDemand class StormOnDemand
class PrivateIp < Fog::Model class PrivateIp < Fog::Model
attribute :zone attribute :zones
attribute :uniq_id
def initialize(attributes={}) def initialize(attributes={})
super super

View file

@ -15,15 +15,24 @@ module Fog
end end
def get(server_id) def get(server_id)
if server_id && server = service.get_private_ip(private_ip).body service.get_private_ip(:uniq_id => server_id).body[:ip]
new(server)
elsif !server_id
nil
end
rescue Excon::Errors::Forbidden
nil
end end
def attach(server_id)
res = service.attach_server_to_private_ip(:uniq_id => server_id).body
res[:attached].to_i == 1 ? true : false
end
def detach(server_id)
r = service.detach_server_from_private_ip(:uniq_id => server_id).body
r[:detached].to_i == 1 ? true : false
end
def attached?(server_id)
r = service.check_server_attached(:uniq_id => server_id).body
r[:is_attached].to_i == 1 ? true : false
end
end end
end end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def attach_server_to_private_ip(options={})
request(
:path => '/Network/Private/attach',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def check_server_attached(options={})
request(
:path => '/Network/Private/isAttached',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def detach_server_from_private_ip(options={})
request(
:path => '/Network/Private/detach',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def get_private_ip(options={})
request(
:path => '/Network/Private/getIP',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -5,8 +5,8 @@ module Fog
def list_private_ips(options = {}) def list_private_ips(options = {})
request( request(
:path => "/network/private/get", :path => "/Network/Private/get",
:body => Fog::JSON.encode(options) :body => Fog::JSON.encode(:params => options)
) )
end end