deltacloud-core 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. data/Rakefile +40 -28
  2. data/bin/deltacloud-db-upgrade +24 -0
  3. data/bin/deltacloudd +20 -9
  4. data/config.ru +12 -53
  5. data/db/migrations/1_add_realm_to_machine_template.rb +23 -0
  6. data/deltacloud-core.gemspec +11 -5
  7. data/lib/cimi/collections.rb +4 -31
  8. data/lib/cimi/collections/address_templates.rb +2 -5
  9. data/lib/cimi/collections/addresses.rb +2 -5
  10. data/lib/cimi/collections/base.rb +18 -6
  11. data/lib/cimi/collections/credentials.rb +2 -5
  12. data/lib/cimi/collections/machine_images.rb +2 -1
  13. data/lib/cimi/collections/machine_templates.rb +2 -5
  14. data/lib/cimi/collections/machines.rb +6 -9
  15. data/lib/cimi/collections/network_ports.rb +3 -3
  16. data/lib/cimi/collections/networks.rb +5 -8
  17. data/lib/cimi/collections/system_templates.rb +72 -0
  18. data/lib/cimi/collections/systems.rb +194 -0
  19. data/lib/cimi/collections/volume_configurations.rb +1 -1
  20. data/lib/cimi/collections/volume_images.rb +2 -1
  21. data/lib/cimi/collections/volume_templates.rb +3 -2
  22. data/lib/cimi/collections/volumes.rb +2 -2
  23. data/lib/cimi/dependencies.rb +0 -2
  24. data/lib/cimi/helpers/cimi_helper.rb +12 -57
  25. data/lib/cimi/helpers/database_helper.rb +0 -4
  26. data/lib/cimi/models.rb +25 -14
  27. data/lib/cimi/models/address.rb +4 -31
  28. data/lib/cimi/models/address_create.rb +51 -0
  29. data/lib/cimi/models/address_template.rb +8 -52
  30. data/lib/cimi/models/address_template_create.rb +44 -0
  31. data/lib/cimi/models/base.rb +44 -6
  32. data/lib/cimi/models/cloud_entry_point.rb +1 -1
  33. data/lib/cimi/models/credential.rb +1 -1
  34. data/lib/cimi/models/credential_create.rb +46 -0
  35. data/lib/cimi/models/credential_template.rb +24 -0
  36. data/lib/cimi/models/machine.rb +1 -71
  37. data/lib/cimi/models/machine_configuration.rb +3 -3
  38. data/lib/cimi/models/machine_create.rb +49 -0
  39. data/lib/cimi/models/machine_image.rb +2 -25
  40. data/lib/cimi/models/machine_image_create.rb +41 -0
  41. data/lib/cimi/models/machine_template.rb +14 -34
  42. data/lib/cimi/models/machine_template_create.rb +33 -0
  43. data/lib/cimi/models/network.rb +0 -38
  44. data/lib/cimi/models/network_create.rb +43 -0
  45. data/lib/cimi/models/network_port.rb +17 -17
  46. data/lib/cimi/models/network_template.rb +2 -3
  47. data/lib/cimi/models/resource.rb +22 -3
  48. data/lib/cimi/models/schema.rb +94 -8
  49. data/lib/cimi/models/system.rb +67 -0
  50. data/lib/cimi/models/system_template.rb +63 -0
  51. data/lib/cimi/models/volume.rb +2 -42
  52. data/lib/cimi/models/volume_configuration.rb +4 -4
  53. data/lib/cimi/models/volume_create.rb +58 -0
  54. data/lib/cimi/models/volume_image.rb +8 -17
  55. data/lib/cimi/models/volume_image_create.rb +47 -0
  56. data/lib/cimi/models/volume_template.rb +6 -19
  57. data/lib/cimi/models/volume_template_create.rb +33 -0
  58. data/lib/db.rb +14 -22
  59. data/lib/db/volume_template.rb +1 -1
  60. data/lib/deltacloud/api.rb +6 -5
  61. data/lib/deltacloud/collections.rb +4 -27
  62. data/lib/deltacloud/collections/base.rb +4 -0
  63. data/lib/deltacloud/collections/images.rb +1 -1
  64. data/lib/deltacloud/collections/instances.rb +2 -2
  65. data/lib/deltacloud/core_ext/array.rb +1 -0
  66. data/lib/deltacloud/core_ext/integer.rb +13 -9
  67. data/lib/deltacloud/core_ext/string.rb +45 -28
  68. data/lib/deltacloud/drivers/arubacloud/arubacloud_driver.rb +0 -9
  69. data/lib/deltacloud/drivers/base_driver.rb +45 -16
  70. data/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb +78 -8
  71. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +13 -9
  72. data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +44 -0
  73. data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +164 -90
  74. data/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb +74 -0
  75. data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +3 -3
  76. data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +3 -3
  77. data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +3 -3
  78. data/lib/deltacloud/drivers/mock/mock_client.rb +17 -1
  79. data/lib/deltacloud/drivers/mock/mock_driver.rb +161 -204
  80. data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +80 -0
  81. data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +6 -1
  82. data/lib/deltacloud/drivers/openstack/openstack_driver.rb +61 -68
  83. data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +0 -9
  84. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +11 -6
  85. data/lib/deltacloud/drivers/terremark/terremark_driver.rb +0 -8
  86. data/lib/deltacloud/drivers/vsphere/vsphere_client.rb +11 -4
  87. data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +0 -12
  88. data/lib/deltacloud/helpers/collection_helper.rb +106 -0
  89. data/lib/deltacloud/helpers/deltacloud_helper.rb +12 -8
  90. data/lib/deltacloud/models/address.rb +19 -17
  91. data/lib/deltacloud/models/base_model.rb +29 -26
  92. data/lib/deltacloud/models/blob.rb +22 -20
  93. data/lib/deltacloud/models/bucket.rb +21 -16
  94. data/lib/deltacloud/models/firewall.rb +18 -16
  95. data/lib/deltacloud/models/firewall_rule.rb +22 -20
  96. data/lib/deltacloud/models/image.rb +29 -28
  97. data/lib/deltacloud/models/instance.rb +92 -94
  98. data/lib/deltacloud/models/instance_address.rb +42 -40
  99. data/lib/deltacloud/models/instance_profile.rb +28 -26
  100. data/lib/deltacloud/models/key.rb +47 -45
  101. data/lib/deltacloud/models/load_balancer.rb +32 -31
  102. data/lib/deltacloud/models/metric.rb +76 -29
  103. data/lib/deltacloud/models/provider.rb +15 -13
  104. data/lib/deltacloud/models/realm.rb +15 -21
  105. data/lib/deltacloud/models/storage_snapshot.rb +23 -19
  106. data/lib/deltacloud/models/storage_volume.rb +35 -34
  107. data/lib/deltacloud/version.rb +1 -1
  108. data/lib/deltacloud_rack.rb +22 -0
  109. data/lib/initialize.rb +28 -0
  110. data/lib/initializers/database_initialize.rb +76 -0
  111. data/lib/initializers/frontend_initialize.rb +42 -0
  112. data/lib/initializers/mock_initialize.rb +33 -0
  113. data/lib/sinatra/rack_logger.rb +35 -24
  114. data/tests/cimi/collections/cloud_entry_point_test.rb +1 -7
  115. data/tests/cimi/collections/machine_images_test.rb +2 -2
  116. data/tests/cimi/collections/machine_templates_test.rb +75 -0
  117. data/tests/cimi/collections/machines_test.rb +2 -2
  118. data/tests/cimi/collections/system_templates_test.rb +41 -0
  119. data/tests/cimi/collections/systems_test.rb +50 -0
  120. data/tests/cimi/db/database_helper_test.rb +17 -25
  121. data/tests/cimi/db/db_helper.rb +1 -12
  122. data/tests/cimi/db/entity_test.rb +7 -8
  123. data/tests/cimi/model/machine_create_spec.rb +44 -0
  124. data/tests/cimi/model/machine_template_spec.rb +29 -0
  125. data/tests/cimi/model/resource_spec.rb +40 -0
  126. data/tests/cimi/model/schema_spec.rb +37 -0
  127. data/tests/cimi/spec_helper.rb +3 -0
  128. data/tests/deltacloud/collections/buckets_collection_test.rb +1 -1
  129. data/tests/deltacloud/collections/drivers_collection_test.rb +2 -2
  130. data/tests/deltacloud/collections/hardware_profiles_collection_test.rb +2 -2
  131. data/tests/deltacloud/collections/images_collection_test.rb +2 -2
  132. data/tests/deltacloud/collections/instance_states_collection_test.rb +1 -1
  133. data/tests/deltacloud/collections/instances_collection_test.rb +6 -3
  134. data/tests/deltacloud/collections/keys_collection_test.rb +2 -2
  135. data/tests/deltacloud/collections/realms_collection_test.rb +2 -2
  136. data/tests/deltacloud/collections/storage_snapshots_collection_test.rb +2 -2
  137. data/tests/deltacloud/collections/storage_volumes_collection_test.rb +2 -2
  138. data/tests/deltacloud/collections_test.rb +5 -5
  139. data/tests/deltacloud/common.rb +2 -13
  140. data/tests/deltacloud/launcher_test.rb +3 -3
  141. data/tests/deltacloud/rack_test.rb +2 -2
  142. data/tests/deltacloud/server_test.rb +1 -1
  143. data/tests/drivers/base/base_driver_test.rb +5 -5
  144. data/tests/drivers/base/common.rb +2 -12
  145. data/tests/drivers/ec2/buckets_test.rb +1 -1
  146. data/tests/drivers/ec2/images_test.rb +2 -2
  147. data/tests/drivers/ec2/instance_test.rb +6 -6
  148. data/tests/drivers/ec2/keys_test.rb +3 -3
  149. data/tests/drivers/ec2/realms_test.rb +2 -2
  150. data/tests/drivers/ec2/storage_snapshots_test.rb +1 -1
  151. data/tests/drivers/fgcp/common.rb +32 -0
  152. data/tests/drivers/fgcp/firewall_test.rb +70 -0
  153. data/tests/drivers/fgcp/hardware_profiles_test.rb +61 -0
  154. data/tests/drivers/fgcp/images_test.rb +46 -0
  155. data/tests/drivers/fgcp/provider_test.rb +27 -0
  156. data/tests/drivers/fgcp/realms_test.rb +53 -0
  157. data/tests/drivers/fgcp/storage_volumes_test.rb +58 -0
  158. data/tests/drivers/gogrid/images_test.rb +2 -2
  159. data/tests/drivers/gogrid/instances_test.rb +2 -2
  160. data/tests/drivers/gogrid/realms_test.rb +2 -2
  161. data/tests/drivers/mock/images_test.rb +4 -4
  162. data/tests/drivers/mock/instances_test.rb +9 -9
  163. data/tests/drivers/mock/keys_test.rb +3 -3
  164. data/tests/drivers/mock/realms_test.rb +2 -2
  165. data/tests/drivers/mock/storage_snapshots_test.rb +2 -2
  166. data/tests/drivers/mock/storage_volumes_test.rb +4 -4
  167. data/tests/drivers/models/instance_test.rb +2 -2
  168. data/tests/drivers/openstack/images_test.rb +2 -2
  169. data/tests/drivers/openstack/instances_test.rb +2 -3
  170. data/tests/drivers/openstack/keys_test.rb +1 -1
  171. data/tests/drivers/openstack/realms_test.rb +2 -11
  172. data/tests/drivers/rhevm/common.rb +33 -12
  173. data/tests/drivers/rhevm/images_test.rb +20 -12
  174. data/tests/drivers/rhevm/instance_test.rb +62 -46
  175. data/tests/drivers/rhevm/provider_test.rb +12 -6
  176. data/tests/drivers/rhevm/realms_test.rb +15 -9
  177. data/tests/ec2/query_parser_test.rb +1 -1
  178. data/tests/test_helper.rb +68 -12
  179. data/views/addresses/show.html.haml +1 -1
  180. data/views/buckets/show.html.haml +1 -1
  181. data/views/errors/{500.html.haml → common.html.haml} +0 -0
  182. data/views/errors/common.xml.haml +17 -0
  183. data/views/firewalls/index.xml.haml +2 -2
  184. data/views/firewalls/new.html.haml +2 -2
  185. data/views/images/show.html.haml +1 -1
  186. data/views/instances/run_command.html.haml +1 -1
  187. data/views/instances/show.html.haml +3 -3
  188. data/views/keys/index.html.haml +1 -0
  189. data/views/keys/show.html.haml +8 -4
  190. data/views/keys/show.xml.haml +3 -2
  191. data/views/load_balancers/new.html.haml +1 -1
  192. data/views/load_balancers/show.html.haml +2 -2
  193. data/views/metrics/show.html.haml +1 -1
  194. data/views/realms/index.html.haml +0 -2
  195. data/views/realms/show.html.haml +0 -4
  196. data/views/realms/show.xml.haml +0 -3
  197. data/views/storage_snapshots/index.html.haml +1 -1
  198. data/views/storage_snapshots/new.html.haml +1 -1
  199. data/views/storage_volumes/new.html.haml +2 -2
  200. data/views/storage_volumes/show.html.haml +3 -3
  201. metadata +90 -41
  202. data/views/errors/400.html.haml +0 -41
  203. data/views/errors/400.xml.haml +0 -3
  204. data/views/errors/401.html.haml +0 -26
  205. data/views/errors/401.xml.haml +0 -3
  206. data/views/errors/403.html.haml +0 -42
  207. data/views/errors/403.xml.haml +0 -9
  208. data/views/errors/404.html.haml +0 -28
  209. data/views/errors/404.xml.haml +0 -3
  210. data/views/errors/405.html.haml +0 -29
  211. data/views/errors/405.xml.haml +0 -5
  212. data/views/errors/409.html.haml +0 -47
  213. data/views/errors/409.xml.haml +0 -11
  214. data/views/errors/500.xml.haml +0 -13
  215. data/views/errors/501.html.haml +0 -44
  216. data/views/errors/501.xml.haml +0 -1
  217. data/views/errors/502.html.haml +0 -44
  218. data/views/errors/502.xml.haml +0 -1
  219. data/views/errors/504.html.haml +0 -43
  220. data/views/errors/504.xml.haml +0 -1
