deltacloud-core 0.1.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/DISCLAIMER +8 -0
- data/{COPYING → LICENSE} +0 -0
- data/NOTICE +13 -0
- data/Rakefile +50 -51
- data/bin/deltacloudd +8 -1
- data/config.ru +0 -2
- data/config/drivers.yaml +48 -0
- data/deltacloud-core.gemspec +75 -0
- data/deltacloud.rb +3 -2
- data/lib/deltacloud/backend_capability.rb +15 -3
- data/lib/deltacloud/base_driver.rb +0 -2
- data/lib/deltacloud/base_driver/base_driver.rb +85 -89
- data/lib/deltacloud/base_driver/features.rb +61 -7
- data/lib/deltacloud/base_driver/mock_driver.rb +42 -43
- data/lib/deltacloud/core_ext.rb +18 -0
- data/lib/deltacloud/core_ext/integer.rb +31 -0
- data/lib/deltacloud/core_ext/string.rb +50 -0
- data/lib/deltacloud/drivers/azure/azure_driver.rb +71 -22
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +641 -584
- data/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb +0 -2
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +167 -0
- data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +39 -1
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +41 -25
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob1.yml +6 -3
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob2.yml +6 -3
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob3.yml +4 -2
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob4.yml +5 -2
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob5.yml +4 -2
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol1.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol2.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol3.yml +1 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +138 -30
- data/lib/deltacloud/drivers/opennebula/cloud_client.rb +13 -15
- data/lib/deltacloud/drivers/opennebula/occi_client.rb +13 -15
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +13 -15
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +224 -113
- data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +332 -0
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +221 -170
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +0 -1
- data/lib/deltacloud/drivers/sbc/sbc_client.rb +247 -0
- data/lib/deltacloud/drivers/sbc/sbc_driver.rb +297 -0
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +0 -2
- data/lib/deltacloud/hardware_profile.rb +1 -3
- data/lib/deltacloud/helpers.rb +0 -2
- data/lib/deltacloud/helpers/application_helper.rb +86 -12
- data/lib/deltacloud/helpers/blob_stream.rb +19 -2
- data/lib/deltacloud/helpers/conversion_helper.rb +0 -2
- data/lib/deltacloud/helpers/hardware_profiles_helper.rb +0 -2
- data/lib/deltacloud/method_serializer.rb +0 -2
- data/lib/deltacloud/models/base_model.rb +0 -2
- data/lib/deltacloud/models/blob.rb +1 -2
- data/lib/deltacloud/models/bucket.rb +0 -2
- data/lib/deltacloud/models/image.rb +0 -2
- data/lib/deltacloud/models/instance.rb +19 -2
- data/lib/deltacloud/models/instance_profile.rb +4 -2
- data/lib/deltacloud/models/key.rb +0 -2
- data/lib/deltacloud/models/load_balancer.rb +0 -2
- data/lib/deltacloud/models/realm.rb +0 -2
- data/lib/deltacloud/models/storage_snapshot.rb +0 -2
- data/lib/deltacloud/models/storage_volume.rb +4 -2
- data/lib/deltacloud/runner.rb +132 -0
- data/lib/deltacloud/state_machine.rb +0 -2
- data/lib/deltacloud/validation.rb +9 -7
- data/lib/drivers.rb +36 -48
- data/lib/sinatra/accept_media_types.rb +26 -0
- data/lib/sinatra/lazy_auth.rb +16 -0
- data/lib/sinatra/rabbit.rb +112 -54
- data/lib/sinatra/rack_driver_select.rb +50 -16
- data/lib/sinatra/rack_etag.rb +79 -0
- data/lib/sinatra/rack_matrix_params.rb +84 -0
- data/lib/sinatra/rack_runtime.rb +47 -0
- data/lib/sinatra/static_assets.rb +16 -0
- data/lib/sinatra/url_for.rb +31 -4
- data/public/favicon.ico +0 -0
- data/public/images/bread-bg.png +0 -0
- data/public/images/error.png +0 -0
- data/public/images/pending.png +0 -0
- data/public/images/running.png +0 -0
- data/public/images/stopped.png +0 -0
- data/public/javascripts/application.js +35 -0
- data/public/stylesheets/compiled/application.css +59 -5
- data/public/stylesheets/compiled/screen.css +1 -1
- data/server.rb +293 -29
- data/support/fedora/deltacloud-core +78 -0
- data/support/fedora/deltacloud-core.spec +143 -0
- data/support/fedora/deltacloudd +78 -18
- data/support/fedora/rubygem-deltacloud-core.spec +76 -40
- data/tests/common.rb +172 -0
- data/tests/drivers/mock/api_test.rb +133 -0
- data/tests/drivers/mock/hardware_profiles_test.rb +134 -0
- data/tests/drivers/mock/images_test.rb +126 -0
- data/tests/drivers/mock/instance_states_test.rb +71 -0
- data/tests/drivers/mock/instances_test.rb +236 -0
- data/tests/drivers/mock/realms_test.rb +93 -0
- data/tests/drivers/mock/setup.rb +3 -0
- data/tests/drivers/mock/url_for_test.rb +67 -0
- data/tests/drivers/rackspace/api_test.rb +41 -0
- data/tests/drivers/rackspace/hardware_profiles_test.rb +53 -0
- data/tests/drivers/rackspace/images_test.rb +40 -0
- data/tests/drivers/rackspace/instances_test.rb +161 -0
- data/tests/drivers/rackspace/realms_test.rb +36 -0
- data/tests/drivers/rackspace/setup.rb +14 -0
- data/tests/drivers/rhevm/api_test.rb +39 -0
- data/tests/drivers/rhevm/hardware_profiles_test.rb +53 -0
- data/tests/drivers/rhevm/images_test.rb +42 -0
- data/tests/drivers/rhevm/instances_test.rb +179 -0
- data/tests/drivers/rhevm/realms_test.rb +35 -0
- data/tests/drivers/rhevm/setup.rb +14 -0
- data/tests/rabbit_test.rb +52 -0
- data/views/api/show.html.haml +2 -5
- data/views/blobs/new.html.haml +17 -1
- data/views/blobs/show.html.haml +6 -0
- data/views/blobs/show.xml.haml +5 -1
- data/views/buckets/index.html.haml +1 -12
- data/views/buckets/index.xml.haml +3 -5
- data/views/docs/operation.html.haml +23 -11
- data/views/drivers/index.html.haml +15 -0
- data/views/drivers/index.xml.haml +7 -0
- data/views/drivers/show.html.haml +20 -0
- data/views/drivers/show.xml.haml +7 -0
- data/views/error.html.haml +31 -0
- data/views/errors/auth_exception.xml.haml +2 -1
- data/views/errors/backend_capability_failure.xml.haml +2 -1
- data/views/errors/backend_error.html.haml +3 -0
- data/views/errors/backend_error.xml.haml +2 -2
- data/views/errors/validation_failure.xml.haml +3 -2
- data/views/images/index.html.haml +1 -6
- data/views/images/index.xml.haml +2 -0
- data/views/images/new.html.haml +14 -0
- data/views/images/show.xml.haml +2 -0
- data/views/instances/index.html.haml +8 -6
- data/views/instances/index.xml.haml +4 -0
- data/views/instances/new.html.haml +40 -11
- data/views/instances/run.html.haml +9 -0
- data/views/instances/run.xml.haml +7 -0
- data/views/instances/run_command.html.haml +16 -0
- data/views/instances/show.html.haml +14 -0
- data/views/instances/show.xml.haml +12 -4
- data/views/layout.html.haml +7 -2
- data/views/load_balancers/index.html.haml +1 -1
- data/views/load_balancers/new.html.haml +2 -2
- data/views/load_balancers/show.html.haml +1 -1
- data/views/storage_snapshots/index.html.haml +3 -0
- data/views/storage_snapshots/new.html.haml +9 -0
- data/views/storage_volumes/attach.html.haml +20 -0
- data/views/storage_volumes/index.html.haml +16 -1
- data/views/storage_volumes/index.xml.haml +1 -10
- data/views/storage_volumes/new.html.haml +17 -0
- data/views/storage_volumes/show.html.haml +8 -0
- data/views/storage_volumes/show.xml.haml +25 -3
- metadata +197 -127
- data/lib/deltacloud/drivers/rackspace/rackspace_client.rb +0 -130
- data/parse.rb +0 -7
- data/test.rb +0 -3
- data/views/api/drivers.xml.haml +0 -6
@@ -0,0 +1,41 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
|
4
|
+
module RackspaceTest
|
5
|
+
|
6
|
+
class ApiTest < Test::Unit::TestCase
|
7
|
+
include Rack::Test::Methods
|
8
|
+
|
9
|
+
def app
|
10
|
+
Sinatra::Application
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_01_it_returns_entry_points
|
14
|
+
get_auth_url '/api;driver=rackspace/?force_auth=1'
|
15
|
+
(last_xml_response/'/api').first[:driver].should == 'rackspace'
|
16
|
+
(last_xml_response/'/api/link').length.should > 0
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_02_it_has_rackspace_features
|
20
|
+
get_url '/api;driver=rackspace'
|
21
|
+
features = (last_xml_response/'/api/link[@rel="instances"]/feature').collect { |f| f[:name] }
|
22
|
+
features.include?('user_name').should == true
|
23
|
+
features.include?('authentication_password').should == true
|
24
|
+
features.include?('user_files').should == true
|
25
|
+
features.length.should == 3
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_03_it_has_rackspace_collections
|
29
|
+
get_url '/api;driver=rackspace'
|
30
|
+
collections = (last_xml_response/'/api/link').collect { |f| f[:rel] }
|
31
|
+
collections.include?('instance_states').should == true
|
32
|
+
collections.include?('instances').should == true
|
33
|
+
collections.include?('images').should == true
|
34
|
+
collections.include?('buckets').should == true
|
35
|
+
collections.include?('realms').should == true
|
36
|
+
collections.include?('hardware_profiles').should == true
|
37
|
+
collections.length.should == 7
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
|
4
|
+
module RackspaceTest
|
5
|
+
|
6
|
+
class HardwareProfilesTest < Test::Unit::TestCase
|
7
|
+
include Rack::Test::Methods
|
8
|
+
|
9
|
+
def app
|
10
|
+
Sinatra::Application
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_01_it_returns_hardware_profiles
|
14
|
+
get_auth_url '/api;driver=rackspace/hardware_profiles'
|
15
|
+
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 7
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_02_each_hardware_profile_has_a_name
|
19
|
+
get_auth_url '/api;driver=rackspace/hardware_profiles'
|
20
|
+
(last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
|
21
|
+
(profile/'name').text.should_not == nil
|
22
|
+
(profile/'name').text.should_not == ''
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_03_each_hardware_profile_has_correct_properties
|
27
|
+
get_auth_url '/api;driver=rackspace/hardware_profiles'
|
28
|
+
(last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
|
29
|
+
(profile/'property[@name="architecture"]').first[:value].should == 'x86_64'
|
30
|
+
(profile/'property[@name="memory"]').first[:unit].should == 'MB'
|
31
|
+
(profile/'property[@name="memory"]').first[:kind].should == 'fixed'
|
32
|
+
(profile/'property[@name="storage"]').first[:unit].should == 'GB'
|
33
|
+
(profile/'property[@name="storage"]').first[:kind].should == 'fixed'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_04_it_returns_single_hardware_profile
|
38
|
+
get_auth_url '/api;driver=rackspace/hardware_profiles/1'
|
39
|
+
(last_xml_response/'hardware_profile/name').first.text.should == '1'
|
40
|
+
(last_xml_response/'hardware_profile/property[@name="architecture"]').first[:value].should == 'x86_64'
|
41
|
+
(last_xml_response/'hardware_profile/property[@name="memory"]').first[:value].should == '256'
|
42
|
+
(last_xml_response/'hardware_profile/property[@name="storage"]').first[:value].should == '10'
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_05_it_filter_hardware_profiles
|
46
|
+
get_auth_url '/api;driver=rackspace/hardware_profiles?architecture=i386'
|
47
|
+
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 0
|
48
|
+
get_auth_url '/api;driver=rackspace/hardware_profiles?architecture=x86_64'
|
49
|
+
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 7
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
|
4
|
+
module RackspaceTest
|
5
|
+
|
6
|
+
class ImagesTest < Test::Unit::TestCase
|
7
|
+
include Rack::Test::Methods
|
8
|
+
|
9
|
+
def app
|
10
|
+
Sinatra::Application
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_01_it_returns_images
|
14
|
+
get_auth_url '/api;driver=rackspace/images'
|
15
|
+
(last_xml_response/'images/image').length.should > 0
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_02_each_image_has_correct_properties
|
19
|
+
get_auth_url '/api;driver=rackspace/images'
|
20
|
+
(last_xml_response/'images/image').each do |image|
|
21
|
+
(image/'name').should_not == nil
|
22
|
+
(image/'name').should_not == ''
|
23
|
+
(image/'description').should_not == nil
|
24
|
+
(image/'description').should_not == ''
|
25
|
+
(image/'architecture').should_not == nil
|
26
|
+
(image/'architecture').should_not == ''
|
27
|
+
(image/'state').text.should == 'ACTIVE'
|
28
|
+
(image/'owner_id').text.should == ENV['API_USER']
|
29
|
+
(image/'actions/link').length.should == 1
|
30
|
+
(image/'actions/link').first[:rel].should == 'create_instance'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_03_it_returns_single_image
|
35
|
+
get_auth_url '/api;driver=rackspace/images/71'
|
36
|
+
(last_xml_response/'image').length.should == 1
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
|
4
|
+
module RackspaceTest
|
5
|
+
|
6
|
+
class InstancesTest < Test::Unit::TestCase
|
7
|
+
include Rack::Test::Methods
|
8
|
+
|
9
|
+
def app
|
10
|
+
Sinatra::Application
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_01_01_it_can_create_instance_without_hardware_profile
|
14
|
+
params = {
|
15
|
+
:image_id => '71',
|
16
|
+
:'api[driver]' => 'rackspace',
|
17
|
+
}
|
18
|
+
post_url '/api/instances', params
|
19
|
+
last_response.status.should == 201 # Created
|
20
|
+
@@instance = last_xml_response
|
21
|
+
(@@instance/'instance').length.should > 0
|
22
|
+
(@@instance/'instance/name').first.text.should_not == nil
|
23
|
+
(@@instance/'instance/name').first.text.should_not == nil
|
24
|
+
(@@instance/'instance/owner_id').first.text.should_not == ''
|
25
|
+
(@@instance/'instance/owner_id').first.text.should == ENV['API_USER']
|
26
|
+
(@@instance/'instance/state').first.text.should == 'PENDING'
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_01_02_it_can_create_instance_with_hardware_profile
|
30
|
+
params = {
|
31
|
+
:image_id => '71',
|
32
|
+
:hwp_id => '2',
|
33
|
+
:'api[driver]' => 'rackspace',
|
34
|
+
}
|
35
|
+
post_url '/api/instances', params
|
36
|
+
last_response.status.should == 201 # Created
|
37
|
+
@@instance2 = last_xml_response
|
38
|
+
(@@instance2/'instance').length.should > 0
|
39
|
+
(@@instance2/'instance/name').first.text.should_not == nil
|
40
|
+
(@@instance2/'instance/name').first.text.should_not == nil
|
41
|
+
(@@instance2/'instance/owner_id').first.text.should_not == ''
|
42
|
+
(@@instance2/'instance/owner_id').first.text.should == ENV['API_USER']
|
43
|
+
(@@instance2/'instance/state').first.text.should == 'PENDING'
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_02_01_created_instance_has_correct_authentication
|
47
|
+
(@@instance/'instance/authentication').first.should_not == nil
|
48
|
+
(@@instance/'instance/authentication').first[:type].should == 'password'
|
49
|
+
(@@instance/'instance/authentication/login/username').first.text.should == 'root'
|
50
|
+
(@@instance/'instance/authentication/login/password').first.text.should_not == nil
|
51
|
+
(@@instance/'instance/authentication/login/password').first.text.should_not == ''
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_02_02_created_instance_has_correct_authentication
|
55
|
+
(@@instance2/'instance/authentication').first.should_not == nil
|
56
|
+
(@@instance2/'instance/authentication').first[:type].should == 'password'
|
57
|
+
(@@instance2/'instance/authentication/login/username').first.text.should == 'root'
|
58
|
+
(@@instance2/'instance/authentication/login/password').first.text.should_not == nil
|
59
|
+
(@@instance2/'instance/authentication/login/password').first.text.should_not == ''
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_03_01_created_instance_has_correct_addresses
|
63
|
+
(@@instance/'instance/public_addresses/address').length.should > 0
|
64
|
+
(@@instance/'instance/public_addresses/address').first.text.should_not == nil
|
65
|
+
(@@instance/'instance/public_addresses/address').first.text.should_not == ''
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_03_02_created_instance_has_correct_addresses
|
69
|
+
(@@instance2/'instance/public_addresses/address').length.should > 0
|
70
|
+
(@@instance2/'instance/public_addresses/address').first.text.should_not == nil
|
71
|
+
(@@instance2/'instance/public_addresses/address').first.text.should_not == ''
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_03_02_created_instance_has_correct_hardware_profile
|
75
|
+
(@@instance2/'instance/hardware_profile').length.should == 1
|
76
|
+
(@@instance2/'instance/hardware_profile').first[:id].should == "2"
|
77
|
+
(@@instance2/'instance/hardware_profile').first[:href].should_not == nil
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_04_01_created_instance_goes_to_running_state
|
81
|
+
20.times do |tick|
|
82
|
+
get_auth_url "/api;driver=rackspace/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
|
83
|
+
last_response.status.should_not == 500
|
84
|
+
state = (last_xml_response/'instance/state').first.text
|
85
|
+
break if state=='RUNNING'
|
86
|
+
sleep(5)
|
87
|
+
end
|
88
|
+
@@instance = last_xml_response
|
89
|
+
get_auth_url "/api;driver=rackspace/instances/#{(@@instance/'instance').first[:id]}"
|
90
|
+
last_response.status.should_not == 500
|
91
|
+
(last_xml_response/'instance/state').first.text.should == 'RUNNING'
|
92
|
+
(last_xml_response/'instance/actions/link[@rel="reboot"]').first.should_not == nil
|
93
|
+
(last_xml_response/'instance/actions/link[@rel="stop"]').first.should_not == nil
|
94
|
+
(last_xml_response/'instance/actions/link[@rel="create_image"]').first.should_not == nil
|
95
|
+
(last_xml_response/'instance/actions/link[@rel="run"]').first.should_not == nil
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_04_02_created_instance_goes_to_running_state
|
99
|
+
20.times do |tick|
|
100
|
+
get_auth_url "/api;driver=rackspace/instances/#{(@@instance2/'instance').first[:id]}", { :tick => tick}
|
101
|
+
last_response.status.should_not == 500
|
102
|
+
state = (last_xml_response/'instance/state').first.text
|
103
|
+
break if state=='RUNNING'
|
104
|
+
sleep(5)
|
105
|
+
end
|
106
|
+
@@instance2 = last_xml_response
|
107
|
+
get_auth_url "/api;driver=rackspace/instances/#{(@@instance2/'instance').first[:id]}"
|
108
|
+
last_response.status.should_not == 500
|
109
|
+
(last_xml_response/'instance/state').first.text.should == 'RUNNING'
|
110
|
+
(last_xml_response/'instance/actions/link[@rel="reboot"]').first.should_not == nil
|
111
|
+
(last_xml_response/'instance/actions/link[@rel="stop"]').first.should_not == nil
|
112
|
+
(last_xml_response/'instance/actions/link[@rel="create_image"]').first.should_not == nil
|
113
|
+
(last_xml_response/'instance/actions/link[@rel="run"]').first.should_not == nil
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_05_01_created_instance_can_be_rebooted
|
117
|
+
params = {
|
118
|
+
:'api[driver]' => 'rackspace',
|
119
|
+
}
|
120
|
+
post_url "/api/instances/#{(@@instance/'instance').first[:id]}/reboot", params
|
121
|
+
last_response.status.should == 200
|
122
|
+
20.times do |tick|
|
123
|
+
get_auth_url "/api;driver=rackspace/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
|
124
|
+
last_response.status.should_not == 500
|
125
|
+
state = (last_xml_response/'instance/state').first.text
|
126
|
+
break if state=='RUNNING'
|
127
|
+
sleep(5)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_06_01_created_instance_can_be_destroyed
|
132
|
+
params = {
|
133
|
+
:'api[driver]' => 'rackspace',
|
134
|
+
}
|
135
|
+
post_url "/api/instances/#{(@@instance/'instance').first[:id]}/stop", params
|
136
|
+
last_response.status.should == 200
|
137
|
+
20.times do |tick|
|
138
|
+
get_auth_url "/api;driver=rackspace/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
|
139
|
+
last_response.status.should_not == 500
|
140
|
+
break if last_response.status == 404
|
141
|
+
sleep(5)
|
142
|
+
end
|
143
|
+
last_response.status.should == 404
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_06_02_created_instance_can_be_destroyed
|
147
|
+
params = {
|
148
|
+
:'api[driver]' => 'rackspace',
|
149
|
+
}
|
150
|
+
post_url "/api/instances/#{(@@instance2/'instance').first[:id]}/stop", params, authenticate
|
151
|
+
last_response.status.should == 200
|
152
|
+
20.times do |tick|
|
153
|
+
get_auth_url "/api;driver=rackspace/instances/#{(@@instance2/'instance').first[:id]}", { :tick => tick}
|
154
|
+
last_response.status.should_not == 500
|
155
|
+
break if last_response.status == 404
|
156
|
+
sleep(5)
|
157
|
+
end
|
158
|
+
last_response.status.should == 404
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
|
4
|
+
module RackspaceTest
|
5
|
+
|
6
|
+
class RealmsTest < Test::Unit::TestCase
|
7
|
+
include Rack::Test::Methods
|
8
|
+
|
9
|
+
def app
|
10
|
+
Sinatra::Application
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_01_it_returns_realms
|
14
|
+
get_auth_url '/api;driver=rackspace/realms'
|
15
|
+
(last_xml_response/'realms/realm').length.should == 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_02_each_realm_has_a_name
|
19
|
+
get_auth_url '/api;driver=rackspace/realms'
|
20
|
+
(last_xml_response/'realms/realm').each do |profile|
|
21
|
+
(profile/'name').text.should_not == nil
|
22
|
+
(profile/'name').text.should_not == ''
|
23
|
+
(profile/'name').text.should == 'United States'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_03_it_returns_single_realm
|
28
|
+
get_auth_url '/api;driver=rackspace/realms/us'
|
29
|
+
(last_xml_response/'realm').first[:id].should == 'us'
|
30
|
+
(last_xml_response/'realm/name').first.text.should == 'United States'
|
31
|
+
(last_xml_response/'realm/state').first.text.should == 'AVAILABLE'
|
32
|
+
(last_xml_response/'realm/limit').first.text.should == ''
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
ENV['API_DRIVER'] = "rackspace"
|
2
|
+
ENV['API_USER'] = 'michalfojtik'
|
3
|
+
ENV['API_PASSWORD'] = '47de1170d57eb8f11dba2f6e7fd26838'
|
4
|
+
|
5
|
+
require 'vcr'
|
6
|
+
|
7
|
+
DeltacloudTestCommon::record!
|
8
|
+
|
9
|
+
VCR.config do |c|
|
10
|
+
c.cassette_library_dir = "#{File.dirname(__FILE__)}/../../../tests/drivers/rackspace/fixtures/"
|
11
|
+
c.stub_with :webmock
|
12
|
+
c.default_cassette_options = { :record => :none }
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
|
4
|
+
module RHEVMTest
|
5
|
+
|
6
|
+
class ApiTest < Test::Unit::TestCase
|
7
|
+
include Rack::Test::Methods
|
8
|
+
|
9
|
+
def app
|
10
|
+
Sinatra::Application
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_01_it_returns_entry_points
|
14
|
+
get_auth_url '/api;driver=rhevm?force_auth=1'
|
15
|
+
(last_xml_response/'/api').first[:driver].should == 'rhevm'
|
16
|
+
(last_xml_response/'/api/link').length.should > 0
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_02_it_has_rhevm_features
|
20
|
+
get_url '/api;driver=rhevm'
|
21
|
+
features = (last_xml_response/'/api/link[@rel="instances"]/feature').collect { |f| f[:name] }
|
22
|
+
features.include?('user_name').should == true
|
23
|
+
features.include?('hardware_profiles').should == true
|
24
|
+
features.length.should == 2
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_03_it_has_rhevm_collections
|
28
|
+
get_url '/api;driver=rhevm'
|
29
|
+
collections = (last_xml_response/'/api/link').collect { |f| f[:rel] }
|
30
|
+
collections.include?('instance_states').should == true
|
31
|
+
collections.include?('instances').should == true
|
32
|
+
collections.include?('images').should == true
|
33
|
+
collections.include?('realms').should == true
|
34
|
+
collections.include?('hardware_profiles').should == true
|
35
|
+
collections.length.should == 8
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
|
4
|
+
module RHEVMTest
|
5
|
+
|
6
|
+
class HardwareProfilesTest < Test::Unit::TestCase
|
7
|
+
include Rack::Test::Methods
|
8
|
+
|
9
|
+
def app
|
10
|
+
Sinatra::Application
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_01_it_returns_hardware_profiles
|
14
|
+
get_auth_url '/api;driver=rhevm/hardware_profiles'
|
15
|
+
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 2
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_02_each_hardware_profile_has_a_name
|
19
|
+
get_auth_url '/api;driver=rhevm/hardware_profiles'
|
20
|
+
(last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
|
21
|
+
(profile/'name').text.should_not == nil
|
22
|
+
(profile/'name').text.should_not == ''
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_03_each_hardware_profile_has_correct_properties
|
27
|
+
get_auth_url '/api;driver=rhevm/hardware_profiles'
|
28
|
+
(last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
|
29
|
+
(profile/'property[@name="architecture"]').first[:value].should == 'x86_64'
|
30
|
+
(profile/'property[@name="memory"]').first[:unit].should == 'MB'
|
31
|
+
(profile/'property[@name="memory"]').first[:kind].should == 'range'
|
32
|
+
(profile/'property[@name="storage"]').first[:unit].should == 'GB'
|
33
|
+
(profile/'property[@name="storage"]').first[:kind].should == 'range'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_04_it_returns_single_hardware_profile
|
38
|
+
get_auth_url '/api;driver=rhevm/hardware_profiles/DESKTOP'
|
39
|
+
(last_xml_response/'hardware_profile/name').first.text.should == 'DESKTOP'
|
40
|
+
(last_xml_response/'hardware_profile/property[@name="architecture"]').first[:value].should == 'x86_64'
|
41
|
+
(last_xml_response/'hardware_profile/property[@name="memory"]').first[:value].should == '512'
|
42
|
+
(last_xml_response/'hardware_profile/property[@name="storage"]').first[:value].should == '1'
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_05_it_filter_hardware_profiles
|
46
|
+
get_auth_url '/api;driver=rhevm/hardware_profiles?architecture=i386'
|
47
|
+
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 0
|
48
|
+
get_auth_url '/api;driver=rhevm/hardware_profiles?architecture=x86_64'
|
49
|
+
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 2
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
|
4
|
+
module RHEVMTest
|
5
|
+
|
6
|
+
class ImagesTest < Test::Unit::TestCase
|
7
|
+
include Rack::Test::Methods
|
8
|
+
|
9
|
+
def app
|
10
|
+
Sinatra::Application
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_01_it_returns_images
|
14
|
+
get_auth_url '/api;driver=rhevm/images'
|
15
|
+
(last_xml_response/'images/image').length.should > 0
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_02_each_image_has_correct_properties
|
19
|
+
get_auth_url '/api;driver=rhevm/images'
|
20
|
+
(last_xml_response/'images/image').each do |image|
|
21
|
+
(image/'name').should_not == nil
|
22
|
+
(image/'name').should_not == ''
|
23
|
+
(image/'description').should_not == nil
|
24
|
+
(image/'description').should_not == ''
|
25
|
+
(image/'architecture').should_not == nil
|
26
|
+
(image/'architecture').should_not == ''
|
27
|
+
(image/'state').text.should == 'OK'
|
28
|
+
(image/'owner_id').text.should == ENV['API_USER']
|
29
|
+
(image/'actions/link').length.should == 1
|
30
|
+
(image/'actions/link').first[:rel].should == 'create_instance'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_03_it_returns_single_image
|
35
|
+
get_auth_url '/api;driver=rhevm/images/bb2e79bd-fd73-46a1-b391-a390b1998f03'
|
36
|
+
(last_xml_response/'image').length.should == 1
|
37
|
+
(last_xml_response/'image/name').text.should == 'F14-Minimal-Srv'
|
38
|
+
(last_xml_response/'image/state').text.should == 'OK'
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|