fog-openstack 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/README.md +2 -2
  4. data/Rakefile +1 -8
  5. data/docs/orchestration.md +19 -0
  6. data/fog-openstack.gemspec +2 -1
  7. data/gemfiles/Gemfile-1.9 +2 -1
  8. data/lib/fog/dns/openstack/v2.rb +20 -0
  9. data/lib/fog/dns/openstack/v2/models/recordset.rb +55 -0
  10. data/lib/fog/dns/openstack/v2/models/recordsets.rb +30 -0
  11. data/lib/fog/dns/openstack/v2/models/zone.rb +50 -0
  12. data/lib/fog/dns/openstack/v2/models/zones.rb +30 -0
  13. data/lib/fog/dns/openstack/v2/requests/delete_recordset.rb +5 -3
  14. data/lib/fog/dns/openstack/v2/requests/delete_zone.rb +5 -3
  15. data/lib/fog/dns/openstack/v2/requests/get_quota.rb +4 -2
  16. data/lib/fog/dns/openstack/v2/requests/get_recordset.rb +4 -2
  17. data/lib/fog/dns/openstack/v2/requests/get_zone.rb +5 -3
  18. data/lib/fog/dns/openstack/v2/requests/list_recordsets.rb +29 -5
  19. data/lib/fog/dns/openstack/v2/requests/list_zones.rb +4 -1
  20. data/lib/fog/dns/openstack/v2/requests/update_quota.rb +4 -3
  21. data/lib/fog/dns/openstack/v2/requests/update_recordset.rb +4 -1
  22. data/lib/fog/dns/openstack/v2/requests/update_zone.rb +4 -1
  23. data/lib/fog/introspection/openstack.rb +3 -8
  24. data/lib/fog/monitoring/openstack.rb +7 -1
  25. data/lib/fog/monitoring/openstack/models/alarm.rb +0 -1
  26. data/lib/fog/monitoring/openstack/models/alarm_definition.rb +1 -0
  27. data/lib/fog/monitoring/openstack/models/dimension_value.rb +19 -0
  28. data/lib/fog/monitoring/openstack/models/dimension_values.rb +16 -0
  29. data/lib/fog/monitoring/openstack/models/metrics.rb +8 -0
  30. data/lib/fog/monitoring/openstack/models/notification_method.rb +8 -1
  31. data/lib/fog/monitoring/openstack/models/notification_methods.rb +4 -0
  32. data/lib/fog/monitoring/openstack/requests/list_dimension_values.rb +21 -0
  33. data/lib/fog/monitoring/openstack/requests/list_notification_method_types.rb +21 -0
  34. data/lib/fog/monitoring/openstack/requests/{update_notification_method.rb → patch_notification_method.rb} +1 -1
  35. data/lib/fog/monitoring/openstack/requests/put_notification_method.rb +19 -0
  36. data/lib/fog/network/openstack.rb +12 -8
  37. data/lib/fog/network/openstack/requests/create_network.rb +54 -63
  38. data/lib/fog/network/openstack/requests/update_network.rb +27 -8
  39. data/lib/fog/openstack.rb +44 -28
  40. data/lib/fog/openstack/version.rb +1 -1
  41. data/lib/fog/orchestration/openstack.rb +1 -0
  42. data/lib/fog/orchestration/openstack/models/stack.rb +4 -0
  43. data/lib/fog/orchestration/openstack/requests/cancel_update.rb +26 -0
  44. metadata +13 -30
  45. data/tests/fixtures/introspection.yaml +0 -287
  46. data/tests/helper.rb +0 -24
  47. data/tests/helpers/collection_helper.rb +0 -97
  48. data/tests/helpers/compute/flavors_helper.rb +0 -32
  49. data/tests/helpers/compute/server_helper.rb +0 -25
  50. data/tests/helpers/compute/servers_helper.rb +0 -10
  51. data/tests/helpers/formats_helper.rb +0 -98
  52. data/tests/helpers/formats_helper_tests.rb +0 -110
  53. data/tests/helpers/mock_helper.rb +0 -17
  54. data/tests/helpers/model_helper.rb +0 -31
  55. data/tests/helpers/responds_to_helper.rb +0 -11
  56. data/tests/helpers/schema_validator_tests.rb +0 -107
  57. data/tests/helpers/succeeds_helper.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 562236470fef48eeb59f994f20b39968991a886b
