2013-01-18 15:06:41 -05:00
|
|
|
Shindo.tests("Fog::Compute[:hp] | address requests", ['hp', 'address']) do
|
2012-04-05 16:07:57 -04:00
|
|
|
|
|
|
|
@floating_ips_format = {
|
|
|
|
'instance_id' => Fog::Nullable::Integer,
|
|
|
|
'ip' => Fog::Nullable::String,
|
|
|
|
'fixed_ip' => Fog::Nullable::String,
|
|
|
|
'id' => Integer
|
|
|
|
}
|
|
|
|
|
2012-04-26 16:49:42 -04:00
|
|
|
@base_image_id = ENV["BASE_IMAGE_ID"] || 1242
|
2012-04-10 18:11:56 -04:00
|
|
|
|
2012-04-05 16:07:57 -04:00
|
|
|
tests('success') do
|
|
|
|
|
|
|
|
tests("#list_addresses").formats({'floating_ips' => [@floating_ips_format]}) do
|
|
|
|
Fog::Compute[:hp].list_addresses.body
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#allocate_address").formats(@floating_ips_format) do
|
|
|
|
data = Fog::Compute[:hp].allocate_address.body['floating_ip']
|
|
|
|
@address_id = data['id']
|
|
|
|
@ip_address = data['ip']
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
2012-04-05 17:20:09 -04:00
|
|
|
tests("#get_address('#{@address_id}')").formats(@floating_ips_format) do
|
|
|
|
Fog::Compute[:hp].get_address(@address_id).body['floating_ip']
|
|
|
|
end
|
|
|
|
|
2012-04-10 18:11:56 -04:00
|
|
|
@server = Fog::Compute[:hp].servers.create(:name => 'fogaddresstests', :flavor_id => 100, :image_id => @base_image_id)
|
2012-04-05 16:07:57 -04:00
|
|
|
@server.wait_for { ready? }
|
|
|
|
|
|
|
|
tests("#associate_address('#{@server.id}', '#{@ip_address}')").succeeds do
|
|
|
|
Fog::Compute[:hp].associate_address(@server.id, @ip_address)
|
2013-01-18 15:06:41 -05:00
|
|
|
tests("#get_address").returns(@ip_address, "server has associated ip address") do
|
|
|
|
@server.reload
|
|
|
|
@server.addresses['private'][1]['addr']
|
2012-04-05 17:20:09 -04:00
|
|
|
end
|
2012-04-05 16:07:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("#disassociate_address('#{@server.id}', '#{@ip_address}')").succeeds do
|
|
|
|
Fog::Compute[:hp].disassociate_address(@server.id, @ip_address)
|
|
|
|
end
|
|
|
|
|
|
|
|
@server.destroy
|
|
|
|
|
|
|
|
tests("#release_address('#{@address_id}')").succeeds do
|
|
|
|
Fog::Compute[:hp].release_address(@address_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
|
2012-04-05 17:20:09 -04:00
|
|
|
tests("#get_address('invalidaddress', 'invalidip')").raises(Fog::Compute::HP::NotFound) do
|
|
|
|
Fog::Compute[:hp].get_address('invalidaddress')
|
|
|
|
end
|
|
|
|
|
2012-04-10 18:11:56 -04:00
|
|
|
tests("#associate_address('invalidserver', 'invalidip')").raises(Excon::Errors::InternalServerError) do
|
2012-04-05 16:07:57 -04:00
|
|
|
Fog::Compute[:hp].associate_address('invalidserver', 'invalidip')
|
|
|
|
end
|
|
|
|
|
2012-04-10 18:11:56 -04:00
|
|
|
tests("#disassociate_address('invalidserver', 'invalidip')").raises(Excon::Errors::InternalServerError) do
|
2012-04-05 16:07:57 -04:00
|
|
|
Fog::Compute[:hp].disassociate_address('invalidserver', 'invalidip')
|
|
|
|
end
|
|
|
|
|
2012-04-05 17:20:09 -04:00
|
|
|
tests("#release_address('invalidaddress')").raises(Fog::Compute::HP::NotFound) do
|
|
|
|
Fog::Compute[:hp].release_address('invalidaddress')
|
2012-04-05 16:07:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|