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
@@ -4,11 +4,14 @@ module Fog
4
4
  class V2
5
5
  class Real
6
6
  def list_zones(options = {})
7
+ headers, options = Fog::DNS::OpenStack::V2.setup_headers(options)
8
+
7
9
  request(
8
10
  :expects => 200,
9
11
  :method => 'GET',
10
12
  :path => 'zones',
11
- :query => options
13
+ :query => options,
14
+ :headers => headers
12
15
  )
13
16
  end
14
17
  end
@@ -4,13 +4,14 @@ module Fog
4
4
  class V2
5
5
  class Real
6
6
  def update_quota(project_id, options = {})
7
- all_projects = options.key?(:all_projects) ? options.delete(:all_projects) : false
7
+ headers, options = Fog::DNS::OpenStack::V2.setup_headers(options)
8
+
8
9
  request(
9
- :headers => {"X-Auth-All-Projects" => all_projects},
10
10
  :body => Fog::JSON.encode(options),
11
11
  :expects => 200,
12
12
  :method => 'PATCH',
13
- :path => "quotas/#{project_id}"
13
+ :path => "quotas/#{project_id}",
14
+ :headers => headers
14
15
  )
15
16
  end
16
17
  end
@@ -4,11 +4,14 @@ module Fog
4
4
  class V2
5
5
  class Real
6
6
  def update_recordset(zone_id, id, options = {})
7
+ headers, options = Fog::DNS::OpenStack::V2.setup_headers(options)
8
+
7
9
  request(
8
10
  :body => Fog::JSON.encode(options),
9
11
  :expects => 202,
10
12
  :method => 'PUT',
11
- :path => "zones/#{zone_id}/recordsets/#{id}"
13
+ :path => "zones/#{zone_id}/recordsets/#{id}",
14
+ :headers => headers
12
15
  )
13
16
  end
14
17
  end
@@ -4,11 +4,14 @@ module Fog
4
4
  class V2
5
5
  class Real
6
6
  def update_zone(id, options = {})
7
+ headers, options = Fog::DNS::OpenStack::V2.setup_headers(options)
8
+
7
9
  request(
8
10
  :body => Fog::JSON.encode(options),
9
11
  :expects => 202,
10
12
  :method => 'PATCH',
11
- :path => "zones/#{id}"
13
+ :path => "zones/#{id}",
14
+ :headers => headers
12
15
  )
13
16
  end
14
17
  end
@@ -43,7 +43,7 @@ module Fog
43
43
  def self.data
44
44
  @data ||= Hash.new do |hash, key|
45
45
  # Introspection data is *huge* we load it from a yaml file
46
- file = "../../../../tests/fixtures/introspection.yaml"
46
+ file = "../../../../test/fixtures/introspection.yaml"
47
47
  hash[key] = YAML.load(File.read(File.expand_path(file, __FILE__)))
48
48
  end
49
49
  end
@@ -80,7 +80,7 @@ module Fog
80
80
  def initialize(options = {})
81
81
  initialize_identity options
82
82
 
83
- @openstack_service_type = options[:openstack_service_type] || ['introspection']
83
+ @openstack_service_type = options[:openstack_service_type] || ['baremetal-introspection']
84
84
  @openstack_service_name = options[:openstack_service_name]
85
85
 
86
86
  @connection_options = options[:connection_options] || {}
@@ -94,12 +94,7 @@ module Fog
94
94
 
95
95
  def set_api_path
96
96
  unless @path.match(SUPPORTED_VERSIONS)
97
- @path = "/" + Fog::OpenStack.get_supported_version(
98
- SUPPORTED_VERSIONS,
99
- @openstack_management_uri,
100
- @auth_token,
101
- @connection_options
102
- )
97
+ @path = "/v1"
103
98
  end
104
99
  end
105
100
  end
@@ -31,6 +31,7 @@ module Fog
31
31
  collection :alarm_states
32
32
  model :alarm_count
33
33
  collection :alarm_counts
34
+ model :dimension_value
34
35
 
35
36
  request_path 'fog/monitoring/openstack/requests'
36
37
  request :create_metric
@@ -45,7 +46,8 @@ module Fog
45
46
  request :create_notification_method
46
47
  request :get_notification_method
