2011-12-02 13:27:44 -05:00
|
|
|
Shindo.tests('Fog::Compute[:ibm] | instance requests', ['ibm']) do
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
@instance_format = {
|
|
|
|
'name' => String,
|
|
|
|
'location' => String,
|
|
|
|
'keyName' => String,
|
|
|
|
'primaryIP' => {
|
2012-02-29 22:24:36 -05:00
|
|
|
'vlan' => Fog::Nullable::String,
|
2011-12-02 13:27:44 -05:00
|
|
|
'type' => Integer,
|
|
|
|
'ip' => String,
|
|
|
|
'hostname' => String,
|
|
|
|
},
|
|
|
|
'productCodes' => Array,
|
|
|
|
'requestId' => String,
|
|
|
|
'imageId' => String,
|
|
|
|
'launchTime' => Integer,
|
|
|
|
'id' => String,
|
2012-02-28 23:59:02 -05:00
|
|
|
'ip' => Fog::Nullable::String,
|
2011-12-02 13:27:44 -05:00
|
|
|
'volumes' => Array,
|
2012-02-28 23:59:02 -05:00
|
|
|
'root-only' => Fog::Nullable::String,
|
2012-02-29 08:38:22 -05:00
|
|
|
'isMiniEphemeral' => Fog::Nullable::String,
|
2011-12-02 13:27:44 -05:00
|
|
|
'instanceType' => String,
|
2012-02-28 23:59:02 -05:00
|
|
|
'diskSize' => Fog::Nullable::String,
|
2011-12-02 13:27:44 -05:00
|
|
|
'requestName' => String,
|
|
|
|
'secondaryIP' => Array,
|
|
|
|
'status' => Integer,
|
|
|
|
'software' => Array,
|
|
|
|
'expirationTime'=> Integer,
|
2012-02-28 23:59:02 -05:00
|
|
|
'owner' => String,
|
2011-12-02 13:27:44 -05:00
|
|
|
}
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
@instances_format = {
|
|
|
|
'instances' => [ @instance_format ]
|
|
|
|
}
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests('success') do
|
|
|
|
|
|
|
|
@instance_id = nil
|
2012-02-20 13:14:02 -05:00
|
|
|
@name = "fog-test-instance-" + Time.now.to_i.to_s(32)
|
2012-02-28 23:51:37 -05:00
|
|
|
@image_id = "20010001"
|
2011-12-02 13:27:44 -05:00
|
|
|
@instance_type = "COP32.1/2048/60"
|
2012-02-28 23:51:37 -05:00
|
|
|
@location = "41"
|
2012-02-28 16:41:21 -05:00
|
|
|
@key_name = "fog-test-key-" + Time.now.to_i.to_s(32)
|
|
|
|
@key = Fog::Compute[:ibm].keys.create(:name => @key_name)
|
2011-12-02 13:27:44 -05:00
|
|
|
|
2012-02-28 16:41:21 -05:00
|
|
|
tests("#create_instance('#{@name}', '#{@image_id}', '#{@instance_type}', '#{@location}', :key_name => '#{@key_name}')").formats(@instances_format) do
|
|
|
|
response = Fog::Compute[:ibm].create_instance(@name, @image_id, @instance_type, @location, :key_name => @key_name).body
|
2011-12-02 13:27:44 -05:00
|
|
|
@instance_id = response['instances'][0]['id']
|
|
|
|
response
|
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests("#get_instance('#{@instance_id}')").formats(@instance_format) do
|
|
|
|
response = Fog::Compute[:ibm].get_instance(@instance_id).body
|
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2012-03-22 08:49:20 -04:00
|
|
|
Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM.timeout) { ready? }
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests("#list_instances").formats(@instances_format) do
|
|
|
|
instances = Fog::Compute[:ibm].list_instances.body
|
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2012-02-13 10:03:00 -05:00
|
|
|
tests("#modify_instance('#{@instance_id}', 'state' => 'restart')") do
|
|
|
|
returns(true) { Fog::Compute[:ibm].modify_instance(@instance_id, 'state' => 'restart').body["success"] }
|
2011-12-02 13:27:44 -05:00
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2012-02-13 10:03:00 -05:00
|
|
|
tests("#modify_instance('#{@instance_id}', 'name' => '#{@name} 2')") do
|
|
|
|
returns(true) { Fog::Compute[:ibm].modify_instance(@instance_id, 'name' => @name + " 2").body["success"] }
|
2011-12-02 13:27:44 -05:00
|
|
|
end
|
|
|
|
|
2012-03-12 15:27:49 -04:00
|
|
|
@expiration_time = (Time.now.to_i + 10) * 1000
|
|
|
|
|
2012-02-13 10:03:00 -05:00
|
|
|
tests("#modify_instance('#{@instance_id}', 'expirationTime' => '#{@expiration_time}')") do
|
|
|
|
returns(@expiration_time) { Fog::Compute[:ibm].modify_instance(@instance_id, 'expirationTime' => @expiration_time).body["expirationTime"] }
|
2011-12-02 13:27:44 -05:00
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests("#delete_instance('#{@instance_id}')") do
|
2012-03-22 08:49:20 -04:00
|
|
|
if Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM.timeout) { ready? }
|
2012-03-17 11:16:22 -04:00
|
|
|
data = Fog::Compute[:ibm].delete_instance(@instance_id)
|
|
|
|
else
|
|
|
|
pending
|
|
|
|
end
|
2011-12-02 13:27:44 -05:00
|
|
|
end
|
|
|
|
|
2012-03-22 08:49:20 -04:00
|
|
|
if @key.wait_for(Fog::IBM.timeout) { instance_ids.empty? }
|
2012-03-17 11:16:22 -04:00
|
|
|
@key.destroy
|
|
|
|
else
|
|
|
|
pending
|
|
|
|
end
|
2012-02-28 16:41:21 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests('failures') do
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2012-03-12 15:30:20 -04:00
|
|
|
tests('#create_instance => 412') do
|
|
|
|
raises(Excon::Errors::PreconditionFailed) do
|
|
|
|
Fog::Compute[:ibm].create_instance("FAIL: 412", @image_id, @instance_type, @location, :key_name => "invalid")
|
|
|
|
end
|
2011-12-02 13:27:44 -05:00
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|