4
- data.tar.gz: 01ae0328e668f1f71851b6bfb8a90e60ace343c1
3
+ metadata.gz: b2e12b17ba616a2d5b1d1290312ff5d1cd489c62
4
+ data.tar.gz: b81c3f55d47899d6f5ecc77b25065ad77f3df5d0
5
5
  SHA512:
6
- metadata.gz: c4d4cbed29e2fa54a229dff53bcdf9902ced680f9dd59c9fa78ed097b79ac1a9db4638ce888e3151ba510705415cbfd66fb6f1235961348263526851aa7581e6
7
- data.tar.gz: 17e26ef37b2e5e5d1b2704c76d2a02de1168cbb60eec3885cf1e9069f56e1d800f77cecc4e586b8926add7d6329882757c681c2af80128952a2d3112deaca045
6
+ metadata.gz: 7b0cc3dfc3872a6cf24819aa45831807d5cbfec03cc9e992aced62f3576218befdb1e67502029e6b708b7a6d3fd3228924b09873e510ffa68304570b99003b5a
7
+ data.tar.gz: f3d442b936d042cdbdc13c3c446fc6f3af09a5c9e602152b154dd61abe18c3b71bd219ce93156df38d220520e7a45d0bdc3dc9c826be1d3e488e3bc211636d76
@@ -2,7 +2,6 @@ language: ruby
2
2
  sudo: false
3
3
  script:
4
4
  - bundle exec rake test
5
- - bundle exec rake minitest
6
5
  - bundle exec rake spec
7
6
  env:
8
7
  - JRUBY_OPTS=--debug
data/README.md CHANGED
@@ -59,7 +59,7 @@ If you're using Keystone V2, you don't need to supply domain details but ensure
59
59
 
60
60
  ```ruby
61
61
  @connection_params = {
62
- openstack_auth_url: "http://devstack.test:5000/v2.0/tokens"
62
+ openstack_auth_url: "http://devstack.test:5000/v2.0/tokens",
63
63
  openstack_username: "admin",
64
64
  openstack_api_key: "password",
65
65
  openstack_project_name: "admin"
@@ -514,7 +514,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
514
514
 
515
515
  ## Contributing
516
516
 
517
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fog-openstack. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
517
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fog/fog-openstack. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
518
518
 
519
519
 
520
520
  ## License
data/Rakefile CHANGED
@@ -6,15 +6,8 @@ RuboCop::RakeTask.new
6
6
 
7
7
  task :default => :test
8
8
 
9
- # To be removed once after Minitest migration
10
- desc 'Run fog-openstack unit tests with Shindo'
11
- task :test do
12
- mock = ENV['FOG_MOCK'] || 'true'
13
- sh("export FOG_MOCK=#{mock} && bundle exec shindont")
14
- end
15
-
16
9
  desc 'Run fog-openstack unit tests with Minitest'
17
- task :minitest do
10
+ task :test do
18
11
  mock = ENV['FOG_MOCK'] || 'true'
19
12
  sh("export FOG_MOCK=#{mock} && bundle exec rake tests:unit")
20
13
  end
@@ -316,3 +316,22 @@ service.templates.validate(:template => content)
316
316
  content=nil
317
317
  >
318
318
  ```
319
+
320
+ ## Cancel Update
321
+ When the stack is updating, you can cancel the update:
322
+
323
+ ```ruby
324
+ # stack.stack_status == 'UPDATE_IN_PROGRESS'
325
+ stack.cancel_update
326
+ => nil
327
+ ```
328
+
329
+ Then you can see the status changed to ROLLBACK_IN_PROGRESS:
330
+
331
+ ```ruby
332
+ stack = service.stacks.get(stack.stack_name, stack.id)
333
+ stack.stack_status
334
+ => "ROLLBACK_IN_PROGRESS"
335
+ ```
336
+
337
+
@@ -24,7 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency 'ipaddress', '>= 0.8'
25
25
 
