bbrowning-deltacloud-core 0.0.1.1 → 0.0.3.1
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/base_driver.rb +22 -11
- data/lib/deltacloud/base_driver.rb +12 -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/lib/sinatra/url_for.rb +3 -4
- data/server.rb +40 -80
- data/{torquebox-ec2-config.ru → support/torquebox/torquebox-ec2-config.ru} +0 -0
- 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 +37 -39
- 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/instances_test.rb
CHANGED
@@ -1,136 +1,219 @@
|
|
1
|
-
require 'tests/
|
1
|
+
require 'tests/common'
|
2
2
|
|
3
|
-
|
3
|
+
module DeltacloudUnitTest
|
4
|
+
class InstancesTest < Test::Unit::TestCase
|
5
|
+
include Rack::Test::Methods
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@options = [:id, :architecture, :memory, :storage]
|
9
|
-
@params = {}
|
10
|
-
self.temp_inst_id = 'inst2'
|
11
|
-
super(*args)
|
12
|
-
end
|
13
|
-
|
14
|
-
attr_accessor :temp_inst_id
|
15
|
-
|
16
|
-
def test_if_instances_are_not_empty
|
17
|
-
get '/api/instances.xml', @params, rack_headers
|
18
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
19
|
-
assert_not_equal 0, doc.xpath('/instances/instance').size
|
20
|
-
end
|
7
|
+
def app
|
8
|
+
Sinatra::Application
|
9
|
+
end
|
21
10
|
|
22
|
-
|
23
|
-
|
24
|
-
send :define_method, method_name do
|
25
|
-
get '/api/instances.xml', @params, rack_headers
|
26
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
27
|
-
instance = doc.xpath('/instances/instance[1]').first
|
28
|
-
assert_not_nil instance.xpath(option.to_s).first
|
11
|
+
def test_it_require_authentication
|
12
|
+
require_authentication?('/api/instances').should == true
|
29
13
|
end
|
30
|
-
end
|
31
14
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
get '/api/instances/inst1.xml', @params, rack_headers
|
36
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
37
|
-
instance = doc.xpath('/instance').first
|
38
|
-
assert_not_nil instance.xpath(option.to_s).first
|
15
|
+
def test_it_returns_instances
|
16
|
+
do_xml_request '/api/instances', {}, true
|
17
|
+
(last_xml_response/'instances/instance').map.size.should > 0
|
39
18
|
end
|
40
|
-
end
|
41
19
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
20
|
+
def test_it_has_correct_attributes_set
|
21
|
+
do_xml_request '/api/images', {}, true
|
22
|
+
(last_xml_response/'images/image').each do |image|
|
23
|
+
image.attributes.keys.sort.should == [ 'href', 'id' ]
|
24
|
+
end
|
25
|
+
end
|
48
26
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
27
|
+
def test_it_has_unique_ids
|
28
|
+
do_xml_request '/api/instances', {}, true
|
29
|
+
ids = []
|
30
|
+
(last_xml_response/'instances/instance').each do |image|
|
31
|
+
ids << image['id'].to_s
|
32
|
+
end
|
33
|
+
ids.sort.should == ids.sort.uniq
|
54
34
|
end
|
55
|
-
end
|
56
35
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
36
|
+
def test_inst1_has_correct_attributes
|
37
|
+
do_xml_request '/api/instances', {}, true
|
38
|
+
instance = (last_xml_response/'instances/instance[@id="inst1"]')
|
39
|
+
test_instance_attributes(instance)
|
40
|
+
end
|
62
41
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
42
|
+
def test_it_returns_valid_realm
|
43
|
+
do_xml_request '/api/instances/inst1', {}, true
|
44
|
+
instance = (last_xml_response/'instance')
|
45
|
+
test_instance_attributes(instance)
|
46
|
+
end
|
68
47
|
|
69
|
-
|
70
|
-
|
48
|
+
def test_it_responses_to_json
|
49
|
+
do_request '/api/instances', {}, true, { :format => :json }
|
50
|
+
JSON::parse(last_response.body).class.should == Hash
|
51
|
+
JSON::parse(last_response.body)['instances'].class.should == Array
|
71
52
|
|
72
|
-
|
53
|
+
do_request '/api/instances/inst1', {}, true, { :format => :json }
|
54
|
+
last_response.status.should == 200
|
55
|
+
JSON::parse(last_response.body).class.should == Hash
|
56
|
+
JSON::parse(last_response.body)['instance'].class.should == Hash
|
57
|
+
end
|
73
58
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
59
|
+
def test_it_responses_to_html
|
60
|
+
do_request '/api/instances', {}, true, { :format => :html }
|
61
|
+
last_response.status.should == 200
|
62
|
+
Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
|
79
63
|
|
80
|
-
|
64
|
+
do_request '/api/instances/inst1', {}, true, { :format => :html }
|
65
|
+
last_response.status.should == 200
|
66
|
+
Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
|
67
|
+
end
|
81
68
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
69
|
+
def test_it_create_a_new_instance_using_image_id
|
70
|
+
params = {
|
71
|
+
:image_id => 'img1'
|
72
|
+
}
|
73
|
+
post '/api/instances', params, authenticate(:format => :xml)
|
74
|
+
last_response.status.should == 302
|
75
|
+
last_response.headers['Location'].should_not == nil
|
76
|
+
do_xml_request last_response.headers['Location'], {}, true
|
77
|
+
(last_xml_response/'instance/name').should_not == nil
|
78
|
+
add_created_instance (last_xml_response/'instance').first['id']
|
79
|
+
test_instance_attributes(last_xml_response/'instance')
|
80
|
+
end
|
87
81
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
82
|
+
def test_it_create_a_new_instance_using_image_id_and_name
|
83
|
+
params = {
|
84
|
+
:image_id => 'img1',
|
85
|
+
:name => "unit_test_instance1"
|
86
|
+
}
|
87
|
+
post '/api/instances', params, authenticate(:format => :xml)
|
88
|
+
last_response.status.should == 302
|
89
|
+
last_response.headers['Location'].should_not == nil
|
90
|
+
do_xml_request last_response.headers['Location'], {}, true
|
91
|
+
(last_xml_response/'instance/name').text.should == 'unit_test_instance1'
|
92
|
+
add_created_instance (last_xml_response/'instance').first['id']
|
93
|
+
test_instance_attributes(last_xml_response/'instance')
|
94
|
+
end
|
94
95
|
|
95
|
-
|
96
|
+
def test_it_create_a_new_instance_using_image_id_and_name_and_hwp
|
97
|
+
params = {
|
98
|
+
:image_id => 'img1',
|
99
|
+
:name => "unit_test_instance1",
|
100
|
+
:hwp_id => "m1-xlarge"
|
101
|
+
}
|
102
|
+
post '/api/instances', params, authenticate(:format => :xml)
|
103
|
+
last_response.status.should == 302
|
104
|
+
last_response.headers['Location'].should_not == nil
|
105
|
+
do_xml_request last_response.headers['Location'], {}, true
|
106
|
+
(last_xml_response/'instance/name').text.should == 'unit_test_instance1'
|
107
|
+
(last_xml_response/'instance/hardware_profile').first['id'].should == 'm1-xlarge'
|
108
|
+
add_created_instance (last_xml_response/'instance').first['id']
|
109
|
+
test_instance_attributes(last_xml_response/'instance')
|
110
|
+
end
|
96
111
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
112
|
+
def test_it_z0_stop_and_start_instance
|
113
|
+
$created_instances.each do |instance_id|
|
114
|
+
do_xml_request "/api/instances/#{instance_id}", {}, true
|
115
|
+
stop_url = (last_xml_response/'actions/link[@rel="stop"]').first['href']
|
116
|
+
stop_url.should_not == nil
|
117
|
+
post create_url(stop_url), {}, authenticate(:format => :xml)
|
118
|
+
last_response.status.should == 200
|
119
|
+
instance = Nokogiri::XML(last_response.body)
|
120
|
+
test_instance_attributes(instance)
|
121
|
+
(instance/'state').text.should == 'STOPPED'
|
122
|
+
do_xml_request "/api/instances/#{instance_id}", {}, true
|
123
|
+
start_url = (last_xml_response/'actions/link[@rel="start"]').first['href']
|
124
|
+
start_url.should_not == nil
|
125
|
+
post create_url(start_url), {}, authenticate(:format => :xml)
|
126
|
+
last_response.status.should == 200
|
127
|
+
instance = Nokogiri::XML(last_response.body)
|
128
|
+
test_instance_attributes(instance)
|
129
|
+
(instance/'state').text.should == 'RUNNING'
|
130
|
+
end
|
131
|
+
end
|
102
132
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
133
|
+
def test_z0_reboot_instance
|
134
|
+
$created_instances.each do |instance_id|
|
135
|
+
do_xml_request "/api/instances/#{instance_id}", {}, true
|
136
|
+
reboot_url = (last_xml_response/'actions/link[@rel="reboot"]').first['href']
|
137
|
+
reboot_url.should_not == nil
|
138
|
+
post create_url(reboot_url), {}, authenticate(:format => :xml)
|
139
|
+
last_response.status.should == 200
|
140
|
+
instance = Nokogiri::XML(last_response.body)
|
141
|
+
test_instance_attributes(instance)
|
142
|
+
(instance/'state').text.should == 'RUNNING'
|
143
|
+
end
|
144
|
+
end
|
109
145
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
146
|
+
def test_z1_stop_created_instances
|
147
|
+
$created_instances.each do |instance_id|
|
148
|
+
do_xml_request "/api/instances/#{instance_id}", {}, true
|
149
|
+
stop_url = (last_xml_response/'actions/link[@rel="stop"]').first['href']
|
150
|
+
stop_url.should_not == nil
|
151
|
+
post create_url(stop_url), {}, authenticate(:format => :xml)
|
152
|
+
last_response.status.should == 200
|
153
|
+
instance = Nokogiri::XML(last_response.body)
|
154
|
+
test_instance_attributes(instance)
|
155
|
+
(instance/'state').text.should == 'STOPPED'
|
156
|
+
end
|
157
|
+
end
|
115
158
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
159
|
+
def test_z2_destroy_created_instances
|
160
|
+
$created_instances.each do |instance_id|
|
161
|
+
do_xml_request "/api/instances/#{instance_id}", {}, true
|
162
|
+
destroy_url = (last_xml_response/'actions/link[@rel="destroy"]').first['href']
|
163
|
+
destroy_url.should_not == nil
|
164
|
+
delete create_url(destroy_url), {}, authenticate(:format => :xml)
|
165
|
+
last_response.status.should == 302
|
166
|
+
do_xml_request last_response.headers['Location'], {}, true
|
167
|
+
(last_xml_response/'instances').should_not == nil
|
168
|
+
do_xml_request "/api/instances/#{instance_id}", {}, true
|
169
|
+
last_response.status.should == 404
|
170
|
+
end
|
171
|
+
end
|
121
172
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
173
|
+
private
|
174
|
+
|
175
|
+
def test_instance_attributes(instance)
|
176
|
+
(instance/'name').should_not == nil
|
177
|
+
(instance/'owner_id').should_not == nil
|
178
|
+
['RUNNING', 'STOPPED'].include?((instance/'state').text).should == true
|
179
|
+
|
180
|
+
(instance/'public_addreses').should_not == nil
|
181
|
+
(instance/'public_addresses/address').map.size.should > 0
|
182
|
+
(instance/'public_addresses/address').first.text.should_not == ""
|
183
|
+
|
184
|
+
(instance/'private_addresses').should_not == nil
|
185
|
+
(instance/'private_addresses/address').map.size.should > 0
|
186
|
+
(instance/'private_addresses/address').first.text.should_not == ""
|
187
|
+
|
188
|
+
(instance/'actions/link').map.size.should > 0
|
189
|
+
(instance/'actions/link').each do |link|
|
190
|
+
link['href'].should_not == ""
|
191
|
+
link['rel'].should_not == ""
|
192
|
+
link['method'].should_not == ""
|
193
|
+
['get', 'post', 'delete', 'put'].include?(link['method']).should == true
|
194
|
+
end
|
195
|
+
|
196
|
+
(instance/'image').size.should > 0
|
197
|
+
(instance/'image').first['href'].should_not == ""
|
198
|
+
(instance/'image').first['id'].should_not == ""
|
199
|
+
do_xml_request (instance/'image').first['href'], {}, true
|
200
|
+
(last_xml_response/'image').should_not == nil
|
201
|
+
(last_xml_response/'image').first['href'] == (instance/'image').first['href']
|
202
|
+
|
203
|
+
(instance/'realm').size.should > 0
|
204
|
+
(instance/'realm').first['href'].should_not == ""
|
205
|
+
(instance/'realm').first['id'].should_not == ""
|
206
|
+
do_xml_request (instance/'realm').first['href']
|
207
|
+
(last_xml_response/'realm').should_not == nil
|
208
|
+
(last_xml_response/'realm').first['href'] == (instance/'realm').first['href']
|
209
|
+
|
210
|
+
(instance/'hardware_profile').size.should > 0
|
211
|
+
(instance/'hardware_profile').first['href'].should_not == ""
|
212
|
+
(instance/'hardware_profile').first['id'].should_not == ""
|
213
|
+
do_xml_request (instance/'hardware_profile').first['href']
|
214
|
+
(last_xml_response/'hardware_profile').should_not == nil
|
215
|
+
(last_xml_response/'hardware_profile').first['href'] == (instance/'hardware_profile').first['href']
|
216
|
+
end
|
127
217
|
|
128
|
-
def test_005_destroy_instance
|
129
|
-
delete '/api/instances/'+self.temp_inst_id+'.xml', {}, rack_headers
|
130
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
131
|
-
assert last_response.ok?
|
132
218
|
end
|
133
|
-
|
134
|
-
include DeltacloudTest
|
135
|
-
|
136
219
|
end
|
data/tests/realms_test.rb
CHANGED
@@ -1,56 +1,78 @@
|
|
1
|
-
require 'tests/
|
1
|
+
require 'tests/common'
|
2
2
|
|
3
|
-
|
3
|
+
module DeltacloudUnitTest
|
4
|
+
class RealmsTest < Test::Unit::TestCase
|
5
|
+
include Rack::Test::Methods
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@options = [:id, :name, :state]
|
9
|
-
@params = {}
|
10
|
-
super(*args)
|
11
|
-
end
|
7
|
+
def app
|
8
|
+
Sinatra::Application
|
9
|
+
end
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
assert_not_equal 0, doc.xpath('/realms/realm').size
|
17
|
-
end
|
11
|
+
def test_it_not_require_authentication
|
12
|
+
require_authentication?('/api/realms').should_not == true
|
13
|
+
end
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
get '/api/realms.xml', @params, rack_headers
|
23
|
-
doc = Nokogiri::XML.parse(last_response.body)
|
24
|
-
realm = doc.xpath('/realms/realm[1]').first
|
25
|
-
assert_not_nil realm.xpath(option.to_s).first
|
15
|
+
def test_it_returns_realms
|
16
|
+
do_xml_request '/api/realms', {}, true
|
17
|
+
(last_xml_response/'realms/realm').map.size.should > 0
|
26
18
|
end
|
27
|
-
end
|
28
19
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
realm = doc.xpath('/realm').first
|
35
|
-
assert_not_nil realm.xpath(option.to_s).first
|
20
|
+
def test_it_has_correct_attributes_set
|
21
|
+
do_xml_request '/api/realms', {}, true
|
22
|
+
(last_xml_response/'realms/realm').each do |realm|
|
23
|
+
realm.attributes.keys.sort.should == [ 'href', 'id' ]
|
24
|
+
end
|
36
25
|
end
|
37
|
-
end
|
38
26
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
assert_equal @params[:state], doc.xpath('/realms/realm/state').first.text
|
45
|
-
end
|
27
|
+
def test_us_has_correct_attributes
|
28
|
+
do_xml_request '/api/realms', {}, true
|
29
|
+
realm = (last_xml_response/'realms/realm[@id="us"]')
|
30
|
+
test_realm_attributes(realm)
|
31
|
+
end
|
46
32
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
33
|
+
def test_it_returns_valid_realm
|
34
|
+
do_xml_request '/api/realms/us', {}, true
|
35
|
+
realm = (last_xml_response/'realm')
|
36
|
+
test_realm_attributes(realm)
|
37
|
+
end
|
53
38
|
|
54
|
-
|
39
|
+
def test_it_has_unique_ids
|
40
|
+
do_xml_request '/api/realms', {}, true
|
41
|
+
ids = []
|
42
|
+
(last_xml_response/'realms/realm').each do |realm|
|
43
|
+
ids << realm['id'].to_s
|
44
|
+
end
|
45
|
+
ids.sort.should == ids.sort.uniq
|
46
|
+
end
|
55
47
|
|
48
|
+
def test_it_responses_to_json
|
49
|
+
do_request '/api/realms', {}, false, { :format => :json }
|
50
|
+
JSON::parse(last_response.body).class.should == Hash
|
51
|
+
JSON::parse(last_response.body)['realms'].class.should == Array
|
52
|
+
|
53
|
+
do_request '/api/realms/us', {}, false, { :format => :json }
|
54
|
+
last_response.status.should == 200
|
55
|
+
JSON::parse(last_response.body).class.should == Hash
|
56
|
+
JSON::parse(last_response.body)['realm'].class.should == Hash
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_it_responses_to_html
|
60
|
+
do_request '/api/realms', {}, false, { :format => :html }
|
61
|
+
last_response.status.should == 200
|
62
|
+
Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
|
63
|
+
|
64
|
+
do_request '/api/realms/us', {}, false, { :format => :html }
|
65
|
+
last_response.status.should == 200
|
66
|
+
Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def test_realm_attributes(realm)
|
72
|
+
(realm/'name').should_not == nil
|
73
|
+
(realm/'limit').should_not == nil
|
74
|
+
['AVAILABLE'].include?((realm/'state').text).should == true
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
56
78
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
- unless defined?(partial)
|
2
2
|
!!! XML
|
3
|
-
%
|
4
|
-
%
|
3
|
+
%hardware_profile{ :href => hardware_profile_url(@profile.name), :id => @profile.name }
|
4
|
+
%name<
|
5
|
+
=@profile.name
|
5
6
|
- @profile.each_property do |prop|
|
6
7
|
- attr = { :name => prop.name, :kind => prop.kind, :unit => prop.unit }
|
7
8
|
- if prop.kind == :fixed
|
data/views/images/index.xml.haml
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
!!! XML
|
2
2
|
%images
|
3
3
|
- @elements.each do |image|
|
4
|
-
%image{:href => image_url(image.id)}
|
5
|
-
- image.attributes.each do |attribute|
|
6
|
-
- haml_tag(attribute, :<) do
|
4
|
+
%image{:href => image_url(image.id), :id => image.id}
|
5
|
+
- image.attributes.select{ |attr| attr!=:id }.each do |attribute|
|
6
|
+
- haml_tag("#{attribute}".tr('-', '_'), :<) do
|
7
7
|
- haml_concat image.send(attribute)
|
8
|
+
|
data/views/images/show.xml.haml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
!!! XML
|
2
|
-
%image{:href => image_url(@image.id)}
|
3
|
-
- @image.attributes.each do |attribute|
|
2
|
+
%image{:href => image_url(@image.id), :id => @image.id}
|
3
|
+
- @image.attributes.select{ |attr| attr!=:id }.each do |attribute|
|
4
4
|
- haml_tag(attribute, :<) do
|
5
5
|
- haml_concat @image.send(attribute)
|
@@ -1,23 +1,21 @@
|
|
1
1
|
!!! XML
|
2
2
|
%instances
|
3
3
|
- @elements.each do |instance|
|
4
|
-
%instance{:href => instance_url(instance.id)}
|
5
|
-
%id #{instance.id}
|
4
|
+
%instance{:href => instance_url(instance.id), :id => instance.id}
|
6
5
|
%name #{instance.name}
|
7
6
|
%owner_id #{instance.owner_id}
|
8
|
-
%image{:href => image_url(instance.image_id)}
|
9
|
-
%realm{:href => realm_url(instance.realm_id)}
|
7
|
+
%image{:href => image_url(instance.image_id), :id => instance.image_id }
|
8
|
+
%realm{:href => realm_url(instance.realm_id), :id => instance.realm_id }
|
10
9
|
%state #{instance.state}
|
11
|
-
- haml_tag :"
|
12
|
-
%id #{instance.instance_profile.id}
|
10
|
+
- haml_tag :"hardware_profile", { :id => instance.instance_profile.id, :href => hardware_profile_url(instance.instance_profile.id)} do
|
13
11
|
- instance.instance_profile.overrides.each do |p, v|
|
14
12
|
%property{:kind => 'fixed', :name => p, :value => v, :unit => Deltacloud::HardwareProfile::unit(p)}
|
15
13
|
%actions
|
16
14
|
- instance.actions.compact.each do |action|
|
17
15
|
%link{:rel => action, :href => self.send("#{action}_instance_url", instance.id), :method => instance_action_method(action)}
|
18
|
-
%
|
16
|
+
%public_addresses
|
19
17
|
- instance.public_addresses.each do |address|
|
20
18
|
%address #{address}
|
21
|
-
%
|
19
|
+
%private_addresses
|
22
20
|
- instance.private_addresses.each do |address|
|
23
21
|
%address #{address}
|
@@ -1,28 +1,27 @@
|
|
1
1
|
!!! XML
|
2
|
-
%instance{:href => instance_url(@instance.id)}
|
3
|
-
%id<
|
4
|
-
=@instance.id
|
2
|
+
%instance{:href => instance_url(@instance.id), :id => @instance.id}
|
5
3
|
%name<
|
6
4
|
=@instance.name
|
7
5
|
%owner_id<
|
8
6
|
=@instance.owner_id
|
9
|
-
%image{:href => image_url(@instance.image_id)}
|
10
|
-
%realm{:href => realm_url(@instance.realm_id)}
|
7
|
+
%image{:href => image_url(@instance.image_id), :id => @instance.image_id }
|
8
|
+
%realm{:href => realm_url(@instance.realm_id), :id => @instance.realm_id }
|
11
9
|
%state<
|
12
10
|
=@instance.state
|
13
|
-
- haml_tag :"
|
14
|
-
%id<
|
15
|
-
=@instance.instance_profile.id
|
11
|
+
- haml_tag :"hardware_profile", {:id => @instance.instance_profile.id, :href => hardware_profile_url(@instance.instance_profile.id)} do
|
16
12
|
- @instance.instance_profile.overrides.each do |p, v|
|
17
13
|
%property{:kind => 'fixed', :name => p, :value => v, :unit => Deltacloud::HardwareProfile::unit(p)}
|
18
14
|
%actions
|
19
15
|
- @instance.actions.compact.each do |instance_action|
|
20
16
|
%link{:rel => instance_action, :method => instance_action_method(instance_action), :href => self.send("#{instance_action}_instance_url", @instance.id)}
|
21
|
-
|
17
|
+
- if @instance.instance_variables.include?("@launch_time")
|
18
|
+
%launch_time<
|
19
|
+
=@instance.launch_time
|
20
|
+
%public_addresses
|
22
21
|
- @instance.public_addresses.each do |address|
|
23
22
|
%address<
|
24
23
|
=address
|
25
|
-
%
|
24
|
+
%private_addresses
|
26
25
|
- @instance.private_addresses.each do |address|
|
27
26
|
%address<
|
28
27
|
=address
|
data/views/realms/index.xml.haml
CHANGED
data/views/realms/show.xml.haml
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
!!!XML
|
2
|
-
%realm{:href => realm_url(@realm.id)}
|
3
|
-
%id<
|
4
|
-
=@realm.id
|
2
|
+
%realm{:href => realm_url(@realm.id), :id => @realm.id }
|
5
3
|
%name<
|
6
4
|
=@realm.name
|
7
5
|
%state<
|
8
6
|
=@realm.state
|
9
|
-
|
10
|
-
|
7
|
+
- unless @realm.limit.eql?(:unlimited)
|
8
|
+
%limit<
|
9
|
+
=@realm.limit
|
@@ -1,11 +1,9 @@
|
|
1
1
|
!!!XML
|
2
|
-
%
|
2
|
+
%storage_snapshots
|
3
3
|
- @elements.each do |snapshot|
|
4
|
-
%
|
5
|
-
%id<
|
6
|
-
=snapshot.id
|
4
|
+
%storage_snapshot{ :href => storage_snapshot_url(snapshot.id), :id => snapshot.id }
|
7
5
|
%created<
|
8
6
|
=snapshot.created
|
9
7
|
%state<
|
10
8
|
=snapshot.state
|
11
|
-
%
|
9
|
+
%storage_volume{ :href => storage_volume_url(snapshot.storage_volume_id), :id => snapshot.storage_volume_id }
|
@@ -1,9 +1,7 @@
|
|
1
1
|
!!!XML
|
2
|
-
%
|
3
|
-
%id<
|
4
|
-
=@storage_snapshot.id
|
2
|
+
%storage_snapshot{:href => storage_snapshot_url(@storage_snapshot.id), :id => @storage_snapshot.id }
|
5
3
|
%created<
|
6
4
|
=@storage_snapshot.created
|
7
5
|
%state<
|
8
6
|
=@storage_snapshot.state
|
9
|
-
%
|
7
|
+
%storage_volume{:href => storage_volume_url(@storage_snapshot.storage_volume_id), :id => @storage_snapshot.storage_volume_id}
|