@@ -22,7 +22,7 @@ describe 'OpenStackDriver Images' do
22
22
 
23
23
  it 'must return list of images' do
24
24
  @driver.images.wont_be_empty
25
- @driver.images.first.must_be_kind_of Image
25
+ @driver.images.first.must_be_kind_of Deltacloud::Image
26
26
  end
27
27
 
28
28
  it 'must allow to filter images' do
@@ -40,7 +40,7 @@ describe 'OpenStackDriver Images' do
40
40
  @driver.image(:id => 'unknown').must_be_nil
41
41
  image = @driver.image :id => openstack_image_id
42
42
  image.wont_be_nil
43
- image.must_be_kind_of Image
43
+ image.must_be_kind_of Deltacloud::Image
44
44
  image.id.must_equal openstack_image_id
45
45
  image.name.wont_be_empty
46
46
  image.owner_id.wont_be_empty
@@ -29,7 +29,7 @@ describe 'OpenStackDriver Instances' do
29
29
 
30
30
  it 'must return list of instances' do
31
31
  @driver.instances.wont_be_empty
32
- @driver.instances.first.must_be_kind_of Instance
32
+ @driver.instances.first.must_be_kind_of Deltacloud::Instance
33
33
  end
34
34
 
35
35
  it 'must allow to filter instances' do
