Merge pull request #189 from ramielrowe/old_recs_audit_report
Accounting for reconciled old launches in nova audit report
This commit is contained in:
commit
9300b2996d
@ -49,6 +49,21 @@ select stacktach_instanceusage.id,
|
|||||||
stacktach_instancereconcile.deleted_at > %s)
|
stacktach_instancereconcile.deleted_at > %s)
|
||||||
) and stacktach_instanceusage.launched_at < %s;"""
|
) and stacktach_instanceusage.launched_at < %s;"""
|
||||||
|
|
||||||
|
OLD_RECONCILES_QUERY = """
|
||||||
|
select stacktach_instancereconcile.id,
|
||||||
|
stacktach_instancereconcile.instance,
|
||||||
|
stacktach_instancereconcile.launched_at from stacktach_instancereconcile
|
||||||
|
left outer join stacktach_instancedeletes on
|
||||||
|
stacktach_instancereconcile.instance = stacktach_instancedeletes.instance
|
||||||
|
where (
|
||||||
|
stacktach_instancereconcile.deleted_at is null and (
|
||||||
|
stacktach_instancedeletes.deleted_at is null or
|
||||||
|
stacktach_instancedeletes.deleted_at > %s
|
||||||
|
)
|
||||||
|
or (stacktach_instancereconcile.deleted_at is not null and
|
||||||
|
stacktach_instancereconcile.deleted_at > %s)
|
||||||
|
) and stacktach_instancereconcile.launched_at < %s;"""
|
||||||
|
|
||||||
reconciler = None
|
reconciler = None
|
||||||
|
|
||||||
|
|
||||||
@ -217,6 +232,21 @@ def _launch_audit_for_period(beginning, ending):
|
|||||||
launch.launched_at):
|
launch.launched_at):
|
||||||
old_launches_dict[instance] = l
|
old_launches_dict[instance] = l
|
||||||
|
|
||||||
|
# NOTE (apmelton)
|
||||||
|
# Django's safe substitution doesn't allow dict substitution...
|
||||||
|
# Thus, we send it 'beginning' three times...
|
||||||
|
old_recs = models.InstanceReconcile.objects\
|
||||||
|
.raw(OLD_RECONCILES_QUERY,
|
||||||
|
[beginning, beginning, beginning])
|
||||||
|
|
||||||
|
for rec in old_recs:
|
||||||
|
instance = rec.instance
|
||||||
|
l = {'id': rec.id, 'launched_at': rec.launched_at}
|
||||||
|
if instance not in old_launches_dict or \
|
||||||
|
(old_launches_dict[instance]['launched_at'] <
|
||||||
|
rec.launched_at):
|
||||||
|
old_launches_dict[instance] = l
|
||||||
|
|
||||||
for instance, launch in old_launches_dict.items():
|
for instance, launch in old_launches_dict.items():
|
||||||
if instance in launches_dict:
|
if instance in launches_dict:
|
||||||
launches_dict[instance].append(launch)
|
launches_dict[instance].append(launch)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user