deltacloud-core 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/LICENSE +23 -0
  2. data/NOTICE +3 -0
  3. data/Rakefile +32 -20
  4. data/bin/deltacloudd +1 -1
  5. data/config.ru +25 -32
  6. data/deltacloud-core.gemspec +1 -1
  7. data/lib/cimi/collections.rb +4 -1
  8. data/lib/cimi/collections/address_templates.rb +2 -2
  9. data/lib/cimi/collections/addresses.rb +1 -1
  10. data/lib/cimi/collections/base.rb +64 -0
  11. data/lib/cimi/collections/{machine_admins.rb → credentials.rb} +12 -12
  12. data/lib/cimi/collections/{vsp_templates.rb → forwarding_group_templates.rb} +12 -16
  13. data/lib/cimi/collections/{vsp_configurations.rb → forwarding_groups.rb} +12 -13
  14. data/lib/cimi/collections/machine_configurations.rb +2 -2
  15. data/lib/cimi/collections/machine_images.rb +1 -1
  16. data/lib/cimi/collections/machines.rb +8 -2
  17. data/lib/cimi/collections/network_configurations.rb +2 -2
  18. data/lib/cimi/collections/{routing_groups.rb → network_port_configurations.rb} +12 -12
  19. data/lib/cimi/collections/{routing_group_templates.rb → network_port_templates.rb} +15 -12
  20. data/lib/cimi/collections/{vsps.rb → network_ports.rb} +33 -32
  21. data/lib/cimi/collections/network_templates.rb +2 -2
  22. data/lib/cimi/collections/networks.rb +17 -2
  23. data/lib/cimi/collections/{entity_metadata.rb → resource_metadata.rb} +10 -10
  24. data/lib/cimi/collections/volume_configurations.rb +1 -1
  25. data/lib/cimi/collections/volume_images.rb +1 -1
  26. data/lib/cimi/collections/volumes.rb +1 -2
  27. data/lib/cimi/dependencies.rb +1 -1
  28. data/lib/cimi/helpers.rb +3 -84
  29. data/lib/cimi/helpers/cimi_helper.rb +15 -14
  30. data/lib/cimi/models.rb +20 -36
  31. data/lib/cimi/models/address.rb +32 -4
  32. data/lib/cimi/models/address_template.rb +2 -2
  33. data/lib/cimi/models/base.rb +24 -5
  34. data/lib/cimi/models/cloud_entry_point.rb +4 -9
  35. data/lib/cimi/models/collection.rb +101 -0
  36. data/lib/cimi/models/{machine_admin.rb → credential.rb} +6 -4
  37. data/lib/cimi/models/disk_collection.rb +1 -2
  38. data/lib/cimi/models/{routing_group_template.rb → forwarding_group.rb} +5 -3
  39. data/lib/cimi/models/{routing_group.rb → forwarding_group_template.rb} +5 -3
  40. data/lib/cimi/models/machine.rb +9 -7
  41. data/lib/cimi/models/machine_configuration.rb +2 -0
  42. data/lib/cimi/models/machine_image.rb +2 -0
  43. data/lib/cimi/models/machine_template.rb +3 -1
  44. data/lib/cimi/models/machine_volume_collection.rb +1 -1
  45. data/lib/cimi/models/network.rb +2 -0
  46. data/lib/cimi/models/network_configuration.rb +4 -8
  47. data/lib/cimi/models/{vsp.rb → network_port.rb} +7 -11
  48. data/lib/cimi/models/{network_configuration_collection.rb → network_port_collection.rb} +25 -8
  49. data/lib/cimi/models/{vsp_configuration.rb → network_port_configuration.rb} +6 -10
  50. data/lib/cimi/models/{network_collection.rb → network_port_configuration_collection.rb} +9 -9
  51. data/lib/cimi/models/{vsp_template.rb → network_port_template.rb} +6 -4
  52. data/lib/cimi/models/{network_template_collection.rb → network_port_template_collection.rb} +10 -8
  53. data/lib/cimi/models/network_template.rb +3 -1
  54. data/lib/cimi/models/{entity_metadata.rb → resource_metadata.rb} +16 -15
  55. data/lib/cimi/models/schema.rb +23 -12
  56. data/lib/cimi/models/volume.rb +2 -0
  57. data/lib/cimi/models/volume_configuration.rb +2 -0
  58. data/lib/cimi/models/volume_image.rb +2 -0
  59. data/lib/cimi/models/volume_template.rb +2 -0
  60. data/lib/cimi/server.rb +10 -6
  61. data/lib/deltacloud/collections.rb +7 -2
  62. data/lib/deltacloud/collections/addresses.rb +3 -1
  63. data/lib/deltacloud/collections/base.rb +64 -0
  64. data/lib/deltacloud/collections/buckets.rb +14 -4
  65. data/lib/deltacloud/collections/drivers.rb +1 -1
  66. data/lib/deltacloud/collections/firewalls.rb +1 -1
  67. data/lib/deltacloud/collections/instances.rb +5 -1
  68. data/lib/deltacloud/collections/keys.rb +1 -1
  69. data/lib/deltacloud/collections/load_balancers.rb +2 -0
  70. data/lib/deltacloud/collections/storage_volumes.rb +3 -5
  71. data/lib/deltacloud/core_ext.rb +1 -0
  72. data/lib/deltacloud/core_ext/hash.rb +8 -0
  73. data/lib/deltacloud/core_ext/ordered_hash.rb +222 -0
  74. data/lib/deltacloud/core_ext/string.rb +9 -0
  75. data/lib/deltacloud/drivers/aruba/aruba_driver.rb +0 -9
  76. data/lib/deltacloud/drivers/base_driver.rb +22 -4
  77. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +0 -4
  78. data/lib/deltacloud/drivers/exceptions.rb +30 -13
  79. data/lib/deltacloud/drivers/features.rb +7 -0
  80. data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +1 -9
  81. data/lib/deltacloud/drivers/google/google_driver.rb +13 -0
  82. data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.1.yml +3 -0
  83. data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.2.yml +3 -0
  84. data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.3.yml +3 -0
  85. data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.4.yml +3 -0
  86. data/lib/deltacloud/drivers/mock/mock_driver.rb +65 -1
  87. data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +55 -32
  88. data/lib/deltacloud/drivers/openstack/openstack_driver.rb +18 -6
  89. data/lib/deltacloud/helpers.rb +0 -75
  90. data/lib/deltacloud/helpers/deltacloud_helper.rb +66 -28
  91. data/lib/deltacloud/helpers/driver_helper.rb +7 -0
  92. data/lib/deltacloud/helpers/rabbit_helper.rb +51 -0
  93. data/lib/deltacloud/server.rb +12 -14
  94. data/lib/deltacloud/version.rb +1 -1
  95. data/lib/deltacloud_rack.rb +26 -2
  96. data/lib/ec2/query_parser.rb +18 -3
  97. data/lib/sinatra/rack_accept.rb +7 -2
  98. data/lib/sinatra/rack_matrix_params.rb +14 -14
  99. data/public/javascripts/cmwgapp.js +2 -2
  100. data/tests/cimi/collections/cloud_entry_point_test.rb +3 -3
  101. data/tests/cimi/collections/machine_images_test.rb +2 -2
  102. data/tests/cimi/collections/machines_test.rb +1 -1
  103. data/tests/cimi/collections/url_helper_test.rb +31 -0
  104. data/tests/cimi/spec/cimi/model/{machine_admin_spec.rb → credential_spec.rb} +4 -4
  105. data/tests/deltacloud/base_collection_test.rb +0 -5
  106. data/tests/deltacloud/collections/buckets_collection_test.rb +1 -1
  107. data/tests/deltacloud/collections/drivers_collection_test.rb +1 -1
  108. data/tests/deltacloud/collections/hardware_profiles_collection_test.rb +1 -1
  109. data/tests/deltacloud/collections/images_collection_test.rb +1 -1
  110. data/tests/deltacloud/collections/instance_states_collection_test.rb +1 -1
  111. data/tests/deltacloud/collections/instances_collection_test.rb +1 -1
  112. data/tests/deltacloud/collections/keys_collection_test.rb +1 -4
  113. data/tests/deltacloud/deltacloud_helper_test.rb +0 -9
  114. data/tests/deltacloud/server_test.rb +1 -1
  115. data/tests/drivers/base/base_driver_test.rb +30 -0
  116. data/tests/drivers/base/common.rb +14 -0
  117. data/tests/drivers/base/exceptions_test.rb +64 -0
  118. data/tests/drivers/ec2/buckets_test.rb +45 -0
  119. data/tests/drivers/ec2/keys_test.rb +1 -1
  120. data/tests/drivers/google/buckets_test.rb +2 -2
  121. data/tests/drivers/google/common.rb +3 -3
  122. data/tests/test_helper.rb +28 -0
  123. data/views/api/show.html.haml +2 -2
  124. data/views/api/show.xml.haml +1 -1
  125. data/views/buckets/index.html.haml +1 -1
  126. data/views/cimi/cloudEntryPoint/index.xml.haml +1 -1
  127. data/views/cimi/collection/index.html.haml +3 -3
  128. data/views/cimi/collection/response.xml.haml +1 -1
  129. data/views/cimi/error.html.haml +1 -1
  130. data/views/cimi/errors/500.xml.haml +1 -1
  131. data/views/cimi/layout.html.haml +1 -1
  132. data/views/cimi/machine_configurations/show.html.haml +2 -2
  133. data/views/cimi/machine_configurations/show.xml.haml +1 -1
  134. data/views/cimi/machine_images/show.html.haml +2 -2
  135. data/views/cimi/machine_images/show.xml.haml +1 -1
  136. data/views/cimi/machines/show.html.haml +2 -2
  137. data/views/cimi/machines/show.xml.haml +1 -1
  138. data/views/cimi/volumes/show.html.haml +2 -2
  139. data/views/cimi/volumes/show.xml.haml +1 -1
  140. data/views/docs/collection.html.haml +1 -1
  141. data/views/docs/collection.xml.haml +2 -2
  142. data/views/docs/index.html.haml +1 -1
  143. data/views/docs/index.xml.haml +1 -1
  144. data/views/docs/operation.xml.haml +1 -1
  145. data/views/error.html.haml +1 -1
  146. data/views/errors/500.html.haml +7 -4
  147. data/views/firewalls/index.html.haml +1 -1
  148. data/views/firewalls/show.html.haml +1 -1
  149. data/views/images/show.html.haml +2 -2
  150. data/views/index.html.haml +9 -0
  151. data/views/instance_states/show.html.haml +1 -1
  152. data/views/instances/run_command.html.haml +1 -1
  153. data/views/instances/show.html.haml +2 -2
  154. data/views/keys/index.html.haml +1 -1
  155. data/views/layout.html.haml +1 -1
  156. data/views/load_balancers/index.html.haml +1 -1
  157. data/views/load_balancers/show.html.haml +3 -3
  158. data/views/storage_snapshots/show.html.haml +1 -1
  159. data/views/storage_volumes/attach.html.haml +1 -1
  160. data/views/storage_volumes/index.html.haml +1 -1
  161. data/views/storage_volumes/show.html.haml +4 -4
  162. metadata +40 -43
  163. data/lib/cimi/models/address_collection.rb +0 -34
  164. data/lib/cimi/models/address_template_collection.rb +0 -34
  165. data/lib/cimi/models/entity_metadata_collection.rb +0 -31
  166. data/lib/cimi/models/machine_admin_collection.rb +0 -34
  167. data/lib/cimi/models/machine_collection.rb +0 -37
  168. data/lib/cimi/models/machine_configuration_collection.rb +0 -36
  169. data/lib/cimi/models/machine_image_collection.rb +0 -36
  170. data/lib/cimi/models/machine_template_collection.rb +0 -36
  171. data/lib/cimi/models/routing_group_collection.rb +0 -34
  172. data/lib/cimi/models/routing_group_template_collection.rb +0 -35
  173. data/lib/cimi/models/volume_collection.rb +0 -36
  174. data/lib/cimi/models/volume_configuration_collection.rb +0 -36
  175. data/lib/cimi/models/volume_image_collection.rb +0 -36
  176. data/lib/cimi/models/volume_template_collection.rb +0 -36
  177. data/lib/cimi/models/vsp_collection.rb +0 -34
  178. data/lib/cimi/models/vsp_configuration_collection.rb +0 -34
  179. data/lib/cimi/models/vsp_template_collection.rb +0 -34
  180. data/lib/deltacloud/helpers/url_helper.rb +0 -115
