diff --git a/lib/fog/hp/requests/compute/associate_address.rb b/lib/fog/hp/requests/compute/associate_address.rb index cacde3de8..cf9c838f4 100644 --- a/lib/fog/hp/requests/compute/associate_address.rb +++ b/lib/fog/hp/requests/compute/associate_address.rb @@ -22,13 +22,18 @@ module Fog response = Excon::Response.new if server = self.data[:servers][server_id] data = {"version"=>4, "addr"=>"#{ip_address}"} - server['addresses']['private'] << data - + if server['addresses']['private'] + server['addresses']['private'] << data + else + server['addresses']['private'] = data + end response.status = 202 - response else - raise Fog::Compute::HP::NotFound + #raise Fog::Compute::HP::NotFound + response.status = 500 + raise(Excon::Errors.status_error({:expects => 200}, response)) end + response end end diff --git a/lib/fog/hp/requests/compute/create_security_group.rb b/lib/fog/hp/requests/compute/create_security_group.rb index 2593eebcb..662021473 100644 --- a/lib/fog/hp/requests/compute/create_security_group.rb +++ b/lib/fog/hp/requests/compute/create_security_group.rb @@ -51,8 +51,8 @@ module Fog def create_security_group(name, description) # all spaces are removed - name = name.strip! - description = description.strip! + name = name.strip + description = description.strip response = Excon::Response.new if self.data[:security_groups].detect {|_,v| v['name'] == name} diff --git a/lib/fog/hp/requests/compute/disassociate_address.rb b/lib/fog/hp/requests/compute/disassociate_address.rb index 2d850eaff..4b2964e8b 100644 --- a/lib/fog/hp/requests/compute/disassociate_address.rb +++ b/lib/fog/hp/requests/compute/disassociate_address.rb @@ -25,10 +25,12 @@ module Fog self.data[:servers][server_id]['addresses']['private'] = data response.status = 202 - response else - raise Fog::Compute::HP::NotFound + #raise Fog::Compute::HP::NotFound + response.status = 500 + raise(Excon::Errors.status_error({:expects => 200}, response)) end + response end end diff --git a/lib/fog/hp/requests/compute/list_server_private_addresses.rb b/lib/fog/hp/requests/compute/list_server_private_addresses.rb index 7b92529c8..bbb0238d5 100644 --- a/lib/fog/hp/requests/compute/list_server_private_addresses.rb +++ b/lib/fog/hp/requests/compute/list_server_private_addresses.rb @@ -38,7 +38,8 @@ module Fog response = Excon::Response.new if server = list_servers_detail.body['servers'].detect {|_| _['id'] == server_id} private_address = [] - data = server['addresses']["#{network_name}"][0] + data = nil + data = server['addresses']["#{network_name}"][0] if server['addresses']["#{network_name}"] if data private_address << data end diff --git a/lib/fog/hp/requests/compute/release_address.rb b/lib/fog/hp/requests/compute/release_address.rb index 87a88cf1f..586c6619d 100644 --- a/lib/fog/hp/requests/compute/release_address.rb +++ b/lib/fog/hp/requests/compute/release_address.rb @@ -27,10 +27,10 @@ module Fog self.data[:addresses].delete(address_id) response.status = 202 response.body = "202 Accepted\n\nThe request is accepted for processing.\n\n " - response else raise Fog::Compute::HP::NotFound end + response end end diff --git a/tests/hp/models/compute/address_tests.rb b/tests/hp/models/compute/address_tests.rb index 6fe192288..8add29942 100644 --- a/tests/hp/models/compute/address_tests.rb +++ b/tests/hp/models/compute/address_tests.rb @@ -1,8 +1,10 @@ Shindo.tests("Fog::Compute[:hp] | address", ['hp']) do + @base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242 + model_tests(Fog::Compute[:hp].addresses, {}, true) do - @server = Fog::Compute[:hp].servers.create(:name => "fogservertests", :flavor_id => 100, :image_id => 1242) + @server = Fog::Compute[:hp].servers.create(:name => "fogservertests", :flavor_id => 100, :image_id => @base_image_id) @server.wait_for { ready? } tests('#server=').succeeds do diff --git a/tests/hp/requests/compute/address_tests.rb b/tests/hp/requests/compute/address_tests.rb index 4e2f3cd3f..2a4970f8c 100644 --- a/tests/hp/requests/compute/address_tests.rb +++ b/tests/hp/requests/compute/address_tests.rb @@ -7,6 +7,8 @@ Shindo.tests('Fog::Compute[:hp] | address requests', ['hp']) do 'id' => Integer } + @base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242 + tests('success') do tests("#list_addresses").formats({'floating_ips' => [@floating_ips_format]}) do @@ -24,14 +26,14 @@ Shindo.tests('Fog::Compute[:hp] | address requests', ['hp']) do Fog::Compute[:hp].get_address(@address_id).body['floating_ip'] end - @server = Fog::Compute[:hp].servers.create(:name => 'fogaddresstests', :flavor_id => 100, :image_id => 1242) + @server = Fog::Compute[:hp].servers.create(:name => 'fogaddresstests', :flavor_id => 100, :image_id => @base_image_id) @server.wait_for { ready? } tests("#associate_address('#{@server.id}', '#{@ip_address}')").succeeds do Fog::Compute[:hp].associate_address(@server.id, @ip_address) tests("#get_address").returns(@server.id, "associated to valid instance id") do pending if Fog.mocking? - Fog::Compute[:hp].get_address(@address_id).body['floating_ip']['instance_id'].to_s + Fog::Compute[:hp].get_address(@address_id).body['floating_ip']['instance_id'] end end @@ -53,11 +55,11 @@ Shindo.tests('Fog::Compute[:hp] | address requests', ['hp']) do Fog::Compute[:hp].get_address('invalidaddress') end - tests("#associate_address('invalidserver', 'invalidip')").raises(Fog::Compute::HP::NotFound) do + tests("#associate_address('invalidserver', 'invalidip')").raises(Excon::Errors::InternalServerError) do Fog::Compute[:hp].associate_address('invalidserver', 'invalidip') end - tests("#disassociate_address('invalidserver', 'invalidip')").raises(Fog::Compute::HP::NotFound) do + tests("#disassociate_address('invalidserver', 'invalidip')").raises(Excon::Errors::InternalServerError) do Fog::Compute[:hp].disassociate_address('invalidserver', 'invalidip') end diff --git a/tests/hp/requests/compute/flavor_tests.rb b/tests/hp/requests/compute/flavor_tests.rb index e06c04c09..c8c5b2853 100644 --- a/tests/hp/requests/compute/flavor_tests.rb +++ b/tests/hp/requests/compute/flavor_tests.rb @@ -36,8 +36,8 @@ Shindo.tests('Fog::Compute[:hp] | flavor requests', ['hp']) do tests('failure') do - tests('#get_flavor_details(0)').raises(Fog::Compute::HP::NotFound) do - Fog::Compute[:hp].get_flavor_details(0) + tests('#get_flavor_details(9999)').raises(Fog::Compute::HP::NotFound) do + Fog::Compute[:hp].get_flavor_details(9999) end end diff --git a/tests/hp/requests/compute/image_tests.rb b/tests/hp/requests/compute/image_tests.rb index c956287b0..cbce0179e 100644 --- a/tests/hp/requests/compute/image_tests.rb +++ b/tests/hp/requests/compute/image_tests.rb @@ -18,7 +18,7 @@ Shindo.tests('Fog::Compute[:hp] | image requests', ['hp']) do 'name' => String } - @base_image_id = 128 #1242 + @base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242 tests('success') do @server_name = "fogservertest" diff --git a/tests/hp/requests/compute/server_address_tests.rb b/tests/hp/requests/compute/server_address_tests.rb index 46c1ecf6e..e1186fc4d 100644 --- a/tests/hp/requests/compute/server_address_tests.rb +++ b/tests/hp/requests/compute/server_address_tests.rb @@ -1,7 +1,9 @@ Shindo.tests('Fog::Compute[:hp] | address requests', ['hp']) do + @base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242 + tests('success') do - @server = Fog::Compute[:hp].servers.create(:name => 'fogaddresstests', :flavor_id => 100, :image_id => 1242) + @server = Fog::Compute[:hp].servers.create(:name => 'fogaddresstests', :flavor_id => 100, :image_id => @base_image_id) # the network name is currently named 'private' tests("#list_server_addresses(#{@server.id})").formats({'addresses' => {"private" => [Hash]}}) do diff --git a/tests/hp/requests/compute/server_tests.rb b/tests/hp/requests/compute/server_tests.rb index 36cb52755..4ec1dceb0 100644 --- a/tests/hp/requests/compute/server_tests.rb +++ b/tests/hp/requests/compute/server_tests.rb @@ -34,13 +34,15 @@ Shindo.tests('Fog::Compute[:hp] | server requests', ['hp']) do } + @base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242 + tests('success') do @server_id = nil @server_name = "fogservertests" - tests("#create_server(#{@server_name}, 100, 1242)").formats(@server_format.merge('adminPass' => String)) do - data = Fog::Compute[:hp].create_server(@server_name, 100, 1242).body['server'] + tests("#create_server(#{@server_name}, 100, #{@base_image_id})").formats(@server_format.merge('adminPass' => String)) do + data = Fog::Compute[:hp].create_server(@server_name, 100, @base_image_id).body['server'] @server_id = data['id'] data end @@ -67,14 +69,14 @@ Shindo.tests('Fog::Compute[:hp] | server requests', ['hp']) do Fog::Compute[:hp].servers.get(@server_id).wait_for { ready? } - tests("#reboot_server(#{@server_id}, 'HARD')").succeeds do - Fog::Compute[:hp].reboot_server(@server_id, 'HARD') + tests("#reboot_server(#{@server_id}, 'SOFT')").succeeds do + Fog::Compute[:hp].reboot_server(@server_id, 'SOFT') end Fog::Compute[:hp].servers.get(@server_id).wait_for { ready? } - tests("#reboot_server(#{@server_id}, 'SOFT')").succeeds do - Fog::Compute[:hp].reboot_server(@server_id, 'SOFT') + tests("#reboot_server(#{@server_id}, 'HARD')").succeeds do + Fog::Compute[:hp].reboot_server(@server_id, 'HARD') end Fog::Compute[:hp].servers.get(@server_id).wait_for { ready? }