fog-openstack 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.travis.yml +6 -2
  4. data/README.md +4 -0
  5. data/Rakefile +10 -2
  6. data/fog-openstack.gemspec +2 -3
  7. data/gemfiles/Gemfile-1.9 +1 -1
  8. data/lib/fog/openstack.rb +14 -6
  9. data/lib/fog/openstack/baremetal.rb +1 -1
  10. data/lib/fog/openstack/common.rb +0 -2
  11. data/lib/fog/openstack/compute.rb +78 -75
  12. data/lib/fog/openstack/core.rb +2 -1
  13. data/lib/fog/openstack/docs/compute.md +1 -1
  14. data/lib/fog/openstack/docs/network.md +283 -0
  15. data/lib/fog/openstack/docs/nfv.md +144 -0
  16. data/lib/fog/openstack/examples/compute/block_device_mapping_v2.rb +4 -4
  17. data/lib/fog/openstack/examples/network/network_add_port.rb +21 -0
  18. data/lib/fog/openstack/examples/network/network_rbac.rb +69 -0
  19. data/lib/fog/openstack/identity.rb +14 -22
  20. data/lib/fog/openstack/identity_v2.rb +1 -1
  21. data/lib/fog/openstack/image_v1.rb +13 -28
  22. data/lib/fog/openstack/image_v2.rb +15 -17
  23. data/lib/fog/openstack/introspection.rb +1 -1
  24. data/lib/fog/openstack/metering.rb +1 -1
  25. data/lib/fog/openstack/models/collection.rb +4 -1
  26. data/lib/fog/openstack/models/compute/availability_zone.rb +5 -0
  27. data/lib/fog/openstack/models/compute/flavor.rb +21 -9
  28. data/lib/fog/openstack/models/compute/server.rb +64 -77
  29. data/lib/fog/openstack/models/compute/snapshot.rb +6 -6
  30. data/lib/fog/openstack/models/compute/volume_attachment.rb +15 -0
  31. data/lib/fog/openstack/models/compute/volume_attachments.rb +20 -0
  32. data/lib/fog/openstack/models/identity_v3/projects.rb +1 -1
  33. data/lib/fog/openstack/models/identity_v3/users.rb +2 -2
  34. data/lib/fog/openstack/models/image_v2/image.rb +41 -22
  35. data/lib/fog/openstack/models/network/floating_ip.rb +1 -0
  36. data/lib/fog/openstack/models/network/rbac_policies.rb +33 -0
  37. data/lib/fog/openstack/models/network/rbac_policy.rb +35 -0
  38. data/lib/fog/openstack/models/nfv/vnf.rb +58 -0
  39. data/lib/fog/openstack/models/nfv/vnfd.rb +53 -0
  40. data/lib/fog/openstack/models/nfv/vnfds.rb +28 -0
  41. data/lib/fog/openstack/models/nfv/vnfs.rb +28 -0
  42. data/lib/fog/openstack/models/volume/snapshot.rb +38 -0
  43. data/lib/fog/openstack/models/volume/snapshots.rb +26 -0
  44. data/lib/fog/openstack/models/volume/volume.rb +32 -2
  45. data/lib/fog/openstack/models/volume/volume_type.rb +3 -4
  46. data/lib/fog/openstack/models/volume_v1/snapshot.rb +43 -0
  47. data/lib/fog/openstack/models/volume_v1/snapshots.rb +16 -0
  48. data/lib/fog/openstack/models/volume_v1/volume.rb +12 -2
  49. data/lib/fog/openstack/models/volume_v2/snapshot.rb +43 -0
  50. data/lib/fog/openstack/models/volume_v2/snapshots.rb +16 -0
  51. data/lib/fog/openstack/models/volume_v2/volume.rb +12 -3
  52. data/lib/fog/openstack/network.rb +53 -46
  53. data/lib/fog/openstack/nfv.rb +158 -0
  54. data/lib/fog/openstack/orchestration.rb +1 -1
  55. data/lib/fog/openstack/planning.rb +1 -1
  56. data/lib/fog/openstack/requests/compute/create_server.rb +1 -1
  57. data/lib/fog/openstack/requests/compute/{create_volume_snapshot.rb → create_snapshot.rb} +16 -16
  58. data/lib/fog/openstack/requests/compute/delete_flavor_metadata.rb +30 -0
  59. data/lib/fog/openstack/requests/compute/evacuate_server.rb +8 -7
  60. data/lib/fog/openstack/requests/compute/get_key_pair.rb +49 -0
  61. data/lib/fog/openstack/requests/compute/list_availability_zones.rb +23 -0
  62. data/lib/fog/openstack/requests/compute/list_volume_attachments.rb +31 -0
  63. data/lib/fog/openstack/requests/compute/update_flavor_metadata.rb +33 -0
  64. data/lib/fog/openstack/requests/network/create_rbac_policy.rb +42 -0
  65. data/lib/fog/openstack/requests/network/delete_rbac_policy.rb +28 -0
  66. data/lib/fog/openstack/requests/network/get_rbac_policy.rb +28 -0
  67. data/lib/fog/openstack/requests/network/list_rbac_policies.rb +25 -0
  68. data/lib/fog/openstack/requests/network/update_port.rb +8 -7
  69. data/lib/fog/openstack/requests/network/update_rbac_policy.rb +41 -0
  70. data/lib/fog/openstack/requests/nfv/create_vnf.rb +37 -0
  71. data/lib/fog/openstack/requests/nfv/create_vnfd.rb +35 -0
  72. data/lib/fog/openstack/requests/nfv/delete_vnf.rb +23 -0
  73. data/lib/fog/openstack/requests/nfv/delete_vnfd.rb +23 -0
  74. data/lib/fog/openstack/requests/nfv/get_vnf.rb +24 -0
  75. data/lib/fog/openstack/requests/nfv/get_vnfd.rb +24 -0
  76. data/lib/fog/openstack/requests/nfv/list_vnfds.rb +25 -0
  77. data/lib/fog/openstack/requests/nfv/list_vnfs.rb +25 -0
  78. data/lib/fog/openstack/requests/nfv/update_vnf.rb +35 -0
  79. data/lib/fog/openstack/requests/volume/action.rb +16 -0
  80. data/lib/fog/openstack/requests/volume/create_snapshot.rb +18 -0
  81. data/lib/fog/openstack/requests/volume/delete_metadata.rb +15 -0
  82. data/lib/fog/openstack/requests/volume/delete_snapshot.rb +5 -5
  83. data/lib/fog/openstack/requests/volume/delete_snapshot_metadata.rb +15 -0
  84. data/lib/fog/openstack/requests/volume/replace_metadata.rb +20 -0
  85. data/lib/fog/openstack/requests/volume/update_metadata.rb +20 -0
  86. data/lib/fog/openstack/requests/volume/update_snapshot.rb +37 -0
  87. data/lib/fog/openstack/requests/volume/update_snapshot_metadata.rb +20 -0
  88. data/lib/fog/openstack/requests/volume/update_volume.rb +25 -0
  89. data/lib/fog/openstack/requests/volume_v1/action.rb +2 -0
  90. data/lib/fog/openstack/requests/volume_v1/create_snapshot.rb +45 -0
  91. data/lib/fog/openstack/requests/volume_v1/delete_metadata.rb +2 -0
  92. data/lib/fog/openstack/requests/volume_v1/delete_snapshot_metadata.rb +2 -0
  93. data/lib/fog/openstack/requests/volume_v1/replace_metadata.rb +2 -0
  94. data/lib/fog/openstack/requests/volume_v1/update_metadata.rb +2 -0
  95. data/lib/fog/openstack/requests/volume_v1/update_snapshot.rb +2 -0
  96. data/lib/fog/openstack/requests/volume_v1/update_snapshot_metadata.rb +2 -0
  97. data/lib/fog/openstack/requests/volume_v1/update_volume.rb +2 -0
  98. data/lib/fog/openstack/requests/volume_v2/action.rb +2 -0
  99. data/lib/fog/openstack/requests/volume_v2/create_snapshot.rb +45 -0
  100. data/lib/fog/openstack/requests/volume_v2/delete_metadata.rb +2 -0
  101. data/lib/fog/openstack/requests/volume_v2/delete_snapshot_metadata.rb +2 -0
  102. data/lib/fog/openstack/requests/volume_v2/replace_metadata.rb +2 -0
  103. data/lib/fog/openstack/requests/volume_v2/update_metadata.rb +2 -0
  104. data/lib/fog/openstack/requests/volume_v2/update_snapshot.rb +2 -0
  105. data/lib/fog/openstack/requests/volume_v2/update_snapshot_metadata.rb +2 -0
  106. data/lib/fog/openstack/requests/volume_v2/update_volume.rb +2 -0
  107. data/lib/fog/openstack/storage.rb +1 -1
  108. data/lib/fog/openstack/version.rb +1 -1
  109. data/lib/fog/openstack/volume.rb +1 -1
  110. data/lib/fog/openstack/volume_v1.rb +29 -21
  111. data/lib/fog/openstack/volume_v2.rb +29 -21
  112. data/supported.md +54 -0
  113. data/tests/openstack/models/identity/ec2_credential_tests.rb +1 -1
  114. data/tests/openstack/models/identity/ec2_credentials_tests.rb +1 -1
  115. data/tests/openstack/models/identity/role_tests.rb +8 -3
  116. data/tests/openstack/models/identity/roles_tests.rb +5 -4
  117. data/tests/openstack/models/identity/tenant_tests.rb +7 -4
  118. data/tests/openstack/models/identity/tenants_tests.rb +10 -5
  119. data/tests/openstack/models/identity/user_tests.rb +4 -3
  120. data/tests/openstack/models/identity/users_tests.rb +10 -6
  121. data/tests/openstack/models/nfv/vnf_tests.rb +35 -0
  122. data/tests/openstack/models/nfv/vnfd_tests.rb +23 -0
  123. data/tests/openstack/models/nfv/vnfds_tests.rb +31 -0
  124. data/tests/openstack/models/nfv/vnfs_tests.rb +38 -0
  125. data/tests/openstack/requests/identity/ec2_credentials_tests.rb +6 -9
  126. data/tests/openstack/requests/identity/helper.rb +12 -4
  127. data/tests/openstack/requests/identity/role_tests.rb +13 -10
  128. data/tests/openstack/requests/identity/tenant_tests.rb +10 -9
  129. data/tests/openstack/requests/identity/user_tests.rb +11 -6
  130. data/tests/openstack/requests/image/image_tests.rb +1 -0
  131. data/tests/openstack/requests/nfv/vnf_tests.rb +70 -0
  132. data/tests/openstack/requests/nfv/vnfd_tests.rb +44 -0
  133. metadata +81 -31
  134. data/lib/fog/openstack/requests/volume/create_volume_snapshot.rb +0 -26
  135. data/lib/fog/openstack/requests/volume_v1/create_volume_snapshot.rb +0 -44
  136. data/lib/fog/openstack/requests/volume_v2/create_volume_snapshot.rb +0 -43
  137. data/tests/openstack/authenticate_tests.rb +0 -200
  138. data/tests/openstack/identity_version_tests.rb +0 -25
  139. data/tests/openstack/storage_tests.rb +0 -18
  140. data/tests/openstack/version_tests.rb +0 -55
  141. data/tests/openstack/volume_tests.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e282e95abf02b0be1feaf68de539e9f46dac483b
