2011-09-08 16:41:21 -04:00
|
|
|
Shindo.tests('Fog::Compute[:glesys] | server requests', ['glesys']) do
|
2011-11-29 13:00:45 -05:00
|
|
|
|
2011-08-17 11:53:20 -04:00
|
|
|
@serverid = nil
|
2011-11-14 12:47:55 -05:00
|
|
|
@hostname = "fog-#{Time.now.to_i}"
|
2011-08-17 11:53:20 -04:00
|
|
|
|
2012-02-20 14:36:39 -05:00
|
|
|
@create = ":hostname => #@hostname, :rootpassword => 'pw#{Time.now.to_i}', "+
|
2015-02-27 08:44:57 -05:00
|
|
|
":datacenter => 'Falkenberg', :platform => 'VMware', :templatename => 'Debian 7.0 64-bit', "+
|
2014-07-09 05:08:34 -04:00
|
|
|
":disksize => '10', :memorysize => '512', :cpucores => '1', :transfer => '500', :bandwidth => '10'"
|
2011-08-17 11:53:20 -04:00
|
|
|
|
2012-02-20 14:36:39 -05:00
|
|
|
@create_vz = ":hostname => #@hostname, :rootpassword => 'pw#{Time.now.to_i}', "+
|
2015-02-27 08:44:57 -05:00
|
|
|
":datacenter => 'Stockholm', :platform => 'OpenVZ', :templatename => 'Debian 7.0 64-bit', "+
|
2014-07-09 05:08:34 -04:00
|
|
|
":disksize => '10', :memorysize => '256', :cpucores => '2', :transfer => '500', :bandwidth => '10'"
|
2012-02-20 14:36:39 -05:00
|
|
|
|
2011-08-17 11:53:20 -04:00
|
|
|
tests('success') do
|
|
|
|
|
|
|
|
tests("#list_servers()").formats(Glesys::Compute::Formats::Servers::LIST) do
|
|
|
|
pending if Fog.mocking?
|
2011-09-08 16:41:21 -04:00
|
|
|
Fog::Compute[:glesys].list_servers.body['response']
|
2011-08-17 11:53:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("#create(#{@create})").formats(Glesys::Compute::Formats::Servers::CREATE) do
|
|
|
|
pending if Fog.mocking?
|
2011-09-08 16:41:21 -04:00
|
|
|
vm = Fog::Compute[:glesys].create(
|
2012-02-20 14:36:39 -05:00
|
|
|
:hostname => @hostname,
|
2015-02-27 08:44:57 -05:00
|
|
|
:description => "Fog test server",
|
2012-02-20 14:36:39 -05:00
|
|
|
:rootpassword => "pw#{Time.now.to_i}",
|
|
|
|
:datacenter => "Falkenberg",
|
2015-02-27 08:44:57 -05:00
|
|
|
:platform => "VMware",
|
|
|
|
:templatename => "Debian 7.0 64-bit",
|
2012-02-20 14:36:39 -05:00
|
|
|
:disksize => "10",
|
|
|
|
:memorysize => "512",
|
|
|
|
:cpucores => "1",
|
2014-07-09 05:08:34 -04:00
|
|
|
:transfer => "500",
|
|
|
|
:bandwidth => "10"
|
2011-08-17 11:53:20 -04:00
|
|
|
)
|
2011-11-29 13:00:45 -05:00
|
|
|
|
2011-08-17 11:53:20 -04:00
|
|
|
@serverid = vm.body['response']['server']['serverid']
|
|
|
|
vm.body['response']
|
|
|
|
end
|
|
|
|
|
|
|
|
unless Fog.mocking?
|
2011-09-08 16:41:21 -04:00
|
|
|
Fog::Compute[:glesys].servers.get(@serverid).wait_for { ready? }
|
2011-08-17 11:53:20 -04:00
|
|
|
end
|
2011-11-29 13:00:45 -05:00
|
|
|
|
2011-08-17 11:53:20 -04:00
|
|
|
tests("#server_details(#{@serverid})").formats(Glesys::Compute::Formats::Servers::DETAILS) do
|
|
|
|
pending if Fog.mocking?
|
2011-09-08 16:41:21 -04:00
|
|
|
Fog::Compute[:glesys].server_details(@serverid).body['response']
|
2011-08-17 11:53:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("#server_status(#{@serverid})").formats(Glesys::Compute::Formats::Servers::STATUS) do
|
|
|
|
pending if Fog.mocking?
|
2011-09-08 16:41:21 -04:00
|
|
|
Fog::Compute[:glesys].server_status(@serverid).body['response']
|
2011-08-17 11:53:20 -04:00
|
|
|
end
|
|
|
|
|
2011-09-08 16:52:43 -04:00
|
|
|
tests("#stop(:serverid => #{@serverid})").formats(Glesys::Compute::Formats::Servers::STOP) do
|
2011-08-17 11:53:20 -04:00
|
|
|
pending if Fog.mocking?
|
2011-09-08 16:41:21 -04:00
|
|
|
Fog::Compute[:glesys].stop(:serverid => @serverid).body['response']
|
2011-08-17 11:53:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Wait for stopped
|
|
|
|
unless Fog.mocking?
|
|
|
|
pending if Fog.mocking?
|
2011-09-08 16:41:21 -04:00
|
|
|
s = Fog::Compute[:glesys].servers.get(@serverid)
|
2011-11-29 13:00:45 -05:00
|
|
|
s.wait_for { s.state == 'stopped' }
|
2011-08-17 11:53:20 -04:00
|
|
|
end
|
|
|
|
|
2012-02-20 14:36:39 -05:00
|
|
|
tests("#start(:serverid => #{@serverid})").formats(Glesys::Compute::Formats::Servers::DETAILS) do
|
2011-08-17 11:53:20 -04:00
|
|
|
pending if Fog.mocking?
|
2011-09-08 16:41:21 -04:00
|
|
|
Fog::Compute[:glesys].start(:serverid => @serverid).body['response']
|
2011-08-17 11:53:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Wait for started
|
|
|
|
unless Fog.mocking?
|
2011-09-08 16:41:21 -04:00
|
|
|
Fog::Compute[:glesys].servers.get(@serverid).wait_for { ready? }
|
2011-08-17 11:53:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("#destroy(:serverid => #{@serverid})").formats(Glesys::Compute::Formats::Servers::DESTROY) do
|
|
|
|
pending if Fog.mocking?
|
2011-09-08 16:41:21 -04:00
|
|
|
Fog::Compute[:glesys].destroy(:serverid => @serverid).body['response']
|
2011-08-17 11:53:20 -04:00
|
|
|
end
|
|
|
|
|
2012-02-20 14:36:39 -05:00
|
|
|
# Test of OpenVZ
|
|
|
|
tests("#create(#{@create_vz})").formats(Glesys::Compute::Formats::Servers::CREATE) do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
vm = Fog::Compute[:glesys].create(
|
|
|
|
:hostname => @hostname,
|
|
|
|
:rootpassword => "pw#{Time.now.to_i}",
|
|
|
|
:datacenter => "Stockholm",
|
|
|
|
:platform => "OpenVZ",
|
2015-02-27 08:44:57 -05:00
|
|
|
:templatename => "Debian 7.0 64-bit",
|
2012-02-20 14:36:39 -05:00
|
|
|
:disksize => "10",
|
|
|
|
:memorysize => "256",
|
|
|
|
:cpucores => "2",
|
2014-07-09 05:08:34 -04:00
|
|
|
:transfer => "500",
|
|
|
|
:bandwidth => "10"
|
2012-02-20 14:36:39 -05:00
|
|
|
)
|
|
|
|
@serverid = vm.body['response']['server']['serverid']
|
|
|
|
vm.body['response']
|
|
|
|
end
|
|
|
|
|
2015-03-06 04:33:36 -05:00
|
|
|
unless Fog.mocking?
|
|
|
|
Fog::Compute[:glesys].servers.get(@serverid).wait_for { ready? }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#edit #{@serverid}").formats(Glesys::Compute::Formats::Servers::EDIT) do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
vm = Fog::Compute[:glesys].edit(
|
|
|
|
:serverid => @serverid,
|
|
|
|
:disksize => "10",
|
|
|
|
:memorysize => "512",
|
|
|
|
:cpucores => "1",
|
|
|
|
:bandwidth => "10"
|
|
|
|
)
|
|
|
|
vm.body['response']
|
|
|
|
end
|
|
|
|
|
2012-02-20 14:36:39 -05:00
|
|
|
tests("#server_details(#{@serverid})").formats(Glesys::Compute::Formats::Servers::DETAILS) do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
Fog::Compute[:glesys].server_details(@serverid).body['response']
|
|
|
|
end
|
|
|
|
|
|
|
|
unless Fog.mocking?
|
|
|
|
Fog::Compute[:glesys].servers.get(@serverid).wait_for { ready? }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#destroy(:serverid => #{@serverid})").formats(Glesys::Compute::Formats::Servers::DESTROY) do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
Fog::Compute[:glesys].destroy(:serverid => @serverid).body['response']
|
|
|
|
end
|
|
|
|
|
2011-08-17 11:53:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
|
|
|
|
tests("#create(:hostname => 0)").raises(Excon::Errors::HTTPStatusError) do
|
|
|
|
pending if Fog.mocking?
|
2011-09-08 16:41:21 -04:00
|
|
|
Fog::Compute[:glesys].create(:hostname => 0)
|
2011-08-17 11:53:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|