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.
Files changed (66) hide show
  1. data/COPYING +176 -502
  2. data/Rakefile +21 -14
  3. data/deltacloud.rb +3 -0
  4. data/lib/deltacloud/base_driver/base_driver.rb +22 -11
  5. data/lib/deltacloud/base_driver.rb +12 -11
  6. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +15 -12
  7. data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +16 -11
  8. data/lib/deltacloud/drivers/mock/data/images/img1.yml +3 -0
  9. data/lib/deltacloud/drivers/mock/data/images/img2.yml +3 -0
  10. data/lib/deltacloud/drivers/mock/data/images/img3.yml +3 -0
  11. data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +16 -0
  12. data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +9 -0
  13. data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +9 -0
  14. data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap1.yml +4 -0
  15. data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap2.yml +4 -0
  16. data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap3.yml +4 -0
  17. data/lib/deltacloud/drivers/mock/data/storage_volumes/vol1.yml +6 -0
  18. data/lib/deltacloud/drivers/mock/data/storage_volumes/vol2.yml +6 -0
  19. data/lib/deltacloud/drivers/mock/data/storage_volumes/vol3.yml +6 -0
  20. data/lib/deltacloud/drivers/mock/mock_driver.rb +13 -11
  21. data/lib/deltacloud/drivers/rackspace/rackspace_client.rb +12 -11
  22. data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +12 -11
  23. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +12 -11
  24. data/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb +12 -11
  25. data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +14 -12
  26. data/lib/deltacloud/drivers/terremark/terremark_driver.rb +12 -11
  27. data/lib/deltacloud/helpers/application_helper.rb +64 -11
  28. data/lib/deltacloud/helpers/conversion_helper.rb +12 -11
  29. data/lib/deltacloud/method_serializer.rb +12 -11
  30. data/lib/deltacloud/models/base_model.rb +12 -11
  31. data/lib/deltacloud/models/image.rb +12 -11
  32. data/lib/deltacloud/models/instance.rb +13 -12
  33. data/lib/deltacloud/models/instance_profile.rb +12 -11
  34. data/lib/deltacloud/models/realm.rb +12 -11
  35. data/lib/deltacloud/models/storage_snapshot.rb +12 -11
  36. data/lib/deltacloud/models/storage_volume.rb +12 -11
  37. data/lib/drivers.rb +12 -0
  38. data/lib/sinatra/rabbit.rb +1 -0
  39. data/lib/sinatra/respond_to.rb +3 -0
  40. data/lib/sinatra/url_for.rb +3 -4
  41. data/server.rb +40 -80
  42. data/{torquebox-ec2-config.ru → support/torquebox/torquebox-ec2-config.ru} +0 -0
  43. data/tests/api_test.rb +37 -0
  44. data/tests/hardware_profiles_test.rb +120 -0
  45. data/tests/images_test.rb +95 -78
  46. data/tests/instance_states_test.rb +52 -0
  47. data/tests/instances_test.rb +193 -110
  48. data/tests/realms_test.rb +66 -44
  49. data/views/errors/not_found.html.haml +6 -0
  50. data/views/errors/not_found.xml.haml +2 -0
  51. data/views/hardware_profiles/index.xml.haml +1 -1
  52. data/views/hardware_profiles/show.xml.haml +3 -2
  53. data/views/images/index.xml.haml +4 -3
  54. data/views/images/show.xml.haml +2 -2
  55. data/views/instances/index.xml.haml +6 -8
  56. data/views/instances/show.xml.haml +9 -10
  57. data/views/realms/index.xml.haml +1 -3
  58. data/views/realms/show.xml.haml +4 -5
  59. data/views/storage_snapshots/index.xml.haml +3 -5
  60. data/views/storage_snapshots/show.xml.haml +2 -4
  61. data/views/storage_volumes/index.xml.haml +7 -7
  62. data/views/storage_volumes/show.xml.haml +2 -4
  63. metadata +37 -39
  64. data/tests/deltacloud_test.rb +0 -60
  65. data/tests/storage_snapshots_test.rb +0 -48
  66. data/tests/storage_volumes_test.rb +0 -48
@@ -1,136 +1,219 @@
1
- require 'tests/deltacloud_test'
1
+ require 'tests/common'
2
2
 
3
- class InstancesTest < Test::Unit::TestCase
3
+ module DeltacloudUnitTest
4
+ class InstancesTest < Test::Unit::TestCase
5
+ include Rack::Test::Methods
4
6
 
