mirror of
https://github.com/ansible/awx.git
synced 2026-03-26 05:15:02 -02:30
change facts_recent to facts_latest
This commit is contained in:
@@ -1157,7 +1157,7 @@ class HostSerializer(BaseSerializerWithVariables):
|
|||||||
ad_hoc_commands = self.reverse('api:host_ad_hoc_commands_list', kwargs={'pk': obj.pk}),
|
ad_hoc_commands = self.reverse('api:host_ad_hoc_commands_list', kwargs={'pk': obj.pk}),
|
||||||
ad_hoc_command_events = self.reverse('api:host_ad_hoc_command_events_list', kwargs={'pk': obj.pk}),
|
ad_hoc_command_events = self.reverse('api:host_ad_hoc_command_events_list', kwargs={'pk': obj.pk}),
|
||||||
fact_versions = self.reverse('api:host_fact_versions_list', kwargs={'pk': obj.pk}),
|
fact_versions = self.reverse('api:host_fact_versions_list', kwargs={'pk': obj.pk}),
|
||||||
facts_recent = self.reverse('api:host_facts_recent_list', kwargs={'pk': obj.pk}),
|
facts_latest = self.reverse('api:host_facts_latest_list', kwargs={'pk': obj.pk}),
|
||||||
))
|
))
|
||||||
if obj.inventory:
|
if obj.inventory:
|
||||||
res['inventory'] = self.reverse('api:inventory_detail', kwargs={'pk': obj.inventory.pk})
|
res['inventory'] = self.reverse('api:inventory_detail', kwargs={'pk': obj.inventory.pk})
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ host_urls = patterns('awx.api.views',
|
|||||||
#url(r'^(?P<pk>[0-9]+)/single_fact/$', 'host_single_fact_view'),
|
#url(r'^(?P<pk>[0-9]+)/single_fact/$', 'host_single_fact_view'),
|
||||||
url(r'^(?P<pk>[0-9]+)/fact_versions/$', 'host_fact_versions_list'),
|
url(r'^(?P<pk>[0-9]+)/fact_versions/$', 'host_fact_versions_list'),
|
||||||
url(r'^(?P<pk>[0-9]+)/fact_view/$', 'host_fact_compare_view'),
|
url(r'^(?P<pk>[0-9]+)/fact_view/$', 'host_fact_compare_view'),
|
||||||
url(r'^(?P<pk>[0-9]+)/facts_recent/$', 'host_facts_recent_list'),
|
url(r'^(?P<pk>[0-9]+)/facts_latest/$', 'host_facts_latest_list'),
|
||||||
)
|
)
|
||||||
|
|
||||||
group_urls = patterns('awx.api.views',
|
group_urls = patterns('awx.api.views',
|
||||||
|
|||||||
@@ -1835,11 +1835,11 @@ class HostFactCompareView(SystemTrackingEnforcementMixin, SubDetailAPIView):
|
|||||||
return Response(self.serializer_class(instance=fact_entry).data)
|
return Response(self.serializer_class(instance=fact_entry).data)
|
||||||
|
|
||||||
|
|
||||||
class HostFactsRecentList(SubListAPIView):
|
class HostFactsLatestList(SubListAPIView):
|
||||||
|
|
||||||
model = FactRecent
|
model = FactLatest
|
||||||
parent_model = Host
|
parent_model = Host
|
||||||
relationship = 'facts_recent'
|
relationship = 'facts_latest'
|
||||||
serializer_class = FactSerializer
|
serializer_class = FactSerializer
|
||||||
new_in_320 = True
|
new_in_320 = True
|
||||||
|
|
||||||
|
|||||||
@@ -2264,12 +2264,12 @@ class RoleAccess(BaseAccess):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class FactRecentAccess(BaseAccess):
|
class FactLatestAccess(BaseAccess):
|
||||||
|
|
||||||
model = FactRecent
|
model = FactLatest
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return FactRecent.objects.distinct()
|
return FactLatest.objects.distinct()
|
||||||
|
|
||||||
|
|
||||||
register_access(User, UserAccess)
|
register_access(User, UserAccess)
|
||||||
@@ -2304,4 +2304,4 @@ register_access(WorkflowJobTemplateNode, WorkflowJobTemplateNodeAccess)
|
|||||||
register_access(WorkflowJobNode, WorkflowJobNodeAccess)
|
register_access(WorkflowJobNode, WorkflowJobNodeAccess)
|
||||||
register_access(WorkflowJobTemplate, WorkflowJobTemplateAccess)
|
register_access(WorkflowJobTemplate, WorkflowJobTemplateAccess)
|
||||||
register_access(WorkflowJob, WorkflowJobAccess)
|
register_access(WorkflowJob, WorkflowJobAccess)
|
||||||
register_access(FactRecent, FactRecentAccess)
|
register_access(FactLatest, FactLatestAccess)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from psycopg2.extensions import AsIs
|
|||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
import awx.main.fields
|
import awx.main.fields
|
||||||
from awx.main.models import FactRecent
|
from awx.main.models import FactLatest
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@@ -20,13 +20,13 @@ class Migration(migrations.Migration):
|
|||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='FactRecent',
|
name='FactLatest',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
('timestamp', models.DateTimeField(default=None, help_text='Date and time of the corresponding fact scan gathering time.', editable=False)),
|
('timestamp', models.DateTimeField(default=None, help_text='Date and time of the corresponding fact scan gathering time.', editable=False)),
|
||||||
('module', models.CharField(max_length=128)),
|
('module', models.CharField(max_length=128)),
|
||||||
('facts', awx.main.fields.JSONBField(default={}, help_text='Arbitrary JSON structure of module facts captured at timestamp for a single host.', blank=True)),
|
('facts', awx.main.fields.JSONBField(default={}, help_text='Arbitrary JSON structure of module facts captured at timestamp for a single host.', blank=True)),
|
||||||
('host', models.ForeignKey(related_name='facts_recent', to='main.Host', help_text='Host for the facts that the fact scan captured.')),
|
('host', models.ForeignKey(related_name='facts_latest', to='main.Host', help_text='Host for the facts that the fact scan captured.')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
@@ -35,10 +35,10 @@ class Migration(migrations.Migration):
|
|||||||
field=awx.main.fields.JSONBField(default={}, help_text='Arbitrary JSON structure of module facts captured at timestamp for a single host.', blank=True),
|
field=awx.main.fields.JSONBField(default={}, help_text='Arbitrary JSON structure of module facts captured at timestamp for a single host.', blank=True),
|
||||||
),
|
),
|
||||||
migrations.AlterIndexTogether(
|
migrations.AlterIndexTogether(
|
||||||
name='factrecent',
|
name='factlatest',
|
||||||
index_together=set([('timestamp', 'module', 'host')]),
|
index_together=set([('timestamp', 'module', 'host')]),
|
||||||
),
|
),
|
||||||
migrations.RunSQL([("CREATE INDEX fact_recent_facts_default_gin ON %s USING gin"
|
migrations.RunSQL([("CREATE INDEX fact_latest_facts_default_gin ON %s USING gin"
|
||||||
"(facts jsonb_path_ops);", [AsIs(FactRecent._meta.db_table)])],
|
"(facts jsonb_path_ops);", [AsIs(FactLatest._meta.db_table)])],
|
||||||
[('DROP INDEX fact_recent_facts_default_gin;', None)]),
|
[('DROP INDEX fact_latest_facts_default_gin;', None)]),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
|
|
||||||
from awx.main.fields import JSONBField
|
from awx.main.fields import JSONBField
|
||||||
|
|
||||||
__all__ = ('Fact', 'FactRecent')
|
__all__ = ('Fact', 'FactLatest')
|
||||||
|
|
||||||
|
|
||||||
class FactRecent(models.Model):
|
class FactLatest(models.Model):
|
||||||
host = models.ForeignKey(
|
host = models.ForeignKey(
|
||||||
'Host',
|
'Host',
|
||||||
related_name='facts_recent',
|
related_name='facts_latest',
|
||||||
db_index=True,
|
db_index=True,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
help_text=_('Host for the facts that the fact scan captured.'),
|
help_text=_('Host for the facts that the fact scan captured.'),
|
||||||
@@ -33,10 +33,10 @@ class FactRecent(models.Model):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_fact(host_id, module, timestamp, facts):
|
def add_fact(host_id, module, timestamp, facts):
|
||||||
qs = FactRecent.objects.filter(host_id=host_id, module=module)
|
qs = FactLatest.objects.filter(host_id=host_id, module=module)
|
||||||
qs.delete()
|
qs.delete()
|
||||||
|
|
||||||
fact_obj = FactRecent.objects.create(host_id=host_id, module=module, timestamp=timestamp, facts=facts)
|
fact_obj = FactLatest.objects.create(host_id=host_id, module=module, timestamp=timestamp, facts=facts)
|
||||||
return fact_obj
|
return fact_obj
|
||||||
|
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ class Fact(models.Model):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_fact(host_id, module, timestamp, facts):
|
def add_fact(host_id, module, timestamp, facts):
|
||||||
FactRecent.add_fact(host_id=host_id, module=module, timestamp=timestamp, facts=facts)
|
FactLatest.add_fact(host_id=host_id, module=module, timestamp=timestamp, facts=facts)
|
||||||
|
|
||||||
fact_obj = Fact.objects.create(host_id=host_id, module=module, timestamp=timestamp, facts=facts)
|
fact_obj = Fact.objects.create(host_id=host_id, module=module, timestamp=timestamp, facts=facts)
|
||||||
fact_obj.save()
|
fact_obj.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user