26
26
  spec.add_development_dependency 'bundler', '~> 1.6'
27
- spec.add_development_dependency 'coveralls'
27
+ # TODO: remove when https://github.com/fog/fog-openstack/issues/202 is fixed
28
+ # spec.add_development_dependency 'coveralls'
28
29
  spec.add_development_dependency "mime-types"
29
30
  spec.add_development_dependency "mime-types-data"
30
31
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -15,5 +15,6 @@ group :development, :test do
15
15
  gem "vcr"
16
16
  gem "webmock", "~> 1.24.6"
17
17
  gem "json", "< 2.0"
18
- gem "coveralls", "< 0.8.15"
18
+ # TODO: remove when https://github.com/fog/fog-openstack/issues/202 is fixed
19
+ # gem "coveralls", "< 0.8.15"
19
20
  end
@@ -18,6 +18,12 @@ module Fog
18
18
  :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
19
19
  :openstack_identity_prefix, :openstack_temp_url_key, :openstack_cache_ttl
20
20
 
21
+ model_path 'fog/dns/openstack/v2/models'
22
+ model :zone
23
+ collection :zones
24
+ model :recordset
25
+ collection :recordsets
26
+
21
27
  request_path 'fog/dns/openstack/v2/requests'
22
28
 
23
29
  request :list_zones
@@ -35,6 +41,20 @@ module Fog
35
41
  request :get_quota
36
42
  request :update_quota
37
43
 
44
+ def self.setup_headers(options)
45
+ # user needs to have admin privileges to ask for all projects
46
+ all_projects = options.delete(:all_projects) || false
47
+
48
+ # user needs to have admin privileges to impersonate another project
49
+ # don't ask for all and one project at the same time
50
+ project_id = options.delete(:project_id) unless all_projects
51
+
52
+ headers = {'X-Auth-All-Projects' => all_projects}
53
+ headers['X-Auth-Sudo-Project-Id'] = project_id unless project_id.nil?
54
+
55
+ [headers, options]
56
+ end
57
+
38
58
  class Mock
39
59
  def self.data
40
60
  @data ||= Hash.new do |hash, key|
