fog 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/Rakefile +1 -0
  2. data/changelog.txt +91 -0
  3. data/fog.gemspec +3 -3
  4. data/lib/fog.rb +1 -1
  5. data/lib/fog/aws/compute.rb +5 -4
  6. data/lib/fog/aws/models/compute/security_group.rb +7 -1
  7. data/lib/fog/aws/models/compute/subnet.rb +0 -1
  8. data/lib/fog/aws/parsers/compute/create_security_group.rb +24 -0
  9. data/lib/fog/aws/requests/cloud_watch/get_metric_statistics.rb +1 -1
  10. data/lib/fog/aws/requests/compute/authorize_security_group_ingress.rb +19 -11
  11. data/lib/fog/aws/requests/compute/create_security_group.rb +5 -3
  12. data/lib/fog/aws/requests/compute/describe_security_groups.rb +1 -1
  13. data/lib/fog/aws/requests/storage/get_object_http_url.rb +2 -2
  14. data/lib/fog/aws/requests/storage/get_object_https_url.rb +2 -2
  15. data/lib/fog/aws/simpledb.rb +6 -1
  16. data/lib/fog/bin.rb +1 -0
  17. data/lib/fog/bin/ibm.rb +34 -0
  18. data/lib/fog/compute.rb +3 -0
  19. data/lib/fog/core/errors.rb +2 -0
  20. data/lib/fog/ibm.rb +176 -0
  21. data/lib/fog/ibm/compute.rb +233 -0
  22. data/lib/fog/ibm/models/compute/address.rb +62 -0
  23. data/lib/fog/ibm/models/compute/addresses.rb +28 -0
  24. data/lib/fog/ibm/models/compute/image.rb +61 -0
  25. data/lib/fog/ibm/models/compute/images.rb +27 -0
  26. data/lib/fog/ibm/models/compute/instance-type.rb +14 -0
  27. data/lib/fog/ibm/models/compute/instance-types.rb +15 -0
  28. data/lib/fog/ibm/models/compute/key.rb +35 -0
  29. data/lib/fog/ibm/models/compute/keys.rb +35 -0
  30. data/lib/fog/ibm/models/compute/location.rb +15 -0
  31. data/lib/fog/ibm/models/compute/locations.rb +27 -0
  32. data/lib/fog/ibm/models/compute/server.rb +193 -0
  33. data/lib/fog/ibm/models/compute/servers.rb +27 -0
  34. data/lib/fog/ibm/models/storage/offering.rb +18 -0
  35. data/lib/fog/ibm/models/storage/offerings.rb +19 -0
  36. data/lib/fog/ibm/models/storage/volume.rb +95 -0
  37. data/lib/fog/ibm/models/storage/volumes.rb +27 -0
  38. data/lib/fog/ibm/requests/compute/clone_image.rb +48 -0
  39. data/lib/fog/ibm/requests/compute/create_address.rb +50 -0
  40. data/lib/fog/ibm/requests/compute/create_image.rb +56 -0
  41. data/lib/fog/ibm/requests/compute/create_instance.rb +80 -0
  42. data/lib/fog/ibm/requests/compute/create_key.rb +61 -0
  43. data/lib/fog/ibm/requests/compute/delete_address.rb +46 -0
  44. data/lib/fog/ibm/requests/compute/delete_image.rb +43 -0
  45. data/lib/fog/ibm/requests/compute/delete_instance.rb +52 -0
  46. data/lib/fog/ibm/requests/compute/delete_key.rb +41 -0
  47. data/lib/fog/ibm/requests/compute/get_image.rb +67 -0
  48. data/lib/fog/ibm/requests/compute/get_image_agreement.rb +66 -0
  49. data/lib/fog/ibm/requests/compute/get_image_manifest.rb +39 -0
  50. data/lib/fog/ibm/requests/compute/get_instance.rb +76 -0
  51. data/lib/fog/ibm/requests/compute/get_instance_logs.rb +25 -0
  52. data/lib/fog/ibm/requests/compute/get_key.rb +49 -0
  53. data/lib/fog/ibm/requests/compute/get_location.rb +55 -0
  54. data/lib/fog/ibm/requests/compute/get_request.rb +78 -0
  55. data/lib/fog/ibm/requests/compute/list_address_offerings.rb +58 -0
  56. data/lib/fog/ibm/requests/compute/list_addresses.rb +53 -0
  57. data/lib/fog/ibm/requests/compute/list_images.rb +58 -0
  58. data/lib/fog/ibm/requests/compute/list_instances.rb +57 -0
  59. data/lib/fog/ibm/requests/compute/list_keys.rb +57 -0
  60. data/lib/fog/ibm/requests/compute/list_locations.rb +37 -0
  61. data/lib/fog/ibm/requests/compute/list_vlans.rb +52 -0
  62. data/lib/fog/ibm/requests/compute/modify_instance.rb +71 -0
  63. data/lib/fog/ibm/requests/compute/modify_key.rb +52 -0
  64. data/lib/fog/ibm/requests/storage/create_volume.rb +66 -0
  65. data/lib/fog/ibm/requests/storage/delete_volume.rb +42 -0
  66. data/lib/fog/ibm/requests/storage/get_volume.rb +72 -0
  67. data/lib/fog/ibm/requests/storage/list_offerings.rb +76 -0
  68. data/lib/fog/ibm/requests/storage/list_volumes.rb +47 -0
  69. data/lib/fog/ibm/storage.rb +82 -0
  70. data/lib/fog/ovirt/compute.rb +1 -0
  71. data/lib/fog/ovirt/models/compute/server.rb +5 -0
  72. data/lib/fog/ovirt/requests/compute/vm_ticket.rb +21 -0
  73. data/lib/fog/providers.rb +1 -0
  74. data/lib/fog/storage.rb +3 -0
  75. data/tests/aws/requests/compute/security_group_tests.rb +37 -39
  76. data/tests/compute/helper.rb +4 -0
  77. data/tests/compute/models/flavors_tests.rb +1 -1
  78. data/tests/helper.rb +1 -1
  79. data/tests/helpers/mock_helper.rb +2 -0
  80. data/tests/ibm/models/compute/image_tests.rb +10 -0
  81. data/tests/ibm/models/compute/key_tests.rb +23 -0
  82. data/tests/ibm/models/compute/keys_tests.rb +35 -0
  83. data/tests/ibm/models/compute/locations_tests.rb +18 -0
  84. data/tests/ibm/models/compute/server_tests.rb +88 -0
  85. data/tests/ibm/models/compute/servers_tests.rb +37 -0
  86. data/tests/ibm/models/storage/volume_tests.rb +60 -0
  87. data/tests/ibm/requests/compute/address_tests.rb +44 -0
  88. data/tests/ibm/requests/compute/image_tests.rb +110 -0
  89. data/tests/ibm/requests/compute/instance_tests.rb +102 -0
  90. data/tests/ibm/requests/compute/key_tests.rb +50 -0
  91. data/tests/ibm/requests/compute/location_tests.rb +28 -0
  92. data/tests/ibm/requests/storage/volume_tests.rb +100 -0
  93. metadata +122 -43