4
- data.tar.gz: 267e6a26085dd1f653d3dc29873b3f2da90ea4ac
3
+ metadata.gz: 266dcbc5dc6dbde51beb0aeb2e2b8caacb3a9a68
4
+ data.tar.gz: a1b4dadc45afb05a56967d2d22c93bba19206ca1
5
5
  SHA512:
6
- metadata.gz: 2673e523851172fdba9bd090628a702183420790368f4153901824e4a645dc35050264e7caf5eba5bba1ed7f56f8d22b3c394b21f2d16efcd0c54420775abc08
7
- data.tar.gz: eb67d3fb407504402fa618a80f6b863beab72f2625f5fe364f2d3acc48743c0187008a5b80e9c6be6eb3c236148e4e9ddaed7ab9469796dc5bb8f1d922ac3691
6
+ metadata.gz: 2cb29370444ea727a5ddcb831bd43247110015485ce100451ec3cfb98a819b94f89ef819cd54b4c152f34a0b9aec511428601ccc3a3b473c77ff6fa44c7c4322
7
+ data.tar.gz: 6905cd3f139d98cbb958b37401737f977af61a0b6deac8519aedc8c73f4ea84566f8e1dc2e486572cbe47b10be01fa4cc4db770f3caa416b9ad13a530843dfe5
data/.rubocop.yml CHANGED
@@ -67,6 +67,7 @@ IfUnlessModifier:
67
67
  Enabled: false
