From 4f9350af562a5922a6de1ca6e732f040a4b3d801 Mon Sep 17 00:00:00 2001 From: Rupak Ganguly Date: Thu, 5 Apr 2012 16:07:32 -0400 Subject: [PATCH] Update mocking support. --- lib/fog/hp/requests/compute/allocate_address.rb | 4 ++-- lib/fog/hp/requests/compute/associate_address.rb | 4 ++-- .../hp/requests/compute/disassociate_address.rb | 14 +++++++------- tests/hp/requests/compute/address_tests.rb | 0 4 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 tests/hp/requests/compute/address_tests.rb diff --git a/lib/fog/hp/requests/compute/allocate_address.rb b/lib/fog/hp/requests/compute/allocate_address.rb index 82c4c96ff..9627a1f50 100644 --- a/lib/fog/hp/requests/compute/allocate_address.rb +++ b/lib/fog/hp/requests/compute/allocate_address.rb @@ -31,10 +31,10 @@ module Fog response = Excon::Response.new response.status = 200 data = { - 'instance_id' => Fog::HP::Mock.instance_id.to_s, + 'instance_id' => Fog::HP::Mock.instance_id.to_i, 'ip' => Fog::HP::Mock.ip_address, 'fixed_ip' => Fog::HP::Mock.ip_address, - 'id' => Fog::Mock.random_numbers(3).to_s + 'id' => Fog::Mock.random_numbers(3).to_i } self.data[:last_modified][:addresses][data['id']] = Time.now self.data[:addresses][data['id']] = data diff --git a/lib/fog/hp/requests/compute/associate_address.rb b/lib/fog/hp/requests/compute/associate_address.rb index 75ddd7502..cacde3de8 100644 --- a/lib/fog/hp/requests/compute/associate_address.rb +++ b/lib/fog/hp/requests/compute/associate_address.rb @@ -22,12 +22,12 @@ module Fog response = Excon::Response.new if server = self.data[:servers][server_id] data = {"version"=>4, "addr"=>"#{ip_address}"} - server['addresses']['novanet_7'] << data + server['addresses']['private'] << data response.status = 202 response else - raise Fog::Compute::HP::Error.new("InvalidServer.NotFound => The server '#{server_id}' does not exist.") + raise Fog::Compute::HP::NotFound end end diff --git a/lib/fog/hp/requests/compute/disassociate_address.rb b/lib/fog/hp/requests/compute/disassociate_address.rb index 631b5cd61..2d850eaff 100644 --- a/lib/fog/hp/requests/compute/disassociate_address.rb +++ b/lib/fog/hp/requests/compute/disassociate_address.rb @@ -21,14 +21,14 @@ module Fog def disassociate_address(server_id, ip_address) response = Excon::Response.new if server = self.data[:servers][server_id] - data = server['addresses']['novanet_7'].reject {|a| a['addr'] == ip_address} - self.data[:servers][server_id]['addresses']['novanet_7'] = data - else - raise Fog::Compute::HP::Error.new("InvalidServer.NotFound => The server '#{server_id}' does not exist.") - end + data = server['addresses']['private'].reject {|a| a['addr'] == ip_address} + self.data[:servers][server_id]['addresses']['private'] = data - response.status = 202 - response + response.status = 202 + response + else + raise Fog::Compute::HP::NotFound + end end end diff --git a/tests/hp/requests/compute/address_tests.rb b/tests/hp/requests/compute/address_tests.rb new file mode 100644 index 000000000..e69de29bb