Class: Fog::Monitoring::OpenStack::Real

Inherits:
Object
  • Object
show all
Includes:
OpenStack::Core
Defined in:
lib/fog/monitoring/openstack.rb,
lib/fog/monitoring/openstack/requests/get_alarm.rb,
lib/fog/monitoring/openstack/requests/list_alarms.rb,
lib/fog/monitoring/openstack/requests/patch_alarm.rb,
lib/fog/monitoring/openstack/requests/delete_alarm.rb,
lib/fog/monitoring/openstack/requests/list_metrics.rb,
lib/fog/monitoring/openstack/requests/update_alarm.rb,
lib/fog/monitoring/openstack/requests/create_metric.rb,
lib/fog/monitoring/openstack/requests/list_statistics.rb,
lib/fog/monitoring/openstack/requests/get_alarm_counts.rb,
lib/fog/monitoring/openstack/requests/find_measurements.rb,
lib/fog/monitoring/openstack/requests/list_metric_names.rb,
lib/fog/monitoring/openstack/requests/create_metric_array.rb,
lib/fog/monitoring/openstack/requests/get_alarm_definition.rb,
lib/fog/monitoring/openstack/requests/list_dimension_values.rb,
lib/fog/monitoring/openstack/requests/list_alarm_definitions.rb,
lib/fog/monitoring/openstack/requests/patch_alarm_definition.rb,
lib/fog/monitoring/openstack/requests/create_alarm_definition.rb,
lib/fog/monitoring/openstack/requests/delete_alarm_definition.rb,
lib/fog/monitoring/openstack/requests/get_notification_method.rb,
lib/fog/monitoring/openstack/requests/put_notification_method.rb,
lib/fog/monitoring/openstack/requests/update_alarm_definition.rb,
lib/fog/monitoring/openstack/requests/list_notification_methods.rb,
lib/fog/monitoring/openstack/requests/patch_notification_method.rb,
lib/fog/monitoring/openstack/requests/create_notification_method.rb,
lib/fog/monitoring/openstack/requests/delete_notification_method.rb,
lib/fog/monitoring/openstack/requests/list_notification_method_types.rb,
lib/fog/monitoring/openstack/requests/list_alarm_state_history_for_all_alarms.rb,
lib/fog/monitoring/openstack/requests/list_alarm_state_history_for_specific_alarm.rb

Instance Attribute Summary

Attributes included from OpenStack::Core

#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_cache_ttl, #openstack_domain_id, #openstack_domain_name, #openstack_identity_prefix, #openstack_project_domain, #openstack_project_domain_id, #openstack_project_id, #openstack_user_domain, #openstack_user_domain_id, #unscoped_token

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OpenStack::Core

#credentials, #initialize_identity, #reload

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/fog/monitoring/openstack.rb', line 81

def initialize(options = {})
  initialize_identity options

  @openstack_service_type           = options[:openstack_service_type] || ['monitoring']
  @openstack_service_name           = options[:openstack_service_name]

  @connection_options               = options[:connection_options] || {}

  authenticate
  @persistent = options[:persistent] || false
  @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end

Class Method Details

.not_found_classObject



77
78
79
# File 'lib/fog/monitoring/openstack.rb', line 77

def self.not_found_class
  Fog::Monitoring::OpenStack::NotFound
end

Instance Method Details

#create_alarm_definition(options) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/create_alarm_definition.rb', line 5

def create_alarm_definition(options)
  request(
    :body    => Fog::JSON.encode(options),
    :expects => [201, 204],
    :method  => 'POST',
    :path    => 'alarm-definitions'
  )
end

#create_metric(options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/monitoring/openstack/requests/create_metric.rb', line 5

def create_metric(options)
  data = options
  # data = {
  #         'name' => name,
  #         'dimensions' => dimensions,
  #         'timestamp' => timestamp,
  #         'value' => value,
  #         'value_meta' => value_meta
  # }

  # _create_metric(data)
  request(
    :body    => Fog::JSON.encode(data),
    :expects => [204],
    :method  => 'POST',
    :path    => 'metrics'
  )
end

#create_metric_array(metrics_list) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/create_metric_array.rb', line 5

def create_metric_array(metrics_list)
  request(
    :body    => Fog::JSON.encode(metrics_list),
    :expects => [204],
    :method  => 'POST',
    :path    => 'metrics'
  )
end

#create_notification_method(options) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/create_notification_method.rb', line 5

def create_notification_method(options)
  request(
    :body    => Fog::JSON.encode(options),
    :expects => [201, 204],
    :method  => 'POST',
    :path    => 'notification-methods'
  )
end

#delete_alarm(id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/monitoring/openstack/requests/delete_alarm.rb', line 5

def delete_alarm(id)
  request(
    :expects => [204],
    :method  => 'DELETE',
    :path    => "alarms/#{id}"
  )
end

