deltacloud-core 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/Rakefile +2 -1
  2. data/bin/deltacloudd +11 -5
  3. data/config.ru +3 -3
  4. data/deltacloud-core.gemspec +24 -18
  5. data/lib/cimi/collections/address_templates.rb +3 -3
  6. data/lib/cimi/collections/addresses.rb +6 -5
  7. data/lib/cimi/collections/entity_metadata.rb +0 -2
  8. data/lib/cimi/collections/machine_admins.rb +5 -5
  9. data/lib/cimi/collections/machine_configurations.rb +2 -2
  10. data/lib/cimi/collections/machine_images.rb +3 -3
  11. data/lib/cimi/collections/machines.rb +32 -10
  12. data/lib/cimi/collections/network_configurations.rb +4 -3
  13. data/lib/cimi/collections/network_templates.rb +4 -3
  14. data/lib/cimi/collections/networks.rb +8 -8
  15. data/lib/cimi/collections/routing_group_templates.rb +4 -3
  16. data/lib/cimi/collections/routing_groups.rb +4 -3
  17. data/lib/cimi/collections/volume_configurations.rb +3 -3
  18. data/lib/cimi/collections/volume_images.rb +3 -3
  19. data/lib/cimi/collections/volumes.rb +4 -3
  20. data/lib/cimi/collections/vsp_configurations.rb +4 -3
  21. data/lib/cimi/collections/vsp_templates.rb +4 -3
  22. data/lib/cimi/collections/vsps.rb +8 -7
  23. data/lib/cimi/helpers.rb +1 -1
  24. data/lib/cimi/helpers/cimi_helper.rb +11 -1
  25. data/lib/cimi/models.rb +4 -0
  26. data/lib/cimi/models/base.rb +11 -1
  27. data/lib/cimi/models/cloud_entry_point.rb +7 -14
  28. data/lib/cimi/models/disk.rb +40 -0
  29. data/lib/cimi/models/disk_collection.rb +38 -0
  30. data/lib/cimi/models/machine.rb +9 -43
  31. data/lib/cimi/models/machine_collection.rb +7 -4
  32. data/lib/cimi/models/machine_configuration.rb +8 -15
  33. data/lib/cimi/models/machine_configuration_collection.rb +6 -4
  34. data/lib/cimi/models/machine_image_collection.rb +6 -4
  35. data/lib/cimi/models/machine_template_collection.rb +6 -4
  36. data/lib/cimi/models/machine_volume.rb +42 -0
  37. data/lib/cimi/models/machine_volume_collection.rb +34 -0
  38. data/lib/cimi/models/network.rb +5 -9
  39. data/lib/cimi/models/network_collection.rb +6 -5
  40. data/lib/cimi/models/schema.rb +20 -0
  41. data/lib/cimi/models/volume_collection.rb +6 -4
  42. data/lib/cimi/models/volume_configuration_collection.rb +6 -4
  43. data/lib/cimi/models/volume_image_collection.rb +6 -4
  44. data/lib/cimi/models/volume_template_collection.rb +6 -4
  45. data/lib/deltacloud/api.rb +3 -3
  46. data/lib/deltacloud/collections/addresses.rb +1 -1
  47. data/lib/deltacloud/collections/firewalls.rb +4 -2
  48. data/lib/deltacloud/collections/keys.rb +1 -1
  49. data/lib/deltacloud/collections/load_balancers.rb +1 -1
  50. data/lib/deltacloud/collections/storage_volumes.rb +4 -4
  51. data/lib/deltacloud/drivers/base_driver.rb +12 -20
  52. data/lib/deltacloud/drivers/ec2/aws_vpc_monkey_patch.rb +294 -0
  53. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +38 -6
  54. data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +4 -0
  55. data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +40 -4
  56. data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +8 -7
  57. data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +422 -416
  58. data/lib/deltacloud/drivers/google/google_driver.rb +2 -1
  59. data/lib/deltacloud/drivers/openstack/openstack_driver.rb +30 -16
  60. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +1 -0
  61. data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +3 -9
  62. data/lib/deltacloud/helpers/deltacloud_helper.rb +0 -2
  63. data/lib/deltacloud/models/firewall_rule.rb +2 -0
  64. data/lib/deltacloud/models/hardware_profile.rb +61 -59
  65. data/{tests/deprecated/core_ext/string.rb → lib/deltacloud/version.rb} +3 -15
  66. data/lib/deltacloud_rack.rb +1 -0
  67. data/lib/ec2/server.rb +5 -3
  68. data/lib/sinatra/rack_accept.rb +53 -53
  69. data/lib/sinatra/rack_etag.rb +1 -1
  70. data/tests/cimi/collections/cloud_entry_point_test.rb +11 -2
  71. data/tests/deltacloud/common.rb +1 -1
  72. data/tests/deltacloud/rack_test.rb +3 -3
  73. data/tests/drivers/base/base_driver_test.rb +6 -2
  74. data/tests/drivers/base/common.rb +1 -0
  75. data/tests/drivers/base/library_test.rb +6 -2
  76. data/tests/drivers/ec2/common.rb +34 -15
  77. data/tests/drivers/ec2/images_test.rb +2 -3
  78. data/tests/drivers/ec2/instance_test.rb +12 -2
  79. data/tests/drivers/ec2/keys_test.rb +2 -2
  80. data/tests/drivers/ec2/realms_test.rb +7 -3
  81. data/tests/drivers/ec2/storage_snapshots_test.rb +2 -3
  82. data/tests/drivers/gogrid/common.rb +24 -0
  83. data/tests/drivers/gogrid/hardware_profiles_test.rb +51 -0
  84. data/tests/drivers/gogrid/images_test.rb +57 -0
  85. data/tests/drivers/gogrid/instances_test.rb +92 -0
  86. data/tests/drivers/gogrid/realms_test.rb +45 -0
  87. data/tests/drivers/google/buckets_test.rb +105 -0
  88. data/tests/drivers/google/common.rb +20 -0
  89. data/tests/drivers/mock/common.rb +1 -0
  90. data/tests/drivers/mock/images_test.rb +3 -2
  91. data/tests/drivers/mock/instances_test.rb +3 -2
  92. data/tests/drivers/mock/keys_test.rb +3 -2
  93. data/tests/drivers/mock/realms_test.rb +3 -2
  94. data/tests/drivers/mock/storage_snapshots_test.rb +3 -2
  95. data/tests/drivers/mock/storage_volumes_test.rb +3 -2
  96. data/tests/drivers/models/address_test.rb +3 -3
  97. data/tests/drivers/models/base_test.rb +4 -2
  98. data/tests/drivers/models/blob_test.rb +3 -3
  99. data/tests/drivers/models/common.rb +3 -0
  100. data/tests/drivers/models/hardware_profile_test.rb +5 -4
  101. data/tests/drivers/models/instance_address_test.rb +3 -3
  102. data/tests/drivers/models/instance_profile_test.rb +3 -3
  103. data/tests/drivers/models/instance_test.rb +3 -3
  104. data/tests/drivers/models/keys_test.rb +3 -3
  105. data/tests/drivers/models/metrics_test.rb +3 -3
  106. data/tests/drivers/openstack/common.rb +26 -0
  107. data/tests/drivers/openstack/hardware_profiles_test.rb +46 -0
  108. data/tests/drivers/openstack/images_test.rb +50 -0
  109. data/tests/drivers/openstack/instances_test.rb +66 -0
  110. data/tests/drivers/openstack/keys_test.rb +61 -0
  111. data/tests/drivers/openstack/realms_test.rb +46 -0
  112. data/tests/drivers/rhevm/common.rb +2 -0
  113. data/tests/drivers/rhevm/images_test.rb +3 -4
  114. data/tests/drivers/rhevm/instance_test.rb +2 -2
  115. data/tests/drivers/rhevm/provider_test.rb +2 -2
  116. data/tests/drivers/rhevm/realms_test.rb +2 -3
  117. data/tests/ec2/common.rb +5 -4
  118. data/tests/ec2/server_test.rb +3 -2
  119. data/tests/helpers/rack/common.rb +3 -0
  120. data/tests/helpers/rack/rack_accept_test.rb +65 -0
  121. data/tests/helpers/rack/rack_date_test.rb +27 -0
  122. data/tests/helpers/rack/rack_driver_select_test.rb +53 -0
  123. data/tests/helpers/rack/rack_etag_test.rb +29 -0
  124. data/tests/helpers/rack/rack_matrix_params_test.rb +72 -0
  125. data/tests/test_helper.rb +44 -36
  126. data/views/hardware_profiles/index.html.haml +1 -1
  127. data/views/hardware_profiles/show.html.haml +2 -2
  128. data/views/hardware_profiles/show.xml.haml +2 -1
  129. data/views/images/show.html.haml +6 -5
  130. metadata +74 -117
  131. data/tests/deprecated/api/common.rb +0 -1
  132. data/tests/deprecated/api/driver_test.rb +0 -79
  133. data/tests/deprecated/api/library_test.rb +0 -6
  134. data/tests/deprecated/cimi/features/step_definitions/common_steps.rb +0 -59
  135. data/tests/deprecated/cimi/features/step_definitions/machine_images_steps.rb +0 -0
  136. data/tests/deprecated/cimi/features/step_definitions/machines_steps.rb +0 -100
  137. data/tests/deprecated/cimi/features/step_definitions/volumes_steps.rb +0 -115
  138. data/tests/deprecated/cimi/features/support/env.rb +0 -75
  139. data/tests/deprecated/common.rb +0 -279
  140. data/tests/deprecated/drivers/ec2/api_test.rb +0 -19
  141. data/tests/deprecated/drivers/ec2/common.rb +0 -23
  142. data/tests/deprecated/drivers/ec2/drivers_test.rb +0 -120
  143. data/tests/deprecated/drivers/ec2/hardware_profiles_test.rb +0 -224
  144. data/tests/deprecated/drivers/ec2/images_test.rb +0 -230
  145. data/tests/deprecated/drivers/ec2/instances_test.rb +0 -356
  146. data/tests/deprecated/drivers/ec2/keys_test.rb +0 -181
  147. data/tests/deprecated/drivers/ec2/realms_test.rb +0 -146
  148. data/tests/deprecated/drivers/fgcp/api_test.rb +0 -47
  149. data/tests/deprecated/drivers/fgcp/hardware_profiles_test.rb +0 -54
  150. data/tests/deprecated/drivers/fgcp/realms_test.rb +0 -42
  151. data/tests/deprecated/drivers/fgcp/setup.rb +0 -13
  152. data/tests/deprecated/drivers/google/api_test.rb +0 -19
  153. data/tests/deprecated/drivers/google/buckets_test.rb +0 -100
  154. data/tests/deprecated/drivers/google/common.rb +0 -54
  155. data/tests/deprecated/drivers/mock/api_test.rb +0 -10
  156. data/tests/deprecated/drivers/mock/buckets_test.rb +0 -195
  157. data/tests/deprecated/drivers/mock/common.rb +0 -7
  158. data/tests/deprecated/drivers/mock/drivers_test.rb +0 -123
  159. data/tests/deprecated/drivers/mock/hardware_profiles_test.rb +0 -224
  160. data/tests/deprecated/drivers/mock/images_test.rb +0 -197
  161. data/tests/deprecated/drivers/mock/instances_test.rb +0 -343
  162. data/tests/deprecated/drivers/mock/keys_test.rb +0 -161
  163. data/tests/deprecated/drivers/mock/realms_test.rb +0 -132
  164. data/tests/deprecated/drivers/mock/storage_snapshots_test.rb +0 -114
  165. data/tests/deprecated/drivers/mock/storage_volumes_test.rb +0 -122
  166. data/tests/deprecated/drivers/openstack/api_test.rb +0 -46
  167. data/tests/deprecated/drivers/openstack/common.rb +0 -21
  168. data/tests/deprecated/drivers/openstack/hardware_profiles_test.rb +0 -64
  169. data/tests/deprecated/drivers/openstack/images_test.rb +0 -46
  170. data/tests/deprecated/drivers/openstack/instances_test.rb +0 -208
  171. data/tests/deprecated/drivers/openstack/realms_test.rb +0 -40
  172. data/tests/deprecated/drivers/rackspace/api_test.rb +0 -46
  173. data/tests/deprecated/drivers/rackspace/buckets_test.rb +0 -150
  174. data/tests/deprecated/drivers/rackspace/common.rb +0 -16
  175. data/tests/deprecated/drivers/rackspace/hardware_profiles_test.rb +0 -58
  176. data/tests/deprecated/drivers/rackspace/images_test.rb +0 -45
  177. data/tests/deprecated/drivers/rackspace/instances_test.rb +0 -166
  178. data/tests/deprecated/drivers/rackspace/realms_test.rb +0 -41
  179. data/tests/deprecated/drivers/rhevm/api_test.rb +0 -45
  180. data/tests/deprecated/drivers/rhevm/common.rb +0 -21
  181. data/tests/deprecated/drivers/rhevm/hardware_profiles_test.rb +0 -58
  182. data/tests/deprecated/drivers/rhevm/images_test.rb +0 -48
  183. data/tests/deprecated/drivers/rhevm/instances_test.rb +0 -182
  184. data/tests/deprecated/drivers/rhevm/realms_test.rb +0 -40
  185. data/tests/deprecated/minitest_common.rb +0 -58
  186. data/tests/deprecated/minitest_common_api_test.rb +0 -115
  187. data/tests/deprecated/rabbit_test.rb +0 -52
