summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorMonsyne Dragon <mdragon@rackspace.com>2012-07-27 19:51:32 +0000
committerMonsyne Dragon <mdragon@rackspace.com>2012-07-27 19:55:03 +0000
commitaad7743f42e559aefde37bb44622986df4e2ae98 (patch)
tree4ac6c94f882f8bf97b0f84d6f893fafd4bcedc65 /nova/compute
parentffaffa12984449aba1468c14f1580c13cd867acf (diff)
Correct host count in instance_usage_audit_log extension.
This fixes bug 1030106. Basically we were not counting disabled hosts in the total host count. Also I have refactored the get_audit_task_logs method, it's really part of the extension (only the extension uses it), so I've moved it out of nova.compute.utils into the extension itself. (the tests that exercise it already lived in the extension's tests anyway.) Change-Id: Iaf42d887b824ba0cbf6ab0ed143a4c01b37b0cb1
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/utils.py58
1 files changed, 0 insertions, 58 deletions
diff --git a/nova/compute/utils.py b/nova/compute/utils.py
index 0370988ea..d3beea68c 100644
--- a/nova/compute/utils.py
+++ b/nova/compute/utils.py
@@ -128,61 +128,3 @@ def start_instance_usage_audit(context, begin, end, host, num_instances):
def finish_instance_usage_audit(context, begin, end, host, errors, message):
db.task_log_end_task(context, "instance_usage_audit", begin, end, host,
errors, message)
-
-
-def get_audit_task_logs(context, begin=None, end=None, before=None):
- """Returns a full log for all instance usage audit tasks on all computes.
-
- :param begin: datetime beginning of audit period to get logs for,
- Defaults to the beginning of the most recently completed
- audit period prior to the 'before' date.
- :param end: datetime ending of audit period to get logs for,
- Defaults to the ending of the most recently completed
- audit period prior to the 'before' date.
- :param before: By default we look for the audit period most recently
- completed before this datetime. Has no effect if both begin and end
- are specified.
- """
- defbegin, defend = utils.last_completed_audit_period(before=before)
- if begin is None:
- begin = defbegin
- if end is None:
- end = defend
- task_logs = db.task_log_get_all(context, "instance_usage_audit",
- begin, end)
- services = db.service_get_all_by_topic(context, "compute")
- hosts = set(serv['host'] for serv in services)
- seen_hosts = set()
- done_hosts = set()
- running_hosts = set()
- total_errors = 0
- total_items = 0
- for tlog in task_logs:
- seen_hosts.add(tlog['host'])
- if tlog['state'] == "DONE":
- done_hosts.add(tlog['host'])
- if tlog['state'] == "RUNNING":
- running_hosts.add(tlog['host'])
- total_errors += tlog['errors']
- total_items += tlog['task_items']
- log = dict((tl['host'], dict(state=tl['state'],
- instances=tl['task_items'],
- errors=tl['errors'],
- message=tl['message']))
- for tl in task_logs)
- missing_hosts = hosts - seen_hosts
- overall_status = "%s hosts done. %s errors." % (
- 'ALL' if len(done_hosts) == len(hosts)
- else "%s of %s" % (len(done_hosts), len(hosts)),
- total_errors)
- return dict(period_beginning=str(begin),
- period_ending=str(end),
- num_hosts=len(hosts),
- num_hosts_done=len(done_hosts),
- num_hosts_running=len(running_hosts),
- num_hosts_not_run=len(missing_hosts),
- hosts_not_run=list(missing_hosts),
- total_instances=total_items,
- total_errors=total_errors,
- overall_status=overall_status,
- log=log)