2012-07-06 08:56:46 -04:00
|
|
|
Shindo.tests('Fog::Compute[:serverlove] | server requests', ['serverlove']) do
|
|
|
|
|
2012-07-15 06:24:36 -04:00
|
|
|
@server_format = {
|
|
|
|
'server' => String,
|
|
|
|
'name' => String,
|
|
|
|
'user' => String,
|
|
|
|
'status' => String,
|
2012-07-15 11:27:44 -04:00
|
|
|
'started' => Fog::Nullable::String,
|
2012-07-15 06:24:36 -04:00
|
|
|
'cpu' => Integer,
|
2012-07-15 11:27:44 -04:00
|
|
|
'mem' => Integer,
|
2012-07-15 06:24:36 -04:00
|
|
|
'persistent' => Fog::Nullable::String,
|
2012-07-15 12:04:33 -04:00
|
|
|
'vnc:password' => Fog::Nullable::String,
|
|
|
|
'nic:0:dhcp' => String,
|
|
|
|
'nic:0:model' => String
|
2012-07-15 06:24:36 -04:00
|
|
|
}
|
|
|
|
|
2012-07-06 08:56:46 -04:00
|
|
|
tests('success') do
|
2012-07-15 06:24:36 -04:00
|
|
|
|
2012-07-15 11:27:44 -04:00
|
|
|
attributes = { 'name' => 'Test', 'cpu' => '1000', 'mem' => '1000', 'persistent' => 'true' }
|
2012-07-15 06:24:36 -04:00
|
|
|
|
|
|
|
tests("#create_server").formats(@server_format) do
|
2012-07-15 12:04:33 -04:00
|
|
|
@server = Fog::Compute[:serverlove].create_server(Fog::Compute::Serverlove::Server.defaults.merge(attributes)).body
|
2012-07-15 06:24:36 -04:00
|
|
|
end
|
2012-07-06 08:56:46 -04:00
|
|
|
|
|
|
|
tests("#list_servers").succeeds do
|
|
|
|
Fog::Compute[:serverlove].servers
|
|
|
|
end
|
2012-07-15 06:24:36 -04:00
|
|
|
|
|
|
|
tests("#update_server").returns(true) do
|
|
|
|
@server['name'] = "Diff"
|
|
|
|
Fog::Compute[:serverlove].update_server(@server['server'], { name: @server['name']})
|
|
|
|
Fog::Compute[:serverlove].servers.get(@server['server']).name == "Diff"
|
|
|
|
end
|
2012-07-15 06:30:45 -04:00
|
|
|
|
2012-07-15 11:27:44 -04:00
|
|
|
tests("assigns drive to server").succeeds do
|
|
|
|
@image = Fog::Compute[:serverlove].create_image('name' => 'Test', 'size' => '4234567890').body
|
|
|
|
# Load centos
|
|
|
|
Fog::Compute[:serverlove].load_standard_image(@image['drive'], '88ed067f-d2b8-42ce-a25f-5297818a3b6f')
|
|
|
|
@server['ide:0:0'] = @image['drive']
|
|
|
|
@server['boot'] = 'ide:0:0'
|
|
|
|
Fog::Compute[:serverlove].update_server(@server['server'], { 'ide:0:0' => @server['ide:0:0'], 'boot' => 'ide:0:0'})
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#start_server").returns(true) do
|
2012-07-15 06:30:45 -04:00
|
|
|
Fog::Compute[:serverlove].start_server(@server['server'])
|
2012-07-15 11:27:44 -04:00
|
|
|
Fog::Compute[:serverlove].servers.get(@server['server']).status == "active"
|
2012-07-15 06:30:45 -04:00
|
|
|
end
|
|
|
|
|
2012-07-15 11:27:44 -04:00
|
|
|
tests("#reset_server").returns(true) do
|
2012-07-15 06:30:45 -04:00
|
|
|
Fog::Compute[:serverlove].reset_server(@server['server'])
|
2012-07-15 11:27:44 -04:00
|
|
|
Fog::Compute[:serverlove].servers.get(@server['server']).status == "active"
|
2012-07-15 06:30:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("#shutdown_server").succeeds do
|
|
|
|
Fog::Compute[:serverlove].shutdown_server(@server['server'])
|
2012-07-15 11:27:44 -04:00
|
|
|
# Can't guarantee the OS will honour this command so don't test status
|
2012-07-15 06:30:45 -04:00
|
|
|
end
|
|
|
|
|
2012-07-15 11:27:44 -04:00
|
|
|
tests("#stop_server").returns(true) do
|
|
|
|
Fog::Compute[:serverlove].start_server(@server['server'])
|
2012-07-15 06:30:45 -04:00
|
|
|
Fog::Compute[:serverlove].stop_server(@server['server'])
|
2012-07-15 11:27:44 -04:00
|
|
|
Fog::Compute[:serverlove].servers.get(@server['server']).status == "stopped"
|
2012-07-15 06:30:45 -04:00
|
|
|
end
|
2012-07-15 06:24:36 -04:00
|
|
|
|
|
|
|
tests("#destroy_server").succeeds do
|
|
|
|
Fog::Compute[:serverlove].destroy_server(@server['server'])
|
|
|
|
end
|
2012-07-15 11:27:44 -04:00
|
|
|
|
|
|
|
tests("destroy test drive").succeeds do
|
|
|
|
Fog::Compute[:serverlove].destroy_image(@image['drive'])
|
|
|
|
end
|
2012-07-06 08:56:46 -04:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|