@@ -37,7 +37,6 @@ describe 'OpenStackDriver Instances' do
37
37
  instances.wont_be_empty
38
38
  instances.must_be_kind_of Array
39
39
  instances.size.must_equal 1
40
- puts instances.inspect
41
40
  instances.first.id.must_equal '815215'
42
41
  @driver.instances(:id => 'unknown').must_be_empty
43
42
  end
@@ -61,7 +60,7 @@ describe 'OpenStackDriver Instances' do
61
60
  instance.image_id.must_equal '78265'
62
61
  instance.name.wont_be_empty
63
62
  instance.wait_for!(@driver, record_retries('inst_launch')) { |i| i.is_running? }
64
- puts @driver.destroy_instance(instance.id).inspect
63
+ @driver.destroy_instance(instance.id)
65
64
  end
66
65
 
67
66
  end
@@ -22,7 +22,7 @@ describe 'OpenStackDriver Keys' do
22
22
 
23
23
  it 'must return list of keys' do
24
24
  @driver.keys.wont_be_empty
25
- @driver.keys.first.must_be_kind_of Key
25
+ @driver.keys.first.must_be_kind_of Deltacloud::Key
26
26
  end
27
27
 
28
28
  it 'must allow to filter keys' do
@@ -5,15 +5,6 @@ require_relative 'common.rb'
5
5
 
6
6
  describe 'OpenStackDriver Realms' do
7
7
 
8
- def credentials
9
- {
10
- :user => "foo@fakedomain.eu+foo@fakedomain.eu-default-tenant",
11
- :password => "1234fake56789",
12
- :provider => "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/"
13
- }
14
- end
15
-
16
-
17
8
  before do
18
9
  @driver = Deltacloud::new(:openstack, credentials)
19
10
  VCR.insert_cassette __name__
@@ -23,7 +14,7 @@ describe 'OpenStackDriver Realms' do
23
14
  VCR.eject_cassette
24
15
  end
25
16
 
26
- it 'must throw error when GET Realms with wrong credentials' do
17
+ it 'must throw error when wrong credentials' do
27
18
  Proc.new do
28
19
  @driver.backend.images(OpenStruct.new(:user => 'unknown+wrong', :password => 'wrong'))
29
20
  end.must_raise Deltacloud::Exceptions::AuthenticationFailure, 'Authentication Failure'
@@ -31,7 +22,7 @@ describe 'OpenStackDriver Realms' do
31
22
 
32
23
  it 'must return list of realms' do
33
24
  @driver.realms.wont_be_empty
34
- @driver.realms.first.must_be_kind_of Realm
25
+ @driver.realms.first.must_be_kind_of Deltacloud::Realm
35
26
  end
36
27
 
37
28
  it 'must allow to retrieve single realm' do
@@ -2,23 +2,44 @@ require 'vcr'
2
2
 
3
3
  require_relative '../../test_helper'
4
4
 
5
- # Credentials used to access RHEV-M server
5
+ # The configuration for RHEVM in ~/.deltacloud/config should look like
6
+ # this:
7
+ # rhevm:
8
+ # user: USERNAME
9
+ # password: PASSWORD
10
+ # provider: https://rhevm.example.com/api
11
+ # preferred:
12
+ # datacenter: UUID of a datacenter/realm
13
+ # vm: UUID of an existing instance
14
+ # template: UUID of an existing template
6
15
  #
7
- # NOTE: If these are changed, the VCR fixtures need to be re-recorded
8
- #
9
- def credentials
10
- {
11
- :user => 'admin@internal',
12
- :password => 'redhat',
13
- :provider => 'https://dell-per610-02.lab.eng.brq.redhat.com/api;9df72b84-0234-11e2-9b87-9386d9b09d4a'
14
- }
16
+ # Anything in the preferred part of the config is also written into
17
+ # ./fixtures/preferences.yml and used when playing back fixtures
18
+
19
+ if vcr_recording?
20
+ Deltacloud::Test::config.save(:rhevm, File.dirname(__FILE__)) do |h|
21
+ u = URI::parse(h["provider"])
22
+ u.host = "rhevm.example.com"
23
+ h["provider"] = u.to_s
24
+ end
25
+ else
26
+ Deltacloud::Test::config.load(:rhevm, File.dirname(__FILE__))
15
27
  end
16
28
 
17
29
  VCR.configure do |c|
18
30
  # NOTE: Empty this directory before re-recording
19
31
  c.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures')
20
32
  c.hook_into :webmock
21
- # Set this to :new_episodes when you want to 're-record'
22
- #c.default_cassette_options = { :record => :new_episodes }
23
- c.default_cassette_options = { :record => :none }
33
+ # Rewrite sensitive information before recording
34
+ c.before_record do |i|
35
+ u = URI::parse(i.request.uri)
36
+ u.host = "rhevm.example.com"
37
+ u.user = "fakeuser"
38
+ u.password = "fakepassword"
39
+ i.request.uri = u.to_s
40
+ end
41
+ c.default_cassette_options = {
42
+ :record => vcr_record_mode,
43
+ :match_requests_on => [ :method, :path, :query ]
44
+ }
24
45
  end
@@ -6,7 +6,10 @@ require_relative 'common'
6
6
  describe 'RhevmDriver Images' do
7
7
 
8
8
  before do
9
- @driver = Deltacloud::new(:rhevm, credentials)
9
+ prefs = Deltacloud::Test::config.preferences(:rhevm)
10
+ @template_id = prefs["template"]
11
+
12
+ @driver = Deltacloud::Test::config.driver(:rhevm)
10
13
  VCR.insert_cassette __name__
11
14
  end
12
15
 
@@ -22,16 +25,18 @@ describe 'RhevmDriver Images' do
22
25
 
23
26
  it 'must return list of images' do
24
27
  @driver.images.wont_be_empty
25
- @driver.images.first.must_be_kind_of Image
28
+ @driver.images.first.must_be_kind_of Deltacloud::Image
26
29
  end
27
30
 
28
31
  it 'must allow to filter images' do