#delete_alarm_definition(id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/monitoring/openstack/requests/delete_alarm_definition.rb', line 5

def delete_alarm_definition(id)
  request(
    :expects => [204],
    :method  => 'DELETE',
    :path    => "alarm-definitions/#{id}"
  )
end

#delete_notification_method(id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/monitoring/openstack/requests/delete_notification_method.rb', line 5

def delete_notification_method(id)
  request(
    :expects => [204],
    :method  => 'DELETE',
    :path    => "notification-methods/#{id}"
  )
end

#find_measurements(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/find_measurements.rb', line 5

def find_measurements(options = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "metrics/measurements",
    :query   => options
  )
end

#get_alarm(id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/monitoring/openstack/requests/get_alarm.rb', line 5

def get_alarm(id)
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "alarms/#{id}"
  )
end

#get_alarm_counts(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/get_alarm_counts.rb', line 5

def get_alarm_counts(options = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "alarms/count",
    :query   => options
  )
end

#get_alarm_definition(id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/monitoring/openstack/requests/get_alarm_definition.rb', line 5

def get_alarm_definition(id)
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "alarm-definitions/#{id}"
  )
end

#get_notification_method(id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/monitoring/openstack/requests/get_notification_method.rb', line 5

def get_notification_method(id)
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "notification-methods/#{id}"
  )
end

#list_alarm_definitions(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/list_alarm_definitions.rb', line 5

def list_alarm_definitions(options = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "alarm-definitions",
    :query   => options
  )
end

#list_alarm_state_history_for_all_alarms(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/list_alarm_state_history_for_all_alarms.rb', line 5

def list_alarm_state_history_for_all_alarms(options = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "alarms/state-history",
    :query   => options
  )
end

#list_alarm_state_history_for_specific_alarm(id, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/list_alarm_state_history_for_specific_alarm.rb', line 5

def list_alarm_state_history_for_specific_alarm(id, options = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "alarms/#{id}/state-history",
    :query   => options
  )
end

#list_alarms(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/list_alarms.rb', line 5

def list_alarms(options = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "alarms",
    :query   => options
  )
end

#list_dimension_values(dimension_name, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/list_dimension_values.rb', line 5

def list_dimension_values(dimension_name, options = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "metrics/dimensions/names/values",
    :query   => options.merge(:dimension_name => dimension_name)
  )
end

#list_metric_names(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/list_metric_names.rb', line 5

def list_metric_names(options = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "metrics/names",
    :query   => options
  )
end

#list_metrics(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/list_metrics.rb', line 5

def list_metrics(options = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "metrics",
    :query   => options
  )
end

#list_notification_method_typesObject



5
6
7
8
9
10
11
# File 'lib/fog/monitoring/openstack/requests/list_notification_method_types.rb', line 5

def list_notification_method_types
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "notification-methods/types"
  )
end

#list_notification_methods(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/list_notification_methods.rb', line 5

def list_notification_methods(options = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "notification-methods",
    :query   => options
  )
end

#list_statistics(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/list_statistics.rb', line 5

def list_statistics(options = {})
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => "metrics/statistics",
    :query   => options
  )
end

#patch_alarm(id, options) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/patch_alarm.rb', line 5

def patch_alarm(id, options)
  request(
    :expects => [200],
    :method  => 'PATCH',
    :path    => "alarms/#{id}",
    :body    => Fog::JSON.encode(options)
  )
end

#patch_alarm_definition(id, alarm_definition) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/patch_alarm_definition.rb', line 5

def patch_alarm_definition(id, alarm_definition)
  request(
    :expects => [200],
    :method  => 'PATCH',
    :path    => "alarm-definitions/#{id}",
    :body    => Fog::JSON.encode(alarm_definition)
  )
end

#put_notification_method(id, notification) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/put_notification_method.rb', line 5

def put_notification_method(id, notification)
  request(
    :expects => [200],
    :method  => 'PUT',
    :path    => "notification-methods/#{id}",
    :body    => Fog::JSON.encode(notification)
  )
end

#update_alarm(id, options) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/update_alarm.rb', line 5

def update_alarm(id, options)
  request(
    :expects => [200],
    :method  => 'PUT',
    :path    => "alarms/#{id}",
    :body    => Fog::JSON.encode(options)
  )
end

#update_alarm_definition(id, alarm_definition) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/update_alarm_definition.rb', line 5

def update_alarm_definition(id, alarm_definition)
  request(
    :expects => [200],
    :method  => 'PUT',
    :path    => "alarm-definitions/#{id}",
    :body    => Fog::JSON.encode(alarm_definition)
  )
end

#update_notification_method(id, notification) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/monitoring/openstack/requests/patch_notification_method.rb', line 5

def update_notification_method(id, notification)
  request(
    :expects => [200],
    :method  => 'PATCH',
    :path    => "notification-methods/#{id}",
    :body    => Fog::JSON.encode(notification)
  )
end