# File lib/fog/openstack/metering.rb, line 32 def self.data @data ||= Hash.new do |hash, key| hash[key] = { :users => {}, :tenants => {} } end end
# File lib/fog/openstack/metering.rb, line 45 def initialize(options={}) require 'multi_json' @openstack_username = options[:openstack_username] @openstack_tenant = options[:openstack_tenant] @openstack_auth_uri = URI.parse(options[:openstack_auth_url]) @auth_token = Fog::Mock.random_base64(64) @auth_token_expiration = (Time.now.utc + 86400).iso8601 management_url = URI.parse(options[:openstack_auth_url]) management_url.port = 8776 management_url.path = '/v1' @openstack_management_url = management_url.to_s @data ||= { :users => {} } unless @data[:users].find {|u| u['name'] == options[:openstack_username]} id = Fog::Mock.random_numbers(6).to_s @data[:users][id] = { 'id' => id, 'name' => options[:openstack_username], 'email' => "#{options[:openstack_username]}@mock.com", 'tenantId' => Fog::Mock.random_numbers(6).to_s, 'enabled' => true } end end
# File lib/fog/openstack/metering.rb, line 80 def credentials { :provider => 'openstack', :openstack_auth_url => @openstack_auth_uri.to_s, :openstack_auth_token => @auth_token, :openstack_management_url => @openstack_management_url } end
# File lib/fog/openstack/metering.rb, line 72 def data self.class.data[@openstack_username] end
# File lib/fog/openstack/requests/metering/get_resource.rb, line 18 def get_resource(resource_id) response = Excon::Response.new response.status = 200 response.body = { 'resource_id'=>'glance', 'project_id'=>'d646b40dea6347dfb8caee2da1484c56', 'user_id'=>'1d5fd9eda19142289a60ed9330b5d284', 'metadata'=>{}} response end
# File lib/fog/openstack/requests/metering/get_samples.rb, line 34 def get_samples(meter_id) response = Excon::Response.new response.status = 200 response.body = [{ 'counter_name'=>'image.size', 'user_id'=>'1d5fd9eda19142289a60ed9330b5d284', 'resource_id'=>'glance', 'timestamp'=>'2013-04-03T23:44:21', 'resource_metadata'=>{}, 'source'=>'artificial', 'counter_unit'=>'bytes', 'counter_volume'=>10.0, 'project_id'=>'d646b40dea6347dfb8caee2da1484c56', 'message_id'=>'14e4a902-9cf3-11e2-a054-003048f5eafc', 'counter_type'=>'gauge'}] response end
# File lib/fog/openstack/requests/metering/get_statistics.rb, line 35 def get_statistics(meter_id, options={}) response = Excon::Response.new response.status = 200 response.body = [{ 'count'=>143, 'duration_start'=>'2013-04-03T23:44:21', 'min'=>10.0, 'max'=>10.0, 'duration_end'=>'2013-04-04T23:24:21', 'period'=>0, 'period_end'=>'2013-04-04T23:24:21', 'duration'=>85200.0, 'period_start'=>'2013-04-03T23:44:21', 'avg'=>10.0, 'sum'=>1430.0}] response end
# File lib/fog/openstack/requests/metering/list_meters.rb, line 34 def list_meters(options={}) response = Excon::Response.new response.status = 200 response.body = [{ 'user_id'=>'1d5fd9eda19142289a60ed9330b5d284', 'name'=>'image.size', 'resource_id'=>'glance', 'project_id'=>'d646b40dea6347dfb8caee2da1484c56', 'type'=>'gauge', 'unit'=>'bytes'}] response end
# File lib/fog/openstack/requests/metering/list_resources.rb, line 18 def list_resources(options = {}) response = Excon::Response.new response.status = 200 response.body = [{ 'resource_id'=>'glance', 'project_id'=>'d646b40dea6347dfb8caee2da1484c56', 'user_id'=>'1d5fd9eda19142289a60ed9330b5d284', 'metadata'=>{}}] response end
Generated with the Darkfish Rdoc Generator 2.