47
48
  request :list_notification_methods
48
- request :update_notification_method
49
+ request :put_notification_method
50
+ request :patch_notification_method
49
51
  request :delete_notification_method
50
52
 
51
53
  request :create_alarm_definition
@@ -65,6 +67,10 @@ module Fog
65
67
  request :list_alarm_state_history_for_specific_alarm
66
68
  request :list_alarm_state_history_for_all_alarms
67
69
 
70
+ request :list_dimension_values
71
+
72
+ request :list_notification_method_types
73
+
68
74
  class Real
69
75
  include Fog::OpenStack::Core
70
76
 
@@ -6,7 +6,6 @@ module Fog
6
6
  class Alarm < Fog::OpenStack::Model
7
7
  identity :id
8
8
 
9
- attribute :name
10
9
  attribute :links
11
10
  attribute :link
12
11
  attribute :alarm_definition
@@ -10,6 +10,7 @@ module Fog
10
10
  attribute :name
11
11
  attribute :description
12
12
  attribute :expression
13
+ attribute :deterministic
13
14
  attribute :expression_data
14
15
  attribute :match_by
15
16
  attribute :severity
@@ -0,0 +1,19 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module Monitoring
5
+ class OpenStack
6
+ class DimensionValue < Fog::OpenStack::Model
7
+ identity :id
8
+
9
+ attribute :metric_name
10
+ attribute :dimension_name
11
+ attribute :values
12
+
13
+ def to_s
14
+ name
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/monitoring/openstack/models/dimension_value'
3
+
4
+ module Fog
5
+ module Monitoring
6
+ class OpenStack
7
+ class DimensionValues < Fog::OpenStack::Collection
8
+ model Fog::Monitoring::OpenStack::DimensionValue
9
+
10
+ def all(dimension_name, options = {})
11
+ load_response(service.list_dimension_values(dimension_name, options), 'elements')
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,6 @@
1
1
  require 'fog/openstack/models/collection'
2
2
  require 'fog/monitoring/openstack/models/metric'
3
+ require 'fog/monitoring/openstack/models/dimension_values'
3
4
 
4
5
  module Fog
5
6
  module Monitoring
@@ -22,6 +23,13 @@ module Fog
22
23
  def create_metric_array(metrics_list = [])
23
24
  service.create_metric_array(metrics_list)
24
25
  end
26
+
27
+ def list_dimension_values(dimension_name, options = {})
28
+ dimension_value = Fog::Monitoring::OpenStack::DimensionValues.new
29
+ dimension_value.load_response(
30
+ service.list_dimension_values(dimension_name, options), 'elements'
31
+ )
32
+ end
25
33
  end
26
34
  end
27
35
  end
@@ -10,6 +10,7 @@ module Fog
10
10
  attribute :links
11
11
  attribute :type
12
12
  attribute :address
13
+ attribute :period
13
14
 
14
15
  def create
15
16
  requires :name, :type, :address
@@ -21,7 +22,13 @@ module Fog
21
22
  def update(attr = nil)
22
23
  requires :name, :type, :address
23
24
  merge_attributes(
24
- service.update_notification_method(id, attr || attributes).body
25
+ service.put_notification_method(id, attr || attributes).body
26
+ )
27
+ end
28
+
29
+ def patch(attr = nil)
30
+ merge_attributes(
31
+ service.patch_notification_method(id, attr || attributes).body
25
32
  )
26
33
  end
27
34
 
@@ -28,6 +28,10 @@ module Fog
28
28
  )
29
29
  end
30
30
 
31
+ def list_types
32
+ service.list_notification_method_types.body['elements'].map { |x| x['type'].to_sym }
33
+ end
34
+
31
35
  def destroy(id)
32
36
  notification_method = find_by_id(id)
33
37
  notification_method.destroy
