diff --git a/lib/fog/storm_on_demand/compute.rb b/lib/fog/storm_on_demand/compute.rb index 90e5aa454..4db0486f0 100644 --- a/lib/fog/storm_on_demand/compute.rb +++ b/lib/fog/storm_on_demand/compute.rb @@ -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 diff --git a/lib/fog/storm_on_demand/models/compute/private_ip.rb b/lib/fog/storm_on_demand/models/compute/private_ip.rb index cd29af9cd..f8f64993e 100644 --- a/lib/fog/storm_on_demand/models/compute/private_ip.rb +++ b/lib/fog/storm_on_demand/models/compute/private_ip.rb @@ -5,8 +5,7 @@ module Fog class StormOnDemand class PrivateIp < Fog::Model - attribute :zone - attribute :uniq_id + attribute :zones def initialize(attributes={}) super diff --git a/lib/fog/storm_on_demand/models/compute/private_ips.rb b/lib/fog/storm_on_demand/models/compute/private_ips.rb index 8e35542c1..36a66333b 100644 --- a/lib/fog/storm_on_demand/models/compute/private_ips.rb +++ b/lib/fog/storm_on_demand/models/compute/private_ips.rb @@ -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 diff --git a/lib/fog/storm_on_demand/requests/compute/attach_server_to_private_ip.rb b/lib/fog/storm_on_demand/requests/compute/attach_server_to_private_ip.rb new file mode 100644 index 000000000..e856ef0da --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/attach_server_to_private_ip.rb @@ -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 diff --git a/lib/fog/storm_on_demand/requests/compute/check_server_attached.rb b/lib/fog/storm_on_demand/requests/compute/check_server_attached.rb new file mode 100644 index 000000000..ccfe53af3 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/check_server_attached.rb @@ -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 diff --git a/lib/fog/storm_on_demand/requests/compute/detach_server_from_private_ip.rb b/lib/fog/storm_on_demand/requests/compute/detach_server_from_private_ip.rb new file mode 100644 index 000000000..10fa14e95 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/detach_server_from_private_ip.rb @@ -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 diff --git a/lib/fog/storm_on_demand/requests/compute/get_private_ip.rb b/lib/fog/storm_on_demand/requests/compute/get_private_ip.rb new file mode 100644 index 000000000..209c8b4c0 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/get_private_ip.rb @@ -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 diff --git a/lib/fog/storm_on_demand/requests/compute/list_private_ips.rb b/lib/fog/storm_on_demand/requests/compute/list_private_ips.rb index d2210d706..2612b2d9a 100644 --- a/lib/fog/storm_on_demand/requests/compute/list_private_ips.rb +++ b/lib/fog/storm_on_demand/requests/compute/list_private_ips.rb @@ -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