Get tenant usage information¶
Overview¶
Gets usage information for a tenant.
Classification¶
- Show
API Operation Object¶
- os-simple-tenant-usage
Synchronous / Asynchronous¶
- -
Request¶
HTTP Request Method¶
- GET
HTTP Request Path¶
{api_endpoint}/v2/{tenant_id}/os-simple-tenant-usage/{tenant_id}
Response¶
HTTP Response Header¶
Format¶
HTTP/1.1 <response_code> <message> (ex. 200 OK)
<response_code>: see “HTTP Responses” section
<message>: message based on the response code
- skip auto insert field such as “X-Compute-Request-Id” and “Content-Length”, “Date”
HTTP Response Body¶
Format¶
{
"tenant_usage": {
"server_usages": [
{
"ended_at": <ended_at>,
"flavor": "<flavor>",
"hours": <hours>,
"instance_id": "<instance_id>",
"local_gb": <local_gb>,
"memory_mb": <memory_mb>,
"name": "<name>",
"started_at": "<started_at>",
"state": "<state>",
"tenant_id": "<tenant_id>",
"uptime": <uptime>,
"vcpus": <vcpus>
}
],
"start": "<start>",
"stop": "<stop>",
"tenant_id": "<tenant_id>",
"total_hours": <total_hours>,
"total_local_gb_usage": <total_local_gb_usage>,
"total_memory_mb_usage": <total_memory_mb_usage>,
"total_vcpus_usage": <total_vcpus_usage>
}
}
Response Parameter¶
item | format | description |
---|---|---|
ended_at | time/date | The end of server |
flavor | String | flavor name |
hours | int | server hour |
instance_id | UUID | instance id |
local_gb | int | local size (GB) |
memory_mb | int | memory size (MB) |
name | String | server name |
started_at | time/date | The start of server |
state | String | server status |
tenant_id | String | tenant id |
uptime | int | server uptime |
vcpus | int(1 - 2^31-1) | number of vcpu |
start | time/date | The start of tenant |
stop | time/date | The stop of tenant |
total_hours | int | total operating time of the tenant |
total_local_gb_usage | int | total amount of used local size |
total_memory_mb_usage | int | total amount of used memory size |
total_vcpus_usage | int(1 - 2^31-1) | total number of used vcpus |
Sample API Request and Response¶
Sample API Request¶
Request URI¶
https://example.com/v2/{tenant_id}/os-simple-tenant-usage/{tenant_id}
Request Header¶
Accept-Encoding: gzip, deflate, compress (optional)
Accept: application/json
X-Auth-Token: ajk3adjiown02
Content-Type: application/json
Request Body¶
- none
Sample API Response¶
Response Header¶
HTTP/1.1 200 OK
<response_code>: see “HTTP Responses” section
<message>: message based on the response code
- skip auto insert field such as “X-Compute-Request-Id” and “Content-Length”, “Date”
Response Body¶
{
"tenant_usage": {
"server_usages": [
{
"ended_at": null,
"flavor": "m1.tiny",
"hours": 1.0,
"instance_id": "1f1deceb-17b5-4c04-84c7-e0d4499c8fe0",
"local_gb": 1,
"memory_mb": 512,
"name": "new-server-test",
"started_at": "2012-10-08T20:10:44.541277",
"state": "active",
"tenant_id": "openstack",
"uptime": 3600,
"vcpus": 1
}
],
"start": "2012-10-08T20:10:44.587336",
"stop": "2012-10-08T21:10:44.587336",
"tenant_id": "openstack",
"total_hours": 1.0,
"total_local_gb_usage": 1.0,
"total_memory_mb_usage": 512.0,
"total_vcpus_usage": 1.0
}
}
Execution Example¶
HTTP Request¶
GET /v2/f66f8e846a65484a9a6740077e72e3dd/os-simple-tenant-usage/f66f8e846a65484a9a6740077e72e3dd HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token: abf1b150aab044549c404ab951b8afef
Accept: application/json
HTTP Response¶
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 20
X-Compute-Request-Id: req-e54d0877-4b8e-407b-8244-57014958a7dc
Date: Wed, 07 Oct 2015 07:21:05 GMT
{"tenant_usage": {"total_memory_mb_usage": 4.977777777777777e-06, "total_vcpus_usage": 3.8888888888888884e-08, "start": "2015-09-18T05:41:18.473117", "tenant_id": "db92a0fc69cb499b8175c04dd3b66686", "stop": "2015-09-18T05:41:18.473131", "server_usages": [{"instance_id": "2a5c8d7e-7041-468b-8a2c-06b4c802205c", "uptime": 45, "started_at": "2015-09-18T05:40:33.000000", "ended_at": null, "memory_mb": 128, "tenant_id": "db92a0fc69cb499b8175c04dd3b66686", "state": "active", "hours": 3.8888888888888884e-08, "vcpus": 1, "flavor": "m1.nano", "local_gb": 20, "name": "scenario-server--982295292"}], "total_hours": 3.8888888888888884e-08, "total_local_gb_usage": 7.777777777777777e-07}}
Error Execution Example¶
HTTP Request¶
GET /v2/f66f8e846a65484a9a740077e72e3dd/os-simple-tenant-usage/f66f8e846a65484a9a6740077e72e3dd HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token: abf1b150aab044549c404ab951b8afef
Accept: application/json
HTTP Response¶
HTTP/1.1 400 Bad Request
Content-Length: 187
Content-Type: application/json; charset=UTF-8
X-Compute-Request-Id: req-48d229d0-f3a5-48d2-99ef-e5e3664bf2bc
Date: Wed, 07 Oct 2015 07:24:59 GMT
{"badRequest": {"message": "Malformed request URL: URL's project_id 'f66f8e846a65484a9a740077e72e3dd' doesn't match Context's project_id 'f66f8e846a65484a9a6740077e72e3dd'", "code": 400}}