@@ -0,0 +1,35 @@
1
+ Shindo.tests('Fog::Compute[:ibm] | keys', ['ibm']) do
2
+
3
+ tests('success') do
4
+
5
+ @key_name = 'fog-test-key' + Time.now.to_i.to_s(32)
6
+ @key = nil
7
+
8
+ tests("Fog::Compute[:ibm].keys.create(:name => '#{@key_name}')") do
9
+ @key = Fog::Compute[:ibm].keys.create(:name => @key_name)
10
+ returns(@key_name) { @key.name }
11
+ end
12
+
13
+ tests('Fog::Compute[:ibm].keys') do
14
+ returns(true) { Fog::Compute[:ibm].keys.length > 0 }
15
+ end
16
+
17
+ tests("Fog::Compute[:ibm].keys.default = '#{@key_name}'") do
18
+ returns(@key_name) { Fog::Compute[:ibm].keys.default = @key_name }
19
+ end
20
+
21
+ tests("Fog::Compute[:ibm].keys.default") do
22
+ @key = Fog::Compute[:ibm].keys.get(@key_name)
23
+ returns(@key.name) { Fog::Compute[:ibm].keys.default.name }
24
+ end
25
+
26
+ tests("Fog::Compute[:ibm].keys.get('#{@key_name}')") do
27
+ key = Fog::Compute[:ibm].keys.get(@key_name)
28
+ returns(@key_name) { key.name }
29
+ end
30
+
31
+ @key.destroy
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,18 @@
1
+ Shindo.tests('Fog::Compute[:ibm] | locations', ['ibm']) do
2
+
3
+ tests('success') do
4
+
5
+ @location_id = '41'
6
+
7
+ tests('Fog::Compute[:ibm].locations') do
8
+ returns(true) { Fog::Compute[:ibm].locations.length > 0 }
9
+ end
10
+
11
+ tests('Fog::Compute[:ibm].locations.get("#{@location_id}")') do
12
+ @location = Fog::Compute[:ibm].locations.get(@location_id)
13
+ returns(@location_id) { @location.id }
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,88 @@
1
+ Shindo.tests('Fog::Compute[:ibm] | server', ['ibm']) do
2
+
3
+ tests('success') do
4
+ # TODO: Fix this for non-mock tests
5
+ @server = nil
6
+ @instance_id = nil
7
+
8
+ @name = "fog-test-instance-" + Time.now.to_i.to_s(32)
9
+ @image_id = "20010001"
10
+ @instance_type = "BRZ32.1/2048/60*175"
11
+ @location_id = "41"
12
+
13
+ @key_name = "fog-test-key-" + Time.now.to_i.to_s(32)
14
+ @key = Fog::Compute[:ibm].keys.create(:name => @key_name)
15
+
16
+ tests('Fog::Compute::IBM::Server.new') do
17
+ @server = Fog::Compute[:ibm].servers.new(
18
+ :name => @name,
19
+ :image_id => @image_id,
20
+ :instance_type => @instance_type,
21
+ :location_id => @location,
22
+ :key_name => @key_name
23
+ )
24
+ returns(@name) { @server.name }
25
+ end
26
+
27
+ tests('Fog::Compute::IBM::Server#save') do
28
+ returns(true) { @server.save }
29
+ returns(String) { @server.id.class }
30
+ @instance_id = @server.id
31
+ end
32
+
33
+ tests('Fog::Compute::IBM::Server#wait_for { ready? }') do
34
+ @server = Fog::Compute[:ibm].servers.get(@instance_id)
35
+ @server.wait_for(Fog::IBM::TIMEOUT) { ready? }
36
+ end
37
+
38
+ tests('Fog::Compute::IBM::Server#id') do
39
+ returns(@instance_id) { @server.id }
40
+ end
41
+
42
+ tests('Fog::Compute::IBM::Server#ready?') do
43
+ returns(true) { @server.ready? }
44
+ end
45
+
46
+ tests('Fog::Compute::IBM::Server#status') do
47
+ returns("Active") { @server.state }
48
+ end
49
+
50
+ # TODO: make this work
51
+ # tests('Fog::Compute::IBM::Server#reboot') do
52
+ # returns(true) { @server.reboot }
53
+ # end
54
+
55
+ tests('Fog::Compute::IBM::Server#rename("name")') do
56
+ name = @server.name + "-rename"
57
+ returns(true) { @server.rename(name) }
58
+ returns(name) { @server.name }
59
+ end
60
+
61
+ tests('Fog::Compute::IBM::Server#image') do
62
+ returns(@image_id) { @server.image.id }
63
+ end
64
+
65
+ tests('Fog::Compute::IBM::Server#to_image') do
66
+ body = @server.to_image(:name => @server.name)
67
+ returns(@server.name) { body['name'] }
68
+ image = Fog::Compute[:ibm].images.get(body['id'])
69
+ image.wait_for(Fog::IBM::TIMEOUT) { ready? || state == 'New' }
70
+ unless image.state == 'Capturing'
71
+ returns(true) { Fog::Compute[:ibm].delete_image(image.id).body['success'] }
72
+ end
73
+ end
74
+
75
+ tests('Fog::Compute::IBM::Server#expire_at') do
76
+ returns(true) { @server.expire_at(Time.now + 60) }
77
+ end
78
+
79
+ tests('Fog::Compute::IBM::Server#destroy') do
80
+ returns(true) { @server.destroy }
81
+ end
82
+
83
+ @key.wait_for(Fog::IBM::TIMEOUT) { instance_ids.empty? }
84
+ @key.destroy
85
+
86
+ end
87
+
88
+ end
@@ -0,0 +1,37 @@
1
+ Shindo.tests('Fog::Compute[:ibm] | servers', ['ibm']) do
2
+
3
+ tests('success') do
4
+
5
+ @name = "fog-test-instance-" + Time.now.to_i.to_s(32)
6
+ @image_id = "20010001"
7
+ @instance_type = "BRZ32.1/2048/60*175"
8
+ @location_id = "41"
9
+ @key_name = "fog-test-key-" + Time.now.to_i.to_s(32)
10
+ @key = Fog::Compute[:ibm].keys.create(:name => @key_name)
11
+
12
+ @n_servers = Fog::Compute[:ibm].servers.length
13
+ @instance_id = Fog::Compute[:ibm].create_instance(@name, @image_id, @instance_type, @location_id, :key_name => @key_name).body["instances"][0]["id"]
14
+
15
+ tests('Fog::Compute[:ibm].servers') do
16
+ returns(@n_servers + 1) { Fog::Compute[:ibm].servers.length }
17
+ end
18
+
19
+ tests('Fog::Compute[:ibm].servers.get("#{@instance_id}")') do
20
+ @server = Fog::Compute[:ibm].servers.get(@instance_id)
21
+ returns(@instance_id) { @server.id }
22
+ end
23
+
24
+ if @server.wait_for(Fog::IBM::TIMEOUT) { ready? }
25
+ @server.destroy
26
+ else
27
+ pending
28
+ end
29
+ if @key.wait_for(Fog::IBM::TIMEOUT) { instance_ids.empty? }
30
+ @key.destroy
31
+ else
32
+ pending
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,60 @@
1
+ Shindo.tests('Fog::Storage[:ibm] | volume', ['ibm']) do
2
+
3
+ tests('success') do
4
+
5
+ @volume = nil
6
+ @volume_id = nil
7
+ @name = "fog test volume"
8
+ @format = "RAW"
9
+ @location_id = "41"
10
+ @size = "256"
11
+ @offering_id = "20001208"
12
+
13
+ tests('Fog::Storage::IBM::Volume.new') do
14
+ @volume = Fog::Storage[:ibm].volumes.new(
15
+ :name => @name,
16
+ :format => @format,
17
+ :location_id => @location_id,
18
+ :size => @size,
19
+ :offering_id => @offering_id
20
+ )
21
+ returns(@name) { @volume.name }
22
+ end
23
+
24
+ tests('Fog::Storage::IBM::Volume#save') do
25
+ returns(true) { @volume.save }
26
+ returns(String) { @volume.id.class }
27
+ @volume.wait_for(Fog::IBM::TIMEOUT) { ready? }
28
+ @volume_id = @volume.id
29
+ end
30
+
31
+ tests("Fog::Storage::IBM::Volume#instance") do
32
+ returns(nil) { @volume.instance }
33
+ end
34
+
35
+ tests("Fog::Storage::IBM::Volume#location_id") do
36
+ returns(String) { @volume.location_id.class }
37
+ end
38
+
39
+ tests('Fog::Storage::IBM::Volume#id') do
40
+ returns(@volume_id) { @volume.id }
41
+ end
42
+
43
+ tests('Fog::Storage::IBM::Volume#ready?') do
44
+ # We do a "get" to advance the state if we are mocked.
45
+ # TODO: Fix this for real connections
46
+ Fog::Storage[:ibm].get_volume(@volume_id)
47
+ returns(true) { @volume.ready? }
48
+ end
49
+
50
+ tests('Fog::Storage::IBM::Volume#status') do
51
+ returns("Detached") { @volume.status }
52
+ end
53
+
54
+ tests('Fog::Storage::IBM::Volume#destroy') do
55
+ returns(true) { @volume.destroy }
56
+ end
57
+
58
+ end
59
+
60
+ end
@@ -0,0 +1,44 @@
1
+ Shindo.tests('Fog::Compute[:ibm] | address requests', ['ibm']) do
2
+
3
+ @address_format = {
4
+ "state" => Integer,
5
+ "offeringId"=> String,
6
+ "location" => String,
7
+ "ip" => String,
8
+ "id" => String,
9
+ "mode" => Integer,
10
+ "hostname" => String,
11
+ "type" => Integer,
12
+ "instanceId" => Fog::Nullable::String,
13
+ "vlan" => Fog::Nullable::String,
14
+ }
15
+
16
+ # create_address doesn't return mode, hostname or type attributes
17
+ @create_address_format = @address_format.reject { |k,v| ["mode", "hostname", "type"].include? k }
18
+ # list_address returns everything
19
+ @list_address_format = { 'addresses' => [ @address_format ] }
20
+
21
+ @address_id = nil
22
+ @location_id = "41"
23
+ @offering_id = "20001223"
24
+
25
+ tests('success') do
26
+
27
+ tests("#create_address('#{@location_id}')").formats(@create_address_format) do
28
+ data = Fog::Compute[:ibm].create_address(@location_id, @offering_id).body
29
+ @address_id = data['id']
30
+ data
31
+ end
32
+
33
+ tests("#list_addresses").formats(@list_address_format) do
34
+ Fog::Compute[:ibm].list_addresses.body
35
+ end
36
+
37
+ tests("#delete_address('#{@address_id}')") do
38
+ Fog::Compute[:ibm].addresses.get(@address_id).wait_for(Fog::IBM::TIMEOUT) { ready? }
39
+ returns(true) { Fog::Compute[:ibm].delete_address(@address_id).body['success'] }
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,110 @@
1
+ Shindo.tests('Fog::Compute[:ibm] | image requests', ['ibm']) do
2
+
3
+ @image_format = {
4
+ 'state' => Integer,
5
+ 'visibility' => String,
6
+ 'platform' => String,
7
+ 'owner' => String,
8
+ 'architecture' => Fog::Nullable::String,
9
+ 'createdTime' => Integer,
10
+ 'location' => String,
11
+ 'productCodes' => Array,
12
+ 'name' => String,
13
+ 'id' => String,
14
+ 'description' => String,
15
+ 'supportedInstanceTypes' => Array,
16
+ 'manifest' => Fog::Nullable::String,
17
+ 'documentation' => Fog::Nullable::String,
18
+ }
19
+
20
+ # TODO: Actually check this format
21
+ @product_code_format = {
22
+ 'detail' => String,
23
+ 'label' => String,
24
+ 'price' => @price_format,
25
+ 'id' => String
26
+ }
27
+
28
+ # TODO: Actually check this format
29
+ @price_format = {
30
+ 'rate' => Float,
31
+ 'unitOfMeasure' => String,
32
+ 'effectiveDate' => Integer,
33
+ 'currencyCode' => String,
34
+ 'pricePerQuantity' => Integer
35
+ }
36
+
37
+ @images_format = {
38
+ 'images' => [ @image_format ]
39
+ }
40
+
41
+ @create_image_format = {
42
+ "name" => String,
43
+ "createdTime" => Integer,
44
+ "productCodes"=> Array,
45
+ "id" => String,
46
+ "description" => String,
47
+ "visibility" => String,
48
+ "state" => Integer
49
+ }
50
+
51
+ @instance_id = nil
52
+ @name = "fog-test-image-instance-" + Time.now.to_i.to_s(32)
53
+ @image_id = "20010001"
54
+ @instance_type = "BRZ32.1/2048/60*175"
55
+ @location = "41"
56
+
57
+ @id = nil
58
+ @cloned_id = nil
59
+ @image_name = "fog test create image"
60
+
61
+ @key_name = "fog-test-key-" + Time.now.to_i.to_s(32)
62
+ @key = Fog::Compute[:ibm].keys.create(:name => @key_name)
63
+
64
+ tests('success') do
65
+
66
+ tests("#list_images").formats(@images_format) do
67
+ Fog::Compute[:ibm].list_images.body
68
+ end
69
+
70
+ tests('#get_image').formats(@image_format) do
71
+ Fog::Compute[:ibm].get_image("20010001").body
72
+ end
73
+
74
+ tests('#create_image').formats(@create_image_format) do
75
+ response = Fog::Compute[:ibm].create_instance(
76
+ @name,
77
+ @image_id,
78
+ @instance_type,
79
+ @location,
80
+ :key_name => @key_name
81
+ ).body
82
+ @instance_id = response['instances'][0]['id']
83
+ Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM::TIMEOUT) { ready? }
84
+ data = Fog::Compute[:ibm].create_image(@instance_id, @image_name, "").body
85
+ @id = data['id']
86
+ data
87
+ end
88
+
89
+ tests('#clone_image') do
90
+ clone_name = 'fog-test-clone-image-' + Time.now.to_i.to_s(32)
91
+ data = Fog::Compute[:ibm].clone_image(@image_id, clone_name, clone_name).body
92
+ @cloned_id = data['ImageID']
93
+ returns(String) { data['ImageID'].class }
94
+ end
95
+
96
+ tests('#delete_image') do
97
+ pending
98
+ returns(true) { Fog::Compute[:ibm].delete_image(@id).body['success'] }
99
+ returns(true) { Fog::Compute[:ibm].delete_image(@cloned_id).body['success'] }
100
+ end
101
+
102
+ @server = Fog::Compute[:ibm].servers.get(@instance_id)
103
+ @server.wait_for(Fog::IBM::TIMEOUT) { ready? }
104
+ @server.destroy
105
+ @key.wait_for(Fog::IBM::TIMEOUT) { instance_ids.empty? }
106
+ @key.destroy
107
+
108
+ end
109
+
110
+ end
@@ -0,0 +1,102 @@
1
+ Shindo.tests('Fog::Compute[:ibm] | instance requests', ['ibm']) do
2
+
3
+ @instance_format = {
4
+ 'name' => String,
5
+ 'location' => String,
6
+ 'keyName' => String,
7
+ 'primaryIP' => {
8
+ 'vlan' => Fog::Nullable::String,
9
+ 'type' => Integer,
10
+ 'ip' => String,
11
+ 'hostname' => String,
12
+ },
13
+ 'productCodes' => Array,
14
+ 'requestId' => String,
15
+ 'imageId' => String,
16
+ 'launchTime' => Integer,
17
+ 'id' => String,
18
+ 'ip' => Fog::Nullable::String,
19
+ 'volumes' => Array,
20
+ 'root-only' => Fog::Nullable::String,
21
+ 'isMiniEphemeral' => Fog::Nullable::String,
22
+ 'instanceType' => String,
23
+ 'diskSize' => Fog::Nullable::String,
24
+ 'requestName' => String,
25
+ 'secondaryIP' => Array,
26
+ 'status' => Integer,
27
+ 'software' => Array,
28
+ 'expirationTime'=> Integer,
29
+ 'owner' => String,
30
+ }
31
+
32
+ @instances_format = {
33
+ 'instances' => [ @instance_format ]
34
+ }
35
+
36
+ tests('success') do
37
+
38
+ @instance_id = nil
39
+ @name = "fog-test-instance-" + Time.now.to_i.to_s(32)
40
+ @image_id = "20010001"
41
+ @instance_type = "COP32.1/2048/60"
42
+ @location = "41"
43
+ @key_name = "fog-test-key-" + Time.now.to_i.to_s(32)
44
+ @key = Fog::Compute[:ibm].keys.create(:name => @key_name)
45
+
46
+ tests("#create_instance('#{@name}', '#{@image_id}', '#{@instance_type}', '#{@location}', :key_name => '#{@key_name}')").formats(@instances_format) do
47
+ response = Fog::Compute[:ibm].create_instance(@name, @image_id, @instance_type, @location, :key_name => @key_name).body
48
+ @instance_id = response['instances'][0]['id']
49
+ response
50
+ end
51
+
52
+ tests("#get_instance('#{@instance_id}')").formats(@instance_format) do
53
+ response = Fog::Compute[:ibm].get_instance(@instance_id).body
54
+ end
55
+
56
+ Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM::TIMEOUT) { ready? }
57
+
58
+ tests("#list_instances").formats(@instances_format) do
59
+ instances = Fog::Compute[:ibm].list_instances.body
60
+ end
61
+
62
+ tests("#modify_instance('#{@instance_id}', 'state' => 'restart')") do
63
+ returns(true) { Fog::Compute[:ibm].modify_instance(@instance_id, 'state' => 'restart').body["success"] }
64
+ end
65
+
66
+ tests("#modify_instance('#{@instance_id}', 'name' => '#{@name} 2')") do
67
+ returns(true) { Fog::Compute[:ibm].modify_instance(@instance_id, 'name' => @name + " 2").body["success"] }
68
+ end
69
+
70
+ @expiration_time = (Time.now.to_i + 10) * 1000
71
+
72
+ tests("#modify_instance('#{@instance_id}', 'expirationTime' => '#{@expiration_time}')") do
73
+ returns(@expiration_time) { Fog::Compute[:ibm].modify_instance(@instance_id, 'expirationTime' => @expiration_time).body["expirationTime"] }
74
+ end
75
+
76
+ tests("#delete_instance('#{@instance_id}')") do
77
+ if Fog::Compute[:ibm].servers.get(@instance_id).wait_for(Fog::IBM::TIMEOUT) { ready? }
78
+ data = Fog::Compute[:ibm].delete_instance(@instance_id)
79
+ else
80
+ pending
81
+ end
82
+ end
83
+
84
+ if @key.wait_for(Fog::IBM::TIMEOUT) { instance_ids.empty? }
85
+ @key.destroy
86
+ else
87
+ pending
88
+ end
89
+
90
+ end
91
+
92
+ tests('failures') do
93
+
94
+ tests('#create_instance => 412') do
95
+ raises(Excon::Errors::PreconditionFailed) do
96
+ Fog::Compute[:ibm].create_instance("FAIL: 412", @image_id, @instance_type, @location, :key_name => "invalid")
97
+ end
98
+ end
99
+
100
+ end
101
+
102
+ end