mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 19:35:02 -02:30
Add smart_inventories endpoint to Host
This commit is contained in:
@@ -36,7 +36,8 @@ from awx.main.models.notifications import (
|
||||
)
|
||||
from awx.main.utils import _inventory_updates
|
||||
|
||||
__all__ = ['Inventory', 'Host', 'Group', 'InventorySource', 'InventoryUpdate', 'CustomInventoryScript']
|
||||
__all__ = ['Inventory', 'Host', 'Group', 'InventorySource', 'InventoryUpdate',
|
||||
'CustomInventoryScript', 'SmartInventoryMembership']
|
||||
|
||||
logger = logging.getLogger('awx.main.models.inventory')
|
||||
|
||||
@@ -346,6 +347,19 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin):
|
||||
return self.groups.exclude(parents__pk__in=group_pks).distinct()
|
||||
|
||||
|
||||
class SmartInventoryMembership(BaseModel):
|
||||
'''
|
||||
A lookup table for Host membership in Smart Inventory
|
||||
'''
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
unique_together = (('host', 'inventory'),)
|
||||
|
||||
inventory = models.ForeignKey('Inventory', related_name='+', on_delete=models.CASCADE)
|
||||
host = models.ForeignKey('Host', related_name='+', on_delete=models.CASCADE)
|
||||
|
||||
|
||||
class Host(CommonModelNameNotUnique):
|
||||
'''
|
||||
A managed node
|
||||
@@ -361,6 +375,11 @@ class Host(CommonModelNameNotUnique):
|
||||
related_name='hosts',
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
smart_inventories = models.ManyToManyField(
|
||||
'Inventory',
|
||||
related_name='+',
|
||||
through='SmartInventoryMembership',
|
||||
)
|
||||
enabled = models.BooleanField(
|
||||
default=True,
|
||||
help_text=_('Is this host online and available for running jobs?'),
|
||||
|
||||
Reference in New Issue
Block a user