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.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/Rakefile +25 -15
- data/{lib/fog/openstack/docs → docs}/compute.md +0 -0
- data/{lib/fog/openstack/docs → docs}/getting_started.md +0 -0
- data/{lib/fog/openstack/docs → docs}/introspection.md +0 -0
- data/{lib/fog/openstack/docs → docs}/metering.md +0 -0
- data/{lib/fog/openstack/docs → docs}/network.md +0 -0
- data/{lib/fog/openstack/docs → docs}/nfv.md +0 -0
- data/{lib/fog/openstack/docs → docs}/orchestration.md +0 -0
- data/{lib/fog/openstack/docs → docs}/planning.md +0 -0
- data/{lib/fog/openstack/docs → docs}/storage.md +0 -0
- data/{lib/fog/openstack/examples → examples}/compute/basics.rb +0 -0
- data/{lib/fog/openstack/examples → examples}/compute/block_device_mapping_v2.rb +0 -0
- data/{lib/fog/openstack/examples → examples}/identity/basics.rb +0 -0
- data/{lib/fog/openstack/examples → examples}/image/upload-test-image.rb +0 -0
- data/{lib/fog/openstack/examples → examples}/introspection/basics.rb +0 -0
- data/{lib/fog/openstack/examples → examples}/network/network_add_port.rb +0 -0
- data/{lib/fog/openstack/examples → examples}/network/network_rbac.rb +0 -0
- data/{lib/fog/openstack/examples → examples}/network/network_subnets_routers.rb +0 -0
- data/{lib/fog/openstack/examples → examples}/planning/basics.rb +0 -0
- data/{lib/fog/openstack/examples → examples}/storage/set-account-quota.rb +0 -0
- data/fog-openstack.gemspec +1 -1
- data/lib/fog/openstack.rb +6 -0
- data/lib/fog/openstack/models/compute/aggregate.rb +3 -2
- data/lib/fog/openstack/models/monitoring/alarm.rb +48 -0
- data/lib/fog/openstack/models/monitoring/alarm_count.rb +17 -0
- data/lib/fog/openstack/models/monitoring/alarm_counts.rb +16 -0
- data/lib/fog/openstack/models/monitoring/alarm_definition.rb +56 -0
- data/lib/fog/openstack/models/monitoring/alarm_definitions.rb +42 -0
- data/lib/fog/openstack/models/monitoring/alarm_state.rb +32 -0
- data/lib/fog/openstack/models/monitoring/alarm_states.rb +20 -0
- data/lib/fog/openstack/models/monitoring/alarms.rb +30 -0
- data/lib/fog/openstack/models/monitoring/measurement.rb +20 -0
- data/lib/fog/openstack/models/monitoring/measurements.rb +16 -0
- data/lib/fog/openstack/models/monitoring/metric.rb +27 -0
- data/lib/fog/openstack/models/monitoring/metrics.rb +28 -0
- data/lib/fog/openstack/models/monitoring/notification_method.rb +40 -0
- data/lib/fog/openstack/models/monitoring/notification_methods.rb +38 -0
- data/lib/fog/openstack/models/monitoring/statistic.rb +20 -0
- data/lib/fog/openstack/models/monitoring/statistics.rb +16 -0
- data/lib/fog/openstack/monitoring.rb +116 -0
- data/lib/fog/openstack/requests/compute/attach_volume.rb +1 -0
- data/lib/fog/openstack/requests/compute/create_aggregate.rb +1 -1
- data/lib/fog/openstack/requests/compute/create_server.rb +2 -2
- data/lib/fog/openstack/requests/compute/detach_volume.rb +1 -0
- data/lib/fog/openstack/requests/compute/update_aggregate.rb +1 -1
- data/lib/fog/openstack/requests/monitoring/create_alarm_definition.rb +19 -0
- data/lib/fog/openstack/requests/monitoring/create_metric.rb +29 -0
- data/lib/fog/openstack/requests/monitoring/create_metric_array.rb +19 -0
- data/lib/fog/openstack/requests/monitoring/create_notification_method.rb +19 -0
- data/lib/fog/openstack/requests/monitoring/delete_alarm.rb +18 -0
- data/lib/fog/openstack/requests/monitoring/delete_alarm_definition.rb +18 -0
- data/lib/fog/openstack/requests/monitoring/delete_notification_method.rb +18 -0
- data/lib/fog/openstack/requests/monitoring/find_measurements.rb +22 -0
- data/lib/fog/openstack/requests/monitoring/get_alarm.rb +22 -0
- data/lib/fog/openstack/requests/monitoring/get_alarm_counts.rb +22 -0
- data/lib/fog/openstack/requests/monitoring/get_alarm_definition.rb +18 -0
- data/lib/fog/openstack/requests/monitoring/get_notification_method.rb +18 -0
- data/lib/fog/openstack/requests/monitoring/list_alarm_definitions.rb +22 -0
- data/lib/fog/openstack/requests/monitoring/list_alarm_state_history_for_all_alarms.rb +22 -0
- data/lib/fog/openstack/requests/monitoring/list_alarm_state_history_for_specific_alarm.rb +22 -0
- data/lib/fog/openstack/requests/monitoring/list_alarms.rb +22 -0
- data/lib/fog/openstack/requests/monitoring/list_metric_names.rb +22 -0
- data/lib/fog/openstack/requests/monitoring/list_metrics.rb +22 -0
- data/lib/fog/openstack/requests/monitoring/list_notification_methods.rb +22 -0
- data/lib/fog/openstack/requests/monitoring/list_statistics.rb +22 -0
- data/lib/fog/openstack/requests/monitoring/patch_alarm.rb +19 -0
- data/lib/fog/openstack/requests/monitoring/patch_alarm_definition.rb +19 -0
- data/lib/fog/openstack/requests/monitoring/update_alarm.rb +19 -0
- data/lib/fog/openstack/requests/monitoring/update_alarm_definition.rb +19 -0
- data/lib/fog/openstack/requests/monitoring/update_notification_method.rb +19 -0
- data/lib/fog/openstack/version.rb +1 -1
- metadata +65 -42
- data/tests/openstack/models/identity/ec2_credential_tests.rb +0 -41
- data/tests/openstack/models/identity/ec2_credentials_tests.rb +0 -58
- data/tests/openstack/models/identity/role_tests.rb +0 -31
- data/tests/openstack/models/identity/roles_tests.rb +0 -21
- data/tests/openstack/models/identity/tenant_tests.rb +0 -33
- data/tests/openstack/models/identity/tenants_tests.rb +0 -31
- data/tests/openstack/models/identity/user_tests.rb +0 -47
- data/tests/openstack/models/identity/users_tests.rb +0 -46
- data/tests/openstack/requests/baremetal/chassis_tests.rb +0 -48
- data/tests/openstack/requests/baremetal/driver_tests.rb +0 -40
- data/tests/openstack/requests/baremetal/node_tests.rb +0 -83
- data/tests/openstack/requests/baremetal/port_tests.rb +0 -56
- data/tests/openstack/requests/identity/ec2_credentials_tests.rb +0 -41
- data/tests/openstack/requests/identity/helper.rb +0 -21
- data/tests/openstack/requests/identity/role_tests.rb +0 -48
- data/tests/openstack/requests/identity/tenant_tests.rb +0 -57
- data/tests/openstack/requests/identity/user_tests.rb +0 -46
- data/tests/openstack/requests/introspection/introspection_tests.rb +0 -297
- 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
|
@@ -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|
|
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
|
-
|
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 = [
|
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
|