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:
parent
71af409b3d
commit
3d470a210a
8 changed files with 88 additions and 12 deletions
|
@ -71,7 +71,11 @@ module Fog
|
|||
request :get_stats
|
||||
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
|
||||
|
||||
|
|
|
@ -5,8 +5,7 @@ module Fog
|
|||
class StormOnDemand
|
||||
|
||||
class PrivateIp < Fog::Model
|
||||
attribute :zone
|
||||
attribute :uniq_id
|
||||
attribute :zones
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
|
|
|
@ -15,15 +15,24 @@ module Fog
|
|||
end
|
||||
|
||||
def get(server_id)
|
||||
if server_id && server = service.get_private_ip(private_ip).body
|
||||
new(server)
|
||||
elsif !server_id
|
||||
nil
|
||||
end
|
||||
rescue Excon::Errors::Forbidden
|
||||
nil
|
||||
service.get_private_ip(:uniq_id => server_id).body[:ip]
|
||||
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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
16
lib/fog/storm_on_demand/requests/compute/get_private_ip.rb
Normal file
16
lib/fog/storm_on_demand/requests/compute/get_private_ip.rb
Normal 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
|
|
@ -5,8 +5,8 @@ module Fog
|
|||
|
||||
def list_private_ips(options = {})
|
||||
request(
|
||||
:path => "/network/private/get",
|
||||
:body => Fog::JSON.encode(options)
|
||||
:path => "/Network/Private/get",
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue