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.
- data/Rakefile +40 -28
- data/bin/deltacloud-db-upgrade +24 -0
- data/bin/deltacloudd +20 -9
- data/config.ru +12 -53
- data/db/migrations/1_add_realm_to_machine_template.rb +23 -0
- data/deltacloud-core.gemspec +11 -5
- data/lib/cimi/collections.rb +4 -31
- data/lib/cimi/collections/address_templates.rb +2 -5
- data/lib/cimi/collections/addresses.rb +2 -5
- data/lib/cimi/collections/base.rb +18 -6
- data/lib/cimi/collections/credentials.rb +2 -5
- data/lib/cimi/collections/machine_images.rb +2 -1
- data/lib/cimi/collections/machine_templates.rb +2 -5
- data/lib/cimi/collections/machines.rb +6 -9
- data/lib/cimi/collections/network_ports.rb +3 -3
- data/lib/cimi/collections/networks.rb +5 -8
- data/lib/cimi/collections/system_templates.rb +72 -0
- data/lib/cimi/collections/systems.rb +194 -0
- data/lib/cimi/collections/volume_configurations.rb +1 -1
- data/lib/cimi/collections/volume_images.rb +2 -1
- data/lib/cimi/collections/volume_templates.rb +3 -2
- data/lib/cimi/collections/volumes.rb +2 -2
- data/lib/cimi/dependencies.rb +0 -2
- data/lib/cimi/helpers/cimi_helper.rb +12 -57
- data/lib/cimi/helpers/database_helper.rb +0 -4
- data/lib/cimi/models.rb +25 -14
- data/lib/cimi/models/address.rb +4 -31
- data/lib/cimi/models/address_create.rb +51 -0
- data/lib/cimi/models/address_template.rb +8 -52
- data/lib/cimi/models/address_template_create.rb +44 -0
- data/lib/cimi/models/base.rb +44 -6
- data/lib/cimi/models/cloud_entry_point.rb +1 -1
- data/lib/cimi/models/credential.rb +1 -1
- data/lib/cimi/models/credential_create.rb +46 -0
- data/lib/cimi/models/credential_template.rb +24 -0
- data/lib/cimi/models/machine.rb +1 -71
- data/lib/cimi/models/machine_configuration.rb +3 -3
- data/lib/cimi/models/machine_create.rb +49 -0
- data/lib/cimi/models/machine_image.rb +2 -25
- data/lib/cimi/models/machine_image_create.rb +41 -0
- data/lib/cimi/models/machine_template.rb +14 -34
- data/lib/cimi/models/machine_template_create.rb +33 -0
- data/lib/cimi/models/network.rb +0 -38
- data/lib/cimi/models/network_create.rb +43 -0
- data/lib/cimi/models/network_port.rb +17 -17
- data/lib/cimi/models/network_template.rb +2 -3
- data/lib/cimi/models/resource.rb +22 -3
- data/lib/cimi/models/schema.rb +94 -8
- data/lib/cimi/models/system.rb +67 -0
- data/lib/cimi/models/system_template.rb +63 -0
- data/lib/cimi/models/volume.rb +2 -42
- data/lib/cimi/models/volume_configuration.rb +4 -4
- data/lib/cimi/models/volume_create.rb +58 -0
- data/lib/cimi/models/volume_image.rb +8 -17
- data/lib/cimi/models/volume_image_create.rb +47 -0
- data/lib/cimi/models/volume_template.rb +6 -19
- data/lib/cimi/models/volume_template_create.rb +33 -0
- data/lib/db.rb +14 -22
- data/lib/db/volume_template.rb +1 -1
- data/lib/deltacloud/api.rb +6 -5
- data/lib/deltacloud/collections.rb +4 -27
- data/lib/deltacloud/collections/base.rb +4 -0
- data/lib/deltacloud/collections/images.rb +1 -1
- data/lib/deltacloud/collections/instances.rb +2 -2
- data/lib/deltacloud/core_ext/array.rb +1 -0
- data/lib/deltacloud/core_ext/integer.rb +13 -9
- data/lib/deltacloud/core_ext/string.rb +45 -28
- data/lib/deltacloud/drivers/arubacloud/arubacloud_driver.rb +0 -9
- data/lib/deltacloud/drivers/base_driver.rb +45 -16
- data/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb +78 -8
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +13 -9
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +44 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +164 -90
- data/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb +74 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +3 -3
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +3 -3
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +3 -3
- data/lib/deltacloud/drivers/mock/mock_client.rb +17 -1
- data/lib/deltacloud/drivers/mock/mock_driver.rb +161 -204
- data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +80 -0
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +6 -1
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +61 -68
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +0 -9
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +11 -6
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +0 -8
- data/lib/deltacloud/drivers/vsphere/vsphere_client.rb +11 -4
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +0 -12
- data/lib/deltacloud/helpers/collection_helper.rb +106 -0
- data/lib/deltacloud/helpers/deltacloud_helper.rb +12 -8
- data/lib/deltacloud/models/address.rb +19 -17
- data/lib/deltacloud/models/base_model.rb +29 -26
- data/lib/deltacloud/models/blob.rb +22 -20
- data/lib/deltacloud/models/bucket.rb +21 -16
- data/lib/deltacloud/models/firewall.rb +18 -16
- data/lib/deltacloud/models/firewall_rule.rb +22 -20
- data/lib/deltacloud/models/image.rb +29 -28
- data/lib/deltacloud/models/instance.rb +92 -94
- data/lib/deltacloud/models/instance_address.rb +42 -40
- data/lib/deltacloud/models/instance_profile.rb +28 -26
- data/lib/deltacloud/models/key.rb +47 -45
- data/lib/deltacloud/models/load_balancer.rb +32 -31
- data/lib/deltacloud/models/metric.rb +76 -29
- data/lib/deltacloud/models/provider.rb +15 -13
- data/lib/deltacloud/models/realm.rb +15 -21
- data/lib/deltacloud/models/storage_snapshot.rb +23 -19
- data/lib/deltacloud/models/storage_volume.rb +35 -34
- data/lib/deltacloud/version.rb +1 -1
- data/lib/deltacloud_rack.rb +22 -0
- data/lib/initialize.rb +28 -0
- data/lib/initializers/database_initialize.rb +76 -0
- data/lib/initializers/frontend_initialize.rb +42 -0
- data/lib/initializers/mock_initialize.rb +33 -0
- data/lib/sinatra/rack_logger.rb +35 -24
- data/tests/cimi/collections/cloud_entry_point_test.rb +1 -7
- data/tests/cimi/collections/machine_images_test.rb +2 -2
- data/tests/cimi/collections/machine_templates_test.rb +75 -0
- data/tests/cimi/collections/machines_test.rb +2 -2
- data/tests/cimi/collections/system_templates_test.rb +41 -0
- data/tests/cimi/collections/systems_test.rb +50 -0
- data/tests/cimi/db/database_helper_test.rb +17 -25
- data/tests/cimi/db/db_helper.rb +1 -12
- data/tests/cimi/db/entity_test.rb +7 -8
- data/tests/cimi/model/machine_create_spec.rb +44 -0
- data/tests/cimi/model/machine_template_spec.rb +29 -0
- data/tests/cimi/model/resource_spec.rb +40 -0
- data/tests/cimi/model/schema_spec.rb +37 -0
- data/tests/cimi/spec_helper.rb +3 -0
- data/tests/deltacloud/collections/buckets_collection_test.rb +1 -1
- data/tests/deltacloud/collections/drivers_collection_test.rb +2 -2
- data/tests/deltacloud/collections/hardware_profiles_collection_test.rb +2 -2
- data/tests/deltacloud/collections/images_collection_test.rb +2 -2
- data/tests/deltacloud/collections/instance_states_collection_test.rb +1 -1
- data/tests/deltacloud/collections/instances_collection_test.rb +6 -3
- data/tests/deltacloud/collections/keys_collection_test.rb +2 -2
- data/tests/deltacloud/collections/realms_collection_test.rb +2 -2
- data/tests/deltacloud/collections/storage_snapshots_collection_test.rb +2 -2
- data/tests/deltacloud/collections/storage_volumes_collection_test.rb +2 -2
- data/tests/deltacloud/collections_test.rb +5 -5
- data/tests/deltacloud/common.rb +2 -13
- data/tests/deltacloud/launcher_test.rb +3 -3
- data/tests/deltacloud/rack_test.rb +2 -2
- data/tests/deltacloud/server_test.rb +1 -1
- data/tests/drivers/base/base_driver_test.rb +5 -5
- data/tests/drivers/base/common.rb +2 -12
- data/tests/drivers/ec2/buckets_test.rb +1 -1
- data/tests/drivers/ec2/images_test.rb +2 -2
- data/tests/drivers/ec2/instance_test.rb +6 -6
- data/tests/drivers/ec2/keys_test.rb +3 -3
- data/tests/drivers/ec2/realms_test.rb +2 -2
- data/tests/drivers/ec2/storage_snapshots_test.rb +1 -1
- data/tests/drivers/fgcp/common.rb +32 -0
- data/tests/drivers/fgcp/firewall_test.rb +70 -0
- data/tests/drivers/fgcp/hardware_profiles_test.rb +61 -0
- data/tests/drivers/fgcp/images_test.rb +46 -0
- data/tests/drivers/fgcp/provider_test.rb +27 -0
- data/tests/drivers/fgcp/realms_test.rb +53 -0
- data/tests/drivers/fgcp/storage_volumes_test.rb +58 -0
- data/tests/drivers/gogrid/images_test.rb +2 -2
- data/tests/drivers/gogrid/instances_test.rb +2 -2
- data/tests/drivers/gogrid/realms_test.rb +2 -2
- data/tests/drivers/mock/images_test.rb +4 -4
- data/tests/drivers/mock/instances_test.rb +9 -9
- data/tests/drivers/mock/keys_test.rb +3 -3
- data/tests/drivers/mock/realms_test.rb +2 -2
- data/tests/drivers/mock/storage_snapshots_test.rb +2 -2
- data/tests/drivers/mock/storage_volumes_test.rb +4 -4
- data/tests/drivers/models/instance_test.rb +2 -2
- data/tests/drivers/openstack/images_test.rb +2 -2
- data/tests/drivers/openstack/instances_test.rb +2 -3
- data/tests/drivers/openstack/keys_test.rb +1 -1
- data/tests/drivers/openstack/realms_test.rb +2 -11
- data/tests/drivers/rhevm/common.rb +33 -12
- data/tests/drivers/rhevm/images_test.rb +20 -12
- data/tests/drivers/rhevm/instance_test.rb +62 -46
- data/tests/drivers/rhevm/provider_test.rb +12 -6
- data/tests/drivers/rhevm/realms_test.rb +15 -9
- data/tests/ec2/query_parser_test.rb +1 -1
- data/tests/test_helper.rb +68 -12
- data/views/addresses/show.html.haml +1 -1
- data/views/buckets/show.html.haml +1 -1
- data/views/errors/{500.html.haml → common.html.haml} +0 -0
- data/views/errors/common.xml.haml +17 -0
- data/views/firewalls/index.xml.haml +2 -2
- data/views/firewalls/new.html.haml +2 -2
- data/views/images/show.html.haml +1 -1
- data/views/instances/run_command.html.haml +1 -1
- data/views/instances/show.html.haml +3 -3
- data/views/keys/index.html.haml +1 -0
- data/views/keys/show.html.haml +8 -4
- data/views/keys/show.xml.haml +3 -2
- data/views/load_balancers/new.html.haml +1 -1
- data/views/load_balancers/show.html.haml +2 -2
- data/views/metrics/show.html.haml +1 -1
- data/views/realms/index.html.haml +0 -2
- data/views/realms/show.html.haml +0 -4
- data/views/realms/show.xml.haml +0 -3
- data/views/storage_snapshots/index.html.haml +1 -1
- data/views/storage_snapshots/new.html.haml +1 -1
- data/views/storage_volumes/new.html.haml +2 -2
- data/views/storage_volumes/show.html.haml +3 -3
- metadata +90 -41
- data/views/errors/400.html.haml +0 -41
- data/views/errors/400.xml.haml +0 -3
- data/views/errors/401.html.haml +0 -26
- data/views/errors/401.xml.haml +0 -3
- data/views/errors/403.html.haml +0 -42
- data/views/errors/403.xml.haml +0 -9
- data/views/errors/404.html.haml +0 -28
- data/views/errors/404.xml.haml +0 -3
- data/views/errors/405.html.haml +0 -29
- data/views/errors/405.xml.haml +0 -5
- data/views/errors/409.html.haml +0 -47
- data/views/errors/409.xml.haml +0 -11
- data/views/errors/500.xml.haml +0 -13
- data/views/errors/501.html.haml +0 -44
- data/views/errors/501.xml.haml +0 -1
- data/views/errors/502.html.haml +0 -44
- data/views/errors/502.xml.haml +0 -1
- data/views/errors/504.html.haml +0 -43
- 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
|
-
|
63
|
+
@driver.destroy_instance(instance.id)
|
65
64
|
end
|
66
65
|
|
67
66
|
end
|
@@ -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
|
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
|
-
#
|
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
|
-
#
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
#
|
22
|
-
|
23
|
-
|
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
|
-
|
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 =>
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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 =>
|
46
|
-
|
47
|
-
|
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 =>
|
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
|
-
|
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
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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 =>
|
43
|
-
|
44
|
-
|
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(
|
51
|
-
:realm_id =>
|
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
|
-
|
60
|
-
@driver.instance(:id => instance.id)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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(
|
75
|
-
:realm_id =>
|
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
|
-
|
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
|
-
|
84
|
-
@driver.instance(:id => instance.id)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|
-
|
96
|
-
|
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
|
-
@
|
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
|
-
|
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
|
-
|
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 =
|
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
|
-
|
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
|
25
|
-
|
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 =>
|
30
|
-
|
31
|
-
|
32
|
-
|
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 =>
|
38
|
-
|
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
|
|