fog-openstack 0.1.31 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +4 -1
  4. data/.travis.yml +5 -5
  5. data/.zuul.yaml +8 -8
  6. data/Rakefile +14 -4
  7. data/fog-openstack.gemspec +3 -2
  8. data/lib/fog/baremetal/openstack.rb +6 -24
  9. data/lib/fog/compute/openstack.rb +6 -27
  10. data/lib/fog/compute/openstack/requests/create_security_group.rb +1 -1
  11. data/lib/fog/compute/openstack/requests/create_server.rb +1 -1
  12. data/lib/fog/compute/openstack/requests/evacuate_server.rb +1 -5
  13. data/lib/fog/container_infra/openstack.rb +6 -25
  14. data/lib/fog/dns/openstack/v1.rb +5 -17
  15. data/lib/fog/dns/openstack/v2.rb +5 -22
  16. data/lib/fog/event/openstack.rb +5 -24
  17. data/lib/fog/identity/openstack.rb +24 -71
  18. data/lib/fog/identity/openstack/v2.rb +6 -4
  19. data/lib/fog/identity/openstack/v3.rb +5 -11
  20. data/lib/fog/image/openstack/v1.rb +8 -21
  21. data/lib/fog/image/openstack/v2.rb +8 -21
  22. data/lib/fog/image/openstack/v2/models/image.rb +1 -1
  23. data/lib/fog/introspection/openstack.rb +4 -19
  24. data/lib/fog/key_manager/openstack.rb +5 -47
  25. data/lib/fog/metering/openstack.rb +8 -23
  26. data/lib/fog/metric/openstack.rb +7 -26
  27. data/lib/fog/monitoring/openstack.rb +3 -12
  28. data/lib/fog/network/openstack.rb +5 -26
  29. data/lib/fog/network/openstack/requests/set_tenant.rb +0 -1
  30. data/lib/fog/nfv/openstack.rb +4 -24
  31. data/lib/fog/openstack.rb +17 -431
  32. data/lib/fog/openstack/auth/catalog.rb +64 -0
  33. data/lib/fog/openstack/auth/catalog/v2.rb +23 -0
  34. data/lib/fog/openstack/auth/catalog/v3.rb +23 -0
  35. data/lib/fog/openstack/auth/name.rb +65 -0
  36. data/lib/fog/openstack/auth/token.rb +69 -0
  37. data/lib/fog/openstack/auth/token/v2.rb +70 -0
  38. data/lib/fog/openstack/auth/token/v3.rb +116 -0
  39. data/lib/fog/openstack/core.rb +100 -76
  40. data/lib/fog/openstack/version.rb +1 -1
  41. data/lib/fog/orchestration/openstack.rb +4 -21
  42. data/lib/fog/planning/openstack.rb +13 -23
  43. data/lib/fog/shared_file_system/openstack.rb +10 -27
  44. data/lib/fog/storage/openstack.rb +6 -11
  45. data/lib/fog/volume/openstack.rb +1 -1
  46. data/lib/fog/volume/openstack/models/backup.rb +2 -2
  47. data/lib/fog/volume/openstack/requests/restore_backup.rb +2 -2
  48. data/lib/fog/volume/openstack/requests/update_volume.rb +12 -1
  49. data/lib/fog/volume/openstack/v1.rb +4 -21
  50. data/lib/fog/volume/openstack/v1/models/volume.rb +1 -2
  51. data/lib/fog/volume/openstack/v1/requests/update_volume.rb +0 -17
  52. data/lib/fog/volume/openstack/v2.rb +4 -21
  53. data/lib/fog/volume/openstack/v2/models/volume.rb +1 -1
  54. data/lib/fog/volume/openstack/v2/requests/update_volume.rb +0 -18
  55. data/lib/fog/workflow/openstack/v2.rb +5 -22
  56. data/playbooks/fog-openstack-unittest-spec/run.yaml +2 -1
  57. data/playbooks/fog-openstack-unittest-test/run.yaml +2 -1
  58. data/unit/auth/catalog_test.rb +252 -0
  59. data/unit/auth/name_test.rb +115 -0
  60. data/unit/auth/token_test.rb +478 -0
  61. data/unit/auth_helper.rb +102 -0
  62. data/unit/test_helper.rb +6 -0
  63. metadata +41 -16
  64. data/lib/fog/compute/openstack/requests/list_tenants.rb +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 64e6fe81feffe46842e7b67179d4df541f816641d4ad3ccf8171654cf437f6f0
