mirror of
https://github.com/ansible/awx.git
synced 2026-02-15 18:20:00 -03:30
Implement passive copying as a new host to a group
requires that the variables isn't special on the new host implements AC-1265
This commit is contained in:
@@ -821,6 +821,17 @@ class GroupHostsList(SubListCreateAPIView):
|
||||
parent_model = Group
|
||||
relationship = 'hosts'
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
parent_group = Group.objects.get(id=self.kwargs['pk'])
|
||||
existing_hosts = Host.objects.filter(inventory=parent_group.inventory, name=request.DATA['name'])
|
||||
if existing_hosts.count() > 0 and ('variables' not in request.DATA or \
|
||||
request.DATA['variables'] == '' or \
|
||||
request.DATA['variables'] == '{}' or \
|
||||
request.DATA['variables'] == '---'):
|
||||
request.DATA['id'] = existing_hosts[0].id
|
||||
return self.attach(request, *args, **kwargs)
|
||||
return super(GroupHostsList, self).create(request, *args, **kwargs)
|
||||
|
||||
class GroupAllHostsList(SubListAPIView):
|
||||
''' the list of all hosts below a group, even including subgroups '''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user