Class: Fog::Metric::OpenStack::Real

Inherits:
Object
  • Object
show all
Includes:
OpenStack::Core
Defined in:
lib/fog/metric/openstack.rb,
lib/fog/metric/openstack/requests/get_metric.rb,
lib/fog/metric/openstack/requests/get_resource.rb,
lib/fog/metric/openstack/requests/list_metrics.rb,
lib/fog/metric/openstack/requests/list_resources.rb,
lib/fog/metric/openstack/requests/get_metric_measures.rb,
lib/fog/metric/openstack/requests/get_resource_metric_measures.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.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fog/metric/openstack.rb', line 97

def initialize(options = {})
  initialize_identity options

  @openstack_service_type           = options[:openstack_service_type] || ['metric']
  @openstack_service_name           = options[:openstack_service_name]
  @openstack_endpoint_type          = options[:openstack_endpoint_type] || 'publicURL'

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

  authenticate
  set_api_path

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

Class Method Details

.not_found_classObject



93
94
95
# File 'lib/fog/metric/openstack.rb', line 93

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

Instance Method Details

#get_metric(metric_id) ⇒ Object



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

def get_metric(metric_id)
  request(
      :expects => 200,
      :method  => 'GET',
      :path    => "metric/#{metric_id}"
  )
end

#get_metric_measures(metric_id, options = {}) ⇒ Object



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

def get_metric_measures(metric_id, options = {})
  request(
      :expects => 200,
      :method  => 'GET',
      :path    => "metric/#{metric_id}/measures",
      :query    => options,
  )
end

#get_resource(resource_id) ⇒ Object



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

def get_resource(resource_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "resource/generic/#{resource_id}"
  )
end

#get_resource_metric_measures(resource_id, metric_name, options = {}) ⇒ Object



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

def get_resource_metric_measures(resource_id, metric_name, options = {})
  request(
      :expects => 200,
      :method  => 'GET',
      :path    => "resource/generic/#{resource_id}/metric/#{metric_name}/measures",
      :query   => options
  )
end

#list_metrics(options = {}) ⇒ Object



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

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

#list_resources(type = "generic", options = {}) ⇒ Object



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

def list_resources(type = "generic", options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "resource/#{Fog::OpenStack.escape(type)}",
    :query   => options
  )
end

#set_api_pathObject



113
114
115
116
117
118
119
120
121
122
# File 'lib/fog/metric/openstack.rb', line 113

def set_api_path
  unless @path.match(SUPPORTED_VERSIONS)
    @path = Fog::OpenStack.get_supported_version_path(
      SUPPORTED_VERSIONS,
      @openstack_management_uri,
      @auth_token,
      @connection_options
    )
  end
end