5
- def initialize(*args)
6
- @collection = 'instances'
7
- @operations = [:index, :show]
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
- [:id, :name, :owner_id, :image, :realm, :state, :actions, :'public-addresses', :'private-addresses'].each do |option|
23
- method_name = :"test_if_instances_index_contain_#{option}"
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
- [:id, :name, :owner_id, :image, :realm, :state, :actions, :'public-addresses', :'private-addresses'].each do |option|
33
- method_name = :"test_if_instance_show_contain_#{option}"
34
- send :define_method, method_name do
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
- def test_instances_filtering_by_id
43
- get '/api/instances.xml', { :id => 'inst1'}, rack_headers
44
- doc = Nokogiri::XML.parse(last_response.body)
45
- assert_equal 1, doc.xpath('/instances/instance').size
46
- assert_equal 'inst1', doc.xpath('/instances/instance/id').first.text
47
- end
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
- def test_instances_filtering_by_state
50
- get '/api/instances.xml', { :state => 'RUNNING'}, rack_headers
51
- doc = Nokogiri::XML.parse(last_response.body)
52
- doc.xpath('/instances/instance').each do |instance|
53
- assert_equal 'RUNNING', instance.xpath('state').first.text
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
- def test_instances_filtering_by_unknown_state
58
- get '/api/instances.xml', { :state => '_TEST_UNKNOWN_STATE'}, rack_headers
59
- doc = Nokogiri::XML.parse(last_response.body)
60
- assert_equal 0, doc.xpath('/instances/instance').size
61
- end
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
- def test_001_create_instance
64
- @params = {
65
- :name => '_test-instance',
66
- :image_id => 'img1'
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
- post '/api/instances.xml', @params, rack_headers
70
- doc = Nokogiri::XML.parse(last_response.body)
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
- self.temp_inst_id = doc.xpath('/instance/id').text
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
- assert_equal @params[:name], doc.xpath('/instance/name').first.text
75
- image_href = doc.xpath('/instance/image').first[:href].to_s
76
- image_id = image_href.gsub(/.*\/(\w+)$/, '\1')
77
- assert_equal @params[:image_id], image_id
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
- def test_create_instance_with_hwp_id
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
- @params = {
83
- :name => '_test-instance',
84
- :image_id => 'img1',
85
- :hwp_id => 'm1-xlarge'
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
- post '/api/instances.xml', @params, rack_headers
89
- doc = Nokogiri::XML.parse(last_response.body)
90
- hwp_href = doc.xpath('/instance/hardware_profile').first[:href].to_s
91
- hwp_id = hwp_href.gsub(/.*\/([\w\-]+)$/, '\1')
92
- assert_equal @params[:hwp_id], hwp_id
93
- end
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
- def test_create_instance_with_realm_id
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
- @params = {
98
- :name => '_test-instance',
99
- :image_id => 'img1',
100
- :realm_id => 'us'
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
- post '/api/instances.xml', @params, rack_headers
104
- doc = Nokogiri::XML.parse(last_response.body)
105
- realm_href = doc.xpath('/instance/realm').first[:href].to_s
106
- realm_id = realm_href.gsub(/.*\/([\w\-]+)$/, '\1')
107
- assert_equal @params[:realm_id], realm_id
108
- end
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
- def test_002_stop_instance
111
- post '/api/instances/'+self.temp_inst_id+'/stop.xml', rack_headers
112
- doc = Nokogiri::XML.parse(last_response.body)
113
- assert_equal 'STOPPED', doc.xpath('/instance/state').first.text
114
- end
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
- def test_003_start_instance
117
- post '/api/instances/'+self.temp_inst_id+'/start.xml', rack_headers
118
- doc = Nokogiri::XML.parse(last_response.body)
119
- assert_equal 'RUNNING', doc.xpath('/instance/state').first.text
120
- end
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
- def test_004_reboot_instance
123
- post '/api/instances/'+self.temp_inst_id+'/reboot.xml', rack_headers
124
- doc = Nokogiri::XML.parse(last_response.body)
125
- assert_equal 'RUNNING', doc.xpath('/instance/state').first.text
126
- end
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/deltacloud_test'
1
+ require 'tests/common'
2
2
 
3
- class RealmsTest < Test::Unit::TestCase
3
+ module DeltacloudUnitTest
4
+ class RealmsTest < Test::Unit::TestCase
5
+ include Rack::Test::Methods
4
6
 
5
- def initialize(*args)
6
- @collection = 'realms'
7
- @operations = [:index, :show]
8
- @options = [:id, :name, :state]
9
- @params = {}
10
- super(*args)
11
- end
7
+ def app
8
+ Sinatra::Application
9
+ end
12
10
 
13
- def test_if_realms_are_not_empty
14
- get '/api/realms.xml', @params, rack_headers
15
- doc = Nokogiri::XML.parse(last_response.body)
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
- [:id, :name, :state].each do |option|
20
- method_name = :"test_if_realms_index_contain_#{option}"
21
- send :define_method, method_name do
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
- [:id, :name, :state].each do |option|
30
- method_name = :"test_if_realm_show_contain_#{option}"
31
- send :define_method, method_name do
32
- get '/api/realms/us.xml', @params, rack_headers
33
- doc = Nokogiri::XML.parse(last_response.body)
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
- def test_realms_filtering_by_state
40
- @params[:state] = 'AVAILABLE'
41
- get '/api/realms.xml', @params, rack_headers
42
- doc = Nokogiri::XML.parse(last_response.body)
43
- assert_equal 2, doc.xpath('/realms/realm').size
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
- def test_realms_filtering_by_id
48
- get '/api/realms.xml', { :id => 'us'}, rack_headers
49
- doc = Nokogiri::XML.parse(last_response.body)
50
- assert_equal 1, doc.xpath('/realms/realm').size
51
- assert_equal 'us', doc.xpath('/realms/realm/id').first.text
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
- include DeltacloudTest
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
@@ -0,0 +1,6 @@
1
+ %h1 Not Found
2
+
3
+ %dl
4
+ %di
5
+ %dt Request URL
6
+ %dd= request.env['REQUEST_URI']
@@ -0,0 +1,2 @@
1
+ %error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
2
+ %message Not Found
@@ -1,4 +1,4 @@
1
1
  !!! XML
2
- %hardware-profiles
2
+ %hardware_profiles
3
3
  - @profiles.each do |prof|
4
4
  = haml :'hardware_profiles/show', :locals => { :@profile => prof, :partial => true }
@@ -1,7 +1,8 @@
1
1
  - unless defined?(partial)
2
2
  !!! XML
3
- %hardware-profile{ :href => hardware_profile_url(@profile.name) }
4
- %id= @profile.name
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
@@ -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
+
@@ -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 :"hardware-profile", { :href => hardware_profile_url(instance.instance_profile.id)} do
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
- %public-addresses
16
+ %public_addresses
19
17
  - instance.public_addresses.each do |address|
20
18
  %address #{address}
21
- %private-addresses
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 :"hardware-profile", {:href => hardware_profile_url(@instance.instance_profile.id)} do
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
- %public-addresses
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
- %private-addresses
24
+ %private_addresses
26
25
  - @instance.private_addresses.each do |address|
27
26
  %address<
28
27
  =address
@@ -1,9 +1,7 @@
1
1
  !!!XML
2
2
  %realms
3
3
  - @elements.each do |realm|
4
- %realm{:href => realm_url(realm.id)}
5
- %id<
6
- =realm.id
4
+ %realm{:href => realm_url(realm.id), :id => realm.id }
7
5
  %name<
8
6
  =realm.name
9
7
  %state<
@@ -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
- %limit<
10
- =@realm.limit.eql?(:unlimited) ? '' : @realm.limit
7
+ - unless @realm.limit.eql?(:unlimited)
8
+ %limit<
9
+ =@realm.limit
@@ -1,11 +1,9 @@
1
1
  !!!XML
2
- %storage-snapshots
2
+ %storage_snapshots
3
3
  - @elements.each do |snapshot|
4
- %storage-snapshot{ :href => storage_snapshot_url(snapshot.id)}
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
- %storage-volume{ :href => storage_volume_url(snapshot.storage_volume_id)}
9
+ %storage_volume{ :href => storage_volume_url(snapshot.storage_volume_id), :id => snapshot.storage_volume_id }
@@ -1,9 +1,7 @@
1
1
  !!!XML
2
- %storage-snapshot{:href => storage_snapshot_url(@storage_snapshot.id)}
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
- %storage-volume{:href => storage_volume_url(@storage_snapshot.storage_volume_id)}
7
+ %storage_volume{:href => storage_volume_url(@storage_snapshot.storage_volume_id), :id => @storage_snapshot.storage_volume_id}