summaryrefslogtreecommitdiff
path: root/novaclient/v2/usage.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/v2/usage.py')
-rw-r--r--novaclient/v2/usage.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/novaclient/v2/usage.py b/novaclient/v2/usage.py
new file mode 100644
index 0000000..585ce11
--- /dev/null
+++ b/novaclient/v2/usage.py
@@ -0,0 +1,61 @@
1#
2# Licensed under the Apache License, Version 2.0 (the "License"); you may
3# not use this file except in compliance with the License. You may obtain
4# a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11# License for the specific language governing permissions and limitations
12# under the License.
13
14"""
15Usage interface.
16"""
17
18from novaclient import base
19
20
21class Usage(base.Resource):
22 """
23 Usage contains information about a tenant's physical resource usage
24 """
25 def __repr__(self):
26 return "<ComputeUsage>"
27
28
29class UsageManager(base.ManagerWithFind):
30 """
31 Manage :class:`Usage` resources.
32 """
33 resource_class = Usage
34
35 def list(self, start, end, detailed=False):
36 """
37 Get usage for all tenants
38
39 :param start: :class:`datetime.datetime` Start date
40 :param end: :class:`datetime.datetime` End date
41 :param detailed: Whether to include information about each
42 instance whose usage is part of the report
43 :rtype: list of :class:`Usage`.
44 """
45 return self._list(
46 "/os-simple-tenant-usage?start=%s&end=%s&detailed=%s" %
47 (start.isoformat(), end.isoformat(), int(bool(detailed))),
48 "tenant_usages")
49
50 def get(self, tenant_id, start, end):
51 """
52 Get usage for a specific tenant.
53
54 :param tenant_id: Tenant ID to fetch usage for
55 :param start: :class:`datetime.datetime` Start date
56 :param end: :class:`datetime.datetime` End date
57 :rtype: :class:`Usage`
58 """
59 return self._get("/os-simple-tenant-usage/%s?start=%s&end=%s" %
60 (tenant_id, start.isoformat(), end.isoformat()),
61 "tenant_usage")