@@ -0,0 +1,55 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module DNS
5
+ class OpenStack
6
+ class V2
7
+ class Recordset < Fog::OpenStack::Model
8
+ identity :id
9
+
10
+ attribute :name
11
+ attribute :project_id
12
+ attribute :status
13
+ attribute :action
14
+ attribute :zone_id
15
+ attribute :zone_name
16
+ attribute :type
17
+ attribute :records
18
+ attribute :version
19
+ attribute :created_at
20
+ attribute :links
21
+
22
+ attribute :ttl
23
+ attribute :description
24
+ attribute :updated_at
25
+
26
+ def save
27
+ raise Fog::Errors::Error, 'Resaving an existing object may create a duplicate' if persisted?
28
+ requires :zone_id, :name, :type, :records
29
+ merge_attributes(service.create_recordset(zone_id, name, type, records, attributes).body)
30
+ true
31
+ end
32
+
33
+ # overwritten because zone_id is needed for get
34
+ def reload(options = {})
35
+ requires :zone_id, :id
36
+ merge_attributes(collection.get(zone_id, id, options).attributes)
37
+ self
38
+ end
39
+
40
+ def update(options = nil)
41
+ requires :zone_id, :id
42
+ merge_attributes(service.update_recordset(zone_id, id, options || attributes).body)
43
+ self
44
+ end
45
+
46
+ def destroy(options = {})
47
+ requires :zone_id, :id
48
+ service.delete_recordset(zone_id, id, options)
49
+ true
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,30 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/dns/openstack/v2/models/recordset'
3
+
4
+ module Fog
5
+ module DNS
6
+ class OpenStack
7
+ class V2
8
+ class Recordsets < Fog::OpenStack::Collection
9
+ model Fog::DNS::OpenStack::V2::Recordset
10
+
11
+ def all(options = {})
12
+ load_response(service.list_recordsets(options), 'recordsets')
13
+ end
14
+
15
+ def find_by_id(zone_id, id, options = {})
16
+ recordset_hash = service.get_recordset(zone_id, id, options).body
17
+ new(recordset_hash.merge(:service => service))
18
+ end
19
+
20
+ alias get find_by_id
21
+
22
+ def destroy(zone_id, id, options = {})
23
+ recordset = find_by_id(zone_id, id, options)
24
+ recordset.destroy
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,50 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module DNS
5
+ class OpenStack
6
+ class V2
7
+ class Zone < Fog::OpenStack::Model
8
+ identity :id
9
+
10
+ attribute :name
11
+ attribute :email
12
+ attribute :pool_id
13
+ attribute :project_id
14
+ attribute :serial
15
+ attribute :status
16
+ attribute :action
17
+ attribute :masters
18
+ attribute :version
19
+ attribute :links
20
+ attribute :created_at
21
+ attribute :transfered_at
22
+
23
+ attribute :ttl
24
+ attribute :description
25
+ attribute :type
26
+ attribute :updated_at
27
+
28
+ def save
29
+ raise Fog::Errors::Error, 'Resaving an existing object may create a duplicate' if persisted?
30
+ requires :name, :email
31
+ merge_attributes(service.create_zone(name, email, attributes).body)
32
+ true
33
+ end
34
+
35
+ def update(options = nil)
36
+ requires :id
37
+ merge_attributes(service.update_zone(id, options || attributes).body)
38
+ self
39
+ end
40
+
41
+ def destroy(options = {})
42
+ requires :id
43
+ service.delete_zone(id, options)
44
+ true
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,30 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/dns/openstack/v2/models/zone'
3
+
4
+ module Fog
5
+ module DNS
6
+ class OpenStack
7
+ class V2
8
+ class Zones < Fog::OpenStack::Collection
9
+ model Fog::DNS::OpenStack::V2::Zone
10
+
11
+ def all(options = {})
12
+ load_response(service.list_zones(options), 'zones')
13
+ end
14
+
15
+ def find_by_id(id, options = {})
16
+ zone_hash = service.get_zone(id, options).body
17
+ new(zone_hash.merge(:service => service))
18
+ end
19
+
20
+ alias get find_by_id
21
+
22
+ def destroy(id, options = {})
23
+ zone = find_by_id(id, options)
24
+ zone.destroy
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -3,17 +3,19 @@ module Fog
3
3
  class OpenStack
4
4
  class V2
5
5
  class Real
6
- def delete_recordset(zone_id, id)
6
+ def delete_recordset(zone_id, id, options = {})
7
+ headers, _options = Fog::DNS::OpenStack::V2.setup_headers(options)
7
8
  request(
8
9
  :expects => 202,
9
10
  :method => 'DELETE',
10
- :path => "zones/#{zone_id}/recordsets/#{id}"
11
+ :path => "zones/#{zone_id}/recordsets/#{id}",
12
+ :headers => headers
11
13
  )
12
14
  end
13
15
  end
14
16
 
15
17
  class Mock
16
- def delete_recordset(zone_id, id)
18
+ def delete_recordset(zone_id, id, _options = {})
17
19
  response = Excon::Response.new
18
20
  response.status = 202
19
21
 
@@ -3,17 +3,19 @@ module Fog
3
3
  class OpenStack
4
4
  class V2
5
5
  class Real
6
- def delete_zone(id)
6
+ def delete_zone(id, options = {})
7
+ headers, _options = Fog::DNS::OpenStack::V2.setup_headers(options)
7
8
  request(
8
9
  :expects => 202,
9
10
  :method => 'DELETE',
10
- :path => "zones/#{id}"
11
+ :path => "zones/#{id}",
12
+ :headers => headers
11
13
  )
12
14
  end
13
15
  end
14
16
 
15
17
  class Mock
16
- def delete_zone(id)
18
+ def delete_zone(id, _options = {})
17
19
  response = Excon::Response.new
18
20
  response.status = 202
