Merge pull request #9654 from amolgautam25/issue_4687

Adding host_metrics for customers who don't have automation analytics

SUMMARY

I am trying to accomplish the following:

 Create a new model that stores details about hostname
 create corresponding migrations for it
 Update the table (main_hostmetrics) after playbook execution
 retrieve the data with custom awx-manage command :  awx-manage host_metrics --since <date> --until <date>


ISSUE TYPE


Feature Pull Request

COMPONENT NAME


API

AWX VERSION

awx: 18.0.0


ADDITIONAL INFORMATION

Reviewed-by: Ryan Petrello <ryan@ryanpetrello.com>
Reviewed-by: Amol Gautam <amol_gautam25@yahoo.co.in>
Reviewed-by: Chris Meyers <None>
Reviewed-by: Jeff Bradberry <None>
Reviewed-by: Bill Nottingham <None>
Reviewed-by: Ladislav Smola <lsmola@redhat.com>
Reviewed-by: Alan Rominger <arominge@redhat.com>
This commit is contained in:
softwarefactory-project-zuul[bot]
2021-05-20 13:55:46 +00:00
committed by GitHub
6 changed files with 123 additions and 1 deletions

View File

@@ -804,6 +804,12 @@ class Group(CommonModelNameNotUnique, RelatedJobsMixin):
return UnifiedJob.objects.non_polymorphic().filter(Q(job__inventory=self.inventory) | Q(inventoryupdate__inventory_source__groups=self))
class HostMetric(models.Model):
hostname = models.CharField(primary_key=True, max_length=512)
first_automation = models.DateTimeField(auto_now_add=True, null=False, db_index=True, help_text=_('When the host was first automated against'))
last_automation = models.DateTimeField(db_index=True, help_text=_('When the host was last automated against'))
class InventorySourceOptions(BaseModel):
"""
Common fields for InventorySource and InventoryUpdate.