mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-21 23:41:49 -05:00
Add smart_inventories endpoint to Host
This commit is contained in:
@@ -58,7 +58,7 @@ import ansiconv
|
||||
from social.backends.utils import load_backends
|
||||
|
||||
# AWX
|
||||
from awx.main.tasks import send_notifications
|
||||
from awx.main.tasks import send_notifications, update_host_smart_inventory_memberships
|
||||
from awx.main.access import get_user_queryset
|
||||
from awx.main.ha import is_ha_environment
|
||||
from awx.api.authentication import TaskAuthentication, TokenGetAuthentication
|
||||
@@ -2006,6 +2006,22 @@ class HostInventorySourcesList(SubListAPIView):
|
||||
new_in_148 = True
|
||||
|
||||
|
||||
class HostSmartInventoriesList(SubListAPIView):
|
||||
model = Inventory
|
||||
serializer_class = InventorySerializer
|
||||
parent_model = Host
|
||||
relationship = 'smart_inventories'
|
||||
new_in_320 = True
|
||||
|
||||
def list(self, *args, **kwargs):
|
||||
try:
|
||||
if settings.AWX_REBUILD_SMART_MEMBERSHIP:
|
||||
update_host_smart_inventory_memberships.delay()
|
||||
return super(HostSmartInventoriesList, self).list(*args, **kwargs)
|
||||
except Exception as e:
|
||||
return Response(dict(error=_(unicode(e))), status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
class HostActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||
|
||||
model = ActivityStream
|
||||
|
||||
Reference in New Issue
Block a user