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
@@ -25,7 +25,7 @@ module Deltacloud::Collections
25
25
  format.xml { haml :"drivers/index" }
26
26
  format.json { @drivers.to_json }
27
27
  format.html { haml :"drivers/index" }
28
- end
28
+ end
29
29
  end
30
30
  end
31
31
 
@@ -22,7 +22,7 @@ module Deltacloud::Collections
22
22
 
23
23
  check_features :for => lambda { |c, f| driver.class.has_feature?(c, f) }
24
24
 
25
- get route_for('/firewalls/:id/new_rule') do
25
+ get '/firewalls/:id/new_rule' do
26
26
  @firewall_name = params[:id]
27
27
  respond_to do |format|
28
28
  format.html {haml :"firewalls/new_rule" }
@@ -31,7 +31,7 @@ module Deltacloud::Collections
31
31
  @keys = driver.keys(credentials) if driver.class.has_feature? :instances, :authentication_key
32
32
  end
33
33
 
34
- get route_for('/instances/:id/run') do
34
+ get '/instances/:id/run' do
35
35
  respond_to do |format|
36
36
  @instance = driver.instances(credentials, :id => params[:id]).first
37
37
  format.html {haml :"instances/run_command" }
@@ -77,16 +77,19 @@ module Deltacloud::Collections
77
77
 
78
78
  action :reboot, :with_capability => :reboot_instance do
79
79
  description "Reboot a running instance."
80
+ param :id, :string, :required
80
81
  control { instance_action(:reboot) }
81
82
  end
82
83
 
83
84
  action :start, :with_capability => :start_instance do
84
85
  description "Start an instance."
86
+ param :id, :string, :required
85
87
  control { instance_action(:start) }
86
88
  end
87
89
 
88
90
  action :stop, :with_capability => :stop_instance do
89
91
  description "Stop a running instance."
92
+ param :id, :string, :required
90
93
  control { instance_action(:stop) }
91
94
  end
92
95
 
@@ -95,6 +98,7 @@ module Deltacloud::Collections
95
98
  end
96
99
 
97
100
  action :run, :with_capability => :run_on_instance do
101
+ param :id, :string, :required
98
102
  param :cmd, :string, :required, [], "Shell command to run on instance"
99
103
  param :private_key, :string, :optional, [], "Private key in PEM format for authentication"
100
104
  param :password, :string, :optional, [], "Password used for authentication"
@@ -21,7 +21,7 @@ module Deltacloud::Collections
21
21
  set :capability, lambda { |m| driver.respond_to? m }
22
22
  check_features :for => lambda { |c, f| driver.class.has_feature?(c, f) }
23
23
 
24
- get route_for('/keys/new') do
24
+ get '/keys/new' do
25
25
  respond_to do |format|
26
26
  format.html { haml :"keys/new" }
27
27
  end
@@ -60,6 +60,7 @@ module Deltacloud::Collections
60
60
  end
61
61
 
62
62
  action :register, :with_capability => :lb_register_instance do
63
+ param :id, :string, :required
63
64
  param :instance_id, :string, :required
64
65
  control do
65
66
  driver.lb_register_instance(credentials, params)
@@ -73,6 +74,7 @@ module Deltacloud::Collections
73
74
  end
74
75
 
75
76
  action :unregister, :with_capability => :lb_unregister_instance do
77
+ param :id, :string, :required
76
78
  param :instance_id, :string, :required
77
79
  control do
78
80
  driver.lb_unregister_instance(credentials, params)
@@ -21,7 +21,7 @@ module Deltacloud::Collections
21
21
 
22
22
  new_route_for(:storage_volumes)
23
23
 
24
- get route_for("/storage_volumes/:id/attach_instance") do
24
+ get "/storage_volumes/:id/attach_instance" do
25
25
  @instances = driver.instances(credentials)
26
26
  respond_to do |format|
27
27
  format.html{ haml :"storage_volumes/attach"}
@@ -33,10 +33,6 @@ module Deltacloud::Collections
33
33
  standard_index_operation
34
34
  standard_show_operation
35
35
 
