deltacloud-core 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +63 -7
- data/bin/deltacloudd +29 -17
- data/config.ru +5 -3
- data/config/drivers/ec2.yaml +9 -0
- data/config/drivers/google.yaml +3 -0
- data/config/drivers/openstack.yaml +3 -0
- data/deltacloud-core.gemspec +1 -1
- data/lib/cimi/dependencies.rb +62 -0
- data/lib/cimi/helpers/cimi_helper.rb +50 -0
- data/lib/cimi/model.rb +52 -0
- data/lib/cimi/model/action.rb +24 -0
- data/lib/cimi/model/base.rb +249 -0
- data/lib/cimi/model/cloud_entry_point.rb +48 -0
- data/lib/cimi/model/entity_metadata.rb +83 -0
- data/lib/cimi/model/entity_metadata_collection.rb +31 -0
- data/lib/cimi/model/errors.rb +40 -0
- data/lib/cimi/model/machine.rb +227 -0
- data/lib/cimi/model/machine_admin.rb +59 -0
- data/lib/cimi/model/machine_admin_collection.rb +34 -0
- data/lib/cimi/model/machine_collection.rb +34 -0
- data/lib/cimi/model/machine_configuration.rb +67 -0
- data/lib/cimi/model/machine_configuration_collection.rb +34 -0
- data/lib/cimi/model/machine_image.rb +46 -0
- data/lib/cimi/model/machine_image_collection.rb +34 -0
- data/lib/cimi/model/machine_template.rb +41 -0
- data/lib/cimi/model/machine_template_collection.rb +34 -0
- data/lib/cimi/model/network.rb +69 -0
- data/lib/cimi/model/network_collection.rb +34 -0
- data/lib/cimi/model/network_configuration.rb +50 -0
- data/lib/cimi/model/network_configuration_collection.rb +34 -0
- data/lib/cimi/model/network_template.rb +26 -0
- data/lib/cimi/model/schema.rb +277 -0
- data/lib/cimi/model/volume.rb +103 -0
- data/lib/cimi/model/volume_collection.rb +34 -0
- data/lib/cimi/model/volume_configuration.rb +60 -0
- data/lib/cimi/model/volume_configuration_collection.rb +34 -0
- data/lib/cimi/model/volume_image.rb +49 -0
- data/lib/cimi/model/volume_image_collection.rb +34 -0
- data/lib/cimi/model/volume_template.rb +23 -0
- data/lib/cimi/model/volume_template_collection.rb +34 -0
- data/lib/cimi/server.rb +575 -0
- data/lib/deltacloud/base_driver/base_driver.rb +11 -1
- data/lib/deltacloud/core_ext.rb +2 -0
- data/lib/deltacloud/core_ext/array.rb +25 -0
- data/lib/deltacloud/core_ext/hash.rb +7 -0
- data/lib/deltacloud/core_ext/proc.rb +31 -0
- data/lib/deltacloud/core_ext/string.rb +15 -0
- data/lib/deltacloud/drivers/condor/condor_driver.rb +2 -1
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +32 -10
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +1 -1
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +1 -1
- data/lib/deltacloud/drivers/google/google_driver.rb +233 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +7 -2
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +7 -2
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +7 -2
- data/lib/deltacloud/drivers/mock/mock_client.rb +17 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +82 -8
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +1 -1
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +47 -0
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +8 -8
- data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +122 -49
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +42 -22
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +1 -1
- data/lib/deltacloud/drivers/sbc/sbc_driver.rb +3 -2
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +2 -2
- data/lib/deltacloud/drivers/vsphere/vsphere_client.rb +25 -4
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +35 -12
- data/lib/deltacloud/hardware_profile.rb +34 -10
- data/lib/deltacloud/helpers/application_helper.rb +3 -28
- data/lib/deltacloud/helpers/blob_stream.rb +2 -1
- data/lib/deltacloud/models.rb +2 -0
- data/lib/deltacloud/models/bucket.rb +1 -1
- data/lib/deltacloud/models/image.rb +1 -1
- data/lib/deltacloud/models/instance.rb +2 -1
- data/lib/deltacloud/models/instance_address.rb +56 -0
- data/lib/deltacloud/models/provider.rb +27 -0
- data/{server.rb → lib/deltacloud/server.rb} +72 -14
- data/lib/deltacloud/validation.rb +31 -10
- data/lib/sinatra/rabbit.rb +34 -26
- data/lib/sinatra/rack_accept.rb +5 -5
- data/lib/sinatra/rack_matrix_params.rb +6 -2
- data/lib/sinatra/rack_syslog.rb +3 -3
- data/lib/sinatra/static_assets.rb +1 -1
- data/lib/sinatra/url_for.rb +1 -7
- data/public/images/bread-bg.png +0 -0
- data/public/images/logo-wide.png +0 -0
- data/public/images/topbar-bg.png +0 -0
- data/public/javascripts/application.js +5 -0
- data/public/javascripts/cmwgapp.js +249 -0
- data/public/javascripts/jquery-1.4.2.min.js +154 -0
- data/public/javascripts/jquery.mobile-1.0rc1.min.js +170 -0
- data/public/stylesheets/images/icons-18-black.png +0 -0
- data/public/stylesheets/images/icons-18-white.png +0 -0
- data/public/stylesheets/images/icons-36-black.png +0 -0
- data/public/stylesheets/images/icons-36-white.png +0 -0
- data/public/stylesheets/jquery.mobile-1.0rc1.min.css +12 -0
- data/public/stylesheets/new.css +4 -0
- data/support/fedora/deltacloud-core.init +20 -13
- data/tests/cimi/features/step_definitions/common_steps.rb +59 -0
- data/tests/cimi/features/step_definitions/machine_images_steps.rb +0 -0
- data/tests/cimi/features/step_definitions/machines_steps.rb +99 -0
- data/tests/cimi/features/step_definitions/volumes_steps.rb +115 -0
- data/tests/cimi/features/support/env.rb +53 -0
- data/tests/common.rb +89 -11
- data/tests/core_ext/string.rb +31 -0
- data/tests/drivers/google/api_test.rb +35 -0
- data/tests/drivers/google/buckets_test.rb +116 -0
- data/tests/drivers/google/setup.rb +38 -0
- data/tests/drivers/mock/instances_test.rb +20 -5
- data/tests/drivers/openstack/api_test.rb +41 -0
- data/tests/drivers/openstack/hardware_profiles_test.rb +53 -0
- data/tests/drivers/openstack/images_test.rb +40 -0
- data/tests/drivers/openstack/instances_test.rb +163 -0
- data/tests/drivers/openstack/realms_test.rb +36 -0
- data/tests/drivers/openstack/setup.rb +20 -0
- data/tests/drivers/rackspace/buckets_test.rb +145 -0
- data/tests/drivers/rackspace/setup.rb +3 -3
- data/tests/drivers/rhevm/api_test.rb +1 -1
- data/tests/drivers/rhevm/images_test.rb +2 -2
- data/tests/drivers/rhevm/instances_test.rb +10 -12
- data/tests/drivers/rhevm/realms_test.rb +4 -4
- data/tests/drivers/rhevm/setup.rb +3 -3
- data/tests/rabbit_test.rb +1 -1
- data/views/api/show.html.haml +13 -0
- data/views/cimi/cloudEntryPoint/index.html.haml +5 -0
- data/views/cimi/cloudEntryPoint/index.xml.haml +9 -0
- data/views/cimi/collection/index.html.haml +45 -0
- data/views/cimi/collection/response.xml.haml +3 -0
- data/views/cimi/error.html.haml +31 -0
- data/views/cimi/errors/400.html.haml +41 -0
- data/views/cimi/errors/400.xml.haml +3 -0
- data/views/cimi/errors/401.html.haml +41 -0
- data/views/cimi/errors/401.xml.haml +2 -0
- data/views/cimi/errors/403.html.haml +42 -0
- data/views/cimi/errors/403.xml.haml +2 -0
- data/views/cimi/errors/404.html.haml +29 -0
- data/views/cimi/errors/404.xml.haml +2 -0
- data/views/cimi/errors/405.html.haml +29 -0
- data/views/cimi/errors/405.xml.haml +5 -0
- data/views/cimi/errors/500.html.haml +43 -0
- data/views/cimi/errors/500.xml.haml +6 -0
- data/views/cimi/errors/502.html.haml +43 -0
- data/views/cimi/errors/502.xml.haml +7 -0
- data/views/cimi/errors/backend_capability_failure.html.haml +29 -0
- data/views/cimi/layout.html.haml +32 -0
- data/views/cimi/machine_configurations/show.html.haml +159 -0
- data/views/cimi/machine_configurations/show.xml.haml +27 -0
- data/views/cimi/machine_images/show.html.haml +79 -0
- data/views/cimi/machine_images/show.xml.haml +17 -0
- data/views/cimi/machines/show.html.haml +177 -0
- data/views/cimi/machines/show.xml.haml +28 -0
- data/views/cimi/volumes/show.html.haml +68 -0
- data/views/cimi/volumes/show.xml.haml +17 -0
- data/views/drivers/show.html.haml +10 -5
- data/views/drivers/show.xml.haml +9 -4
- data/views/error.html.haml +2 -2
- data/views/errors/500.xml.haml +7 -1
- data/views/instances/index.html.haml +1 -1
- data/views/instances/new.html.haml +19 -16
- data/views/instances/show.html.haml +7 -2
- data/views/instances/show.xml.haml +8 -7
- data/views/layout.html.haml +2 -2
- data/views/storage_volumes/show.html.haml +1 -1
- metadata +296 -204
- data/public/javascripts/jquery.mobile-1.0b1.min.js +0 -146
- data/public/stylesheets/jquery.mobile-1.0b1.min.css +0 -8
@@ -0,0 +1,41 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
|
4
|
+
module OpenstackTest
|
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=openstack/?force_auth=1'
|
15
|
+
(last_xml_response/'/api').first[:driver].should == 'openstack'
|
16
|
+
(last_xml_response/'/api/link').length.should > 0
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_02_it_has_openstack_features
|
20
|
+
get_url '/api;driver=openstack'
|
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_openstack_collections
|
29
|
+
get_url '/api;driver=openstack'
|
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 OpenstackTest
|
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=openstack/hardware_profiles'
|
15
|
+
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 5
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_02_each_hardware_profile_has_a_name
|
19
|
+
get_auth_url '/api;driver=openstack/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=openstack/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=openstack/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 == '512'
|
42
|
+
(last_xml_response/'hardware_profile/property[@name="storage"]').first[:value].should == '0'
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_05_it_filter_hardware_profiles
|
46
|
+
get_auth_url '/api;driver=openstack/hardware_profiles?architecture=i386'
|
47
|
+
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 0
|
48
|
+
get_auth_url '/api;driver=openstack/hardware_profiles?architecture=x86_64'
|
49
|
+
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 5
|
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 OpenstackTest
|
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=openstack/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=openstack/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=openstack/images/1'
|
36
|
+
(last_xml_response/'image').length.should == 1
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
|
4
|
+
module OpenstackTest
|
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 => '4',
|
16
|
+
:'api[driver]' => 'openstack',
|
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 => '4',
|
32
|
+
:hwp_id => '2',
|
33
|
+
:'api[driver]' => 'openstack',
|
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
|
+
=begin
|
62
|
+
TODO: Disabled since our testing setup doesn't return IP addresses yet ;-)
|
63
|
+
def test_03_01_created_instance_has_correct_addresses
|
64
|
+
(@@instance/'instance/public_addresses/address').length.should > 0
|
65
|
+
(@@instance/'instance/public_addresses/address').first.text.should_not == nil
|
66
|
+
(@@instance/'instance/public_addresses/address').first.text.should_not == ''
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_03_02_created_instance_has_correct_addresses
|
70
|
+
(@@instance2/'instance/public_addresses/address').length.should > 0
|
71
|
+
(@@instance2/'instance/public_addresses/address').first.text.should_not == nil
|
72
|
+
(@@instance2/'instance/public_addresses/address').first.text.should_not == ''
|
73
|
+
end
|
74
|
+
=end
|
75
|
+
|
76
|
+
def test_03_02_created_instance_has_correct_hardware_profile
|
77
|
+
(@@instance2/'instance/hardware_profile').length.should == 1
|
78
|
+
(@@instance2/'instance/hardware_profile').first[:id].should == "2"
|
79
|
+
(@@instance2/'instance/hardware_profile').first[:href].should_not == nil
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_04_01_created_instance_goes_to_running_state
|
83
|
+
20.times do |tick|
|
84
|
+
get_auth_url "/api;driver=openstack/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
|
85
|
+
last_response.status.should_not == 500
|
86
|
+
state = (last_xml_response/'instance/state').first.text
|
87
|
+
break if state=='RUNNING'
|
88
|
+
sleep(5)
|
89
|
+
end
|
90
|
+
@@instance = last_xml_response
|
91
|
+
get_auth_url "/api;driver=openstack/instances/#{(@@instance/'instance').first[:id]}"
|
92
|
+
last_response.status.should_not == 500
|
93
|
+
(last_xml_response/'instance/state').first.text.should == 'RUNNING'
|
94
|
+
(last_xml_response/'instance/actions/link[@rel="reboot"]').first.should_not == nil
|
95
|
+
(last_xml_response/'instance/actions/link[@rel="stop"]').first.should_not == nil
|
96
|
+
(last_xml_response/'instance/actions/link[@rel="create_image"]').first.should_not == nil
|
97
|
+
(last_xml_response/'instance/actions/link[@rel="run"]').first.should_not == nil
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_04_02_created_instance_goes_to_running_state
|
101
|
+
20.times do |tick|
|
102
|
+
get_auth_url "/api;driver=openstack/instances/#{(@@instance2/'instance').first[:id]}", { :tick => tick}
|
103
|
+
last_response.status.should_not == 500
|
104
|
+
state = (last_xml_response/'instance/state').first.text
|
105
|
+
break if state=='RUNNING'
|
106
|
+
sleep(5)
|
107
|
+
end
|
108
|
+
@@instance2 = last_xml_response
|
109
|
+
get_auth_url "/api;driver=openstack/instances/#{(@@instance2/'instance').first[:id]}"
|
110
|
+
last_response.status.should_not == 500
|
111
|
+
(last_xml_response/'instance/state').first.text.should == 'RUNNING'
|
112
|
+
(last_xml_response/'instance/actions/link[@rel="reboot"]').first.should_not == nil
|
113
|
+
(last_xml_response/'instance/actions/link[@rel="stop"]').first.should_not == nil
|
114
|
+
(last_xml_response/'instance/actions/link[@rel="create_image"]').first.should_not == nil
|
115
|
+
(last_xml_response/'instance/actions/link[@rel="run"]').first.should_not == nil
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_05_01_created_instance_can_be_rebooted
|
119
|
+
params = {
|
120
|
+
:'api[driver]' => 'openstack',
|
121
|
+
}
|
122
|
+
post_url "/api/instances/#{(@@instance/'instance').first[:id]}/reboot", params
|
123
|
+
last_response.status.should == 200
|
124
|
+
20.times do |tick|
|
125
|
+
get_auth_url "/api;driver=openstack/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
|
126
|
+
last_response.status.should_not == 500
|
127
|
+
state = (last_xml_response/'instance/state').first.text
|
128
|
+
break if state=='RUNNING'
|
129
|
+
sleep(5)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_06_01_created_instance_can_be_destroyed
|
134
|
+
params = {
|
135
|
+
:'api[driver]' => 'openstack',
|
136
|
+
}
|
137
|
+
post_url "/api/instances/#{(@@instance/'instance').first[:id]}/stop", params
|
138
|
+
last_response.status.should == 200
|
139
|
+
20.times do |tick|
|
140
|
+
get_auth_url "/api;driver=openstack/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
|
141
|
+
last_response.status.should_not == 500
|
142
|
+
break if last_response.status == 404
|
143
|
+
sleep(5)
|
144
|
+
end
|
145
|
+
last_response.status.should == 404
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_06_02_created_instance_can_be_destroyed
|
149
|
+
params = {
|
150
|
+
:'api[driver]' => 'openstack',
|
151
|
+
}
|
152
|
+
post_url "/api/instances/#{(@@instance2/'instance').first[:id]}/stop", params, authenticate
|
153
|
+
last_response.status.should == 200
|
154
|
+
20.times do |tick|
|
155
|
+
get_auth_url "/api;driver=openstack/instances/#{(@@instance2/'instance').first[:id]}", { :tick => tick}
|
156
|
+
last_response.status.should_not == 500
|
157
|
+
break if last_response.status == 404
|
158
|
+
sleep(5)
|
159
|
+
end
|
160
|
+
last_response.status.should == 404
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
|
4
|
+
module OpenstackTest
|
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=openstack/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=openstack/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=openstack/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,20 @@
|
|
1
|
+
ENV.delete 'API_VERBOSE'
|
2
|
+
ENV['API_DRIVER'] = "openstack"
|
3
|
+
ENV['API_USER'] = 'mfojtik'
|
4
|
+
ENV['API_PASSWORD'] = 'test'
|
5
|
+
ENV['API_PROVIDER'] = 'http://mfojtik-2.brq.redhat.com:8774/auth/1.1'
|
6
|
+
|
7
|
+
require 'vcr'
|
8
|
+
DeltacloudTestCommon::record!
|
9
|
+
|
10
|
+
VCR.config do |c|
|
11
|
+
c.cassette_library_dir = "#{File.dirname(__FILE__)}/../../../tests/drivers/openstack/fixtures/"
|
12
|
+
c.stub_with :webmock
|
13
|
+
c.default_cassette_options = { :record => :new_episodes }
|
14
|
+
end
|
15
|
+
|
16
|
+
class WebMock::Config
|
17
|
+
def net_http_connect_on_start
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/common'
|
3
|
+
#require 'webmock/test_unit'
|
4
|
+
module RackspaceTest
|
5
|
+
|
6
|
+
class BucketsTest < Test::Unit::TestCase
|
7
|
+
include Rack::Test::Methods
|
8
|
+
|
9
|
+
def app
|
10
|
+
Sinatra::Application
|
11
|
+
end
|
12
|
+
|
13
|
+
@@created_bucket_name="testbucki2rpux3wdelme"
|
14
|
+
@@created_blob_name="testblobk1ds91kVdelme"
|
15
|
+
@@created_blob_local_file="#{File.dirname(__FILE__)}/fixtures/deltacloud_blob_test.png"
|
16
|
+
|
17
|
+
def test_01_it_can_create_new_bucket
|
18
|
+
params = {
|
19
|
+
:name => @@created_bucket_name,
|
20
|
+
:'api[driver]' => 'rackspace'
|
21
|
+
}
|
22
|
+
post_url '/api/buckets', params
|
23
|
+
last_response.status.should == 201 # Created
|
24
|
+
bucket = last_xml_response
|
25
|
+
check_bucket_basics(bucket)
|
26
|
+
(bucket/'bucket/size').first.text.should == "0"
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_02_it_can_post_new_blob
|
30
|
+
temp_file=File.open(@@created_blob_local_file)
|
31
|
+
params = {
|
32
|
+
'blob_id' => @@created_blob_name,
|
33
|
+
:meta_params=>"2",
|
34
|
+
:meta_name1=>"Author",
|
35
|
+
:meta_value1=>"deltacloud",
|
36
|
+
:meta_name2=>"foo",
|
37
|
+
:meta_value2=>"bar",
|
38
|
+
:'api[driver]' => 'rackspace'
|
39
|
+
}
|
40
|
+
uri="/api/buckets/#{@@created_bucket_name}"
|
41
|
+
vcr_cassette = "post-"+Digest::SHA1.hexdigest("#{uri}-#{params.sort_by {|k,v| k.to_s}}")
|
42
|
+
params.merge!({'blob_data' => Rack::Test::UploadedFile.new(temp_file.path, "text/html")})
|
43
|
+
post_url uri, params, {'vcr_cassette'=>vcr_cassette}
|
44
|
+
last_response.status.should == 200
|
45
|
+
blob= last_xml_response
|
46
|
+
check_blob_basics(blob)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_03_it_can_retrieve_named_bucket_details
|
50
|
+
params = {
|
51
|
+
:'api[driver]' => 'rackspace'
|
52
|
+
}
|
53
|
+
get_url "/api/buckets/#{@@created_bucket_name}", params
|
54
|
+
last_response.status.should == 200
|
55
|
+
bucket = last_xml_response
|
56
|
+
check_bucket_basics(bucket)
|
57
|
+
(bucket/'bucket/size').first.text.should == "1" #assuming blob created succesfully right?
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_04_it_can_retrieve_named_blob_details
|
61
|
+
params = {
|
62
|
+
:'api[driver]' => 'rackspace'
|
63
|
+
}
|
64
|
+
get_url "/api/buckets/#{@@created_bucket_name}/#{@@created_blob_name}", params
|
65
|
+
last_response.status.should == 200
|
66
|
+
blob = last_xml_response
|
67
|
+
check_blob_basics(blob)
|
68
|
+
check_blob_metadata(blob, {"author"=>"deltacloud", "foo"=>"bar"})
|
69
|
+
end
|
70
|
+
|
71
|
+
# def test_05_it_can_retrieve_blob_metadata
|
72
|
+
# params = {
|
73
|
+
# :'api[driver]' => 'rackspace'
|
74
|
+
# }
|
75
|
+
# head_url "/api/buckets/#{@@created_bucket_name}/#{@@created_blob_name}", params
|
76
|
+
# last_response.status.should == 204
|
77
|
+
#debugger
|
78
|
+
# blob = last_xml_response
|
79
|
+
# check_blob_basics(blob)
|
80
|
+
# check_blob_metadata(blob, {"author"=>"deltacloud", "foo"=>"bar"})
|
81
|
+
|
82
|
+
# end
|
83
|
+
|
84
|
+
def test_06_it_can_update_blob_metadata
|
85
|
+
params = {
|
86
|
+
:'api[driver]' => 'rackspace'
|
87
|
+
}
|
88
|
+
new_meta = {"X-Deltacloud-Blobmeta-author" => "ApacheDeltacloud", "X-Deltacloud-Blobmeta-oof" => "rab"}
|
89
|
+
new_meta.each_pair do |k,v|
|
90
|
+
header k, v
|
91
|
+
end
|
92
|
+
post_url "/api/buckets/#{@@created_bucket_name}/#{@@created_blob_name}", params
|
93
|
+
last_response.status.should == 204
|
94
|
+
new_meta.each_pair do |k,v|
|
95
|
+
(last_response.headers[k]==v).should == true
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_07_it_can_delete_blob
|
100
|
+
params = {
|
101
|
+
:'api[driver]' => 'rackspace'
|
102
|
+
}
|
103
|
+
delete_url "/api/buckets/#{@@created_bucket_name}/#{@@created_blob_name}", params
|
104
|
+
last_response.status.should == 204
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_08_it_can_delete_bucket
|
108
|
+
params = {
|
109
|
+
:'api[driver]' => 'rackspace'
|
110
|
+
}
|
111
|
+
delete_url "/api/buckets/#{@@created_bucket_name}", params
|
112
|
+
last_response.status.should == 204
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
|
117
|
+
def check_bucket_basics(bucket)
|
118
|
+
(bucket/'bucket/name').first.text.should == @@created_bucket_name
|
119
|
+
(bucket/'bucket').attribute("id").text.should == @@created_bucket_name
|
120
|
+
(bucket/'bucket').length.should > 0
|
121
|
+
(bucket/'bucket/name').first.text.should_not == nil
|
122
|
+
(bucket/'bucket').attribute("href").text.should_not == nil
|
123
|
+
end
|
124
|
+
|
125
|
+
def check_blob_basics(blob)
|
126
|
+
(blob/'blob').length.should == 1
|
127
|
+
(blob/'blob').attribute("id").text.should_not == nil
|
128
|
+
(blob/'blob').attribute("href").text.should_not==nil
|
129
|
+
(blob/'blob/bucket').text.should_not == nil
|
130
|
+
(blob/'blob/content_length').text.should_not == nil
|
131
|
+
(blob/'blob/content_type').text.should_not == nil
|
132
|
+
(blob/'blob').attribute("id").text.should == @@created_blob_name
|
133
|
+
(blob/'blob/bucket').text.should == @@created_bucket_name
|
134
|
+
(blob/'blob/content_length').text.to_i.should == File.size(@@created_blob_local_file)
|
135
|
+
end
|
136
|
+
|
137
|
+
def check_blob_metadata(blob, metadata_hash)
|
138
|
+
(0.. (((blob/'blob/user_metadata').first).elements.size - 1) ).each do |i|
|
139
|
+
metadata_hash.has_key?(((blob/'blob/user_metadata').first).elements[i].attribute("key").value).should == true
|
140
|
+
metadata_hash.has_value?(((blob/'blob/user_metadata').first).elements[i].children[1].text).should == true
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
end
|