@@ -0,0 +1,21 @@
1
+ module Fog
2
+ module Monitoring
3
+ class OpenStack
4
+ class Real
5
+ def list_dimension_values(dimension_name, options = {})
6
+ request(
7
+ :expects => [200],
8
+ :method => 'GET',
9
+ :path => "metrics/dimensions/names/values",
10
+ :query => options.merge(:dimension_name => dimension_name)
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ # def list_dimension_values(dimension_name, options = {})
17
+ # end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Fog
2
+ module Monitoring
3
+ class OpenStack
4
+ class Real
5
+ def list_notification_method_types
6
+ request(
7
+ :expects => [200],
8
+ :method => 'GET',
9
+ :path => "notification-methods/types"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ # def list_notification_method_types
16
+ #
17
+ # end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -5,7 +5,7 @@ module Fog
5
5
  def update_notification_method(id, notification)
6
6
  request(
7
7
  :expects => [200],
8
- :method => 'PUT',
8
+ :method => 'PATCH',
9
9
  :path => "notification-methods/#{id}",
10
10
  :body => Fog::JSON.encode(notification)
11
11
  )
@@ -0,0 +1,19 @@
1
+ module Fog
2
+ module Monitoring
3
+ class OpenStack
4
+ class Real
5
+ def put_notification_method(id, notification)
6
+ request(
7
+ :expects => [200],
8
+ :method => 'PUT',
9
+ :path => "notification-methods/#{id}",
10
+ :body => Fog::JSON.encode(notification)
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ end
17
+ end
18
+ end
19
+ end
@@ -185,6 +185,7 @@ module Fog
185
185
  class Mock
186
186
  def self.data
187
187
  @data ||= Hash.new do |hash, key|
188
+ qos_policy_id = Fog::UUID.uuid
188
189
  network_id = Fog::UUID.uuid
189
190
  subnet_id = Fog::UUID.uuid
190
191
  tenant_id = Fog::Mock.random_hex(8)
@@ -198,18 +199,21 @@ module Fog
198
199
  'shared' => true,
199
200
  'status' => 'ACTIVE',
200
201
  'tenant_id' => tenant_id,
201
- 'provider_network_type' => 'vlan',
202
+ 'provider:network:type' => 'vlan',
202
203
  'router:external' => false,
203
204
  'admin_state_up' => true,
205
+ 'qos_policy_id' => qos_policy_id,
206
+ 'port_security_enabled' => 'port_security_enabled'
204
207
  },
205
208
  'e624a36d-762b-481f-9b50-4154ceb78bbb' => {
206
- 'id' => 'e624a36d-762b-481f-9b50-4154ceb78bbb',
207
- 'name' => 'network_1',
208
- 'subnets' => ['2e4ec6a4-0150-47f5-8523-e899ac03026e'],
209
- 'shared' => false,
210
- 'status' => 'ACTIVE',
211
- 'admin_state_up' => true,
212
- 'tenant_id' => 'f8b26a6032bc47718a7702233ac708b9',
209
+ 'id' => 'e624a36d-762b-481f-9b50-4154ceb78bbb',
210
+ 'name' => 'network_1',
211
+ 'subnets' => ['2e4ec6a4-0150-47f5-8523-e899ac03026e'],
212
+ 'shared' => false,
213
+ 'status' => 'ACTIVE',
214
+ 'admin_state_up' => true,
215
+ 'tenant_id' => 'f8b26a6032bc47718a7702233ac708b9',
216
+ 'router:external' => false,
213
217
  }
214
218
  },
215
219
  :ports => {},
@@ -2,48 +2,57 @@ module Fog
2
2
  module Network
3
3
  class OpenStack
4
4
  class Real
5
- def create_network(options = {})
6
- data = {'network' => {}}
5
+ CREATE_OPTIONS = [
6
+ :name,
7
+ :shared,
8
+ :admin_state_up,
9
+ :qos_policy_id,
10
+ :port_security_enabled,
11
+ :tenant_id,
12
+ ].freeze
7
13
 
8
- vanilla_options = [
9
- :name,
10
- :shared,
11
- :admin_state_up,
12
- :tenant_id
13
- ]
14
+ # Advanced Features through API Extensions
15
+ #
16
+ # Not strictly required but commonly found in OpenStack
17
+ # installs with Quantum networking.
18
+ #
19
+ # @see http://docs.openstack.org/trunk/openstack-network/admin/content/provider_attributes.html
14
20
 
15
- vanilla_options.reject { |o| options[o].nil? }.each do |key|
16
- data['network'][key] = options[key]
17
- end
21
+ EXTENTED_OPTIONS = [
22
+ :provider_network_type,
23
+ :provider_segmentation_id,
24
+ :provider_physical_network,
25
+ :router_external,
26
+ ].freeze
18
27
 
19
- # Advanced Features through API Extensions
20
- #
21
- # Not strictly required but commonly found in OpenStack
22
- # installs with Quantum networking.
23
- #
24
- # @see http://docs.openstack.org/trunk/openstack-network/admin/content/provider_attributes.html
25
- provider_options = [
26
- :router_external,
27
- :provider_network_type,
28
- :provider_segmentation_id,
29
- :provider_physical_network
30
- ]
28
+ # Map Fog::Network::OpenStack::Network
29
+ # model attributes to OpenStack provider attributes
30
+ ALIASES = {
31
+ :provider_network_type => 'provider:network_type',
31
32
 
32
- # Map Fog::Network::OpenStack::Network
33
- # model attributes to OpenStack provider attributes
34
- aliases = {
35
- :provider_network_type => 'provider:network_type',
36
- # Not applicable to the "local" or "gre" network types
37
- :provider_physical_network => 'provider:physical_network',
38
- :provider_segmentation_id => 'provider:segmentation_id',
39
- :router_external => 'router:external'
40
- }
33
+ # Not applicable to the "local" or "gre" network types
34
+ :provider_physical_network => 'provider:physical_network',
35
+ :provider_segmentation_id => 'provider:segmentation_id',
36
+
37
+ :router_external => 'router:external'
38
+ }.freeze
41
39
 
42
- provider_options.reject { |o| options[o].nil? }.each do |key|
43
- aliased_key = aliases[key] || key
44
- data['network'][aliased_key] = options[key]
40
+ def self.create(options)
41
+ data = {}
42
+ CREATE_OPTIONS.reject { |o| options[o].nil? }.each do |key|
43
+ data[key.to_s] = options[key]
44
+ end
45
+
46
+ EXTENTED_OPTIONS.reject { |o| options[o].nil? }.each do |key|
47
+ aliased_key = ALIASES[key] || key
48
+ data[aliased_key] = options[key]
45
49
  end
50
+ data
51
+ end
46
52
 
53
+ def create_network(options = {})
54
+ data = {}
55
+ data['network'] = self.class.create(options)
47
56
  request(
48
57
  :body => Fog::JSON.encode(data),
49
58
  :expects => [201],
@@ -58,35 +67,17 @@ module Fog
58
67
  response = Excon::Response.new
59
68
  response.status = 201
60
69
  data = {
61
- 'id' => Fog::Mock.random_numbers(6).to_s,
62
- 'name' => options[:name],
63
- 'shared' => options[:shared],
64
- 'subnets' => [],
65
- 'status' => 'ACTIVE',
66
- 'admin_state_up' => options[:admin_state_up],
67
- 'tenant_id' => options[:tenant_id],
68
- }
69
-
70
- # Add provider specific attributes when found
71
- #
72
- provider_options = [
73
- :router_external,
74
- :provider_network_type,
75
- :provider_segmentation_id,
76
- :provider_physical_network
77
- ]
78
- aliases = {
79
- :provider_network_type => 'provider:network_type',
80
- # Not applicable to the "local" or "gre" network types
81
- :provider_physical_network => 'provider:physical_network',
82
- :provider_segmentation_id => 'provider:segmentation_id',
83
- :router_external => 'router:external'
70
+ 'id' => Fog::Mock.random_numbers(6).to_s,
71
+ 'name' => options[:name],
72
+ 'shared' => options[:shared],
73
+ 'subnets' => [],
74
+ 'status' => 'ACTIVE',
75
+ 'admin_state_up' => options[:admin_state_up],
76
+ 'tenant_id' => options[:tenant_id],
77
+ 'qos_policy_id' => options[:qos_policy_id],
78
+ 'port_security_enabled' => options[:port_security_enabled]
84
79
  }
85
- provider_options.reject { |o| options[o].nil? }.each do |key|
86
- aliased_key = aliases[key] || key
87
- data[aliased_key] = options[key]
88
- end
89
-
80
+ data.merge!(Fog::Network::OpenStack::Real.create(options))
90
81
  self.data[:networks][data['id']] = data
91
82
  response.body = {'network' => data}
92
83
  response