36
- operation :show, :with_capability => :storage_volume do
37
- control { show(:storage_volume) }
38
- end
39
-
40
36
  operation :create, :with_capability => :create_storage_volume do
41
37
  param :snapshot_id, :string, :optional
42
38
  param :capacity, :string, :optional
@@ -54,6 +50,7 @@ module Deltacloud::Collections
54
50
  end
55
51
 
56
52
  action :attach, :with_capability => :attach_storage_volume do
53
+ param :id, :string, :required
57
54
  param :instance_id,:string, :required
58
55
  param :device, :string, :required
59
56
  control do
@@ -68,6 +65,7 @@ module Deltacloud::Collections
68
65
  end
69
66
 
70
67
  action :detach, :with_capability => :detach_storage_volume do
68
+ param :id, :string, :required
71
69
  control do
72
70
  volume = driver.storage_volume(credentials, :id => params[:id])
73
71
  @storage_volume = driver.detach_storage_volume(credentials, :id => volume.id,
@@ -19,5 +19,6 @@ require 'require_relative' if RUBY_VERSION < '1.9'
19
19
  require_relative './core_ext/array'
20
20
  require_relative './core_ext/hash'
21
21
  require_relative './core_ext/integer'
22
+ require_relative './core_ext/ordered_hash'
22
23
  require_relative './core_ext/proc'
23
24
  require_relative './core_ext/string'
@@ -35,4 +35,12 @@ class Hash
35
35
  self
36
36
  end
37
37
 
38
+ def to_query_params
39
+ return '' if empty?
40
+ '?' + self.map do |k,v|
41
+ next if k.nil?
42
+ "#{k}=#{URI.escape(v.to_s.strip, /[^#{URI::PATTERN::UNRESERVED}]/)}"
43
+ end.compact.join('&')
44
+ end
45
+
38
46
  end
@@ -0,0 +1,222 @@
1
+ # Code from ActiveSupport, https://github.com/rails/rails/tree/3-2-stable/activesupport
2
+ # MIT licensed
3
+ begin
4
+ require 'psych'
5
+ rescue LoadError
6
+ end
7
+
8
+ require 'yaml'
9
+
10
+ YAML.add_builtin_type("omap") do |type, val|
11
+ OrderedHash[val.map{ |v| v.to_a.first }]
12
+ end
13
+
14
+ # The order of iteration over hashes in Ruby 1.8 is undefined. For example, you do not know the
15
+ # order in which +keys+ will return keys, or +each+ yield pairs. <tt>ActiveSupport::OrderedHash</tt>
16
+ # implements a hash that preserves insertion order, as in Ruby 1.9:
17
+ #
18
+ # oh = ActiveSupport::OrderedHash.new
19
+ # oh[:a] = 1
20
+ # oh[:b] = 2
21
+ # oh.keys # => [:a, :b], this order is guaranteed
22
+ #
23
+ # <tt>ActiveSupport::OrderedHash</tt> is namespaced to prevent conflicts with other implementations.
24
+ class OrderedHash < ::Hash
25
+ def to_yaml_type
26
+ "!tag:yaml.org,2002:omap"
27
+ end
28
+
29
+ def encode_with(coder)
30
+ coder.represent_seq '!omap', map { |k,v| { k => v } }
31
+ end
32
+
33
+ def to_yaml(opts = {})
34
+ if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck?
35
+ return super
36
+ end
37
+
38
+ YAML.quick_emit(self, opts) do |out|
39
+ out.seq(taguri) do |seq|
40
+ each do |k, v|
41
+ seq.add(k => v)
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ def nested_under_indifferent_access
48
+ self
49
+ end
50
+
51
+ # Returns true to make sure that this hash is extractable via <tt>Array#extract_options!</tt>
52
+ def extractable_options?
53
+ true
54
+ end
55
+
56
+ # Hash is ordered in Ruby 1.9!
57
+ if RUBY_VERSION < '1.9'
58
+
59
+ # In MRI the Hash class is core and written in C. In particular, methods are
60
+ # programmed with explicit C function calls and polymorphism is not honored.
61
+ #
62
+ # For example, []= is crucial in this implementation to maintain the @keys
63
+ # array but hash.c invokes rb_hash_aset() originally. This prevents method
64
+ # reuse through inheritance and forces us to reimplement stuff.
65
+ #
66
+ # For instance, we cannot use the inherited #merge! because albeit the algorithm
67
+ # itself would work, our []= is not being called at all by the C code.
68
+
69
+ def initialize(*args, &block)
70
+ super
71
+ @keys = []
72
+ end
73
+
74
+ def self.[](*args)
75
+ ordered_hash = new
76
+
77
+ if (args.length == 1 && args.first.is_a?(Array))
78
+ args.first.each do |key_value_pair|
79
+ next unless (key_value_pair.is_a?(Array))
80
+ ordered_hash[key_value_pair[0]] = key_value_pair[1]
81
+ end
82
+
83
+ return ordered_hash
84
+ end
85
+
86
+ unless (args.size % 2 == 0)
87
+ raise ArgumentError.new("odd number of arguments for Hash")
88
+ end
89
+
90
+ args.each_with_index do |val, ind|
91
+ next if (ind % 2 != 0)
92
+ ordered_hash[val] = args[ind + 1]
93
+ end
94
+
95
+ ordered_hash
96
+ end
97
+
98
+ def initialize_copy(other)
99
+ super
100
+ # make a deep copy of keys
101
+ @keys = other.keys
102
+ end
103
+
104
+ def []=(key, value)
105
+ @keys << key unless has_key?(key)
106
+ super
107
+ end
108
+
109
+ def delete(key)
110
+ if has_key? key
111
+ index = @keys.index(key)
112
+ @keys.delete_at index
113
+ end
114
+ super
115
+ end
116
+
117
+ def delete_if
118
+ super
119
+ sync_keys!
120
+ self
121
+ end
122
+
123
+ def reject!
124
+ super
125
+ sync_keys!
126
+ self
127
+ end
128
+
129
+ def reject(&block)
130
+ dup.reject!(&block)
131
+ end
132
+
133
+ def keys
134
+ @keys.dup
135
+ end
136
+
137
+ def values
138
+ @keys.collect { |key| self[key] }
139
+ end
140
+
141
+ def to_hash
142
+ self
143
+ end
144
+
145
+ def to_a
146
+ @keys.map { |key| [ key, self[key] ] }
147
+ end
148
+
149
+ def each_key
150
+ return to_enum(:each_key) unless block_given?
151
+ @keys.each { |key| yield key }
152
+ self
153
+ end
154
+
155
+ def each_value
156
+ return to_enum(:each_value) unless block_given?
157
+ @keys.each { |key| yield self[key]}
158
+ self
159
+ end
160
+
161
+ def each
162
+ return to_enum(:each) unless block_given?
163
+ @keys.each {|key| yield [key, self[key]]}
164
+ self
165
+ end
166
+
167
+ def each_pair
168
+ return to_enum(:each_pair) unless block_given?
169
+ @keys.each {|key| yield key, self[key]}
170
+ self
171
+ end
172
+
173
+ alias_method :select, :find_all
174
+
175
+ def clear
176
+ super
177
+ @keys.clear
178
+ self
179
+ end
180
+
181
+ def shift
182
+ k = @keys.first
183
+ v = delete(k)
184
+ [k, v]
185
+ end
186
+
187
+ def merge!(other_hash)
188
+ if block_given?
189
+ other_hash.each { |k, v| self[k] = key?(k) ? yield(k, self[k], v) : v }
190
+ else
191
+ other_hash.each { |k, v| self[k] = v }
192
+ end
193
+ self
194
+ end
195
+
196
+ alias_method :update, :merge!
197
+
198
+ def merge(other_hash, &block)
199
+ dup.merge!(other_hash, &block)
200
+ end
201
+
202
+ # When replacing with another hash, the initial order of our keys must come from the other hash -ordered or not.
203
+ def replace(other)
204
+ super
205
+ @keys = other.keys
206
+ self
207
+ end
208
+
209
+ def invert
210
+ OrderedHash[self.to_a.map!{|key_value_pair| key_value_pair.reverse}]
211
+ end
212
+
213
+ def inspect
214
+ "#<OrderedHash #{super}>"
215
+ end
216
+
217
+ private
218
+ def sync_keys!
219
+ @keys.delete_if {|k| !has_key?(k)}
220
+ end
221
+ end
222
+ end
@@ -73,6 +73,15 @@ class String
73
73
  "#{self[0..(length/2)]}#{end_string}"
74
74
  end
75
75
 
76
+ def remove_matrix_params
77
+ self.gsub(/;([^\/]*)/, '').gsub(/\?(.*)$/, '')
78
+ end
79
+
80
+ def convert_query_params(params={})
81
+ gsub(/:(\w+)/) { |p| params.delete(p[1..-1].to_sym) } +
82
+ params.to_query_params
83
+ end
84
+
76
85
  unless "".respond_to? :each
77
86
  alias :each :each_line
78
87
  end
@@ -197,10 +197,6 @@ class ArubaDriver < Deltacloud::BaseDriver
197
197
  end
198
198
  end
199
199
 
200
- def supported_collections
201
- DEFAULT_COLLECTIONS + [ :addresses ]
202
- end
203
-
204
200
  def configured_providers
205
201
  Deltacloud::Drivers::driver_config[:aruba][:entrypoints]["compute"].keys
206
202
  end
@@ -248,11 +244,6 @@ class ArubaDriver < Deltacloud::BaseDriver
248
244
  end
249
245
  end
250
246
 
251
- def address(credentials, opts={})
252
- addrs = addresses(credentials, opts)
253
- filter_on(addrs, :id, opts).first
254
- end
255
-
256
247
  def create_address(credentials, opts={})
257
248
  client = new_client(credentials)
258
249
  safely do
@@ -64,10 +64,6 @@ module Deltacloud
64
64
  self.class.name.split('::').last.gsub('Driver', '').downcase
65
65
  end
66
66
 
67
- def self.exceptions(&block)
68
- ExceptionHandler::exceptions(&block)
69
- end
70
-
71
67
  def self.define_hardware_profile(profile_id, &block)
72
68
  @hardware_profiles ||= []
73
69
  hw_profile = @hardware_profiles.find{|e| e.id == profile_id }
@@ -155,6 +151,23 @@ module Deltacloud
155
151
  (self.class.instance_methods - superclass_methods).include? method
156
152
  end
157
153
 
154
+ def supported_collections(credentials)
155
+ collection_arr = []
156
+ Deltacloud::Collections.deltacloud_modules.each do |m|
157
+ m.collections.each do |c|
158
+ # Get the required capability for the :index operation (like 'realms' or 'instance_state_machine')
159
+ index_operation_capability = c.operation(:index).required_capability
160
+ # Then use this capability to check if the 'capability' lambda defined
161
+ # for the Sinatra::Base class evaluate to 'true'
162
+ next if m.settings.respond_to?(:capability) and !m.settings.capability(index_operation_capability)
163
+ yield c if block_given?
164
+ collection_arr << c
165
+ end
166
+ end
167
+ collection_arr
168
+ end
169
+
170
+
158
171
  ## Capabilities
159
172
  # The rabbit dsl supports declaring a capability that is required
160
173
  # in the backend driver for the call to succeed. A driver can
@@ -238,6 +251,11 @@ module Deltacloud
238
251
  firewalls(credentials, opts).first if has_capability?(:firewalls)
239
252
  end
240
253
 
254
+ def address(credentials, opts={})
255
+ addresses(credentials, opts).first if has_capability?(:addresses)
256
+ end
257
+
258
+
241
259
  MEMBER_SHOW_METHODS = [ :realm, :image, :instance, :storage_volume, :bucket, :blob,
242
260
  :key, :firewall ] unless defined?(MEMBER_SHOW_METHODS)
243
261
 
@@ -697,10 +697,6 @@ module Deltacloud
697
697
  end
698
698
  end
699
699
 
700
- def address(credentials, opts={})
701
- addresses(credentials, :id => opts[:id]).first
702
- end
703
-
704
700
  def create_address(credentials, opts={})
705
701
  ec2 = new_client(credentials)
706
702
  safely do