diff options
author | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-09-01 00:16:34 +0000 |
---|---|---|
committer | Tarmac <> | 2011-09-01 00:16:34 +0000 |
commit | 65231ec1b9296bb26544d414e3033c9058ba07b7 (patch) | |
tree | a07dc22352352b7599433b8cf46a6d857777ec7e /bin/instance-usage-audit | |
parent | 3bc7a44dad3233595beb20b63204f16f1cb4376e (diff) | |
parent | 0f83de82b93d714be6df16b7f151141ab3f4d987 (diff) | |
download | nova-65231ec1b9296bb26544d414e3033c9058ba07b7.tar.gz nova-65231ec1b9296bb26544d414e3033c9058ba07b7.tar.xz nova-65231ec1b9296bb26544d414e3033c9058ba07b7.zip |
Simple usage extension for nova. Uses db to calculate tenant_usage for specified time periods.
Methods:
* index: return a list of tenant_usages, with option of incuding detailed server_usage
* show: returns a specific tenant_usage object
tenant_usage object:
* tenant_usage.total_memory_mb_usage: sum of memory_mb * hours for all instances in tenant for this period
* tenant_usage.total_local_gb_usage: sum of local_gb * hours for all instances in tenant for this period
* tenant_usage.total_vcpus_usage: sum of vcpus * hours for all instances in tenant for this period
* tenant_usage.total_hours: sum of all instance hours for this period
* tenant_usage.server_usages: A detailed list of server_usages, which describe the usage of a specific server
For larger instances db tables, indexes on instance.launched_at and instance.terminated_at should significantly help performance.
Diffstat (limited to 'bin/instance-usage-audit')
-rwxr-xr-x | bin/instance-usage-audit | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/bin/instance-usage-audit b/bin/instance-usage-audit index a06c6b1b3..7ce5732e7 100755 --- a/bin/instance-usage-audit +++ b/bin/instance-usage-audit @@ -102,9 +102,8 @@ if __name__ == '__main__': logging.setup() begin, end = time_period(FLAGS.instance_usage_audit_period) print "Creating usages for %s until %s" % (str(begin), str(end)) - instances = db.instance_get_active_by_window(context.get_admin_context(), - begin, - end) + ctxt = context.get_admin_context() + instances = db.instance_get_active_by_window_joined(ctxt, begin, end) print "%s instances" % len(instances) for instance_ref in instances: usage_info = utils.usage_from_instance(instance_ref, |