2012-02-23 03:40:31 -05:00
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class OpenStack
|
|
|
|
class Real
|
|
|
|
|
|
|
|
def get_usage(tenant_id, date_start, date_end)
|
2012-03-06 01:43:02 -05:00
|
|
|
params = Hash.new
|
2012-05-28 06:13:00 -04:00
|
|
|
params[:start] = date_start.utc.iso8601.chop!
|
|
|
|
params[:end] = date_end.utc.iso8601.chop!
|
2012-02-23 03:40:31 -05:00
|
|
|
request(
|
|
|
|
:expects => [200, 203],
|
|
|
|
:method => 'GET',
|
2012-03-06 01:43:02 -05:00
|
|
|
:path => "os-simple-tenant-usage/#{tenant_id}",
|
|
|
|
:query => params
|
2012-02-23 03:40:31 -05:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
2012-03-06 01:43:02 -05:00
|
|
|
def get_usage(tenant_id, date_start, date_end)
|
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 200
|
|
|
|
response.body = {"tenant_usage"=>
|
2012-05-28 06:13:00 -04:00
|
|
|
{"total_memory_mb_usage" => 0.0,
|
|
|
|
"total_vcpus_usage" => 0.0,
|
2012-03-06 01:43:02 -05:00
|
|
|
"total_hours" => 0.0,
|
2012-05-28 06:13:00 -04:00
|
|
|
"tenant_id" => tenant_id,
|
|
|
|
"stop" => date_start,
|
|
|
|
"start" => date_end,
|
2012-03-06 01:43:02 -05:00
|
|
|
"total_local_gb_usage" => 0.0,
|
|
|
|
"server_usages" =>[{
|
2012-05-28 06:13:00 -04:00
|
|
|
"hours" => 0.0,
|
|
|
|
"uptime" => 69180,
|
|
|
|
"local_gb" => 0,
|
|
|
|
"ended_at" => nil,
|
|
|
|
"name" => "test server",
|
|
|
|
"tenant_id" => tenant_id,
|
|
|
|
"vcpus" => 1,
|
|
|
|
"memory_mb" => 512,
|
|
|
|
"state" => "active",
|
|
|
|
"flavor" => "m1.tiny",
|
2012-03-06 01:43:02 -05:00
|
|
|
"started_at" => "2012-03-05 09:11:44"
|
|
|
|
}
|
2012-05-28 06:13:00 -04:00
|
|
|
]
|
2012-03-06 01:43:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
response
|
2012-02-23 03:40:31 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-03-06 01:43:02 -05:00
|
|
|
end
|