4
- data.tar.gz: fdb13d901f583c649011f7574293031b455ed310984fdbceb20f3bb3680e205c
2
+ SHA1:
3
+ metadata.gz: c70342e05368a8b5eee2e3b0cc8bfa02f2201156
4
+ data.tar.gz: d0794fd0a519e1e9a1e0501d22f04b14f5f17c90
5
5
  SHA512:
6
- metadata.gz: 24766268b47e478a821f15e523b3d33c01b4bcda8de04905b1168838263584368face4b3a40c9e9a11ac4435d3e2ed92bd2db6dab1feb98adcc8070db391b81e
7
- data.tar.gz: 83fca28ad50848a581dea2450e49312162bee8448bdbe8bcb69b939cb0abe4f7a5beed21def6bd9f64ad883090ce252fbc4ed3d7e15efd1fa330160b670607d4
6
+ metadata.gz: 9c974aa8e32e72c4bf8397c5881563e7349a54ce13b3f3f92dddd2f8434d32ee53b3c636f0316f7da4c18ca03b95e808e6848f4ea4e3c8595b84de1e8213297d
7
+ data.tar.gz: 7e1d1a0ebcbdd7582beb275d66a66bb24dfa08b64072a015a57c8c311aa67217b040e2b33b7be418ef379ccffb59f21399aae04dd381381b81b1e7e38266307a
data/.gitignore CHANGED
@@ -11,3 +11,4 @@ gemfiles/Gemfile-1.9.lock
11
11
  .DS_Store
12
12
  .idea/
13
13
  vendor/bundle
14
+ test/.lorem.txt
data/.rubocop.yml CHANGED
@@ -41,7 +41,7 @@ Metrics/BlockLength:
41
41
  - it
42
42
  - model_tests
43
43
  - namespace
44
- - draw
44
+ - draw
45
45
  ParameterLists:
46
46
  Severity: refactor
47
47
  PerceivedComplexity:
@@ -54,6 +54,9 @@ SingleLineMethods:
54
54
  AllowIfMethodIsEmpty: false
55
55
  SpaceInsideHashLiteralBraces:
56
56
  EnforcedStyle: no_space
57
+ Style/RegexpLiteral:
58
+ EnforcedStyle: slashes
59
+ AllowInnerSlashes: true
57
60
  TrivialAccessors:
58
61
  AllowPredicates: true
59
62
  #
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  before_install:
4
- - gem install bundler --version '~> 1'
4
+ - gem update bundler
5
5
  script:
6
6
  - bundle exec rake test TESTOPTS="--verbose"
7
7
  - bundle exec rake spec
@@ -10,13 +10,13 @@ env:
10
10
  matrix:
11
11
  fast_finish: true
12
12
  include:
13
- - rvm: 2.3.8
13
+ - rvm: 2.2.10
14
14
  gemfile: Gemfile
15
- - rvm: 2.4.5
15
+ - rvm: 2.3.7
16
16
  gemfile: Gemfile
17
- - rvm: 2.5.3
17
+ - rvm: 2.4.4
18
18
  gemfile: Gemfile
19
- - rvm: 2.6.0
19
+ - rvm: 2.5.1
20
20
  gemfile: Gemfile
21
21
  - rvm: jruby-head
22
22
  gemfile: Gemfile
data/.zuul.yaml CHANGED
@@ -12,10 +12,10 @@
12
12
  run: playbooks/fog-openstack-unittest-test/run.yaml
13
13
  vars:
14
14
  rvm:
15
- 2.3.8
16
- 2.4.5
17
- 2.5.3
18
- 2.6.0
15
+ 2.2.10
16
+ 2.3.7
17
+ 2.4.4
18
+ 2.5.1
19
19
  jruby-head
20
20
  nodeset: ubuntu-xenial
21
21
 
@@ -27,9 +27,9 @@
27
27
  run: playbooks/fog-openstack-unittest-spec/run.yaml
28
28
  vars:
29
29
  rvm:
30
- 2.3.8
31
- 2.4.5
32
- 2.5.3
33
- 2.6.0
30
+ 2.2.10
31
+ 2.3.7
32
+ 2.4.4
33
+ 2.5.1
34
34
  jruby-head
35
35
  nodeset: ubuntu-xenial
data/Rakefile CHANGED
@@ -4,18 +4,20 @@ require 'rake/testtask'
4
4
 
5
5
  RuboCop::RakeTask.new
6
6
 
7
- task :default => ['tests:unit', 'tests:spec']
7
+ task :default => ['tests:mock', 'tests:spec', 'tests:unit']
8
8
 
9
- task :test => 'tests:unit'
9
+ task :mock => 'tests:mock'
10
10
 
11
11
  task :spec => "tests:spec"
12
12
 
