2011-12-02 13:27:44 -05:00
|
|
|
Shindo.tests('Fog::Compute[:ibm] | image requests', ['ibm']) do
|
|
|
|
|
|
|
|
@image_format = {
|
|
|
|
'state' => Integer,
|
|
|
|
'visibility' => String,
|
|
|
|
'platform' => String,
|
|
|
|
'owner' => String,
|
2012-02-28 23:59:02 -05:00
|
|
|
'architecture' => Fog::Nullable::String,
|
2011-12-02 13:27:44 -05:00
|
|
|
'createdTime' => Integer,
|
|
|
|
'location' => String,
|
|
|
|
'productCodes' => Array,
|
|
|
|
'name' => String,
|
|
|
|
'id' => String,
|
|
|
|
'description' => String,
|
|
|
|
'supportedInstanceTypes' => Array,
|
2012-02-28 23:59:02 -05:00
|
|
|
'manifest' => Fog::Nullable::String,
|
|
|
|
'documentation' => Fog::Nullable::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
|
|
|
# TODO: Actually check this format
|
|
|
|
@product_code_format = {
|
|
|
|
'detail' => String,
|
|
|
|
'label' => String,
|
|
|
|
'price' => @price_format,
|
2012-02-13 10:51:03 -05:00
|
|
|
'id' => 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
|
|
|
# TODO: Actually check this format
|
|
|
|
@price_format = {
|
|
|
|
'rate' => Float,
|
|
|
|
'unitOfMeasure' => String,
|
|
|
|
'effectiveDate' => Integer,
|
|
|
|
'currencyCode' => String,
|
|
|
|
'pricePerQuantity' => Integer
|
|
|
|
}
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
@images_format = {
|
|
|
|
'images' => [ @image_format ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@create_image_format = {
|
|
|
|
"name" => String,
|
|
|
|
"createdTime" => Integer,
|
|
|
|
"productCodes"=> Array,
|
|
|
|
"id" => String,
|
|
|
|
"description" => String,
|
|
|
|
"visibility" => String,
|
|
|
|
"state" => Integer
|
|
|
|
}
|
|
|
|
|
|
|
|
@instance_id = nil
|
2012-02-20 13:14:02 -05:00
|
|
|
@name = "fog-test-image-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 = "BRZ32.1/2048/60*175"
|
2012-02-28 23:51:37 -05:00
|
|
|
@location = "41"
|
2011-12-02 13:27:44 -05:00
|
|
|
|
|
|
|
@id = nil
|
|
|
|
@cloned_id = nil
|
|
|
|
@image_name = "fog test create image"
|
|
|
|
|
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
|
|
|
|
|
|
|
tests('success') do
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests("#list_images").formats(@images_format) do
|
|
|
|
Fog::Compute[:ibm].list_images.body
|
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests('#get_image').formats(@image_format) do
|
2012-02-28 23:51:37 -05:00
|
|
|
Fog::Compute[:ibm].get_image("20010001").body
|
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('#create_image').formats(@create_image_format) do
|
|
|
|
response = Fog::Compute[:ibm].create_instance(
|
2012-02-13 10:51:03 -05:00
|
|
|
@name,
|
|
|
|
@image_id,
|
|
|
|
@instance_type,
|
|
|
|
@location,
|
2012-02-28 16:41:21 -05:00
|
|
|
:key_name => @key_name
|
2011-12-02 13:27:44 -05:00
|
|
|
).body
|
|
|
|
@instance_id = response['instances'][0]['id']
|
2012-02-29 00:30:05 -05:00
|
|
|
Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM::TIMEOUT) { ready? }
|
2011-12-02 13:27:44 -05:00
|
|
|
data = Fog::Compute[:ibm].create_image(@instance_id, @image_name, "").body
|
|
|
|
@id = data['id']
|
2012-02-13 10:51:03 -05:00
|
|
|
data
|
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('#clone_image') do
|
2012-02-20 13:14:02 -05:00
|
|
|
clone_name = 'fog-test-clone-image-' + Time.now.to_i.to_s(32)
|
2012-02-29 12:51:19 -05:00
|
|
|
data = Fog::Compute[:ibm].clone_image(@image_id, clone_name, clone_name).body
|
2011-12-02 13:27:44 -05:00
|
|
|
@cloned_id = data['ImageID']
|
|
|
|
returns(String) { data['ImageID'].class }
|
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
|
|
|
tests('#delete_image') do
|
2012-03-13 19:53:59 -04:00
|
|
|
pending
|
2012-02-13 10:51:03 -05:00
|
|
|
returns(true) { Fog::Compute[:ibm].delete_image(@id).body['success'] }
|
|
|
|
returns(true) { Fog::Compute[:ibm].delete_image(@cloned_id).body['success'] }
|
2011-12-02 13:27:44 -05:00
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2012-03-13 19:53:59 -04:00
|
|
|
@server = Fog::Compute[:ibm].servers.get(@instance_id)
|
|
|
|
@server.wait_for(Fog::IBM::TIMEOUT) { ready? }
|
|
|
|
@server.destroy
|
2012-02-29 00:30:05 -05:00
|
|
|
@key.wait_for(Fog::IBM::TIMEOUT) { instance_ids.empty? }
|
2012-02-28 16:41:21 -05:00
|
|
|
@key.destroy
|
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
end
|
|
|
|
|
2012-02-13 10:51:03 -05:00
|
|
|
end
|