19
21
 
@@ -4,11 +4,13 @@ module Fog
4
4
  class V2
5
5
  class Real
6
6
  def get_quota(project_id = nil)
7
+ headers, _options = Fog::DNS::OpenStack::V2.setup_headers(:all_projects => !project_id.nil?)
8
+
7
9
  request(
8
- :headers => {"X-Auth-All-Projects" => !project_id.nil?},
9
10
  :expects => 200,
10
11
  :method => 'GET',
11
- :path => "quotas/#{project_id}"
12
+ :path => "quotas/#{project_id}",
13
+ :headers => headers
12
14
  )
13
15
  end
14
16
  end
@@ -3,11 +3,13 @@ module Fog
3
3
  class OpenStack
4
4
  class V2
5
5
  class Real
6
- def get_recordset(zone_id, id)
6
+ def get_recordset(zone_id, id, options = {})
7
+ headers, _options = Fog::DNS::OpenStack::V2.setup_headers(options)
7
8
  request(
8
9
  :expects => 200,
9
10
  :method => 'GET',
10
- :path => "zones/#{zone_id}/recordsets/#{id}"
11
+ :path => "zones/#{zone_id}/recordsets/#{id}",
12
+ :headers => headers
11
13
  )
12
14
  end
13
15
  end
@@ -3,17 +3,19 @@ module Fog
3
3
  class OpenStack
4
4
  class V2
5
5
  class Real
6
- def get_zone(id)
6
+ def get_zone(id, options = {})
7
+ headers, _options = Fog::DNS::OpenStack::V2.setup_headers(options)
7
8
  request(
8
9
  :expects => 200,
9
10
  :method => 'GET',
10
- :path => "zones/#{id}"
11
+ :path => "zones/#{id}",
12
+ :headers => headers
11
13
  )
12
14
  end
13
15
  end
14
16
 
15
17
  class Mock
16
- def get_zone(id)
18
+ def get_zone(id, _options = {})
17
19
  response = Excon::Response.new
18
20
  response.status = 200
19
21
  zone = data[:zone_updated] || data[:zones].first
@@ -3,22 +3,46 @@ module Fog
3
3
  class OpenStack
4
4
  class V2
5
5
  class Real
6
- def list_recordsets(zone_id, options = {})
6
+ def list_recordsets(zone_id = nil, options = {})
7
+ # for backward compatability: consider removing the zone_id param (breaking change)
8
+ unless zone_id.nil?
9
+ if zone_id.kind_of?(Hash)
10
+ options = zone_id
11
+ zone_id = nil
12
+ else
13
+ Fog::Logger.deprecation(
14
+ 'Calling list_recordsets(zone_id) is deprecated, use .list_recordsets(zone_id: value) instead'
15
+ )
16
+ end
17
+ end
18
+
19
+ zone_id = options.delete(:zone_id) if zone_id.nil?
20
+ path = zone_id.nil? ? 'recordsets' : "zones/#{zone_id}/recordsets"
21
+
22
+ headers, options = Fog::DNS::OpenStack::V2.setup_headers(options)
23
+
7
24
  request(
8
25
  :expects => 200,
9
26
  :method => 'GET',
10
- :path => "zones/#{zone_id}/recordsets",
11
- :query => options
27
+ :path => path,
28
+ :query => options,
29
+ :headers => headers
12
30
  )
13
31
  end
14
32
  end
15
33
 
16
34
  class Mock
17
- def list_recordsets(zone_id, _options = {})
35
+ def list_recordsets(zone_id = nil, options = {})
36
+ if zone_id.kind_of?(Hash)
37
+ options = zone_id
38
+ zone_id = nil
39
+ end
40
+ zone_id = options.delete(:zone_id) if zone_id.nil?
41
+
18
42
  response = Excon::Response.new
19
43
  response.status = 200
20
44
  data[:recordsets]["recordsets"].each do |rs|
21
- rs["zone_id"] = zone_id
45
+ rs["zone_id"] = zone_id unless zone_id.nil?
22
46
  end
23
47
  response.body = data[:recordsets]
24
48
  response