fog-openstack 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/Rakefile +25 -15
  4. data/{lib/fog/openstack/docs → docs}/compute.md +0 -0
  5. data/{lib/fog/openstack/docs → docs}/getting_started.md +0 -0
  6. data/{lib/fog/openstack/docs → docs}/introspection.md +0 -0
  7. data/{lib/fog/openstack/docs → docs}/metering.md +0 -0
  8. data/{lib/fog/openstack/docs → docs}/network.md +0 -0
  9. data/{lib/fog/openstack/docs → docs}/nfv.md +0 -0
  10. data/{lib/fog/openstack/docs → docs}/orchestration.md +0 -0
  11. data/{lib/fog/openstack/docs → docs}/planning.md +0 -0
  12. data/{lib/fog/openstack/docs → docs}/storage.md +0 -0
  13. data/{lib/fog/openstack/examples → examples}/compute/basics.rb +0 -0
  14. data/{lib/fog/openstack/examples → examples}/compute/block_device_mapping_v2.rb +0 -0
  15. data/{lib/fog/openstack/examples → examples}/identity/basics.rb +0 -0
  16. data/{lib/fog/openstack/examples → examples}/image/upload-test-image.rb +0 -0
  17. data/{lib/fog/openstack/examples → examples}/introspection/basics.rb +0 -0
  18. data/{lib/fog/openstack/examples → examples}/network/network_add_port.rb +0 -0
  19. data/{lib/fog/openstack/examples → examples}/network/network_rbac.rb +0 -0
  20. data/{lib/fog/openstack/examples → examples}/network/network_subnets_routers.rb +0 -0
  21. data/{lib/fog/openstack/examples → examples}/planning/basics.rb +0 -0
  22. data/{lib/fog/openstack/examples → examples}/storage/set-account-quota.rb +0 -0
  23. data/fog-openstack.gemspec +1 -1
  24. data/lib/fog/openstack.rb +6 -0
  25. data/lib/fog/openstack/models/compute/aggregate.rb +3 -2
  26. data/lib/fog/openstack/models/monitoring/alarm.rb +48 -0
  27. data/lib/fog/openstack/models/monitoring/alarm_count.rb +17 -0
  28. data/lib/fog/openstack/models/monitoring/alarm_counts.rb +16 -0
  29. data/lib/fog/openstack/models/monitoring/alarm_definition.rb +56 -0
  30. data/lib/fog/openstack/models/monitoring/alarm_definitions.rb +42 -0
  31. data/lib/fog/openstack/models/monitoring/alarm_state.rb +32 -0
  32. data/lib/fog/openstack/models/monitoring/alarm_states.rb +20 -0
  33. data/lib/fog/openstack/models/monitoring/alarms.rb +30 -0
  34. data/lib/fog/openstack/models/monitoring/measurement.rb +20 -0
  35. data/lib/fog/openstack/models/monitoring/measurements.rb +16 -0
  36. data/lib/fog/openstack/models/monitoring/metric.rb +27 -0
  37. data/lib/fog/openstack/models/monitoring/metrics.rb +28 -0
  38. data/lib/fog/openstack/models/monitoring/notification_method.rb +40 -0
  39. data/lib/fog/openstack/models/monitoring/notification_methods.rb +38 -0
  40. data/lib/fog/openstack/models/monitoring/statistic.rb +20 -0
  41. data/lib/fog/openstack/models/monitoring/statistics.rb +16 -0
  42. data/lib/fog/openstack/monitoring.rb +116 -0
  43. data/lib/fog/openstack/requests/compute/attach_volume.rb +1 -0
  44. data/lib/fog/openstack/requests/compute/create_aggregate.rb +1 -1
  45. data/lib/fog/openstack/requests/compute/create_server.rb +2 -2
  46. data/lib/fog/openstack/requests/compute/detach_volume.rb +1 -0
  47. data/lib/fog/openstack/requests/compute/update_aggregate.rb +1 -1
  48. data/lib/fog/openstack/requests/monitoring/create_alarm_definition.rb +19 -0
  49. data/lib/fog/openstack/requests/monitoring/create_metric.rb +29 -0
  50. data/lib/fog/openstack/requests/monitoring/create_metric_array.rb +19 -0
  51. data/lib/fog/openstack/requests/monitoring/create_notification_method.rb +19 -0
  52. data/lib/fog/openstack/requests/monitoring/delete_alarm.rb +18 -0
  53. data/lib/fog/openstack/requests/monitoring/delete_alarm_definition.rb +18 -0
  54. data/lib/fog/openstack/requests/monitoring/delete_notification_method.rb +18 -0
  55. data/lib/fog/openstack/requests/monitoring/find_measurements.rb +22 -0
  56. data/lib/fog/openstack/requests/monitoring/get_alarm.rb +22 -0
  57. data/lib/fog/openstack/requests/monitoring/get_alarm_counts.rb +22 -0
  58. data/lib/fog/openstack/requests/monitoring/get_alarm_definition.rb +18 -0
  59. data/lib/fog/openstack/requests/monitoring/get_notification_method.rb +18 -0
  60. data/lib/fog/openstack/requests/monitoring/list_alarm_definitions.rb +22 -0
  61. data/lib/fog/openstack/requests/monitoring/list_alarm_state_history_for_all_alarms.rb +22 -0
  62. data/lib/fog/openstack/requests/monitoring/list_alarm_state_history_for_specific_alarm.rb +22 -0
  63. data/lib/fog/openstack/requests/monitoring/list_alarms.rb +22 -0
  64. data/lib/fog/openstack/requests/monitoring/list_metric_names.rb +22 -0
  65. data/lib/fog/openstack/requests/monitoring/list_metrics.rb +22 -0
  66. data/lib/fog/openstack/requests/monitoring/list_notification_methods.rb +22 -0
  67. data/lib/fog/openstack/requests/monitoring/list_statistics.rb +22 -0
  68. data/lib/fog/openstack/requests/monitoring/patch_alarm.rb +19 -0
  69. data/lib/fog/openstack/requests/monitoring/patch_alarm_definition.rb +19 -0
  70. data/lib/fog/openstack/requests/monitoring/update_alarm.rb +19 -0
  71. data/lib/fog/openstack/requests/monitoring/update_alarm_definition.rb +19 -0
  72. data/lib/fog/openstack/requests/monitoring/update_notification_method.rb +19 -0
  73. data/lib/fog/openstack/version.rb +1 -1
  74. metadata +65 -42
  75. data/tests/openstack/models/identity/ec2_credential_tests.rb +0 -41
  76. data/tests/openstack/models/identity/ec2_credentials_tests.rb +0 -58
  77. data/tests/openstack/models/identity/role_tests.rb +0 -31
  78. data/tests/openstack/models/identity/roles_tests.rb +0 -21
  79. data/tests/openstack/models/identity/tenant_tests.rb +0 -33
  80. data/tests/openstack/models/identity/tenants_tests.rb +0 -31
  81. data/tests/openstack/models/identity/user_tests.rb +0 -47
  82. data/tests/openstack/models/identity/users_tests.rb +0 -46
  83. data/tests/openstack/requests/baremetal/chassis_tests.rb +0 -48
  84. data/tests/openstack/requests/baremetal/driver_tests.rb +0 -40
  85. data/tests/openstack/requests/baremetal/node_tests.rb +0 -83
  86. data/tests/openstack/requests/baremetal/port_tests.rb +0 -56
  87. data/tests/openstack/requests/identity/ec2_credentials_tests.rb +0 -41
  88. data/tests/openstack/requests/identity/helper.rb +0 -21
  89. data/tests/openstack/requests/identity/role_tests.rb +0 -48
  90. data/tests/openstack/requests/identity/tenant_tests.rb +0 -57
  91. data/tests/openstack/requests/identity/user_tests.rb +0 -46
  92. data/tests/openstack/requests/introspection/introspection_tests.rb +0 -297
  93. data/tests/openstack/requests/introspection/rules_tests.rb +0 -46
