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-16 14:50:27 -04:00
|
|
|
'smp' => Fog::Nullable::String,
|
2012-07-15 06:24:36 -04:00
|
|
|
'persistent' => Fog::Nullable::String,
|
2012-07-16 14:22:30 -04:00
|
|
|
'vnc' => 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"
|
2012-09-04 16:56:05 -04:00
|
|
|
Fog::Compute[:serverlove].update_server(@server['server'], { :name => @server['name']})
|
2012-07-15 06:24:36 -04:00
|
|
|
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
|
2012-07-16 15:01:21 -04:00
|
|
|
@image = Fog::Compute[:serverlove].create_image('name' => 'Test', 'size' => '24234567890').body
|
2012-07-16 14:23:13 -04:00
|
|
|
# Load debian
|
|
|
|
Fog::Compute[:serverlove].load_standard_image(@image['drive'], 'aca2fa0b-40bc-4e06-ad99-f1467690d5de')
|
|
|
|
Fog::Compute[:serverlove].update_server(@server['server'], { 'ide:0:0' => @image['drive'], 'boot' => 'ide:0:0'})
|
2012-07-15 11:27:44 -04:00
|
|
|
end
|
|
|
|
|
2012-07-16 15:30:03 -04:00
|
|
|
tests("waits for imaging...").returns(true) do
|
|
|
|
while(percent_complete = Fog::Compute[:serverlove].images.get(@image['drive']).imaging)
|
|
|
|
sleep(1)
|
|
|
|
STDERR.print "#{percent_complete} "
|
|
|
|
break if percent_complete.include?("100")
|
|
|
|
end
|
|
|
|
STDERR.print "100% "
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2012-07-15 11:27:44 -04:00
|
|
|
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
|