13
+ task :unit => 'tests:unit'
14
+
13
15
  namespace :tests do
14
- desc 'Run fog-openstack tests with Minitest'
16
+ desc 'Run fog-openstack tests with Mock class'
15
17
  Rake::TestTask.new do |t|
16
18
  ENV['FOG_MOCK']= ENV['FOG_MOCK'].nil? ? 'true' : ENV['FOG_MOCK']
17
19
 
18
- t.name = 'unit'
20
+ t.name = 'mock'
19
21
  t.libs.push [ "lib", "test" ]
20
22
  t.test_files = FileList['test/**/*.rb']
21
23
  t.verbose = true
@@ -28,4 +30,12 @@ namespace :tests do
28
30
  t.pattern = 'spec/**/*_spec.rb'
29
31
  t.verbose = true
30
32
  end
33
+
34
+ desc 'Run fog-openstack unit tests'
35
+ Rake::TestTask.new do |t|
36
+ t.name = 'unit'
37
+ t.libs.push [ "lib", "unit" ]
38
+ t.pattern = 'unit/**/*_test.rb'
39
+ t.verbose = true
40
+ end
31
41
  end
@@ -25,14 +25,15 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency 'fog-json', '>= 1.0'
26
26
  spec.add_dependency 'ipaddress', '>= 0.8'
27
27
 
28
- spec.add_development_dependency 'bundler', '~> 1'
28
+ spec.add_development_dependency 'bundler', '~> 1.6'
29
29
  spec.add_development_dependency 'coveralls'
30
30
  spec.add_development_dependency "mime-types"
31
31
  spec.add_development_dependency "mime-types-data"
32
+ spec.add_development_dependency 'minitest'
33
+ spec.add_development_dependency 'pry-byebug'
32
34
  spec.add_development_dependency 'rake', '~> 10.0'
33
35
  spec.add_development_dependency 'rubocop'
34
36
  spec.add_development_dependency 'shindo', '~> 0.3'
35
- spec.add_development_dependency 'minitest'
36
37
  spec.add_development_dependency 'vcr'
37
38
  spec.add_development_dependency 'webmock', '~> 1.24.6'
38
39
  end
@@ -248,35 +248,17 @@ module Fog
248
248
  class Real
249
249
  include Fog::OpenStack::Core
250
250
 
251
+ def default_service_type
252
+ %w[baremetal]
253
+ end
254
+
251
255
  # NOTE: uncommenting this should be treated as api-change!
252
256
  # def self.not_found_class
253
257
  # Fog::Baremetal::OpenStack::NotFound
254
258
  # end
255
259
 
256
- def initialize(options = {})
257
- initialize_identity options
258
-
259
- @openstack_service_type = options[:openstack_service_type] || ['baremetal']
260
- @openstack_service_name = options[:openstack_service_name]
261
-
262
- @connection_options = options[:connection_options] || {}
263
-
264
- authenticate
265
- set_api_path
266
-
267
- @persistent = options[:persistent] || false
268
- @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
269
- end
270
-
271
- private
272
-
273
- def set_api_path
274
- unless @path.match(SUPPORTED_VERSIONS)
275
- @path = "/" + Fog::OpenStack.get_supported_version(SUPPORTED_VERSIONS,
276
- @openstack_management_uri,
277
- @auth_token,
278
- @connection_options)
279
- end
260
+ def default_path_prefix
261
+ 'v1'
280
262
  end
281
263
  end
282
264
  end
@@ -14,7 +14,7 @@ module Fog
14
14
  :openstack_project_name, :openstack_project_id,
15
15
  :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
16
16
  :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
17
- :openstack_identity_prefix
17
+ :openstack_identity_api_version
18
18
 
19
19
  ## MODELS
20
20
  #
@@ -197,7 +197,6 @@ module Fog
197
197
  request :delete_key_pair
198
198
 
199
199
  # Tenant
200
- request :list_tenants
201
200
  request :set_tenant
202
201
  request :get_limits
203
202
 
@@ -355,16 +354,10 @@ module Fog
355
354
  @auth_token = Fog::Mock.random_base64(64)
356
355
  @auth_token_expiration = (Time.now.utc + 86400).iso8601
357
356
 
358
- initialize_identity options
359
-
360
357
  management_url = URI.parse(options[:openstack_auth_url])
361
358
  management_url.port = 8774
362
359
  management_url.path = '/v1.1/1'
363
360
  @openstack_management_url = management_url.to_s
364
-
365
- identity_public_endpoint = URI.parse(options[:openstack_auth_url])
366
- identity_public_endpoint.port = 5000
367
- @openstack_identity_public_endpoint = identity_public_endpoint.to_s
368
361
  end