@@ -0,0 +1,20 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module Monitoring
5
+ class OpenStack
6
+ class Measurement < Fog::OpenStack::Model
7
+ identity :id
8
+
9
+ attribute :name
10
+ attribute :dimensions
11
+ attribute :columns
12
+ attribute :measurements
13
+
14
+ def to_s
15
+ name
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/openstack/models/monitoring/measurement'
3
+
4
+ module Fog
5
+ module Monitoring
6
+ class OpenStack
7
+ class Measurements < Fog::OpenStack::Collection
8
+ model Fog::Monitoring::OpenStack::Measurement
9
+
10
+ def find(options = {})
11
+ load_response(service.find_measurements(options), 'elements')
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,27 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module Monitoring
5
+ class OpenStack
6
+ class Metric < Fog::OpenStack::Model
7
+ identity :id
8
+
9
+ attribute :name
10
+ attribute :dimensions
11
+ attribute :timestamp
12
+ attribute :value
13
+ attribute :value_meta
14
+
15
+ def to_s
16
+ name
17
+ end
18
+
19
+ def create
20
+ requires :name, :timestamp, :value
21
+ service.create_metric(attributes).body['metric']
22
+ self
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,28 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/openstack/models/monitoring/metric'
3
+
4
+ module Fog
5
+ module Monitoring
6
+ class OpenStack
7
+ class Metrics < Fog::OpenStack::Collection
8
+ model Fog::Monitoring::OpenStack::Metric
9
+
10
+ def all(options = {})
11
+ load_response(service.list_metrics(options), 'elements')
12
+ end
13
+
14
+ def list_metric_names(options = {})
15
+ load_response(service.list_metric_names(options), 'elements')
16
+ end
17
+
18
+ def create(attributes)
19
+ super(attributes)
20
+ end
21
+
22
+ def create_metric_array(metrics_list = [])
23
+ service.create_metric_array(metrics_list)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,40 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module Monitoring
5
+ class OpenStack
6
+ class NotificationMethod < Fog::OpenStack::Model
7
+ identity :id
8
+
9
+ attribute :name
10
+ attribute :links
11
+ attribute :type
12
+ attribute :address
13
+
14
+ def create
15
+ requires :name, :type, :address
16
+ merge_attributes(
17
+ service.create_notification_method(attributes).body
18
+ )
19
+ end
20
+
21
+ def update(attr = nil)
22
+ requires :name, :type, :address
23
+ merge_attributes(
24
+ service.update_notification_method(id, attr || attributes).body
25
+ )
26
+ end
27
+
28
+ def destroy
29
+ requires :id
30
+ service.delete_notification_method(id)
31
+ true
32
+ end
33
+
34
+ def to_s
35
+ name
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,38 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/openstack/models/monitoring/notification_method'
3
+
4
+ module Fog
5
+ module Monitoring
6
+ class OpenStack
7
+ class NotificationMethods < Fog::OpenStack::Collection
8
+ model Fog::Monitoring::OpenStack::NotificationMethod
9
+
10
+ def all(options = {})
11
+ load_response(service.list_notification_methods(options), 'elements')
12
+ end
13
+
14
+ def create(attributes)
15
+ super(attributes)
16
+ end
17
+
18
+ def patch(attributes)
19
+ super(attributes)
20
+ end
21
+
22
+ def find_by_id(id)
23
+ cached_notification_method = detect { |notification_method| notification_method.id == id }
24
+ return cached_notification_method if cached_notification_method
25
+ notification_method_hash = service.get_notification_method(id).body
26
+ Fog::Monitoring::OpenStack::NotificationMethod.new(
27
+ notification_method_hash.merge(:service => service)
28
+ )
29
+ end
30
+
31
+ def destroy(id)
32
+ notification_method = find_by_id(id)
33
+ notification_method.destroy
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,20 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module Monitoring
5
+ class OpenStack
6
+ class Statistic < Fog::OpenStack::Model
7
+ identity :id
8
+
9
+ attribute :name
10
+ attribute :dimension
11
+ attribute :columns
12
+ attribute :statistics
13
+
14
+ def to_s
15
+ name
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/openstack/models/monitoring/statistic'
3
+
4
+ module Fog
5
+ module Monitoring
6
+ class OpenStack
7
+ class Statistics < Fog::OpenStack::Collection
8
+ model Fog::Monitoring::OpenStack::Statistic
9
+
10
+ def all(options = {})
11
+ load_response(service.list_statistics(options), 'elements')
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,116 @@
1
+
2
+ module Fog
3
+ module Monitoring
4
+ class OpenStack < Fog::Service
5
+ requires :openstack_auth_url
6
+ recognizes :openstack_auth_token, :openstack_management_url,
7
+ :persistent, :openstack_service_type, :openstack_service_name,
8
+ :openstack_tenant, :openstack_tenant_id, :openstack_userid,
9
+ :openstack_api_key, :openstack_username, :openstack_identity_endpoint,
10
+ :current_user, :current_tenant, :openstack_region,
11
+ :openstack_endpoint_type, :openstack_auth_omit_default_port,
12
+ :openstack_project_name, :openstack_project_id,
13
+ :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
14
+ :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
15
+ :openstack_identity_prefix, :openstack_temp_url_key
16
+
17
+ model_path 'fog/openstack/models/monitoring'
18
+ model :metric
19
+ collection :metrics
20
+ model :measurement
21
+ collection :measurements
22
+ model :statistic
23
+ collection :statistics
24
+ model :notification_method
25
+ collection :notification_methods
26
+ model :alarm_definition
27
+ collection :alarm_definitions
28
+ model :alarm
29
+ collection :alarms
30
+ model :alarm_state
31
+ collection :alarm_states
32
+ model :alarm_count
33
+ collection :alarm_counts
34
+
35
+ request_path 'fog/openstack/requests/monitoring'
36
+ request :create_metric
37
+ request :create_metric_array
38
+ request :list_metrics
39
+ request :list_metric_names
40
+
41
+ request :find_measurements
42
+
43
+ request :list_statistics
44
+
45
+ request :create_notification_method
46
+ request :get_notification_method
47
+ request :list_notification_methods
48
+ request :update_notification_method
49
+ request :delete_notification_method
50
+
51
+ request :create_alarm_definition
52
+ request :list_alarm_definitions
53
+ request :patch_alarm_definition
54
+ request :update_alarm_definition
55
+ request :get_alarm_definition
56
+ request :delete_alarm_definition
57
+
58
+ request :list_alarms
59
+ request :get_alarm
60
+ request :patch_alarm
61
+ request :update_alarm
62
+ request :delete_alarm
63
+ request :get_alarm_counts
64
+
65
+ request :list_alarm_state_history_for_specific_alarm
66
+ request :list_alarm_state_history_for_all_alarms
67
+
68
+ class Real
69
+ include Fog::OpenStack::Core
70
+
71
+ def initialize(options = {})
72
+ initialize_identity options
73
+
74
+ @openstack_service_type = options[:openstack_service_type] || ['monitoring']
75
+ @openstack_service_name = options[:openstack_service_name]
76
+
77
+ @connection_options = options[:connection_options] || {}
78
+
79
+ authenticate
80
+ @persistent = options[:persistent] || false
81
+ @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
82
+ end
83
+
84
+ def request(params, parse_json = true)
85
+ begin
86
+ response = @connection.request(params.merge(:headers => {
87
+ 'Content-Type' => 'application/json',
88
+ 'Accept' => 'application/json',
89
+ 'X-Auth-Token' => @auth_token
90
+ }.merge!(params[:headers] || {}),
91
+ :path => "#{@path}/#{params[:path]}"))
92
+ rescue Excon::Errors::Unauthorized => error
93
+ if error.response.body != 'Bad username or password' # token expiration
94
+ @openstack_must_reauthenticate = true
95
+ authenticate
96
+ retry
97
+ else # bad credentials
98
+ raise error
99
+ end
100
+ rescue Excon::Errors::HTTPStatusError => error
101
+ raise case error
102
+ when Excon::Errors::NotFound
103
+ Fog::Monitoring::OpenStack::NotFound.slurp(error)
104
+ else
105
+ error
106
+ end
107
+ end
108
+ if !response.body.empty? && parse_json && response.get_header('Content-Type') =~ %r{application/json}
109
+ response.body = Fog::JSON.decode(response.body)
110
+ end
111
+ response
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
@@ -29,6 +29,7 @@ module Fog
29
29
  'device' => device
