2011-09-26 02:41:54 -04:00
|
|
|
Shindo.tests('Fog::Compute[:openstack] | server requests', ['openstack']) do
|
|
|
|
|
2012-12-07 16:45:01 -05:00
|
|
|
@detailed_server_format = {
|
2011-09-29 14:10:21 -04:00
|
|
|
'id' => String,
|
|
|
|
'addresses' => Hash,
|
|
|
|
'flavor' => Hash,
|
|
|
|
'hostId' => String,
|
|
|
|
'image' => Hash,
|
|
|
|
'metadata' => Hash,
|
|
|
|
'name' => String,
|
|
|
|
'progress' => Integer,
|
|
|
|
'status' => String,
|
2011-09-26 02:41:54 -04:00
|
|
|
'accessIPv4' => Fog::Nullable::String,
|
|
|
|
'accessIPv6' => Fog::Nullable::String,
|
2012-10-22 20:58:40 -04:00
|
|
|
'links' => Array,
|
|
|
|
'created' => String,
|
2012-12-06 17:30:30 -05:00
|
|
|
'updated' => String,
|
|
|
|
'user_id' => String,
|
|
|
|
}
|
|
|
|
|
|
|
|
@create_format = {
|
|
|
|
'adminPass' => String,
|
|
|
|
'id' => String,
|
|
|
|
'links' => Array,
|
|
|
|
'security_groups' => Fog::Nullable::Array,
|
2011-09-26 02:41:54 -04:00
|
|
|
}
|
|
|
|
|
2011-09-29 14:10:21 -04:00
|
|
|
@image_format = {
|
|
|
|
'created' => Fog::Nullable::String,
|
|
|
|
'id' => String,
|
|
|
|
'name' => String,
|
|
|
|
'progress' => Fog::Nullable::Integer,
|
|
|
|
'status' => String,
|
|
|
|
'updated' => String,
|
|
|
|
'minRam' => Integer,
|
|
|
|
'minDisk' => Integer,
|
|
|
|
'server' => Hash,
|
|
|
|
'metadata' => Hash,
|
|
|
|
'links' => Array
|
|
|
|
}
|
|
|
|
|
2011-09-26 02:41:54 -04:00
|
|
|
tests('success') do
|
|
|
|
|
2012-12-07 16:45:01 -05:00
|
|
|
@image_id = get_image_ref
|
2011-09-29 14:10:21 -04:00
|
|
|
@snapshot_id = nil
|
2012-12-07 16:45:01 -05:00
|
|
|
@flavor_id = get_flavor_ref
|
2011-09-26 02:41:54 -04:00
|
|
|
|
2012-12-06 17:30:30 -05:00
|
|
|
tests('#create_server("test", #{@image_id} , 19)').formats(@create_format, false) do
|
2011-09-29 14:10:21 -04:00
|
|
|
data = Fog::Compute[:openstack].create_server("test", @image_id, @flavor_id).body['server']
|
2011-09-26 02:41:54 -04:00
|
|
|
@server_id = data['id']
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
|
|
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? }
|
|
|
|
|
2011-09-29 14:10:21 -04:00
|
|
|
#CREATE
|
2012-12-07 16:45:01 -05:00
|
|
|
tests("#get_server_details(#{@server_id})").formats(@detailed_server_format, false) do
|
2011-09-26 02:41:54 -04:00
|
|
|
Fog::Compute[:openstack].get_server_details(@server_id).body['server']
|
|
|
|
end
|
|
|
|
|
2011-09-29 14:10:21 -04:00
|
|
|
#LIST
|
|
|
|
#NOTE: we can remove strict=false if we remove uuid from GET /servers
|
|
|
|
tests('#list_servers').formats({'servers' => [OpenStack::Compute::Formats::SUMMARY]}, false) do
|
2011-09-26 02:41:54 -04:00
|
|
|
Fog::Compute[:openstack].list_servers.body
|
|
|
|
end
|
|
|
|
|
2011-09-29 14:10:21 -04:00
|
|
|
#DETAILS
|
2012-12-07 16:45:01 -05:00
|
|
|
tests('#list_servers_detail').formats({'servers' => [@detailed_server_format]}, false) do
|
2011-09-26 02:41:54 -04:00
|
|
|
Fog::Compute[:openstack].list_servers_detail.body
|
|
|
|
end
|
|
|
|
|
2011-09-29 14:10:21 -04:00
|
|
|
#CHANGE PASSWORD
|
2012-12-07 16:45:01 -05:00
|
|
|
if set_password_enabled
|
|
|
|
tests("#change_server_password(#{@server_id}, 'fogupdatedserver')").succeeds do
|
|
|
|
Fog::Compute[:openstack].change_server_password(@server_id, 'foggy')
|
|
|
|
end
|
|
|
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? }
|
2011-09-29 14:10:21 -04:00
|
|
|
end
|
2011-09-26 02:41:54 -04:00
|
|
|
|
2011-09-29 14:10:21 -04:00
|
|
|
#UPDATE SERVER NAME
|
2011-09-26 02:41:54 -04:00
|
|
|
tests("#update_server(#{@server_id}, :name => 'fogupdatedserver')").succeeds do
|
|
|
|
Fog::Compute[:openstack].update_server(@server_id, :name => 'fogupdatedserver')
|
|
|
|
end
|
|
|
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? }
|
|
|
|
|
2011-09-29 14:10:21 -04:00
|
|
|
#CREATE IMAGE WITH METADATA
|
|
|
|
tests("#create_image(#{@server_id}, 'fog')").formats('image' => @image_format) do
|
|
|
|
data = Fog::Compute[:openstack].create_image(@server_id, 'fog', {"foo" => "bar"}).body
|
|
|
|
@snapshot_id = data['image']['id']
|
|
|
|
data
|
|
|
|
end
|
|
|
|
Fog::Compute[:openstack].images.get(@snapshot_id).wait_for { ready? }
|
|
|
|
|
|
|
|
#REBUILD
|
2012-12-07 16:45:01 -05:00
|
|
|
tests("#rebuild_server(#{@server_id}, #{@snapshot_id}, 'fog')").formats({'server' => @detailed_server_format}, false) do
|
2011-09-29 14:10:21 -04:00
|
|
|
Fog::Compute[:openstack].rebuild_server(@server_id, @snapshot_id, 'fog', 'newpass', {"foo" => "bar"}).body
|
|
|
|
end
|
|
|
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? } if not Fog.mocking?
|
|
|
|
|
|
|
|
#RESIZE
|
2012-12-07 16:45:01 -05:00
|
|
|
tests("#resize_server(#{@server_id}, #{get_flavor_ref_resize})").succeeds do
|
|
|
|
Fog::Compute[:openstack].resize_server(@server_id, get_flavor_ref_resize)
|
2011-09-29 14:10:21 -04:00
|
|
|
end
|
|
|
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { self.state == 'VERIFY_RESIZE' } if not Fog.mocking?
|
|
|
|
|
|
|
|
#RESIZE CONFIRM
|
2012-12-07 16:45:01 -05:00
|
|
|
tests("#resize_confirm(#{@server_id}, #{get_flavor_ref_resize})").succeeds do
|
2012-07-02 04:08:23 -04:00
|
|
|
Fog::Compute[:openstack].confirm_resize_server(@server_id)
|
2011-09-29 14:10:21 -04:00
|
|
|
end
|
|
|
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? } if not Fog.mocking?
|
|
|
|
|
|
|
|
#REBOOT - HARD
|
2011-09-26 02:41:54 -04:00
|
|
|
tests("#reboot_server(#{@server_id}, 'HARD')").succeeds do
|
|
|
|
Fog::Compute[:openstack].reboot_server(@server_id, 'HARD')
|
|
|
|
end
|
|
|
|
|
2011-09-29 14:10:21 -04:00
|
|
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? } if not Fog.mocking?
|
2011-09-26 02:41:54 -04:00
|
|
|
|
2011-09-29 14:10:21 -04:00
|
|
|
#REBOOT - SOFT
|
2011-09-26 02:41:54 -04:00
|
|
|
tests("#reboot_server(#{@server_id}, 'SOFT')").succeeds do
|
|
|
|
Fog::Compute[:openstack].reboot_server(@server_id, 'SOFT')
|
|
|
|
end
|
|
|
|
|
2011-09-29 14:10:21 -04:00
|
|
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? } if not Fog.mocking?
|
2011-09-26 02:41:54 -04:00
|
|
|
|
2011-09-29 14:10:21 -04:00
|
|
|
#DELETE
|
2011-09-26 02:41:54 -04:00
|
|
|
tests("#delete_server(#{@server_id})").succeeds do
|
|
|
|
Fog::Compute[:openstack].delete_server(@server_id)
|
|
|
|
end
|
|
|
|
|
2012-12-07 16:45:01 -05:00
|
|
|
#DELETE IMAGE
|
|
|
|
tests("#delete_image(#{@snapshot_id})").succeeds do
|
|
|
|
Fog::Compute[:openstack].delete_image(@snapshot_id)
|
|
|
|
end
|
|
|
|
|
2011-09-26 02:41:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
|
|
|
|
tests('#delete_server(0)').raises(Fog::Compute::OpenStack::NotFound) do
|
|
|
|
Fog::Compute[:openstack].delete_server(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#get_server_details(0)').raises(Fog::Compute::OpenStack::NotFound) do
|
|
|
|
Fog::Compute[:openstack].get_server_details(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#update_server(0, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver')").raises(Fog::Compute::OpenStack::NotFound) do
|
|
|
|
Fog::Compute[:openstack].update_server(0, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#reboot_server(0)').raises(Fog::Compute::OpenStack::NotFound) do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
Fog::Compute[:openstack].reboot_server(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|