68
68
  NumericLiterals:
69
69
  AutoCorrect: false
70
+ MinDigits: 7
70
71
  ParallelAssignment:
71
72
  Enabled: false
72
73
  PerlBackrefs:
data/.travis.yml CHANGED
@@ -1,7 +1,11 @@
1
1
  language: ruby
2
2
  sudo: false
3
- script: bundle exec rake test
4
- env: JRUBY_OPTS=--debug
3
+ script:
4
+ - bundle exec rake test
5
+ - bundle exec rake minitest
6
+ - bundle exec rake spec
7
+ env:
8
+ - JRUBY_OPTS=--debug
5
9
  matrix:
6
10
  fast_finish: true
7
11
  include:
data/README.md CHANGED
@@ -6,6 +6,10 @@ This is the plugin Gem to talk to [OpenStack](http://openstack.org) clouds via f
6
6
 
7
7
  The main maintainers for the OpenStack sections are @dhague, @Ladas, @seanhandley, @mdarby and @jjasghar. Please send CC them on pull requests.
8
8
 
9
+ ## Supported OpenStack APIs
10
+
11
+ See the list of [supported OpenStack projects](supported.md).
12
+
9
13
  ## Installation
10
14
 
11
15
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rubocop/rake_task'
3
- require "minitest/spec"
3
+ require 'rake/testtask'
4
4
 
5
5
  RuboCop::RakeTask.new
6
6
 
@@ -12,7 +12,15 @@ task :test do
12
12
  sh("export FOG_MOCK=#{mock} && bundle exec shindont")
13
13
  end
14
14
 
15
- require 'rake/testtask'
15
+ # The following is transition period until all shindo tests in /tests have been
16
+ # migrated over minitest /test
17
+ desc "Run fog-openstack unit tests for /test"
18
+ Rake::TestTask.new do |t|
19
+ t.name = 'minitest'
20
+ t.libs.push [ "lib", "test" ]
21
+ t.test_files = FileList['test/openstack/*.rb']
22
+ t.verbose = true
23
+ end
16
24
 
17
25
  desc "Run fog-openstack unit tests for /spec"
18
26
  Rake::TestTask.new do |t|
@@ -19,9 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency 'fog-core', '>= 1.38'
22
+ spec.add_dependency 'fog-core', '>= 1.39'
23
23
  spec.add_dependency 'fog-json', '>= 1.0'
24
- spec.add_dependency 'fog-xml', '>= 0.1'
25
24
  spec.add_dependency 'ipaddress', '>= 0.8'
26
25
 
27
26
  spec.add_development_dependency 'bundler', '~> 1.6'
@@ -33,5 +32,5 @@ Gem::Specification.new do |spec|
33
32
  spec.add_development_dependency 'shindo', '~> 0.3'
34
33
  spec.add_development_dependency 'minitest'
35
34
  spec.add_development_dependency 'vcr'
36
- spec.add_development_dependency 'webmock'
35
+ spec.add_development_dependency 'webmock', '~> 1.24.6'
37
36
  end
data/gemfiles/Gemfile-1.9 CHANGED
@@ -15,5 +15,5 @@ group :development, :test do
15
15
  gem "shindo", "~> 0.3"
16
16
  gem "minitest"
17
17
  gem "vcr"
18
- gem "webmock"
18
+ gem "webmock", "~> 1.24.6"
19
19
  end
data/lib/fog/openstack.rb CHANGED
@@ -41,6 +41,10 @@ module Fog
41
41
  autoload :OpenStack, File.expand_path('../openstack/orchestration', __FILE__)
42
42
  end
43
43
 
44
+ module NFV
45
+ autoload :OpenStack, File.expand_path('../openstack/nfv', __FILE__)
46
+ end
47
+
44
48
  module Volume
45
49
  autoload :OpenStack, File.expand_path('../openstack/volume', __FILE__)
46
50
  end
@@ -64,6 +68,7 @@ module Fog
64
68
  service(:volume, 'Volume')
65
69
  service(:metering, 'Metering')
66
70
  service(:orchestration, 'Orchestration')
71
+ service(:nfv, 'NFV')
67
72
  service(:baremetal, 'Baremetal')
68
73
  service(:planning, 'Planning')
69
74
  service(:introspection, 'Introspection')
@@ -220,13 +225,16 @@ module Fog
220
225
  :method => 'GET'
221
226
  }