30
30
  }
31
31
  self.data[:volumes][volume_id]['attachments'] << data
32
+ self.data[:volumes][volume_id]['status'] = 'in-use'
32
33
  response.body = { 'volumeAttachment' => data }
33
34
  response
34
35
  end
@@ -9,7 +9,7 @@ module Fog
9
9
  }
10
10
  }
11
11
 
12
- vanilla_options = ["availability_zone"]
12
+ vanilla_options = [:availability_zone]
13
13
 
14
14
  vanilla_options.select{|o| options[o]}.each do |key|
15
15
  data['aggregate'][key] = options[key]
@@ -147,9 +147,9 @@ module Fog
147
147
  end
148
148
 
149
149
  if block_devices = options["block_device_mapping_v2"]
150
- block_devices.each { |bd| compute.volumes.get(bd[:uuid]).attach(server_id, bd[:device_name]) }
150
+ block_devices.each { |bd| volumes.get(bd[:uuid]).attach(server_id, bd[:device_name]) }
151
151
  elsif block_device = options["block_device_mapping"]
152
- compute.volumes.get(block_device[:volume_id]).attach(server_id, block_device[:device_name])
152
+ volumes.get(block_device[:volume_id]).attach(server_id, block_device[:device_name])
153
153
  end
154
154
 
