deltacloud-core 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +176 -502
- data/Rakefile +21 -14
- data/deltacloud.rb +3 -0
- data/lib/deltacloud/base_driver.rb +12 -11
- data/lib/deltacloud/base_driver/base_driver.rb +22 -11
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +15 -12
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +16 -11
- data/lib/deltacloud/drivers/mock/data/images/img1.yml +3 -0
- data/lib/deltacloud/drivers/mock/data/images/img2.yml +3 -0
- data/lib/deltacloud/drivers/mock/data/images/img3.yml +3 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +16 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +9 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +9 -0
- data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap1.yml +4 -0
- data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap2.yml +4 -0
- data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap3.yml +4 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol1.yml +6 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol2.yml +6 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol3.yml +6 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +13 -11
- data/lib/deltacloud/drivers/rackspace/rackspace_client.rb +12 -11
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +12 -11
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +12 -11
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb +12 -11
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +14 -12
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +12 -11
- data/lib/deltacloud/helpers/application_helper.rb +64 -11
- data/lib/deltacloud/helpers/conversion_helper.rb +12 -11
- data/lib/deltacloud/method_serializer.rb +12 -11
- data/lib/deltacloud/models/base_model.rb +12 -11
- data/lib/deltacloud/models/image.rb +12 -11
- data/lib/deltacloud/models/instance.rb +13 -12
- data/lib/deltacloud/models/instance_profile.rb +12 -11
- data/lib/deltacloud/models/realm.rb +12 -11
- data/lib/deltacloud/models/storage_snapshot.rb +12 -11
- data/lib/deltacloud/models/storage_volume.rb +12 -11
- data/lib/drivers.rb +12 -0
- data/lib/sinatra/rabbit.rb +1 -0
- data/lib/sinatra/respond_to.rb +3 -0
- data/server.rb +40 -80
- data/tests/api_test.rb +37 -0
- data/tests/hardware_profiles_test.rb +120 -0
- data/tests/images_test.rb +95 -78
- data/tests/instance_states_test.rb +52 -0
- data/tests/instances_test.rb +193 -110
- data/tests/realms_test.rb +66 -44
- data/views/errors/not_found.html.haml +6 -0
- data/views/errors/not_found.xml.haml +2 -0
- data/views/hardware_profiles/index.xml.haml +1 -1
- data/views/hardware_profiles/show.xml.haml +3 -2
- data/views/images/index.xml.haml +4 -3
- data/views/images/show.xml.haml +2 -2
- data/views/instances/index.xml.haml +6 -8
- data/views/instances/show.xml.haml +9 -10
- data/views/realms/index.xml.haml +1 -3
- data/views/realms/show.xml.haml +4 -5
- data/views/storage_snapshots/index.xml.haml +3 -5
- data/views/storage_snapshots/show.xml.haml +2 -4
- data/views/storage_volumes/index.xml.haml +7 -7
- data/views/storage_volumes/show.xml.haml +2 -4
- metadata +156 -81
- data/tests/deltacloud_test.rb +0 -60
- data/tests/storage_snapshots_test.rb +0 -48
- data/tests/storage_volumes_test.rb +0 -48
data/tests/deltacloud_test.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'rack/test'
|
4
|
-
require 'base64'
|
5
|
-
require 'nokogiri'
|
6
|
-
require 'pp'
|
7
|
-
require 'sinatra'
|
8
|
-
|
9
|
-
ENV['API_DRIVER']='mock'
|
10
|
-
ENV['API_HOST']='localhost'
|
11
|
-
|
12
|
-
require 'server'
|
13
|
-
|
14
|
-
set :environment => :test
|
15
|
-
|
16
|
-
module DeltacloudTest
|
17
|
-
include Rack::Test::Methods
|
18
|
-
|
19
|
-
def app
|
20
|
-
Sinatra::Application
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_if_response_is_valid
|
24
|
-
get '/api/'+@collection+'.xml', @params, rack_headers
|
25
|
-
assert last_response.ok?
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_if_http_status_is_correct_with_wrong_credentials
|
29
|
-
return if ['realms'].include?(@collection)
|
30
|
-
wrong_header = rack_headers
|
31
|
-
wrong_header['HTTP_AUTHORIZATION'] = authorization('wronguser', 'wrongpassword')
|
32
|
-
get '/api/'+@collection+'.xml', @params, wrong_header
|
33
|
-
assert_equal 403, last_response.status
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_if_index_operation_proper_root_element
|
37
|
-
get '/api/'+@collection+'.xml', @params, rack_headers
|
38
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
39
|
-
assert_equal @collection.gsub('_', '-'), doc.root.name
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_html_response
|
43
|
-
get '/api/'+@collection+'.html', @params, rack_headers
|
44
|
-
doc = Nokogiri::HTML.parse(last_response.body)
|
45
|
-
assert_equal 'html', doc.root.name
|
46
|
-
end
|
47
|
-
|
48
|
-
def authorization(username, password)
|
49
|
-
"Basic " + Base64.encode64("#{username}:#{password}")
|
50
|
-
end
|
51
|
-
|
52
|
-
def rack_headers
|
53
|
-
return {
|
54
|
-
'HTTP_AUTHORIZATION' => authorization('mockuser', 'mockpassword'),
|
55
|
-
'SERVER_PORT' => '4040',
|
56
|
-
'Accept' => 'application/xml;q=1'
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'tests/deltacloud_test'
|
2
|
-
|
3
|
-
class StorageSnapshotsTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def initialize(*args)
|
6
|
-
@collection = 'storage_snapshots'
|
7
|
-
@operations = [:index, :show]
|
8
|
-
@options = [:id, :architecture, :memory, :storage]
|
9
|
-
@params = {}
|
10
|
-
super(*args)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_if_storage_snapshots_are_not_empty
|
14
|
-
get '/api/storage_snapshots.xml', @params, rack_headers
|
15
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
16
|
-
assert_not_equal 0, doc.xpath('/storage-snapshots/storage-snapshot').size
|
17
|
-
end
|
18
|
-
|
19
|
-
[:id, :created, :state, :'storage-volume'].each do |option|
|
20
|
-
method_name = :"test_if_storage_snapshots_index_contain_#{option}"
|
21
|
-
send :define_method, method_name do
|
22
|
-
get '/api/storage_snapshots.xml', @params, rack_headers
|
23
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
24
|
-
storage_volume = doc.xpath('/storage-snapshots/storage-snapshot[1]').first
|
25
|
-
assert_not_nil storage_volume.xpath(option.to_s).first
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
[:id, :created, :state, :'storage-volume'].each do |option|
|
30
|
-
method_name = :"test_if_storage_volume_show_contain_#{option}"
|
31
|
-
send :define_method, method_name do
|
32
|
-
get '/api/storage_snapshots/snap3.xml', @params, rack_headers
|
33
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
34
|
-
storage_volume = doc.xpath('/storage-snapshot').first
|
35
|
-
assert_not_nil storage_volume.xpath(option.to_s).first
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_storage_snapshots_filtering_by_id
|
40
|
-
get '/api/storage_snapshots.xml', { :id => 'snap3'}, rack_headers
|
41
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
42
|
-
assert_equal 1, doc.xpath('/storage-snapshots/storage-snapshot').size
|
43
|
-
assert_equal 'snap3', doc.xpath('/storage-snapshots/storage-snapshot/id').first.text
|
44
|
-
end
|
45
|
-
|
46
|
-
include DeltacloudTest
|
47
|
-
|
48
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'tests/deltacloud_test'
|
2
|
-
|
3
|
-
class StorageVolumesTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def initialize(*args)
|
6
|
-
@collection = 'storage_volumes'
|
7
|
-
@operations = [:index, :show]
|
8
|
-
@options = [:id, :architecture, :memory, :storage]
|
9
|
-
@params = {}
|
10
|
-
super(*args)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_if_storage_volumes_are_not_empty
|
14
|
-
get '/api/storage_volumes.xml', @params, rack_headers
|
15
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
16
|
-
assert_not_equal 0, doc.xpath('/storage-volumes/storage-volume').size
|
17
|
-
end
|
18
|
-
|
19
|
-
[:id, :created, :capacity, :device, :state].each do |option|
|
20
|
-
method_name = :"test_if_storage_volumes_index_contain_#{option}"
|
21
|
-
send :define_method, method_name do
|
22
|
-
get '/api/storage_volumes.xml', @params, rack_headers
|
23
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
24
|
-
storage_volume = doc.xpath('/storage-volumes/storage-volume[1]').first
|
25
|
-
assert_not_nil storage_volume.xpath(option.to_s).first
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
[:id, :created, :capacity, :device, :state].each do |option|
|
30
|
-
method_name = :"test_if_storage_volume_show_contain_#{option}"
|
31
|
-
send :define_method, method_name do
|
32
|
-
get '/api/storage_volumes/vol2.xml', @params, rack_headers
|
33
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
34
|
-
storage_volume = doc.xpath('/storage-volume').first
|
35
|
-
assert_not_nil storage_volume.xpath(option.to_s).first
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_storage_volumes_filtering_by_id
|
40
|
-
get '/api/storage_volumes.xml', { :id => 'vol2'}, rack_headers
|
41
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
42
|
-
assert_equal 1, doc.xpath('/storage-volumes/storage-volume').size
|
43
|
-
assert_equal 'vol2', doc.xpath('/storage-volumes/storage-volume/id').first.text
|
44
|
-
end
|
45
|
-
|
46
|
-
include DeltacloudTest
|
47
|
-
|
48
|
-
end
|