222
227
  user_id = body['token']['user']['id']
223
- response = Fog::Core::Connection.new(
224
- "#{uri.scheme}://#{uri.host}:#{uri.port}/v3/users/#{user_id}/projects", false, connection_options).request(request_body)
228
+ project_uri = uri.clone
229
+ project_uri.path = uri.path.sub('/auth/tokens', "/users/#{user_id}/projects")
230
+ project_uri_param = "#{project_uri.scheme}://#{project_uri.host}:#{project_uri.port}#{project_uri.path}"
231
+ response = Fog::Core::Connection.new(project_uri_param, false, connection_options).request(request_body)
225
232
 
226
233
  projects_body = Fog::JSON.decode(response.body)
227
234
  if projects_body['projects'].empty?
228
235
  options[:openstack_domain_id] = body['token']['user']['domain']['id']
229
236
  else
237
+ options[:openstack_project_id] = projects_body['projects'].first['id']
230
238
  options[:openstack_project_name] = projects_body['projects'].first['name']
231
239
  options[:openstack_domain_id] = projects_body['projects'].first['domain_id']
232
240
  end
@@ -274,9 +282,9 @@ module Fog
274
282
  identity_url = identity_service['endpoints'].find { |e| e['interface']=='public' }['url'] if identity_service
275
283
 