369
362
 
370
363
  def data
@@ -383,29 +376,15 @@ module Fog
383
376
  Fog::Compute::OpenStack::NotFound
384
377
  end
385
378
 
379
+ def default_service_type
380
+ %w[compute]
381
+ end
382
+
386
383
  def initialize(options = {})
387
384
  @supported_versions = SUPPORTED_VERSIONS
388
385
  @supported_microversion = SUPPORTED_MICROVERSION
389
386
  @microversion_key = 'X-OpenStack-Nova-API-Version'
390
-
391
- initialize_identity options
392
-
393
- @openstack_identity_service_type = options[:openstack_identity_service_type] || 'identity'
394
-
395
- @openstack_service_type = options[:openstack_service_type] || %w(nova compute)
396
- @openstack_service_name = options[:openstack_service_name]
397
-
398
- @connection_options = options[:connection_options] || {}
399
-
400
- authenticate
401
-
402
- unless @path =~ %r{/(v2|v2\.0|v2\.1)}
403
- raise Fog::OpenStack::Errors::ServiceUnavailable,
404
- "OpenStack compute binding only supports version v2 and v2.1"
405
- end
406
-
407
- @persistent = options[:persistent] || false
408
- @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
387
+ super
409
388
  end
410
389
  end
411
390
  end
@@ -21,7 +21,7 @@ module Fog
21
21
 
22
22
  class Mock
23
23
  def create_security_group(name, description)
24
- Fog::Identity::OpenStack.new(:openstack_auth_url => credentials[:openstack_auth_url])
24
+ Fog::Identity::OpenStack.new(:openstack_auth_url => credentials[:openstack_auth_url], :openstack_identity_api_version => 'v2.0')
25
25
  tenant_id = Fog::Identity::OpenStack::V2::Mock.data[current_tenant][:tenants].keys.first
26
26
  security_group_id = Fog::Mock.random_numbers(2).to_i + 1
