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
@@ -12,11 +12,11 @@ describe Deltacloud::Collections::StorageSnapshots do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'has index operation' do
|
15
|
-
@collection.operation(:index).must_equal
|
15
|
+
@collection.operation(:index).must_equal Deltacloud::Rabbit::StorageSnapshotsCollection::IndexOperation
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'has show operation' do
|
19
|
-
@collection.operation(:show).must_equal
|
19
|
+
@collection.operation(:show).must_equal Deltacloud::Rabbit::StorageSnapshotsCollection::ShowOperation
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'returns list of storage_snapshots in various formats with index operation' do
|
@@ -12,11 +12,11 @@ describe Deltacloud::Collections::StorageVolumes do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'has index operation' do
|
15
|
-
@collection.operation(:index).must_equal
|
15
|
+
@collection.operation(:index).must_equal Deltacloud::Rabbit::StorageVolumesCollection::IndexOperation
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'has show operation' do
|
19
|
-
@collection.operation(:show).must_equal
|
19
|
+
@collection.operation(:show).must_equal Deltacloud::Rabbit::StorageVolumesCollection::ShowOperation
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'returns list of storage_volumes in various formats with index operation' do
|
@@ -12,7 +12,7 @@ describe Deltacloud do
|
|
12
12
|
|
13
13
|
it 'must provide access to collection classes' do
|
14
14
|
Deltacloud.collections.wont_be_empty
|
15
|
-
Deltacloud.collections.must_include
|
15
|
+
Deltacloud.collections.must_include Deltacloud::Rabbit::DriversCollection
|
16
16
|
end
|
17
17
|
|
18
18
|
describe Deltacloud::Collections do
|
@@ -20,13 +20,13 @@ describe Deltacloud do
|
|
20
20
|
it 'must return collection by name' do
|
21
21
|
Deltacloud::Collections.must_respond_to :collection
|
22
22
|
Deltacloud::Collections.collection(:drivers).wont_be_nil
|
23
|
-
Deltacloud::Collections.collection(:drivers).must_equal
|
23
|
+
Deltacloud::Collections.collection(:drivers).must_equal Deltacloud::Rabbit::DriversCollection
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'must provide access to Deltacloud Sinatra modules' do
|
27
|
-
Deltacloud::Collections.must_respond_to :
|
28
|
-
Deltacloud::Collections.
|
29
|
-
Deltacloud::Collections.
|
27
|
+
Deltacloud::Collections.must_respond_to :modules
|
28
|
+
Deltacloud::Collections.modules(:deltacloud).wont_be_empty
|
29
|
+
Deltacloud::Collections.modules(:deltacloud).must_include Deltacloud::Collections::Drivers
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
data/tests/deltacloud/common.rb
CHANGED
@@ -1,17 +1,6 @@
|
|
1
1
|
require_relative '../test_helper.rb'
|
2
|
-
require_relative File.join('..', '..', 'lib', 'deltacloud_rack.rb')
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
Deltacloud::configure do |server|
|
7
|
-
server.root_url '/api'
|
8
|
-
server.version Deltacloud::API_VERSION
|
9
|
-
server.klass 'Deltacloud::API'
|
10
|
-
server.logger Rack::DeltacloudLogger.setup(ENV['API_LOG'], ENV['API_VERBOSE'])
|
11
|
-
server.default_driver :mock
|
12
|
-
end
|
13
|
-
|
14
|
-
Deltacloud.require_frontend!
|
3
|
+
Deltacloud.require_frontend! :deltacloud
|
15
4
|
|
16
5
|
def check_json_serialization_for(model, sample_id, optional_attrs=[])
|
17
6
|
header 'Accept', 'application/json'
|
@@ -21,7 +10,7 @@ def check_json_serialization_for(model, sample_id, optional_attrs=[])
|
|
21
10
|
get root_url + "/#{model.to_s.pluralize}/#{sample_id}"
|
22
11
|
status.must_equal 200
|
23
12
|
json[model.to_s].wont_be_empty
|
24
|
-
klass =
|
13
|
+
klass = Deltacloud.const_get(model.to_s.camelize)
|
25
14
|
klass.attributes.each do |attr|
|
26
15
|
attr = attr.to_s.gsub(/_id$/,'') if attr.to_s =~ /_id$/
|
27
16
|
json[model.to_s].keys.must_include attr.to_s unless optional_attrs.include? attr
|
@@ -53,7 +53,7 @@ describe "deltacloudd" do
|
|
53
53
|
pid = Process.fork
|
54
54
|
if pid.nil? then
|
55
55
|
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..'))
|
56
|
-
exec("./bin/deltacloudd -i mock -p 3011")
|
56
|
+
exec("./bin/deltacloudd -e test -i mock -p 3011")
|
57
57
|
else
|
58
58
|
Process.detach(pid) && @pids << pid
|
59
59
|
wait_for_port_open(3011).must_equal true
|
@@ -67,7 +67,7 @@ describe "deltacloudd" do
|
|
67
67
|
pid = Process.fork
|
68
68
|
if pid.nil? then
|
69
69
|
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..'))
|
70
|
-
exec("./bin/deltacloudd -i mock -f deltacloud,cimi,ec2 -p 3011")
|
70
|
+
exec("./bin/deltacloudd -e test -i mock -f deltacloud,cimi,ec2 -p 3011")
|
71
71
|
else
|
72
72
|
Process.detach(pid) && @pids << pid
|
73
73
|
wait_for_port_open(3011).must_equal true
|
@@ -82,7 +82,7 @@ describe "deltacloudd" do
|
|
82
82
|
pid = Process.fork
|
83
83
|
if pid.nil? then
|
84
84
|
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..'))
|
85
|
-
exec("./bin/deltacloudd -w -i mock -p 3011")
|
85
|
+
exec("./bin/deltacloudd -e test -w -i mock -p 3011")
|
86
86
|
else
|
87
87
|
Process.detach(pid) && @pids << pid
|
88
88
|
wait_for_port_open(3011).must_equal true
|
@@ -38,12 +38,12 @@ describe Deltacloud do
|
|
38
38
|
|
39
39
|
it 'should provide the correct version' do
|
40
40
|
Deltacloud.config[:deltacloud].version.must_equal Deltacloud::API_VERSION
|
41
|
-
Deltacloud.config[:cimi].version.must_equal Deltacloud::
|
41
|
+
Deltacloud.config[:cimi].version.must_equal Deltacloud::CIMI_API_VERSION
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should provide the logger facility' do
|
45
45
|
Deltacloud.config[:deltacloud].logger.must_equal Rack::DeltacloudLogger
|
46
|
-
Deltacloud.config[:cimi].logger.must_equal
|
46
|
+
Deltacloud.config[:cimi].logger.must_equal Rack::DeltacloudLogger
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|
@@ -43,7 +43,7 @@ describe Deltacloud::API do
|
|
43
43
|
it 'must return list of collections on OPTIONS' do
|
44
44
|
options root_url
|
45
45
|
headers['Allow'].wont_be_nil
|
46
|
-
headers['Allow'].split(',').must_include '
|
46
|
+
headers['Allow'].split(',').must_include 'Deltacloud::Rabbit::DriversCollection'
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'must support setting driver and provider using POST' do
|
@@ -41,7 +41,7 @@ describe Deltacloud::BaseDriver do
|
|
41
41
|
def supported_collections(credentials)
|
42
42
|
collections = super
|
43
43
|
#lets add images/instances just for testing of method override from base
|
44
|
-
collections + [
|
44
|
+
collections + [Deltacloud::Rabbit::ImagesCollection, Deltacloud::Rabbit::InstancesCollection]
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -57,13 +57,13 @@ describe Deltacloud::BaseDriver do
|
|
57
57
|
Thread.current[:driver] = 'test'
|
58
58
|
credentials = OpenStruct.new(:user => 'unkown', :password => 'wrong')
|
59
59
|
@driver.supported_collections(credentials).wont_be_empty
|
60
|
-
@driver.supported_collections(credentials).must_include
|
60
|
+
@driver.supported_collections(credentials).must_include Deltacloud::Rabbit::InstancesCollection
|
61
61
|
#check override of supported_collections, we added Images above
|
62
|
-
@driver.supported_collections(credentials).must_include
|
63
|
-
@driver.supported_collections(credentials).wont_include
|
62
|
+
@driver.supported_collections(credentials).must_include Deltacloud::Rabbit::ImagesCollection
|
63
|
+
@driver.supported_collections(credentials).wont_include Deltacloud::Rabbit::KeysCollection
|
64
64
|
#switch driver, check supported_collections
|
65
65
|
Thread.current[:driver] = 'mock'
|
66
|
-
@driver.supported_collections(credentials).must_include
|
66
|
+
@driver.supported_collections(credentials).must_include Deltacloud::Rabbit::KeysCollection
|
67
67
|
#restore driver to not impact other tests
|
68
68
|
Thread.current[:driver] = current_driver
|
69
69
|
end
|
@@ -1,15 +1,5 @@
|
|
1
1
|
require_relative '../../test_helper'
|
2
2
|
|
3
|
-
require_relative File.join('..', '..', '..', 'lib', '
|
3
|
+
require_relative File.join('..', '..', '..', 'lib', 'initializers', 'frontend_initialize')
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
Deltacloud::configure do |server|
|
8
|
-
server.root_url '/api'
|
9
|
-
server.version Deltacloud::API_VERSION
|
10
|
-
server.klass 'Deltacloud::API'
|
11
|
-
server.logger Rack::DeltacloudLogger.setup(ENV['API_LOG'], ENV['API_VERBOSE'])
|
12
|
-
server.default_driver :mock
|
13
|
-
end
|
14
|
-
|
15
|
-
Deltacloud.require_frontend!
|
5
|
+
Deltacloud.require_frontend!(:deltacloud)
|
@@ -36,7 +36,7 @@ describe 'Ec2Driver Buckets' do
|
|
36
36
|
@dcloud_other_provider = Deltacloud::new(:ec2, credentials.merge!(:provider=>"eu-west-1"))
|
37
37
|
#get the bucket and check
|
38
38
|
retrieved_bucket = @dcloud_other_provider.bucket(:id=>bucket.name)
|
39
|
-
retrieved_bucket.must_be_kind_of Bucket
|
39
|
+
retrieved_bucket.must_be_kind_of Deltacloud::Bucket
|
40
40
|
retrieved_bucket.name.must_equal bucket.name
|
41
41
|
#delete the bucket
|
42
42
|
@driver.delete_bucket(bucket.id)
|
@@ -22,7 +22,7 @@ describe 'Ec2Driver 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
|
@@ -39,7 +39,7 @@ describe 'Ec2Driver Images' do
|
|
39
39
|
|
40
40
|
it 'must allow to retrieve single image' do
|
41
41
|
@driver.image(:id => 'ami-aecd60c7').wont_be_nil
|
42
|
-
@driver.image(:id => 'ami-aecd60c7').must_be_kind_of Image
|
42
|
+
@driver.image(:id => 'ami-aecd60c7').must_be_kind_of Deltacloud::Image
|
43
43
|
@driver.image(:id => 'ami-aecd60c7').id.must_equal 'ami-aecd60c7'
|
44
44
|
@driver.image(:id => 'ami-aaaaaaaa').must_be_nil
|
45
45
|
@driver.image(:id => 'unknown').must_be_nil
|
@@ -22,7 +22,7 @@ describe 'Ec2Driver Instances' do
|
|
22
22
|
|
23
23
|
it 'must return list of instances' do
|
24
24
|
@driver.instances.wont_be_empty
|
25
|
-
@driver.instances.first.must_be_kind_of Instance
|
25
|
+
@driver.instances.first.must_be_kind_of Deltacloud::Instance
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'must allow to filter instances' do
|
@@ -40,7 +40,7 @@ describe 'Ec2Driver Instances' do
|
|
40
40
|
|
41
41
|
it 'must allow to retrieve single instance' do
|
42
42
|
@driver.instance(:id => 'i-4d15f036').wont_be_nil
|
43
|
-
@driver.instance(:id => 'i-4d15f036').must_be_kind_of Instance
|
43
|
+
@driver.instance(:id => 'i-4d15f036').must_be_kind_of Deltacloud::Instance
|
44
44
|
@driver.instance(:id => 'i-4d15f036').id.must_equal 'i-4d15f036'
|
45
45
|
@driver.instance(:id => 'i-00000000').must_be_nil
|
46
46
|
@driver.instance(:id => 'unknown').must_be_nil
|
@@ -55,7 +55,7 @@ describe 'Ec2Driver Instances' do
|
|
55
55
|
:'firewalls1' => 'default'
|
56
56
|
)
|
57
57
|
instance = instance.wait_for!(@driver, record_retries) { |i| i.is_running? }
|
58
|
-
instance.must_be_kind_of Instance
|
58
|
+
instance.must_be_kind_of Deltacloud::Instance
|
59
59
|
instance.is_running?.must_equal true
|
60
60
|
@driver.instance(:id => instance.id).wont_be_nil
|
61
61
|
@driver.instance(:id => instance.id).id.must_equal instance.id
|
@@ -82,7 +82,7 @@ describe 'Ec2Driver Instances' do
|
|
82
82
|
)
|
83
83
|
instances.wont_be_empty
|
84
84
|
instances.size.must_equal 2
|
85
|
-
instances.each { |i| i.must_be_kind_of Instance }
|
85
|
+
instances.each { |i| i.must_be_kind_of Deltacloud::Instance }
|
86
86
|
instances = instances.map { |instance| instance.wait_for!(@driver, record_retries("#{instance.id}-running")) { |i| i.is_running? } }
|
87
87
|
instances.each { |i| i.is_running?.must_equal true }
|
88
88
|
instances.each { |i| @driver.destroy_instance(i.id) }
|
@@ -95,7 +95,7 @@ describe 'Ec2Driver Instances' do
|
|
95
95
|
instance = @driver.create_instance('ami-aecd60c7',
|
96
96
|
:realm_id => realm_id,
|
97
97
|
:hwp_id => 'm1.small')
|
98
|
-
instance.must_be_kind_of Instance
|
98
|
+
instance.must_be_kind_of Deltacloud::Instance
|
99
99
|
instance.realm_id.must_equal realm_id
|
100
100
|
@driver.destroy_instance(instance.id)
|
101
101
|
end
|
@@ -103,7 +103,7 @@ describe 'Ec2Driver Instances' do
|
|
103
103
|
it 'must allow to reboot instance in running state' do
|
104
104
|
instance = @driver.create_instance('ami-aecd60c7', :realm_id => 'us-east-1a', :hwp_id => 't1.micro')
|
105
105
|
instance = instance.wait_for!(@driver, record_retries) { |i| i.is_running? }
|
106
|
-
instance.must_be_kind_of Instance
|
106
|
+
instance.must_be_kind_of Deltacloud::Instance
|
107
107
|
instance.is_running?.must_equal true
|
108
108
|
@driver.reboot_instance(instance.id)
|
109
109
|
@driver.instance(:id => instance.id).state.must_equal 'RUNNING'
|
@@ -22,7 +22,7 @@ describe 'Ec2Driver 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
|
@@ -35,7 +35,7 @@ describe 'Ec2Driver Keys' do
|
|
35
35
|
|
36
36
|
it 'must allow to retrieve single key' do
|
37
37
|
@driver.key(:id => 'test1').wont_be_nil
|
38
|
-
@driver.key(:id => 'test1').must_be_kind_of Key
|
38
|
+
@driver.key(:id => 'test1').must_be_kind_of Deltacloud::Key
|
39
39
|
@driver.key(:id => 'test1').id.must_equal 'test1'
|
40
40
|
@driver.key(:id => 'unknown').must_be_nil
|
41
41
|
end
|
@@ -43,7 +43,7 @@ describe 'Ec2Driver Keys' do
|
|
43
43
|
it 'must allow to create a new key' do
|
44
44
|
key = @driver.create_key(:key_name => 'test-key-1')
|
45
45
|
key.wont_be_nil
|
46
|
-
key.must_be_kind_of Key
|
46
|
+
key.must_be_kind_of Deltacloud::Key
|
47
47
|
Proc.new { @driver.create_key(:key_name => 'test-key-1') }.must_raise Deltacloud::Exceptions::ProviderError, 'KeyExist'
|
48
48
|
@driver.destroy_key :id => key.id
|
49
49
|
@driver.key(:id => key.id).must_be_nil
|
@@ -22,7 +22,7 @@ describe 'Ec2Driver Realms' do
|
|
22
22
|
|
23
23
|
it 'must return list of realms' do
|
24
24
|
@driver.realms.wont_be_empty
|
25
|
-
@driver.realms.first.must_be_kind_of Realm
|
25
|
+
@driver.realms.first.must_be_kind_of Deltacloud::Realm
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'must allow to filter realms' do
|
@@ -35,7 +35,7 @@ describe 'Ec2Driver Realms' do
|
|
35
35
|
|
36
36
|
it 'must allow to retrieve single realm' do
|
37
37
|
@driver.realm(:id => 'us-east-1a').wont_be_nil
|
38
|
-
@driver.realm(:id => 'us-east-1a').must_be_kind_of Realm
|
38
|
+
@driver.realm(:id => 'us-east-1a').must_be_kind_of Deltacloud::Realm
|
39
39
|
@driver.realm(:id => 'us-east-1b').id.must_equal 'us-east-1b'
|
40
40
|
@driver.realm(:id => 'unknown').must_be_nil
|
41
41
|
end
|
@@ -21,7 +21,7 @@ describe 'Ec2Driver StorageSnapshots' do
|
|
21
21
|
|
22
22
|
it 'must return list of storage snapshots' do
|
23
23
|
@driver.storage_snapshots.wont_be_empty
|
24
|
-
@driver.storage_snapshots.first.must_be_kind_of StorageSnapshot
|
24
|
+
@driver.storage_snapshots.first.must_be_kind_of Deltacloud::StorageSnapshot
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'must allow to filter storage snapshots' do
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
|
3
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
4
|
+
require_relative '../../test_helper.rb'
|
5
|
+
|
6
|
+
|
7
|
+
# Credentials used to access FGCP server
|
8
|
+
#
|
9
|
+
ENV['FGCP_CERT_DIR'] = File.join(File.dirname(__FILE__), 'cert')
|
10
|
+
def credentials
|
11
|
+
{
|
12
|
+
:user => 'fgcp-testuser',
|
13
|
+
:password => 'fgcp-password',
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
#require 'turn' #internal_use_only
|
18
|
+
#Turn.config.format = :outline #internal_use_only
|
19
|
+
|
20
|
+
|
21
|
+
VCR.configure do |c|
|
22
|
+
# NOTE: Empty this directory before re-recording
|
23
|
+
c.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures')
|
24
|
+
c.hook_into :webmock
|
25
|
+
c.default_cassette_options = {
|
26
|
+
:record => :new_episodes,
|
27
|
+
# :record => :none,
|
28
|
+
:match_requests_on => [:method,
|
29
|
+
VCR.request_matchers.uri_without_param(:Signature, :AccessKeyId)]
|
30
|
+
}
|
31
|
+
#c.debug_logger = File.open(File.join('log', 'vcr.log'), 'w')
|
32
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
3
|
+
|
4
|
+
require_relative 'common.rb'
|
5
|
+
|
6
|
+
describe 'FgcpDriver Firewalls' do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@driver = Deltacloud::new(:fgcp, credentials)
|
10
|
+
VCR.insert_cassette __name__
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
VCR.eject_cassette
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'must throw error when wrong credentials' do
|
18
|
+
Proc.new do
|
19
|
+
@driver.backend.firewalls(OpenStruct.new(:user => 'unknown', :password => 'wrong'))
|
20
|
+
end.must_raise Deltacloud::Exceptions::AuthenticationFailure, 'Authentication Failure'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'must return list of firewalls' do
|
24
|
+
fws = @driver.firewalls
|
25
|
+
fws.wont_be_empty
|
26
|
+
fws.each { |fw| fw.must_be_kind_of Deltacloud::Firewall }
|
27
|
+
fws.each { |fw| fw.id.wont_be_nil }
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'must allow to filter firewalls' do
|
31
|
+
fw = @driver.firewalls(:id => 'UZXC0GRT-ZG8ZJCJ07-S-0001')
|
32
|
+
fw.wont_be_empty
|
33
|
+
fw.must_be_kind_of Array
|
34
|
+
fw.size.must_equal 1
|
35
|
+
fw.first.id.must_equal 'UZXC0GRT-ZG8ZJCJ07-S-0001'
|
36
|
+
@driver.firewalls(:id => 'UZXC0GRT-ZG8ZJCJ07-S-0000').must_be_empty
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'must allow to retrieve single firewall' do
|
40
|
+
fw = @driver.firewall(:id => 'UZXC0GRT-ZG8ZJCJ07-S-0001')
|
41
|
+
fw.wont_be_nil
|
42
|
+
fw.must_be_kind_of Deltacloud::Firewall
|
43
|
+
fw.id.must_equal 'UZXC0GRT-ZG8ZJCJ07-S-0001'
|
44
|
+
@driver.firewall(:id => 'UZXC0GRT-ZG8ZJCJ07-S-0000').must_be_nil
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'must describe single firewall' do
|
48
|
+
fw = @driver.firewall(:id => 'UZXC0GRT-ZG8ZJCJ07-S-0001')
|
49
|
+
fw.wont_be_nil
|
50
|
+
fw.id.must_equal 'UZXC0GRT-ZG8ZJCJ07-S-0001'
|
51
|
+
fw.name.must_equal 'Firewall'
|
52
|
+
fw.owner_id.wont_be_nil
|
53
|
+
fw.description.wont_be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'must list firewall rules' do
|
57
|
+
fw = @driver.firewall(:id => 'UZXC0GRT-ZG8ZJCJ07-S-0001')
|
58
|
+
fw.wont_be_nil
|
59
|
+
fw.rules.wont_be_empty
|
60
|
+
fw.rules.first.must_be_kind_of Deltacloud::FirewallRule
|
61
|
+
fw.rules.first.allow_protocol.wont_be_nil
|
62
|
+
fw.rules.first.port_from.wont_be_nil
|
63
|
+
fw.rules.first.port_to.wont_be_nil
|
64
|
+
fw.rules.first.direction.wont_be_nil
|
65
|
+
fw.rules.first.rule_action.wont_be_nil
|
66
|
+
fw.rules.first.log_rule.wont_be_nil
|
67
|
+
fw.rules.first.sources.wont_be_empty
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
3
|
+
|
4
|
+
require_relative 'common.rb'
|
5
|
+
|
6
|
+
describe 'FgcpDriver HardwareProfiles' do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@driver = Deltacloud::new(:fgcp, credentials)
|
10
|
+
VCR.insert_cassette __name__
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
VCR.eject_cassette
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'must throw error when wrong credentials' do
|
18
|
+
Proc.new do
|
19
|
+
@driver.backend.hardware_profiles(OpenStruct.new(:user => 'unknown', :password => 'wrong'))
|
20
|
+
end.must_raise Deltacloud::Exceptions::AuthenticationFailure, 'Authentication Failure'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'must return list of hardware_profiles' do
|
24
|
+
hardware_profiles = @driver.hardware_profiles
|
25
|
+
hardware_profiles.wont_be_empty
|
26
|
+
hardware_profiles.first.must_be_kind_of Deltacloud::HardwareProfile
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'must allow to filter hardware_profiles' do
|
30
|
+
hardware_profiles = @driver.hardware_profiles :id => 'economy'
|
31
|
+
hardware_profiles.wont_be_empty
|
32
|
+
hardware_profiles.must_be_kind_of Array
|
33
|
+
hardware_profiles.size.must_equal 1
|
34
|
+
hardware_profiles.first.id.must_equal 'economy'
|
35
|
+
@driver.hardware_profiles(:id => 'unknown').must_be_empty
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'must allow to retrieve single hardware_profile' do
|
39
|
+
hardware_profile = @driver.hardware_profile :id => 'economy'
|
40
|
+
hardware_profile.wont_be_nil
|
41
|
+
hardware_profile.id.must_equal 'economy'
|
42
|
+
hardware_profile.properties.must_be_kind_of Array
|
43
|
+
hardware_profile.properties.wont_be_empty
|
44
|
+
@driver.hardware_profile(:id => 'unknown').must_be_nil
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'must include correct attributes' do
|
48
|
+
hardware_profile = @driver.hardware_profiles.first
|
49
|
+
hardware_profile.cpu.wont_be_nil
|
50
|
+
hardware_profile.cpu.value.wont_be :<, 1
|
51
|
+
hardware_profile.memory.wont_be_nil
|
52
|
+
hardware_profile.memory.value.wont_be :<=, 1740 #1740.8 is lowest (economy)
|
53
|
+
hardware_profile.storage.must_be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'must include at least four profiles' do
|
57
|
+
hardware_profiles = @driver.hardware_profiles
|
58
|
+
hardware_profiles.size.wont_be :<, 4
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|