From 408bec0b00cf1f80e6776ca633019e025773dc06 Mon Sep 17 00:00:00 2001 From: Rupak Ganguly Date: Tue, 6 Dec 2011 15:56:49 -0500 Subject: [PATCH] Enable and implement get address for request layer along with mocking support for the compute service. --- lib/fog/hp/compute.rb | 1 + lib/fog/hp/requests/compute/get_address.rb | 45 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 lib/fog/hp/requests/compute/get_address.rb diff --git a/lib/fog/hp/compute.rb b/lib/fog/hp/compute.rb index e4dd43ded..29296adaa 100644 --- a/lib/fog/hp/compute.rb +++ b/lib/fog/hp/compute.rb @@ -34,6 +34,7 @@ module Fog request :delete_security_group request :delete_security_group_rule request :delete_server + request :get_address request :get_flavor_details request :get_image_details request :get_security_group diff --git a/lib/fog/hp/requests/compute/get_address.rb b/lib/fog/hp/requests/compute/get_address.rb new file mode 100644 index 000000000..e7ceb7234 --- /dev/null +++ b/lib/fog/hp/requests/compute/get_address.rb @@ -0,0 +1,45 @@ +module Fog + module Compute + class HP + class Real + + # Get details about an existing floating IP address + # + # ==== Parameters + # * 'address_id'<~Integer> - Id of floating IP address get details for + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # * 'floating_ip'<~Hash> - + # * 'id'<~Integer> - Id of the address + # * 'ip'<~String> - Floating IP of the address + # * 'instance_id'<~String> - Id of the associated server instance + # * 'fixed_ip'<~String> - Fixed IP of the address + def get_address(address_id) + request( + :expects => [200], + :method => 'GET', + :path => "os-floating-ips/#{address_id}" + ) + end + + end + + class Mock + + def get_address(address_id) + response = Excon::Response.new + if address = self.data[:addresses][address_id] + response.status = 200 + response.body = { 'floating_ip' => address } + response + else + raise Fog::Compute::HP::NotFound + end + end + + end + end + end +end