29
- @driver.images(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').wont_be_empty
30
- @driver.images(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').must_be_kind_of Array
31
- @driver.images(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').size.must_equal 1
32
- @driver.images(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').first.id.must_equal '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5'
33
- @driver.images(:owner_id => 'admin@internal').each do |img|
34
- img.owner_id.must_equal 'admin@internal'
32
+ imgs = @driver.images(:id => @template_id)
33
+ imgs.wont_be_empty
34
+ imgs.must_be_kind_of Array
35
+ imgs.size.must_equal 1
36
+ imgs.first.id.must_equal @template_id
37
+ owner_id = imgs.first.owner_id
38
+ @driver.images(:owner_id => owner_id).each do |img|
39
+ img.owner_id.must_equal owner_id
35
40
  end
36
41
  @driver.images(:id => 'ami-aaaaaaaa').must_be_empty
37
42
  @driver.images(:id => 'unknown').must_be_empty
@@ -42,9 +47,10 @@ describe 'RhevmDriver Images' do
42
47
  # of YAML under Ruby 1.8.
43
48
  #
44
49
  if RUBY_VERSION =~ /^1\.9/
45
- @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').wont_be_nil
46
- @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').must_be_kind_of Image
47
- @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').id.must_equal '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5'
50
+ img = @driver.image(:id => @template_id)
51
+ img.wont_be_nil
52
+ img.must_be_kind_of Deltacloud::Image
53
+ img.id.must_equal @template_id
48
54
  @driver.image(:id => 'ami-aaaaaaaa').must_be_nil
49
55
  @driver.image(:id => 'unknown').must_be_nil
50
56
  end
@@ -52,7 +58,7 @@ describe 'RhevmDriver Images' do
52
58
 
53
59
  it 'must throw proper exception when destroying used image' do
54
60
  if RUBY_VERSION =~ /^1\.9/
55
- image = @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5')
61
+ image = @driver.image(:id => @template_id)
56
62
  image.wont_be_nil
57
63
  image.state.must_equal 'OK'
58
64
  Proc.new {
@@ -62,6 +68,8 @@ describe 'RhevmDriver Images' do
62
68
  end
63
69
 
64
70
  it 'must support destroying images' do
71
+ skip "Depends on hardcoded image"
72
+ # FIXME: we need to create a new image here, and then destroy it
65
73
  image = @driver.image(:id => '5472e759-dee1-4e90-a2bf-79b61a601e80')
66
74
  image.wont_be_nil
67
75
  image.state.must_equal 'OK'
@@ -6,7 +6,12 @@ require_relative 'common.rb'
6
6
  describe 'RhevmDriver Instances' do
7
7
 
8
8
  before do
9
- @driver = Deltacloud::new(:rhevm, credentials)
9
+ prefs = Deltacloud::Test::config.preferences(:rhevm)
10
+ @dc_id = prefs["datacenter"]
11
+ @vm_id = prefs["vm"]
12
+ @template_id = prefs["template"]
13
+
14
+ @driver = Deltacloud::Test::config.driver(:rhevm)
10
15
  VCR.insert_cassette __name__
11
16
  end
12
17
 
@@ -22,83 +27,94 @@ describe 'RhevmDriver Instances' do
22
27
 
23
28
  it 'must return list of instances' do
24
29
  @driver.instances.wont_be_empty
25
- @driver.instances.first.must_be_kind_of Instance
30
+ @driver.instances.first.must_be_kind_of Deltacloud::Instance
26
31
  end
27
32
 
28
33
  it 'must allow to filter instances' do
29
- @driver.instances(:id =>'a949192d-55eb-465c-9ef1-d59581a562a3').wont_be_empty
30
- @driver.instances(:id =>'a949192d-55eb-465c-9ef1-d59581a562a3').must_be_kind_of Array
31
- @driver.instances(:id =>'a949192d-55eb-465c-9ef1-d59581a562a3').size.must_equal 1
32
- @driver.instances(:id => 'a949192d-55eb-465c-9ef1-d59581a562a3').first.id.must_equal 'a949192d-55eb-465c-9ef1-d59581a562a3'
33
- @driver.instances(:owner_id => 'admin@internal').wont_be_empty
34
- @driver.instances(:owner_id => 'admin@internal').each do |inst|
35
- inst.owner_id.must_equal 'admin@internal'
36
- end
34
+ insts = @driver.instances(:id =>@vm_id)
35
+ insts.wont_be_empty
36
+ insts.must_be_kind_of Array
37
+ insts.size.must_equal 1
38
+ insts.first.id.must_equal @vm_id
37
39
  @driver.instances(:id => 'i-00000000').must_be_empty
38
40
  @driver.instances(:id => 'unknown').must_be_empty
39
41
  end
40
42
 
41
43
  it 'must allow to retrieve single instance' do
42
- @driver.instance(:id => 'a949192d-55eb-465c-9ef1-d59581a562a3').wont_be_nil
43
- @driver.instance(:id => 'a949192d-55eb-465c-9ef1-d59581a562a3').must_be_kind_of Instance
44
- @driver.instance(:id => 'a949192d-55eb-465c-9ef1-d59581a562a3').id.must_equal 'a949192d-55eb-465c-9ef1-d59581a562a3'
44
+ inst = @driver.instance(:id => @vm_id)
45
+ inst.wont_be_nil
46
+ inst.must_be_kind_of Deltacloud::Instance
47
+ inst.id.must_equal @vm_id
45
48
  @driver.instance(:id => 'i-00000000').must_be_nil
46
49
  @driver.instance(:id => 'unknown').must_be_nil
47
50
  end
48
51
 
49
52
  it 'must allow to create a new instance and destroy it' do
50
- instance = @driver.create_instance('5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5',
51
- :realm_id => '99408929-82cf-4dc7-a532-9d998063fa95',
53
+ instance = @driver.create_instance(@template_id,
54
+ :realm_id => @dc_id,
52
55
  :hwp_id => 'SERVER',
53
56
  :hwp_memory => '1024',
54
57
  :user_data => 'test user data'
55
58
  )
56
- instance = instance.wait_for!(@driver, record_retries) { |i| i.is_stopped? }
57
- instance.must_be_kind_of Instance
59
+ instance = instance.wait_for!(@driver, record_retries('', :timeout => 60)) { |i| i.is_stopped? }
60
+ instance.must_be_kind_of Deltacloud::Instance
58
61
  instance.is_running?.must_equal false
59
- @driver.instance(:id => instance.id).wont_be_nil
60
- @driver.instance(:id => instance.id).id.must_equal instance.id
61
- @driver.instance(:id => instance.id).name.wont_be_nil
62
- @driver.instance(:id => instance.id).instance_profile.name.must_equal 'SERVER'
63
- @driver.instance(:id => instance.id).instance_profile.memory.must_equal 1024
64
- @driver.instance(:id => instance.id).realm_id.must_equal '99408929-82cf-4dc7-a532-9d998063fa95'
65
- @driver.instance(:id => instance.id).image_id.must_equal '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5'
66
- @driver.instance(:id => instance.id).owner_id.must_equal 'admin@internal'
67
- @driver.instance(:id => instance.id).state.must_equal 'STOPPED'
68
- @driver.instance(:id => instance.id).actions.must_include :start
62
+
63
+ inst = @driver.instance(:id => instance.id)
64
+ inst.wont_be_nil
65
+ inst.id.must_equal instance.id
66
+ inst.name.wont_be_nil
67
+ inst.instance_profile.name.must_equal 'SERVER'
68
+ inst.instance_profile.memory.must_equal 1024
69
+ inst.realm_id.must_equal @dc_id
70
+ inst.image_id.must_equal @template_id
71
+ inst.state.must_equal 'STOPPED'
72
+ inst.actions.must_include :start
69
73
  @driver.destroy_instance(instance.id)
70
74
  instance.wait_for!(@driver, record_retries('destroy')) { |i| i.nil? }
71
75
  end
72
76
 
77
+
73
78
  it 'must allow to create a new instance and make it running' do
74
- instance = @driver.create_instance('5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5',
75
- :realm_id => '99408929-82cf-4dc7-a532-9d998063fa95',
79
+ instance = @driver.create_instance(@template_id,
80
+ :realm_id => @dc_id,
76
81
  :hwp_id => 'SERVER',
77
82
  :hwp_memory => '1024',
78
83
  :user_data => 'test user data'
79
84
  )
80
- instance = instance.wait_for!(@driver, record_retries) { |i| i.is_stopped? }
81
- instance.must_be_kind_of Instance
85
+ instance = instance.wait_for!(@driver, record_retries('', :timeout => 60)) { |i| i.is_stopped? }
86
+ skip "Skip this test due to RHEVm bug: https://bugzilla.redhat.com/show_bug.cgi?id=910741"
87
+ instance.must_be_kind_of Deltacloud::Instance
82
88
  instance.is_running?.must_equal false
83
- @driver.instance(:id => instance.id).wont_be_nil
84
- @driver.instance(:id => instance.id).id.must_equal instance.id
85
- @driver.instance(:id => instance.id).name.wont_be_nil
86
- @driver.instance(:id => instance.id).instance_profile.name.must_equal 'SERVER'
87
- @driver.instance(:id => instance.id).instance_profile.memory.must_equal 1024
88
- @driver.instance(:id => instance.id).realm_id.must_equal '99408929-82cf-4dc7-a532-9d998063fa95'
89
- @driver.instance(:id => instance.id).image_id.must_equal '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5'
90
- @driver.instance(:id => instance.id).owner_id.must_equal 'admin@internal'
91
- @driver.instance(:id => instance.id).state.must_equal 'STOPPED'
92
- @driver.instance(:id => instance.id).actions.must_include :start
89
+
90
+ inst = @driver.instance(:id => instance.id)
91
+ inst.wont_be_nil
92
+ inst.id.must_equal instance.id
93
+ inst.name.wont_be_nil
94
+ inst.instance_profile.name.must_equal 'SERVER'
95
+ inst.instance_profile.memory.must_equal 1024
96
+ inst.realm_id.must_equal @dc_id
97
+ inst.image_id.must_equal @template_id
98
+ inst.state.must_equal 'STOPPED'
99
+ inst.actions.must_include :start
100
+
93
101
  @driver.start_instance(instance.id)
94
- instance = instance.wait_for!(@driver, record_retries('start')) { |i| i.is_running? }
95
- @driver.instance(:id => instance.id).state.must_equal 'RUNNING'
96
- Proc.new { @driver.destroy_instance(instance.id) }.must_raise Deltacloud::Exceptions::BackendError, 'Cannot remove VM. VM is running.'
102
+ instance = instance.wait_for!(@driver, record_retries('start', :timeout => 60)) { |i| i.is_running? }
103
+
104
+ inst = @driver.instance(:id => instance.id)
105
+ inst.state.must_equal 'RUNNING'
106
+ inst.actions.must_include :stop
107
+
108
+ Proc.new do
109
+ @driver.destroy_instance(instance.id)
110
+ end.must_raise Deltacloud::Exceptions::BackendError, 'Cannot remove VM. VM is running.'
111
+
97
112
  @driver.stop_instance(instance.id)
98
- instance = instance.wait_for!(@driver, record_retries('stop')) { |i| i.is_stopped? }
113
+ instance = instance.wait_for!(@driver, record_retries('stop', :timeout => 60)) { |i| i.is_stopped? }
99
114
  @driver.instance(:id => instance.id).state.must_equal 'STOPPED'
115
+
100
116
  @driver.destroy_instance(instance.id)
101
- instance.wait_for!(@driver, record_retries('destroy')) { |i| i.nil? }
117
+ instance.wait_for!(@driver, record_retries('destroy', :timeout => 60)) { |i| i.nil? }
102
118
  end
103
119
 
104
120
  end
@@ -6,7 +6,8 @@ require_relative 'common.rb'
6
6
  describe 'RHEV-M provider test' do
7
7
 
8
8
  before do
9
- @driver = Deltacloud::new(:rhevm, credentials)
9
+ @config = Deltacloud::Test::config
10
+ @driver = @config.driver(:rhevm)
10
11
  VCR.insert_cassette __name__
11
12
  end
12
13
 
@@ -15,7 +16,9 @@ describe 'RHEV-M provider test' do
15
16
  end
16
17
 
17
18
  it 'must throw error when using wrong provider' do
18
- wrong_driver = Deltacloud::new(:rhevm, credentials.merge(:provider => 'unknown'))
19
+ creds = @config.credentials(:rhevm).merge(:provider => 'unknown')
20
+ creds[:provider] = 'unknown'
21
+ wrong_driver = Deltacloud::new(:rhevm, creds)
19
22
  Proc.new {
20
23
  wrong_driver.realms
21
24
  }.must_raise Deltacloud::Exceptions::BackendError
@@ -23,19 +26,22 @@ describe 'RHEV-M provider test' do
23
26
 
24
27
  it 'must support listing of available providers' do
25
28
  @driver.providers.wont_be_empty
26
- @driver.providers.each { |p| p.must_be_kind_of Provider }
29
+ @driver.providers.each { |p| p.must_be_kind_of Deltacloud::Provider }
27
30
  @driver.providers.each { |p| p.name.wont_be_empty }
28
31
  @driver.providers.each { |p| p.id.wont_be_empty }
29
32
  @driver.providers.each { |p| p.url.wont_be_empty }
30
33
  end
31
34
 
32
35
  it 'must switch realms when switching between different clusters' do
33
-
34
- provider1 = @driver.provider(:id => '9df72b84-0234-11e2-9b87-9386d9b09d4a')
36
+ provs = @driver.providers
37
+ if provs.size < 2
38
+ skip "We need at least two providers (clusters)"
39
+ end
40
+ provider1 = provs[0]
35
41
  provider1.wont_be_nil
36
42
  provider1.url.wont_be_empty
37
43
 
38
- provider2 = @driver.provider(:id => '9df72b84-0234-11e2-9b87-9386d9b09d4a')
44
+ provider2 = provs[1]
39
45
  provider2.wont_be_nil
40
46
  provider2.url.wont_be_empty
41
47
 
@@ -6,7 +6,10 @@ require_relative 'common.rb'
6
6
  describe 'RhevmDriver Realms' do
7
7
 
8
8
  before do
9
- @driver = Deltacloud::new(:rhevm, credentials)
9
+ prefs = Deltacloud::Test::config.preferences(:rhevm)
10
+ @dc_id = prefs["datacenter"]
11
+
12
+ @driver = Deltacloud::Test::config.driver(:rhevm)
10
13
  VCR.insert_cassette __name__
11
14
  end
12
15
 
@@ -21,21 +24,24 @@ describe 'RhevmDriver Realms' do
21
24
  end
22
25
 
23
26
  it 'must return list of realms' do
24
- @driver.realms.wont_be_empty
25
- @driver.realms.first.must_be_kind_of Realm
27
+ realms = @driver.realms
28
+ realms.wont_be_empty
29
+ realms.first.must_be_kind_of Deltacloud::Realm
26
30
  end
27
31
 
28
32
  it 'must allow to filter realms' do
29
- @driver.realms(:id => '99408929-82cf-4dc7-a532-9d998063fa95').wont_be_empty
30
- @driver.realms(:id => '99408929-82cf-4dc7-a532-9d998063fa95').must_be_kind_of Array
31
- @driver.realms(:id => '99408929-82cf-4dc7-a532-9d998063fa95').size.must_equal 1
32
- @driver.realms(:id => '99408929-82cf-4dc7-a532-9d998063fa95').first.id.must_equal '99408929-82cf-4dc7-a532-9d998063fa95'
33
+ realms = @driver.realms(:id => @dc_id)
34
+ realms.wont_be_empty
35
+ realms.must_be_kind_of Array
36
+ realms.size.must_equal 1
37
+ realms.first.id.must_equal @dc_id
33
38
  @driver.realms(:id => 'unknown').must_be_empty
34
39
  end
35
40
 
36
41
  it 'must allow to retrieve single realm' do
37
- @driver.realm(:id => '99408929-82cf-4dc7-a532-9d998063fa95').wont_be_nil
38
- @driver.realm(:id => '99408929-82cf-4dc7-a532-9d998063fa95').must_be_kind_of Realm
42
+ realm = @driver.realm(:id => @dc_id)
43
+ realm.wont_be_nil
44
+ realm.must_be_kind_of Deltacloud::Realm
39
45
  @driver.realm(:id => 'unknown').must_be_nil
40
46
  end
41
47