data/LICENSE CHANGED
@@ -319,3 +319,26 @@ For the lib/sinatra/url_for.rb component:
319
319
  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
320
320
  OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
321
321
  USE OR OTHER DEALINGS IN THE SOFTWARE.
322
+
323
+ For the lib/deltacloud/core_ext/ordered_hash.rb component:
324
+
325
+ Copyright (c) 2005-2011 David Heinemeier Hansson
326
+
327
+ Permission is hereby granted, free of charge, to any person obtaining
328
+ a copy of this software and associated documentation files (the
329
+ "Software"), to deal in the Software without restriction, including
330
+ without limitation the rights to use, copy, modify, merge, publish,
331
+ distribute, sublicense, and/or sell copies of the Software, and to
332
+ permit persons to whom the Software is furnished to do so, subject to
333
+ the following conditions:
334
+
335
+ The above copyright notice and this permission notice shall be
336
+ included in all copies or substantial portions of the Software.
337
+
338
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
339
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
340
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
341
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
342
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
343
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
344
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/NOTICE CHANGED
@@ -20,3 +20,6 @@ This product includes icons created by David Vignon licensed under LGPL
20
20
 
21
21
  This product includes software developed by Christian Neukirchen
22
22
  (https://github.com/rack/rack)
23
+
24
+ This product includes software developed by the Ruby On Rails project
25
+ (https://github.com/rails)
data/Rakefile CHANGED
@@ -86,36 +86,48 @@ namespace :mock do
86
86
  end
87
87
 
88
88
  desc "List the routes defined by Rabbit"
89
- task :routes do
90
- load File.join(File.dirname(__FILE__), 'config.ru')
91
- Deltacloud.collections.each do |c|
92
- puts "\033[1;32;m#{c.name}\33[0m"
93
- c.operations.each do |o|
94
- puts "\033[1;37m%6s\033[0m :%-10s %-30s (%s)" % [
95
- o.http_method.to_s.upcase,
96
- o.operation_name,
97
- o.full_path,
98
- o.description[0..100]
99
- ]
100
- end
101
- unless c.collections.empty?
102
- puts
103
- c.collections.each do |s|
104
- puts "\033[1;32;m#{s.name}\33[0m"
105
- s.operations.each do |o|
106
- puts "\033[1;37m%6s\033[0m :%-10s %-30s (%s)" % [
89
+ [:cimi, :deltacloud].each do |frontend|
90
+ namespace frontend do
91
+ desc "Print all routes defined for #{frontend.to_s.capitalize}"
92
+ task :routes do
93
+ ENV['API_FRONTEND'] = frontend.to_s
94
+ load File.join(File.dirname(__FILE__), 'config.ru')
95
+ f_class = (frontend == :cimi) ? CIMI : Deltacloud
96
+ f_class.collections.each do |c|
97
+ puts "\033[1;32;m#{c.name}\33[0m"
98
+ c.operations.each do |o|
99
+ puts "\033[1;37m%6s\033[0m :%-10s %-35s (%s)" % [
107
100
  o.http_method.to_s.upcase,
108
101
  o.operation_name,
109
102
  o.full_path,
110
- o.description[0..100]
103
+ Sinatra::Rabbit.generate_url_helper_for(c, o)[1]
111
104
  ]
112
105
  end
106
+ unless c.collections.empty?
107
+ puts
108
+ c.collections.each do |s|
109
+ puts "\033[1;32;m#{s.name}\33[0m"
110
+ s.operations.each do |o|
111
+ puts "\033[1;37m%6s\033[0m :%-10s %-35s (%s)" % [
112
+ o.http_method.to_s.upcase,
113
+ o.operation_name,
114
+ o.full_path,
115
+ o.description[0..100]
116
+ ]
117
+ end
118
+ end
119
+ end
120
+ puts
113
121
  end
114
122
  end
115
- puts
116
123
  end
117
124
  end
118
125
 
126
+ desc 'List Deltacloud routes'
127
+ task :routes do
128
+ Rake::Task['deltacloud:routes'].invoke
129
+ end
130
+
119
131
  DRIVERS = [:mock, :ec2, :rhevm, :google, :gogrid, :openstack]
120
132
 
121
133
  desc 'Run all tests'
@@ -240,7 +240,7 @@ else
240
240
  command = argv_opts.join(" ")
241
241
  Dir::chdir($top_srcdir)
242
242
  rerun = Rerun::Runner.new(command,
243
- :dir => File::join($top_srcdir, "lib", "deltacloud"))
243
+ :dir => File::join($top_srcdir, "lib"))
244
244
  rerun.start
245
245
  rerun.join
246
246
  else
data/config.ru CHANGED
@@ -26,65 +26,58 @@ Deltacloud::configure do |server|
26
26
  server.root_url '/api'
27
27
  server.version Deltacloud::API_VERSION
28
28
  server.klass 'Deltacloud::API'
29
- server.logger Rack::DeltacloudLogger.setup(ENV['API_LOG'], ENV['API_VERBOSE'])
30
- server.default_driver ENV['API_DRIVER']
31
29
  end
32
30
 
33
31
  Deltacloud::configure(:cimi) do |server|
34
32
  server.root_url '/cimi'
35
33
  server.version Deltacloud::API_VERSION
36
34
  server.klass 'CIMI::API'
37
- server.logger Rack::DeltacloudLogger.setup(ENV['API_LOG'], ENV['API_VERBOSE'])
38
- server.default_driver ENV['API_DRIVER']
39
35
  end
40
36
 
41
37
  Deltacloud::configure(:ec2) do |server|
42
38
  server.root_url '/ec2'
43
39
  server.version '2012-04-01'
44
40
  server.klass 'Deltacloud::EC2::API'
45
- server.logger Rack::DeltacloudLogger.setup(ENV['API_LOG'], ENV['API_VERBOSE'])
46
- server.default_driver ENV['API_DRIVER']
47
41
  end
48
42
 
49
43
  routes = {}
50
44
 
45
+ def frontends
46
+ ENV['API_FRONTEND'].split(',').size > 1 ?
47
+ ENV['API_FRONTEND'].split(',') : [ENV['API_FRONTEND']]
48
+ end
49
+
51
50
  # If user wants to launch multiple frontends withing a single instance of DC API
52
51
  # then require them and prepare the routes for Rack
53
52
  #
54
53
  # NOTE: The '/' will not be generated, since multiple frontends could have
55
54
  # different root_url's
56
55
  #
57
- if ENV['API_FRONTEND'].split(',').size > 1
58
-
59
- ENV['API_FRONTEND'].split(',').each do |frontend|
60
- Deltacloud[frontend.to_sym].require!
61
- routes.merge!({
62
- Deltacloud[frontend].root_url => Deltacloud[frontend].klass
63
- })
56
+ frontends.each do |frontend|
57
+ if Deltacloud[frontend.to_sym].nil?
58
+ puts "ERROR: Unknown frontend (#{frontend}). Valid values are 'deltacloud,cimi,ec2'"
59
+ exit(1)
64
60
  end
61
+ Deltacloud[frontend.to_sym].require!
62
+ routes.merge!({
63
+ Deltacloud[frontend].root_url => Deltacloud[frontend].klass
64
+ })
65
+ end
65
66
 
66
- else
67
- Deltacloud[ENV['API_FRONTEND'].to_sym].require!
68
- Deltacloud[ENV['API_FRONTEND'].to_sym].default_frontend!
69
- class IndexEntrypoint < Sinatra::Base
70
- get "/" do
71
- redirect Deltacloud.default_frontend.root_url, 301
72
- end
73
- end
74
- routes['/'] = IndexEntrypoint.new
75
- routes[Deltacloud.default_frontend.root_url] = Deltacloud.default_frontend.klass
67
+ def static_dir_for(name)
68
+ Rack::Directory.new( File.join(File.dirname(__FILE__), "public", name))
76
69
  end
77
70
 
71
+ # Mount static assets directories and index entrypoint
72
+ #
73
+ routes.merge!({
74
+ '/' => Deltacloud::IndexApp,
75
+ '/stylesheets' => static_dir_for('stylesheets'),
76
+ '/javascripts' => static_dir_for('javascripts'),
77
+ '/images' => static_dir_for('images')
78
+ })
78
79
 
79
80
  run Rack::Builder.new {
80
81
  use Rack::MatrixParams
81
- use Rack::DriverSelect
82
-
83
- routes.merge!({
84
- "/stylesheets" => Rack::Directory.new( File.join(File.dirname(__FILE__), "public", "stylesheets") ),
85
- "/javascripts" => Rack::Directory.new( File.join(File.dirname(__FILE__), "public", "javascripts") )
86
- })
87
-
88
82
  run Rack::URLMap.new(routes)
89
-
90
- } if respond_to? :run
83
+ }
@@ -69,7 +69,7 @@ Gem::Specification.new do |s|
69
69
  s.add_dependency('rake', '>= 0.8.7')
70
70
  s.add_dependency('haml', '>= 2.2.17')
71
71
  s.add_dependency('sinatra', '>= 1.3.0')
72
- s.add_dependency('sinatra-rabbit', '>= 1.0.10')
72
+ s.add_dependency('sinatra-rabbit', '>= 1.0.11')
73
73
  s.add_dependency('crack')
74
74
  s.add_dependency('rack', '>= 1.0.0')
75
75
  s.add_dependency('rack-accept')
@@ -14,6 +14,8 @@
14
14
  # License for the specific language governing permissions and limitations
15
15
  # under the License.
16
16
 
17
+ require_relative './collections/base'
18
+
17
19
  module CIMI
18
20
 
19
21
  def self.collection_names
@@ -35,8 +37,9 @@ module CIMI
35
37
  end
36
38
 
37
39
  Dir[File.join(File::dirname(__FILE__), "collections", "*.rb")].each do |collection|
38
- require collection
39
40
  base_collection_name = File.basename(collection).gsub('.rb', '')
41
+ next if base_collection_name == 'base'
42
+ require_relative collection
40
43
  cimi_module_class = CIMI::Collections.const_get(base_collection_name.camelize)
41
44
  cimi_modules << cimi_module_class
42
45
  unless cimi_module_class.collections.nil?
@@ -24,7 +24,7 @@ module CIMI::Collections
24
24
  description 'List all AddressTemplates in the AddressTemplateCollection'
25
25
  param :CIMISelect, :string, :optional
26
26
  control do
27
- address_templates = AddressTemplateCollection.default(self).filter_by(params[:CIMISelect])
27
+ address_templates = AddressTemplate.list(self).filter_by(params[:CIMISelect])
28
28
  respond_to do |format|
29
29
  format.xml {address_templates.to_xml}
30
30
  format.json {address_templates.to_json}
@@ -32,7 +32,7 @@ module CIMI::Collections
32
32
  end
33
33
  end
34
34
 
35
- operation :show, :with_capability => :address_template do
35
+ operation :show, :with_capability => :address_templates do
36
36
  description 'Show a specific AddressTemplate'
37
37
  control do
38
38
  address_template = CIMI::Model::AddressTemplate.find(params[:id], self)
@@ -26,7 +26,7 @@ module CIMI::Collections
26
26
  description 'List all Addresses in the AddressCollection'
27
27
  param :CIMISelect, :string, :optional
28
28
  control do
29
- addresses = AddressCollection.default(self).filter_by(params[:CIMISelect])
29
+ addresses = Address.list(self).filter_by(params[:CIMISelect])
30
30
  respond_to do |format|
31
31
  format.xml {addresses.to_xml}
32
32
  format.json {addresses.to_json}
@@ -0,0 +1,64 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership. The
4
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the
6
+ # License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations
14
+ # under the License.
15
+
16
+ require_relative '../models'
17
+
18
+ module CIMI::Collections
19
+ class Base < Sinatra::Base
20
+
21
+ include Sinatra::Rabbit
22
+ include Sinatra::Rabbit::Features
23
+ include CIMI::Model
24
+
25
+ helpers Deltacloud::Helpers::Drivers
26
+ helpers Sinatra::AuthHelper
27
+ helpers Sinatra::Rabbit::URLHelper
28
+ helpers Deltacloud::Helpers::Application
29
+ helpers CIMI::Helper
30
+
31
+ register Rack::RespondTo
32
+
33
+ enable :method_override
34
+ disable :show_exceptions
35
+ disable :dump_errors
36
+
37
+ set :config, Deltacloud[:cimi]
38
+ set :root_url, config.root_url
39
+ set :root_path, config.root_url
40
+ set :version, config.version
41
+ set :root, File.join(File.dirname(__FILE__), '..', '..', '..')
42
+ set :views, root + '/views/cimi'
43
+ set :public_folder, root + '/public'
44
+ set :documentation_class, CIMI
45
+
46
+ error do
47
+ report_error
48
+ end
49
+
50
+ error Deltacloud::ExceptionHandler::ValidationFailure do
51
+ report_error
52
+ end
53
+
54
+ before do
55
+ # Respond with 400, If we don't get a http Host header,
56
+ halt 400, "Unable to find HTTP Host header" if @env['HTTP_HOST'] == nil
57
+ end
58
+
59
+ after do
60
+ headers 'CIMI-Specification-Version' => Deltacloud[:cimi].version
61
+ end
62
+
63
+ end
64
+ end
@@ -14,21 +14,21 @@
14
14
  # under the License.
15
15
 
16
16
  module CIMI::Collections
17
- class MachineAdmins < Base
17
+ class Credentials < Base
18
18
 
19
19
  set :capability, lambda { |m| driver.respond_to? m }
20
20
 
21
- collection :machine_admins do
21
+ collection :credentials do
22
22
  description 'Machine Admin entity'
23
23
 
24
24
  operation :index, :with_capability => :keys do
25
25
  description "List all machine admins"
26
26
  param :CIMISelect, :string, :optional
27
27
  control do
28
- machine_admins = MachineAdminCollection.default(self).filter_by(params[:CIMISelect])
28
+ credentials = Credential.list(self).filter_by(params[:CIMISelect])
29
29
  respond_to do |format|
30
- format.xml { machine_admins.to_xml }
31
- format.json { machine_admins.to_json }
30
+ format.xml { credentials.to_xml }
31
+ format.json { credentials.to_json }
32
32
  end
33
33
  end
34
34
  end
@@ -36,10 +36,10 @@ module CIMI::Collections
36
36
  operation :show, :with_capability => :key do
37
37
  description "Show specific machine admin"
38
38
  control do
39
- machine_admin = MachineAdmin.find(params[:id], self)
39
+ credential = Credential.find(params[:id], self)
40
40
  respond_to do |format|
41
- format.xml { machine_admin.to_xml }
42
- format.json { machine_admin.to_json }
41
+ format.xml { credential.to_xml }
42
+ format.json { credential.to_json }
43
43
  end
44
44
  end
45
45
  end
@@ -48,9 +48,9 @@ module CIMI::Collections
48
48
  description "Show specific machine admin"
49
49
  control do
50
50
  if request.content_type.end_with?("+json")
51
- new_admin = MachineAdmin.create_from_json(request.body.read, self)
51
+ new_admin = Credential.create_from_json(request.body.read, self)
52
52
  else
53
- new_admin = MachineAdmin.create_from_xml(request.body.read, self)
53
+ new_admin = Credential.create_from_xml(request.body.read, self)
54
54
  end
55
55
  status 201 # Created
56
56
  respond_to do |format|
@@ -61,9 +61,9 @@ module CIMI::Collections
61
61
  end
62
62
 
63
63
  operation :delete, :with_capability => :destroy_key do
64
- description "Delete specified MachineAdmin entity"
64
+ description "Delete specified Credential entity"
65
65
  control do
66
- MachineAdmin.delete!(params[:id], self)
66
+ Credential.delete!(params[:id], self)
67
67
  no_content_with_status(200)
68
68
  end
69
69
  end
@@ -12,39 +12,35 @@
12
12
  # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
13
  # License for the specific language governing permissions and limitations
14
14
  # under the License.
15
-
16
15
  module CIMI::Collections
17
- class VspTemplates < Base
16
+ class ForwardingGroupTemplates < Base
18
17
 
19
18
  set :capability, lambda { |m| driver.respond_to? m }
20
19
 
21
- collection :vsp_templates do
22
-
23
- description 'The VSP Template is a set of Configuration values for realizing a VSP. A VSP Template may be used to create multiple VSPs'
20
+ collection :forwarding_group_templates do
24
21
 
25
- operation :index, :with_capability => :vsp_templates do
26
- description 'List all VSPTemplates in the VSPTemplateCollection'
22
+ operation :index, :with_capability => :forwarding_groups do
23
+ description 'List all ForwardingGroupTemplates in the ForwardingGroupTemplateCollection'
27
24
  param :CIMISelect, :string, :optional
28
25
  control do
29
- vsp_templates = VSPTemplateCollection.default(self).filter_by(params[:CIMISelect])
26
+ forwarding_group_templates = ForwardingGroupTemplate.list(self).filter_by(params[:CIMISelect])
30
27
  respond_to do |format|
31
- format.xml {vsp_templates.to_xml}
32
- format.json {vsp_templates.to_json}
28
+ format.xml {forwarding_group_templates.to_xml}
29
+ format.json {forwarding_group_templates.to_json}
33
30
  end
34
31
  end
35
32
  end
36
33
 
37
- operation :show, :with_capability => :vsp_template do
38
- description 'Show a specific VSPTemplate'
34
+ operation :show, :with_capability => :forwarding_groups do
35
+ description 'Show a specific ForwardingGroupTemplate'
39
36
  control do
40
- vsp_template = VSPTemplate.find(params[:id], self)
37
+ forwarding_group_template = ForwardingGroupTemplate.find(params[:id], self)
41
38
  respond_to do |format|
42
- format.xml {vsp_template.to_xml}
43
- format.json {vsp_template.to_json}
39
+ format.xml {forwarding_group_template.to_xml}
40
+ format.json {forwarding_group_template.to_json}
44
41
  end
45
42
  end
46
43
  end
47
-
48
44
  end
49
45
 
50
46
  end
@@ -12,33 +12,32 @@
12
12
  # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
13
  # License for the specific language governing permissions and limitations
14
14
  # under the License.
15
-
16
15
  module CIMI::Collections
17
- class VspConfigurations < Base
16
+ class ForwardingGroups < Base
18
17
 
19
18
  set :capability, lambda { |m| driver.respond_to? m }
20
19
 
21
- collection :vsp_configurations do
20
+ collection :forwarding_groups do
22
21
 
23
- operation :index, :with_capability => :vsp_configurations do
24
- description 'List all VSPConfigurations in the VSPConfigurationCollection'
22
+ operation :index, :with_capability => :forwarding_groups do
23
+ description 'List all ForwardingGroups in the ForwardingGroupsCollection'
25
24
  param :CIMISelect, :string, :optional
26
25
  control do
27
- vsp_configs = VSPConfigurationCollection.default(self).filter_by(params[:CIMISelect])
26
+ forwarding_groups = ForwardingGroup.list(self).filter_by(params[:CIMISelect])
28
27
  respond_to do |format|
29
- format.xml {vsp_configs.to_xml}
30
- format.json {vsp_configs.to_json}
28
+ format.xml {forwarding_groups.to_xml}
29
+ format.json {forwarding_groups.to_json}
31
30
  end
32
31
  end
33
32
  end
34
33
 
35
- operation :show, :with_capability => :vsp_configuration do
36
- description 'Show a specific VSPConfiguration'
34
+ operation :show, :with_capability => :forwarding_groups do
35
+ description 'Show a specific ForwardingGroup'
37
36
  control do
38
- vsp_config = VSPConfiguration.find(params[:id], self)
37
+ forwarding_group = ForwardingGroup.find(params[:id], self)
39
38
  respond_to do |format|
40
- format.xml {vsp_config.to_xml}
41
- format.json {vsp_config.to_json}
39
+ format.xml {forwarding_group.to_xml}
40
+ format.json {forwarding_group.to_json}
42
41
  end
43
42
  end
44
43
  end