276
284
  if body['token']['project']
277
- tenant = body['token']['project']['name']
278
- else
279
- tenant = body['token']['user']['project']['name'] if body['token']['user']['project']
285
+ tenant = body['token']['project']
286
+ elsif body['token']['user']['project']
287
+ tenant = body['token']['user']['project']
280
288
  end
281
289
 
282
290
  return {
@@ -497,7 +505,7 @@ module Fog
497
505
  # Find a version in the path (e.g. the v1 in /xyz/v1/tenantid/abc) and get the path up until that version (e.g. /xyz))
498
506
  path_components = uri.path.split '/'
499
507
  version_component_index = path_components.index{|comp| comp.match(/v[0-9].?[0-9]?/) }
500
- versionless_path = (path_components.take(version_component_index).join '/' if version_component_index) || ''
508
+ versionless_path = (path_components.take(version_component_index).join '/' if version_component_index) || uri.path
501
509
  connection = Fog::Core::Connection.new("#{uri.scheme}://#{uri.host}:#{uri.port}#{versionless_path}", false, connection_options)
502
510
  response = connection.request({
503
511
  :expects => [200, 204, 300],
@@ -11,7 +11,7 @@ module Fog
11
11
  :openstack_tenant, :openstack_tenant_id,
12
12
  :openstack_api_key, :openstack_username, :openstack_identity_endpoint,
13
13
  :current_user, :current_tenant, :openstack_region,
14
- :openstack_endpoint_type,
14
+ :openstack_endpoint_type, :openstack_cache_ttl,
15
15
  :openstack_project_name, :openstack_project_id,
16
16
  :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
17
17
  :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  module Fog
4
2
  module OpenStack
5
3
  module Common
@@ -9,7 +9,7 @@ module Fog
9
9
  :openstack_tenant, :openstack_tenant_id,
10
10
  :openstack_api_key, :openstack_username, :openstack_identity_endpoint,
11
11
  :current_user, :current_tenant, :openstack_region,
12
- :openstack_endpoint_type,
12
+ :openstack_endpoint_type, :openstack_cache_ttl,
13
13
  :openstack_project_name, :openstack_project_id,
14
14
  :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
15
15
  :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
@@ -44,6 +44,8 @@ module Fog
44
44
  collection :tenants
45
45
  model :volume
46
46
  collection :volumes
47
+ model :volume_attachment
48
+ collection :volume_attachments
47
49
  model :network
48
50
  collection :networks
49
51
  model :snapshot
@@ -133,6 +135,8 @@ module Fog
133
135
  # Flavor Actions
134
136
  request :get_flavor_metadata
135
137
  request :create_flavor_metadata
138
+ request :update_flavor_metadata
139
+ request :delete_flavor_metadata
136
140
 
137
141
  # Flavor Access
138
142
  request :add_flavor_access
@@ -176,6 +180,7 @@ module Fog
176
180
 
177
181
  # Key Pair
178
182
  request :list_key_pairs
183
+ request :get_key_pair
179
184
  request :create_key_pair
180
185
  request :delete_key_pair
181
186
 
@@ -193,9 +198,10 @@ module Fog
193
198
  request :attach_volume
194
199
  request :detach_volume
195
200
  request :get_server_volumes
201
+ request :list_volume_attachments
196
202
 
197
203
  # Snapshot
198
- request :create_volume_snapshot
204
+ request :create_snapshot
199
205
  request :list_snapshots
200
206
  request :list_snapshots_detail
201
207
  request :get_snapshot_details
@@ -217,6 +223,7 @@ module Fog
217
223
  # Zones
218
224
  request :list_zones
219
225
  request :list_zones_detailed
226
+ request :list_availability_zones
220
227
 
221
228
  class Mock
222
229
  attr_reader :auth_token
@@ -227,73 +234,75 @@ module Fog
227
234
  def self.data
228
235
  @data ||= Hash.new do |hash, key|
229
236
  hash[key] = {
230
- :last_modified => {
231
- :images => {},
232
- :servers => {},
233
- :key_pairs => {},
237
+ :last_modified => {
238
+ :images => {},
239
+ :servers => {},
240
+ :key_pairs => {},
234
241
  :security_groups => {},
235
- :addresses => {}
242
+ :addresses => {}
236
243
  },
237
- :aggregates => [{
244
+ :aggregates => [{
238
245
  "availability_zone" => "nova",
239
- "created_at" => "2012-11-16T06:22:23.032493",
240
- "deleted" => false,
241
- "deleted_at" => nil,
242
- "id" => 1,
243
- "name" => "name",
244
- "updated_at" => nil
246
+ "created_at" => "2012-11-16T06:22:23.032493",
247
+ "deleted" => false,
248
+ "deleted_at" => nil,
249
+ "id" => 1,
250
+ "name" => "name",
251
+ "updated_at" => nil
245
252
  }],
246
- :images => {
253
+ :images => {
247
254
  "0e09fbd6-43c5-448a-83e9-0d3d05f9747e" => {
248
- "id"=>"0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
249
- "name"=>"cirros-0.3.0-x86_64-blank",
250
- 'progress' => 100,
251
- 'status' => "ACTIVE",
252
- 'updated' => "",
253
- 'minRam' => 0,
254
- 'minDisk' => 0,
255
- 'metadata' => {},
256
- 'links' => [{"href"=>"http://nova1:8774/v1.1/admin/images/1", "rel"=>"self"}, {"href"=>"http://nova1:8774/admin/images/2", "rel"=>"bookmark"}]
255
+ "id" => "0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
256
+ "name" => "cirros-0.3.0-x86_64-blank",
257
+ 'progress' => 100,
258
+ 'status' => "ACTIVE",
259
+ 'updated' => "",
260
+ 'minRam' => 0,
261
+ 'minDisk' => 0,
262
+ 'metadata' => {},
263
+ 'links' => [{"href" => "http://nova1:8774/v1.1/admin/images/1", "rel" => "self"},
264
+ {"href" => "http://nova1:8774/admin/images/2", "rel" => "bookmark"}]
257
265
  }
258
266
  },
259
- :servers => {},
260
- :key_pairs => {},
261
- :security_groups => {
267
+ :servers => {},
268
+ :key_pairs => {},
269
+ :security_groups => {
262
270
  '0' => {
263
271
  "id" => 0,
264
272
  "tenant_id" => Fog::Mock.random_hex(8),
265
273
  "name" => "default",
266
274
  "description" => "default",
267
275
  "rules" => [
268
- { "id" => 0,
269
- "parent_group_id" => 0,
270
- "from_port" => 68,
271
- "to_port" => 68,
272
- "ip_protocol" => "udp",
273
- "ip_range" => { "cidr" => "0.0.0.0/0" },
274
- "group" => {}, },
276
+ {"id" => 0,
277
+ "parent_group_id" => 0,
278
+ "from_port" => 68,
279
+ "to_port" => 68,
280
+ "ip_protocol" => "udp",
281
+ "ip_range" => {"cidr" => "0.0.0.0/0"},
282
+ "group" => {},
283
+ },
275
284
  ],
276
285
  },
277
286
  },
278
287
  :server_security_group_map => {},
279
- :addresses => {},
280
- :quota => {
281
- 'security_group_rules' => 20,
282
- 'security_groups' => 10,
288
+ :addresses => {},
289
+ :quota => {
290
+ 'security_group_rules' => 20,
291
+ 'security_groups' => 10,
283
292
  'injected_file_content_bytes' => 10240,
284
- 'injected_file_path_bytes' => 256,
285
- 'injected_files' => 5,
286
- 'metadata_items' => 128,
287
- 'floating_ips' => 10,
288
- 'instances' => 10,
289
- 'key_pairs' => 10,
290
- 'gigabytes' => 5000,
291
- 'volumes' => 10,
292
- 'cores' => 20,
293
- 'ram' => 51200
293
+ 'injected_file_path_bytes' => 256,
294
+ 'injected_files' => 5,
295
+ 'metadata_items' => 128,
296
+ 'floating_ips' => 10,
297
+ 'instances' => 10,
298
+ 'key_pairs' => 10,
299
+ 'gigabytes' => 5000,
300
+ 'volumes' => 10,
301
+ 'cores' => 20,
302
+ 'ram' => 51200
294
303
  },
295
- :volumes => {},
296
- :snapshots => {}
304
+ :volumes => {},
305
+ :snapshots => {}
297
306
  }
298
307
  end
299
308
  end
@@ -304,7 +313,7 @@ module Fog
304
313
 
305
314
  include Fog::OpenStack::Core
306
315
 
307
- def initialize(options={})
316
+ def initialize(options = {})
308
317
  @auth_token = Fog::Mock.random_base64(64)
309
318
  @auth_token_expiration = (Time.now.utc + 86400).iso8601
310
319
 
@@ -327,27 +336,26 @@ module Fog
327
336
  def reset_data
328
337
  self.class.data.delete("#{@openstack_username}-#{@current_tenant}")
329
338
  end
330
-
331
339
  end
332
340
 
333
341
  class Real
334
342
  include Fog::OpenStack::Core
335
343
 
336
- def initialize(options={})
344
+ def initialize(options = {})
337
345
  initialize_identity options
338
346
 
339
347
  @openstack_identity_service_type = options[:openstack_identity_service_type] || 'identity'
340
348
 
341
- @openstack_service_type = options[:openstack_service_type] || ['nova', 'compute']
349
+ @openstack_service_type = options[:openstack_service_type] || %w(nova compute)
342
350
  @openstack_service_name = options[:openstack_service_name]
343
351
 
344
352
  @connection_options = options[:connection_options] || {}
345
353
 
346
354
  authenticate
347
355
 
348
- unless @path.match(/1\.1|v2/)
349
- raise Fog::OpenStack::Errors::ServiceUnavailable.new(
350
- "OpenStack compute binding only supports version 2 (a.k.a. 1.1)")
356
+ unless @path =~ /1\.1|v2/
357
+ raise Fog::OpenStack::Errors::ServiceUnavailable,
358
+ "OpenStack compute binding only supports version 2 (a.k.a. 1.1)"
351
359
  end
352
360
 
353
361
  @persistent = options[:persistent] || false
@@ -356,15 +364,13 @@ module Fog
356
364
 
357
365
  def request(params)
358
366
  begin
359
- response = @connection.request(params.merge({
360
- :headers => {
361
- 'Content-Type' => 'application/json',
362
- 'Accept' => 'application/json',
363
- 'X-Auth-Token' => @auth_token
364
- }.merge!(params[:headers] || {}),
365
- :path => "#{@path}/#{params[:path]}",
366
- :query => params[:query]
367
- }))
367
+ response = @connection.request(params.merge(:headers => {
368
+ 'Content-Type' => 'application/json',
369
+ 'Accept' => 'application/json',
370
+ 'X-Auth-Token' => @auth_token
371
+ }.merge!(params[:headers] || {}),
372
+ :path => "#{@path}/#{params[:path]}",
373
+ :query => params[:query]))
368
374
  rescue Excon::Errors::Unauthorized => error
369
375
  if error.response.body != 'Bad username or password' # token expiration
370
376
  @openstack_must_reauthenticate = true
@@ -375,22 +381,19 @@ module Fog
375
381
  end
376
382
  rescue Excon::Errors::HTTPStatusError => error
377
383
  raise case error
378
- when Excon::Errors::NotFound
379
- Fog::Compute::OpenStack::NotFound.slurp(error)
380
- else
381
- error
382
- end
384
+ when Excon::Errors::NotFound
385
+ Fog::Compute::OpenStack::NotFound.slurp(error)
386
+ else
387
+ error
388
+ end
383
389
  end
384
390
 
385
- if !response.body.empty? and response.get_header('Content-Type') == 'application/json'
391
+ if !response.body.empty? && response.get_header('Content-Type') == 'application/json'
386
392
  response.body = Fog::JSON.decode(response.body)
387
393
  end
388
394
 
389
395
  response
390
396
  end
391
-
392
- private
393
-
394
397
  end
395
398
  end
396
399
  end
@@ -2,7 +2,7 @@ module Fog
2
2
  module OpenStack
3
3
  module Core
4
4
  attr_accessor :auth_token
5
- attr_reader :openstack_cache_ttl
5
+ attr_reader :openstack_cache_ttl
6
6
  attr_reader :auth_token_expiration
7
7
  attr_reader :current_user
8
8
  attr_reader :current_user_id
@@ -12,6 +12,7 @@ module Fog
12
12
  attr_reader :openstack_project_domain
13
13
  attr_reader :openstack_domain_id
14
14
  attr_reader :openstack_user_domain_id
15
+ attr_reader :openstack_project_id
15
16
  attr_reader :openstack_project_domain_id
16
17
  attr_reader :openstack_identity_prefix
17
18