mirror of
https://github.com/ansible/awx.git
synced 2026-07-06 22:08:08 -02:30
SCM Inventory model, view, and task system changes
Inventory source file-type combined with a linked project will allow the inventory source to be updated when the project is updated. The inventory update runs in the post-run hook of the project update.
This commit is contained in:
@@ -1074,6 +1074,12 @@ class ProjectPlaybooks(RetrieveAPIView):
|
||||
serializer_class = ProjectPlaybooksSerializer
|
||||
|
||||
|
||||
class ProjectInventories(RetrieveAPIView):
|
||||
|
||||
model = Project
|
||||
serializer_class = ProjectInventoriesSerializer
|
||||
|
||||
|
||||
class ProjectTeamsList(ListAPIView):
|
||||
|
||||
model = Team
|
||||
@@ -1101,6 +1107,17 @@ class ProjectSchedulesList(SubListCreateAPIView):
|
||||
new_in_148 = True
|
||||
|
||||
|
||||
class ProjectScmInventorySources(SubListCreateAPIView):
|
||||
|
||||
view_name = _("Project SCM Inventory Sources")
|
||||
model = Inventory
|
||||
serializer_class = InventorySourceSerializer
|
||||
parent_model = Project
|
||||
relationship = 'scm_inventory_sources'
|
||||
parent_key = 'scm_project'
|
||||
new_in_320 = True
|
||||
|
||||
|
||||
class ProjectActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||
|
||||
model = ActivityStream
|
||||
@@ -1226,6 +1243,17 @@ class ProjectUpdateNotificationsList(SubListAPIView):
|
||||
new_in_300 = True
|
||||
|
||||
|
||||
class ProjectUpdateScmInventoryUpdates(SubListCreateAPIView):
|
||||
|
||||
view_name = _("Project Update SCM Inventory Updates")
|
||||
model = InventoryUpdate
|
||||
serializer_class = InventoryUpdateSerializer
|
||||
parent_model = ProjectUpdate
|
||||
relationship = 'scm_inventory_updates'
|
||||
parent_key = 'scm_project_update'
|
||||
new_in_320 = True
|
||||
|
||||
|
||||
class ProjectAccessList(ResourceAccessList):
|
||||
|
||||
model = User # needs to be User for AccessLists's
|
||||
@@ -2185,7 +2213,7 @@ class InventoryInventorySourcesList(SubListCreateAPIView):
|
||||
new_in_14 = True
|
||||
|
||||
|
||||
class InventorySourceList(ListAPIView):
|
||||
class InventorySourceList(ListCreateAPIView):
|
||||
|
||||
model = InventorySource
|
||||
serializer_class = InventorySourceSerializer
|
||||
@@ -2292,6 +2320,10 @@ class InventorySourceUpdateView(RetrieveAPIView):
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
if obj.source == 'file' and obj.scm_project_id is not None:
|
||||
raise PermissionDenied(detail=_(
|
||||
'Update the project `{}` in order to update this inventory source.'.format(
|
||||
obj.scm_project.name)))
|
||||
if obj.can_update:
|
||||
inventory_update = obj.update()
|
||||
if not inventory_update:
|
||||
|
||||
Reference in New Issue
Block a user