155
155
  self.data[:last_modified][:servers][server_id] = Time.now
@@ -16,6 +16,7 @@ module Fog
16
16
  response = Excon::Response.new
17
17
  if self.data[:volumes][attachment_id] &&
18
18
  self.data[:volumes][attachment_id]['attachments'].reject! { |attachment| attachment['serverId'] == server_id }
19
+ data[:volumes][attachment_id]['status'] = 'available'
19
20
  response.status = 202
20
21
  response
21
22
  else
@@ -3,7 +3,7 @@ module Fog
3
3
  class OpenStack
4
4
  class Real
5
5
  def update_aggregate(uuid, options = {})
6
- vanilla_options = ['name', 'availability_zone']
6
+ vanilla_options = [:name, :availability_zone]
7
7
 
8
8
  data = {'aggregate' => {}}
9
9
  vanilla_options.select{|o| options[o]}.each do |key|
@@ -0,0 +1,19 @@
1
+ module Fog
2
+ module Monitoring
3
+ class OpenStack
4
+ class Real
5
+ def create_alarm_definition(options)
6
+ request(
7
+ :body => Fog::JSON.encode(options),
8
+ :expects => [201, 204],
9
+ :method => 'POST',
10
+ :path => 'alarm-definitions'
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Monitoring
3
+ class OpenStack
4
+ class Real
5
+ def create_metric(options)
6
+ data = options
7
+ # data = {
8
+ # 'name' => name,
9
+ # 'dimensions' => dimensions,
10
+ # 'timestamp' => timestamp,
11
+ # 'value' => value,
12
+ # 'value_meta' => value_meta
13
+ # }
14
+
15
+ # _create_metric(data)
16
+ request(
17
+ :body => Fog::JSON.encode(data),
18
+ :expects => [204],
19
+ :method => 'POST',
20
+ :path => 'metrics'
21
+ )
22
+ end
23
+ end
24
+
25
+ class Mock
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ module Fog
2
+ module Monitoring
3
+ class OpenStack
4
+ class Real
5
+ def create_metric_array(metrics_list)
6
+ request(
7
+ :body => Fog::JSON.encode(metrics_list),
8
+ :expects => [204],
9
+ :method => 'POST',
10
+ :path => 'metrics'
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ end
17
+ end
18
+ end
19
+ end