@@ -1,150 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
2
- require 'tests/drivers/rackspace/common'
3
- #require 'webmock/test_unit'
4
- module RackspaceTest
5
-
6
- class BucketsTest < Test::Unit::TestCase
7
- include Rack::Test::Methods
8
-
9
- def app
10
- Rack::Builder.new {
11
- map '/' do
12
- use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
13
- run Rack::Cascade.new([Deltacloud::API])
14
- end
15
- }
16
- end
17
-
18
- @@created_bucket_name="testbucki2rpux3wdelme"
19
- @@created_blob_name="testblobk1ds91kVdelme"
20
- @@created_blob_local_file="#{File.dirname(__FILE__)}/fixtures/deltacloud_blob_test.png"
21
-
22
- def test_01_it_can_create_new_bucket
23
- params = {
24
- :name => @@created_bucket_name,
25
- :'api[driver]' => 'rackspace'
26
- }
27
- post_url '/api/buckets', params
28
- last_response.status.should == 201 # Created
29
- bucket = last_xml_response
30
- check_bucket_basics(bucket)
31
- (bucket/'bucket/size').first.text.should == "0"
32
- end
33
-
34
- def test_02_it_can_post_new_blob
35
- temp_file=File.open(@@created_blob_local_file)
36
- params = {
37
- 'blob_id' => @@created_blob_name,
38
- :meta_params=>"2",
39
- :meta_name1=>"Author",
40
- :meta_value1=>"deltacloud",
41
- :meta_name2=>"foo",
42
- :meta_value2=>"bar",
43
- :'api[driver]' => 'rackspace'
44
- }
45
- uri="/api/buckets/#{@@created_bucket_name}"
46
- vcr_cassette = "post-"+Digest::SHA1.hexdigest("#{uri}-#{params.sort_by {|k,v| k.to_s}}")
47
- params.merge!({'blob_data' => Rack::Test::UploadedFile.new(temp_file.path, "text/html")})
48
- post_url uri, params, {'vcr_cassette'=>vcr_cassette}
49
- last_response.status.should == 200
50
- blob= last_xml_response
51
- check_blob_basics(blob)
52
- end
53
-
54
- def test_03_it_can_retrieve_named_bucket_details
55
- params = {
56
- :'api[driver]' => 'rackspace'
57
- }
58
- get_url "/api/buckets/#{@@created_bucket_name}", params
59
- last_response.status.should == 200
60
- bucket = last_xml_response
61
- check_bucket_basics(bucket)
62
- (bucket/'bucket/size').first.text.should == "1" #assuming blob created succesfully right?
63
- end
64
-
65
- def test_04_it_can_retrieve_named_blob_details
66
- params = {
67
- :'api[driver]' => 'rackspace'
68
- }
69
- get_url "/api/buckets/#{@@created_bucket_name}/#{@@created_blob_name}", params
70
- last_response.status.should == 200
71
- blob = last_xml_response
72
- check_blob_basics(blob)
73
- check_blob_metadata(blob, {"author"=>"deltacloud", "foo"=>"bar"})
74
- end
75
-
76
- # def test_05_it_can_retrieve_blob_metadata
77
- # params = {
78
- # :'api[driver]' => 'rackspace'
79
- # }
80
- # head_url "/api/buckets/#{@@created_bucket_name}/#{@@created_blob_name}", params
81
- # last_response.status.should == 204
82
- #debugger
83
- # blob = last_xml_response
84
- # check_blob_basics(blob)
85
- # check_blob_metadata(blob, {"author"=>"deltacloud", "foo"=>"bar"})
86
-
87
- # end
88
-
89
- def test_06_it_can_update_blob_metadata
90
- params = {
91
- :'api[driver]' => 'rackspace'
92
- }
93
- new_meta = {"X-Deltacloud-Blobmeta-author" => "ApacheDeltacloud", "X-Deltacloud-Blobmeta-oof" => "rab"}
94
- new_meta.each_pair do |k,v|
95
- header k, v
96
- end
97
- post_url "/api/buckets/#{@@created_bucket_name}/#{@@created_blob_name}", params
98
- last_response.status.should == 204
99
- new_meta.each_pair do |k,v|
100
- (last_response.headers[k]==v).should == true
101
- end
102
- end
103
-
104
- def test_07_it_can_delete_blob
105
- params = {
106
- :'api[driver]' => 'rackspace'
107
- }
108
- delete_url "/api/buckets/#{@@created_bucket_name}/#{@@created_blob_name}", params
109
- last_response.status.should == 204
110
- end
111
-
112
- def test_08_it_can_delete_bucket
113
- params = {
114
- :'api[driver]' => 'rackspace'
115
- }
116
- delete_url "/api/buckets/#{@@created_bucket_name}", params
117
- last_response.status.should == 204
118
- end
119
-
120
- private
121
-
122
- def check_bucket_basics(bucket)
123
- (bucket/'bucket/name').first.text.should == @@created_bucket_name
124
- (bucket/'bucket').attribute("id").text.should == @@created_bucket_name
125
- (bucket/'bucket').length.should > 0
126
- (bucket/'bucket/name').first.text.should_not == nil
127
- (bucket/'bucket').attribute("href").text.should_not == nil
128
- end
129
-
130
- def check_blob_basics(blob)
131
- (blob/'blob').length.should == 1
132
- (blob/'blob').attribute("id").text.should_not == nil
133
- (blob/'blob').attribute("href").text.should_not==nil
134
- (blob/'blob/bucket').text.should_not == nil
135
- (blob/'blob/content_length').text.should_not == nil
136
- (blob/'blob/content_type').text.should_not == nil
137
- (blob/'blob').attribute("id").text.should == @@created_blob_name
138
- (blob/'blob/bucket').text.should == @@created_bucket_name
139
- (blob/'blob/content_length').text.to_i.should == File.size(@@created_blob_local_file)
140
- end
141
-
142
- def check_blob_metadata(blob, metadata_hash)
143
- (0.. (((blob/'blob/user_metadata').first).elements.size - 1) ).each do |i|
144
- metadata_hash.has_key?(((blob/'blob/user_metadata').first).elements[i].attribute("key").value).should == true
145
- metadata_hash.has_value?(((blob/'blob/user_metadata').first).elements[i].children[1].text).should == true
146
- end
147
- end
148
-
149
- end
150
- end
@@ -1,16 +0,0 @@
1
- load File.join(File.dirname(__FILE__), '..', '..', 'common.rb')
2
-
3
- ENV['API_DRIVER'] = "rackspace"
4
- ENV['API_USER'] = 'mandreou'
5
- ENV['API_PASSWORD'] = 'a4d531ef02a37dd32cac1e8e516df9eb'
6
-
7
- require 'vcr'
8
-
9
- DeltacloudTestCommon::record!
10
-
11
- VCR.config do |c|
12
- c.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures')
13
- c.stub_with :webmock
14
- c.default_cassette_options = { :record => :none }
15
- end
16
-
@@ -1,58 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
2
- require 'tests/drivers/rackspace/common'
3
-
4
- module RackspaceTest
5
-
6
- class HardwareProfilesTest < Test::Unit::TestCase
7
- include Rack::Test::Methods
8
-
9
- def app
10
- Rack::Builder.new {
11
- map '/' do
12
- use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
13
- run Rack::Cascade.new([Deltacloud::API])
14
- end
15
- }
16
- end
17
-
18
- def test_01_it_returns_hardware_profiles
19
- get_auth_url '/api;driver=rackspace/hardware_profiles'
20
- (last_xml_response/'hardware_profiles/hardware_profile').length.should == 7
21
- end
22
-
23
- def test_02_each_hardware_profile_has_a_name
24
- get_auth_url '/api;driver=rackspace/hardware_profiles'
25
- (last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
26
- (profile/'name').text.should_not == nil
27
- (profile/'name').text.should_not == ''
28
- end
29
- end
30
-
31
- def test_03_each_hardware_profile_has_correct_properties
32
- get_auth_url '/api;driver=rackspace/hardware_profiles'
33
- (last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
34
- (profile/'property[@name="architecture"]').first[:value].should == 'x86_64'
35
- (profile/'property[@name="memory"]').first[:unit].should == 'MB'
36
- (profile/'property[@name="memory"]').first[:kind].should == 'fixed'
37
- (profile/'property[@name="storage"]').first[:unit].should == 'GB'
38
- (profile/'property[@name="storage"]').first[:kind].should == 'fixed'
39
- end
40
- end
41
-
42
- def test_04_it_returns_single_hardware_profile
43
- get_auth_url '/api;driver=rackspace/hardware_profiles/1'
44
- (last_xml_response/'hardware_profile/name').first.text.should == '1'
45
- (last_xml_response/'hardware_profile/property[@name="architecture"]').first[:value].should == 'x86_64'
46
- (last_xml_response/'hardware_profile/property[@name="memory"]').first[:value].should == '256'
47
- (last_xml_response/'hardware_profile/property[@name="storage"]').first[:value].should == '10'
48
- end
49
-
50
- def test_05_it_filter_hardware_profiles
51
- get_auth_url '/api;driver=rackspace/hardware_profiles?architecture=i386'
52
- (last_xml_response/'hardware_profiles/hardware_profile').length.should == 0
53
- get_auth_url '/api;driver=rackspace/hardware_profiles?architecture=x86_64'
54
- (last_xml_response/'hardware_profiles/hardware_profile').length.should == 7
55
- end
56
-
57
- end
58
- end
@@ -1,45 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
2
- require 'tests/drivers/rackspace/common'
3
-
4
- module RackspaceTest
5
-
6
- class ImagesTest < Test::Unit::TestCase
7
- include Rack::Test::Methods
8
-
9
- def app
10
- Rack::Builder.new {
11
- map '/' do
12
- use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
13
- run Rack::Cascade.new([Deltacloud::API])
14
- end
15
- }
16
- end
17
-
18
- def test_01_it_returns_images
19
- get_auth_url '/api;driver=rackspace/images'
20
- (last_xml_response/'images/image').length.should > 0
21
- end
22
-
23
- def test_02_each_image_has_correct_properties
24
- get_auth_url '/api;driver=rackspace/images'
25
- (last_xml_response/'images/image').each do |image|
26
- (image/'name').should_not == nil
27
- (image/'name').should_not == ''
28
- (image/'description').should_not == nil
29
- (image/'description').should_not == ''
30
- (image/'architecture').should_not == nil
31
- (image/'architecture').should_not == ''
32
- (image/'state').text.should == 'ACTIVE'
33
- (image/'owner_id').text.should == ENV['API_USER']
34
- (image/'actions/link').length.should == 1
35
- (image/'actions/link').first[:rel].should == 'create_instance'
36
- end
37
- end
38
-
39
- def test_03_it_returns_single_image
40
- get_auth_url '/api;driver=rackspace/images/71'
41
- (last_xml_response/'image').length.should == 1
42
- end
43
-
44
- end
45
- end
@@ -1,166 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
2
- require 'tests/drivers/rackspace/common'
3
-
4
- module RackspaceTest
5
-
6
- class InstancesTest < Test::Unit::TestCase
7
- include Rack::Test::Methods
8
-
9
- def app
10
- Rack::Builder.new {
11
- map '/' do
12
- use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
13
- run Rack::Cascade.new([Deltacloud::API])
14
- end
15
- }
16
- end
17
-
18
- def test_01_01_it_can_create_instance_without_hardware_profile
19
- params = {
20
- :image_id => '71',
21
- :'api[driver]' => 'rackspace',
22
- }
23
- post_url '/api/instances', params
24
- last_response.status.should == 201 # Created
25
- @@instance = last_xml_response
26
- (@@instance/'instance').length.should > 0
27
- (@@instance/'instance/name').first.text.should_not == nil
28
- (@@instance/'instance/name').first.text.should_not == nil
29
- (@@instance/'instance/owner_id').first.text.should_not == ''
30
- (@@instance/'instance/owner_id').first.text.should == ENV['API_USER']
31
- (@@instance/'instance/state').first.text.should == 'PENDING'
32
- end
33
-
34
- def test_01_02_it_can_create_instance_with_hardware_profile
35
- params = {
36
- :image_id => '71',
37
- :hwp_id => '2',
38
- :'api[driver]' => 'rackspace',
39
- }
40
- post_url '/api/instances', params
41
- last_response.status.should == 201 # Created
42
- @@instance2 = last_xml_response
43
- (@@instance2/'instance').length.should > 0
44
- (@@instance2/'instance/name').first.text.should_not == nil
45
- (@@instance2/'instance/name').first.text.should_not == nil
46
- (@@instance2/'instance/owner_id').first.text.should_not == ''
47
- (@@instance2/'instance/owner_id').first.text.should == ENV['API_USER']
48
- (@@instance2/'instance/state').first.text.should == 'PENDING'
49
- end
50
-
51
- def test_02_01_created_instance_has_correct_authentication
52
- (@@instance/'instance/authentication').first.should_not == nil
53
- (@@instance/'instance/authentication').first[:type].should == 'password'
54
- (@@instance/'instance/authentication/login/username').first.text.should == 'root'
55
- (@@instance/'instance/authentication/login/password').first.text.should_not == nil
56
- (@@instance/'instance/authentication/login/password').first.text.should_not == ''
57
- end
58
-
59
- def test_02_02_created_instance_has_correct_authentication
60
- (@@instance2/'instance/authentication').first.should_not == nil
61
- (@@instance2/'instance/authentication').first[:type].should == 'password'
62
- (@@instance2/'instance/authentication/login/username').first.text.should == 'root'
63
- (@@instance2/'instance/authentication/login/password').first.text.should_not == nil
64
- (@@instance2/'instance/authentication/login/password').first.text.should_not == ''
65
- end
66
-
67
- def test_03_01_created_instance_has_correct_addresses
68
- (@@instance/'instance/public_addresses/address').length.should > 0
69
- (@@instance/'instance/public_addresses/address').first.text.should_not == nil
70
- (@@instance/'instance/public_addresses/address').first.text.should_not == ''
71
- end
72
-
73
- def test_03_02_created_instance_has_correct_addresses
74
- (@@instance2/'instance/public_addresses/address').length.should > 0
75
- (@@instance2/'instance/public_addresses/address').first.text.should_not == nil
76
- (@@instance2/'instance/public_addresses/address').first.text.should_not == ''
77
- end
78
-
79
- def test_03_02_created_instance_has_correct_hardware_profile
80
- (@@instance2/'instance/hardware_profile').length.should == 1
81
- (@@instance2/'instance/hardware_profile').first[:id].should == "2"
82
- (@@instance2/'instance/hardware_profile').first[:href].should_not == nil
83
- end
84
-
85
- def test_04_01_created_instance_goes_to_running_state
86
- 20.times do |tick|
87
- get_auth_url "/api;driver=rackspace/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
88
- last_response.status.should_not == 500
89
- state = (last_xml_response/'instance/state').first.text
90
- break if state=='RUNNING'
91
- sleep(5)
92
- end
93
- @@instance = last_xml_response
94
- get_auth_url "/api;driver=rackspace/instances/#{(@@instance/'instance').first[:id]}"
95
- last_response.status.should_not == 500
96
- (last_xml_response/'instance/state').first.text.should == 'RUNNING'
97
- (last_xml_response/'instance/actions/link[@rel="reboot"]').first.should_not == nil
98
- (last_xml_response/'instance/actions/link[@rel="stop"]').first.should_not == nil
99
- (last_xml_response/'instance/actions/link[@rel="create_image"]').first.should_not == nil
100
- (last_xml_response/'instance/actions/link[@rel="run"]').first.should_not == nil
101
- end
102
-
103
- def test_04_02_created_instance_goes_to_running_state
104
- 20.times do |tick|
105
- get_auth_url "/api;driver=rackspace/instances/#{(@@instance2/'instance').first[:id]}", { :tick => tick}
106
- last_response.status.should_not == 500
107
- state = (last_xml_response/'instance/state').first.text
108
- break if state=='RUNNING'
109
- sleep(5)
110
- end
111
- @@instance2 = last_xml_response
112
- get_auth_url "/api;driver=rackspace/instances/#{(@@instance2/'instance').first[:id]}"
113
- last_response.status.should_not == 500
114
- (last_xml_response/'instance/state').first.text.should == 'RUNNING'
115
- (last_xml_response/'instance/actions/link[@rel="reboot"]').first.should_not == nil
116
- (last_xml_response/'instance/actions/link[@rel="stop"]').first.should_not == nil
117
- (last_xml_response/'instance/actions/link[@rel="create_image"]').first.should_not == nil
118
- (last_xml_response/'instance/actions/link[@rel="run"]').first.should_not == nil
119
- end
120
-
121
- def test_05_01_created_instance_can_be_rebooted
122
- params = {
123
- :'api[driver]' => 'rackspace',
124
- }
125
- post_url "/api/instances/#{(@@instance/'instance').first[:id]}/reboot", params
126
- last_response.status.should == 202
127
- 20.times do |tick|
128
- get_auth_url "/api;driver=rackspace/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
129
- last_response.status.should_not == 500
130
- state = (last_xml_response/'instance/state').first.text
131
- break if state=='RUNNING'
132
- sleep(5)
133
- end
134
- end
135
-
136
- def test_06_01_created_instance_can_be_destroyed
137
- params = {
138
- :'api[driver]' => 'rackspace',
139
- }
140
- post_url "/api/instances/#{(@@instance/'instance').first[:id]}/stop", params
141
- last_response.status.should == 202
142
- 20.times do |tick|
143
- get_auth_url "/api;driver=rackspace/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
144
- last_response.status.should_not == 500
145
- break if last_response.status == 404
146
- sleep(5)
147
- end
148
- last_response.status.should == 404
149
- end
150
-
151
- def test_06_02_created_instance_can_be_destroyed
152
- params = {
153
- :'api[driver]' => 'rackspace',
154
- }
155
- post_url "/api/instances/#{(@@instance2/'instance').first[:id]}/stop", params, authenticate
156
- last_response.status.should == 202
157
- 20.times do |tick|
158
- get_auth_url "/api;driver=rackspace/instances/#{(@@instance2/'instance').first[:id]}", { :tick => tick}
159
- last_response.status.should_not == 500
160
- break if last_response.status == 404
161
- sleep(5)
162
- end
163
- last_response.status.should == 404
164
- end
165
- end
166
- end
@@ -1,41 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
2
- require 'tests/drivers/rackspace/common'
3
-
4
- module RackspaceTest
5
-
6
- class RealmsTest < Test::Unit::TestCase
7
- include Rack::Test::Methods
8
-
9
- def app
10
- Rack::Builder.new {
11
- map '/' do
12
- use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
13
- run Rack::Cascade.new([Deltacloud::API])
14
- end
15
- }
16
- end
17
-
18
- def test_01_it_returns_realms
19
- get_auth_url '/api;driver=rackspace/realms'
20
- (last_xml_response/'realms/realm').length.should == 1
21
- end
22
-
23
- def test_02_each_realm_has_a_name
24
- get_auth_url '/api;driver=rackspace/realms'
25
- (last_xml_response/'realms/realm').each do |profile|
26
- (profile/'name').text.should_not == nil
27
- (profile/'name').text.should_not == ''
28
- (profile/'name').text.should == 'United States'
29
- end
30
- end
31
-
32
- def test_03_it_returns_single_realm
33
- get_auth_url '/api;driver=rackspace/realms/us'
34
- (last_xml_response/'realm').first[:id].should == 'us'
35
- (last_xml_response/'realm/name').first.text.should == 'United States'
36
- (last_xml_response/'realm/state').first.text.should == 'AVAILABLE'
37
- (last_xml_response/'realm/limit').first.text.should == ''
38
- end
39
-
40
- end
41
- end