Merge pull request #312 from manalilatkar/add_host_and_deployment_in_audit
RM 5495: adding host and deployment info to missing exists entries in the nova usage audit
This commit is contained in:
commit
e2adb255b7
@ -29,6 +29,7 @@ sys.path.append(os.environ.get('STACKTACH_INSTALL_DIR', '/stacktach'))
|
||||
|
||||
import usage_audit
|
||||
|
||||
from stacktach.models import InstanceUsage
|
||||
from stacktach import datetime_to_decimal as dt
|
||||
from stacktach import models
|
||||
from stacktach.reconciler import Reconciler
|
||||
@ -116,14 +117,24 @@ def _audit_launches_to_exists(launches, exists, beginning):
|
||||
rec = reconciler.missing_exists_for_instance(*args)
|
||||
msg = "Couldn't find exists for launch (%s, %s)"
|
||||
msg = msg % (instance, expected['launched_at'])
|
||||
fails.append(['Launch', expected['id'], msg, 'Y' if rec else 'N'])
|
||||
launched_at = dt.dt_from_decimal(expected['launched_at'])
|
||||
usage = InstanceUsage.find(instance, launched_at)[0]
|
||||
host = usage.host()
|
||||
deployment = usage.deployment()
|
||||
fails.append(['Launch', expected['id'], msg,
|
||||
'Y' if rec else 'N', host, deployment])
|
||||
else:
|
||||
rec = False
|
||||
if reconciler:
|
||||
args = (launches[0]['id'], beginning)
|
||||
rec = reconciler.missing_exists_for_instance(*args)
|
||||
msg = "No exists for instance (%s)" % instance
|
||||
fails.append(['Launch', '-', msg, 'Y' if rec else 'N'])
|
||||
launched_at = dt.dt_from_decimal(launches[0]['launched_at'])
|
||||
usage = InstanceUsage.find(instance, launched_at)[0]
|
||||
host = usage.host()
|
||||
deployment = usage.deployment()
|
||||
fails.append(['Launch', '-', msg, 'Y' if rec else 'N', host,
|
||||
deployment])
|
||||
return fails
|
||||
|
||||
|
||||
@ -233,7 +244,7 @@ def store_results(start, end, summary, details):
|
||||
'created': dt.dt_to_decimal(datetime.datetime.utcnow()),
|
||||
'period_start': start,
|
||||
'period_end': end,
|
||||
'version': 6,
|
||||
'version': 7,
|
||||
'name': 'nova usage audit'
|
||||
}
|
||||
|
||||
|
@ -175,11 +175,14 @@ class InstanceUsage(models.Model):
|
||||
rax_options = models.TextField(null=True, blank=True)
|
||||
|
||||
def deployment(self):
|
||||
raws = RawData.objects.filter(request_id=self.request_id)
|
||||
if raws.count() == 0:
|
||||
return False
|
||||
raw = raws[0]
|
||||
return raw.deployment
|
||||
return self.latest_raw_for_request_id().deployment.name
|
||||
|
||||
def latest_raw_for_request_id(self):
|
||||
return RawData.objects.filter(
|
||||
request_id=self.request_id).order_by('-id')[0]
|
||||
|
||||
def host(self):
|
||||
return self.latest_raw_for_request_id().host
|
||||
|
||||
@staticmethod
|
||||
def find(instance, launched_at):
|
||||
|
@ -20,12 +20,11 @@
|
||||
from datetime import datetime
|
||||
|
||||
import unittest
|
||||
from django.db.models import Q
|
||||
import mox
|
||||
from stacktach.models import RawData, GlanceRawData, GenericRawData, ImageDeletes, InstanceExists, ImageExists
|
||||
from tests.unit.utils import IMAGE_UUID_1
|
||||
from stacktach import datetime_to_decimal as dt, models
|
||||
from stacktach.models import RawData, GlanceRawData, GenericRawData
|
||||
from stacktach.models import ImageDeletes, InstanceExists, ImageExists
|
||||
from tests.unit.utils import IMAGE_UUID_1
|
||||
from stacktach import datetime_to_decimal as dt
|
||||
from tests.unit import StacktachBaseTestCase
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user