27
27
  data[:security_groups][security_group_id.to_s] = {
@@ -94,7 +94,7 @@ module Fog
94
94
  response.status = 202
95
95
 
96
96
  server_id = Fog::Mock.random_numbers(6).to_s
97
- identity = Fog::Identity::OpenStack.new :openstack_auth_url => credentials[:openstack_auth_url]
97
+ identity = Fog::Identity::OpenStack.new(:openstack_auth_url => credentials[:openstack_auth_url], :openstack_identity_api_version => 'v2.0')
98
98
  user = identity.users.find do |u|
99
99
  u.name == @openstack_username
100
100
  end
@@ -5,11 +5,7 @@ module Fog
5
5
  def evacuate_server(server_id, host = nil, on_shared_storage = nil, admin_password = nil)
6
6
  evacuate = {}
7
7
  evacuate['host'] = host if host
8
-
9
- if !microversion_newer_than?('2.13') && on_shared_storage
10
- evacuate['onSharedStorage'] = on_shared_storage
11
- end
12
-
8
+ evacuate['onSharedStorage'] = on_shared_storage if on_shared_storage
13
9
  evacuate['adminPass'] = admin_password if admin_password
14
10
  body = {
15
11
  'evacuate' => evacuate
@@ -14,7 +14,7 @@ module Fog
14
14
  :openstack_project_name, :openstack_project_id,
15
15
  :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
16
16
  :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
17
- :openstack_identity_prefix
17
+ :openstack_identity_api_version
18
18
 
19
19
  model_path 'fog/container_infra/openstack/models'
20
20
 
@@ -126,37 +126,18 @@ module Fog
126
126
  Fog::ContainerInfra::OpenStack::NotFound
127
127
  end
128
128
 
129
- def initialize(options = {})
130
- initialize_identity options
131
-
132
- @openstack_service_type = options[:openstack_service_type] || ['container-infra']
133
- @openstack_service_name = options[:openstack_service_name]
134
- @openstack_endpoint_type = options[:openstack_endpoint_type] || 'publicURL'
135
-
136
- @connection_options = options[:connection_options] || {}
137
-
138
- authenticate
139
- set_api_path
129
+ def default_path_prefix
130
+ 'v1'
131
+ end
140
132
 
141
- @persistent = options[:persistent] || false
142
- @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
133
+ def default_service_type
134
+ %w[container-infra]
143
135
  end
144
136
 
145
137
  def request(options = {})
146
138
  options[:headers] = {'OpenStack-API-Version' => "container-infra #{SUPPORTED_MICROVERSION}"}
147
139
  super(options)
148
140
  end
149
-
150
- def set_api_path
151
- unless @path.match(SUPPORTED_VERSIONS)
152
- @path = Fog::OpenStack.get_supported_version_path(
153
- SUPPORTED_VERSIONS,
154
- @openstack_management_uri,
155
- @auth_token,
156
- @connection_options
157
- )
158
- end
159
- end
160
141
  end
161
142
  end
162
143
  end
@@ -14,7 +14,7 @@ module Fog
14
14
  :openstack_project_name, :openstack_project_id,
15
15
  :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
16
16
  :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
17
- :openstack_identity_prefix, :openstack_temp_url_key, :openstack_cache_ttl
17
+ :openstack_identity_api_version, :openstack_temp_url_key, :openstack_cache_ttl
18
18
 
19
19
  request_path 'fog/dns/openstack/v1/requests'
20
20
 
@@ -102,24 +102,12 @@ module Fog
102
102
  Fog::DNS::OpenStack::NotFound
103
103
  end
104
104
 
105
- def initialize(options = {})
106
- initialize_identity options
107
-
108
- @openstack_service_type = options[:openstack_service_type] || ['dns']
109
- @openstack_service_name = options[:openstack_service_name]
110
-
111
- @connection_options = options[:connection_options] || {}
112
-
113
- authenticate
114
- set_api_path
115
- @persistent = options[:persistent] || false
116
- @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
105
+ def default_path_prefix
106
+ 'v1'
117
107
  end
118
108
 
119
- def set_api_path
120
- # version explicitly set to allow usage also in 'DEPRECATED' mitaka version,
121
- # where f.i. quota modification was not possible at the time of creation
122
- @path = '/v1' unless @path =~ /v1/
109
+ def default_service_type
110
+ %w[dns]
123
111
  end
124
112
  end
125
113
  end
@@ -16,7 +16,7 @@ module Fog
16
16
  :openstack_project_name, :openstack_project_id,
17
17
  :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
18
18
  :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
19
- :openstack_identity_prefix, :openstack_temp_url_key, :openstack_cache_ttl
19
+ :openstack_identity_api_version, :openstack_temp_url_key, :openstack_cache_ttl
20
20
 
21
21
  model_path 'fog/dns/openstack/v2/models'
22
22
  model :zone
@@ -311,29 +311,12 @@ module Fog
311
311
  Fog::DNS::OpenStack::NotFound
312
312
  end
313
313
 
314
- def initialize(options = {})
315
- initialize_identity options
316
-
317
- @openstack_service_type = options[:openstack_service_type] || ['dns']
318
- @openstack_service_name = options[:openstack_service_name]
319
-
320
- @connection_options = options[:connection_options] || {}
321
-
322
- authenticate
323
- set_api_path
324
- @persistent = options[:persistent] || false
325
- @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}/", @persistent, @connection_options)
314
+ def default_path_prefix
315
+ 'v2'
326
316
  end
327
317
 
328
- def set_api_path
329
- unless @path.match(SUPPORTED_VERSIONS)
330
- @path = Fog::OpenStack.get_supported_version_path(
331
- SUPPORTED_VERSIONS,
332
- @openstack_management_uri,
333
- @auth_token,
334
- @connection_options
335
- )
336
- end
318
+ def default_service_type
319
+ %w[dns]
337
320
  end
338
321
  end
339
322
  end
@@ -13,7 +13,7 @@ module Fog
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,
16
- :openstack_identity_prefix
16
+ :openstack_identity_api_version
17
17
 
18
18
  model_path 'fog/event/openstack/models'
19
19
 
@@ -88,31 +88,12 @@ module Fog
88
88
  Fog::Event::OpenStack::NotFound
89
89
  end
90
90
 
91
- def initialize(options = {})
92
- initialize_identity options
93
-
94
- @openstack_service_type = options[:openstack_service_type] || ['event']
95
- @openstack_service_name = options[:openstack_service_name]
96
- @openstack_endpoint_type = options[:openstack_endpoint_type] || 'publicURL'
97
-
98
- @connection_options = options[:connection_options] || {}
99
-
100
- authenticate
101
- set_api_path
102
-
103
- @persistent = options[:persistent] || false
104
- @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
91
+ def default_path_prefix
92
+ 'v2'
105
93
  end
106
94
 
107
- def set_api_path
108
- unless @path.match(SUPPORTED_VERSIONS)
109
- @path = "/" + Fog::OpenStack.get_supported_version(
110
- SUPPORTED_VERSIONS,
111
- @openstack_management_uri,
112
- @auth_token,
113
- @connection_options
114
- )
115
- end
95
+ def default_service_type
96
+ %w[event]
116
97
  end
117
98
  end
118
99
  end