mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
Fixes group & host integrity error
This commit is contained in:
@@ -421,6 +421,7 @@ class Command(NoArgsCommand):
|
|||||||
mem_host.instance_id = instance_id
|
mem_host.instance_id = instance_id
|
||||||
self.mem_instance_id_map[instance_id] = mem_host.name
|
self.mem_instance_id_map[instance_id] = mem_host.name
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
def _delete_hosts(self):
|
def _delete_hosts(self):
|
||||||
'''
|
'''
|
||||||
For each host in the database that is NOT in the local list, delete
|
For each host in the database that is NOT in the local list, delete
|
||||||
@@ -462,6 +463,7 @@ class Command(NoArgsCommand):
|
|||||||
len(connection.queries) - queries_before,
|
len(connection.queries) - queries_before,
|
||||||
len(all_del_pks))
|
len(all_del_pks))
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
def _delete_groups(self):
|
def _delete_groups(self):
|
||||||
'''
|
'''
|
||||||
# If overwrite is set, for each group in the database that is NOT in
|
# If overwrite is set, for each group in the database that is NOT in
|
||||||
@@ -493,6 +495,7 @@ class Command(NoArgsCommand):
|
|||||||
len(connection.queries) - queries_before,
|
len(connection.queries) - queries_before,
|
||||||
len(all_del_pks))
|
len(all_del_pks))
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
def _delete_group_children_and_hosts(self):
|
def _delete_group_children_and_hosts(self):
|
||||||
'''
|
'''
|
||||||
Clear all invalid child relationships for groups and all invalid host
|
Clear all invalid child relationships for groups and all invalid host
|
||||||
@@ -554,6 +557,7 @@ class Command(NoArgsCommand):
|
|||||||
len(connection.queries) - queries_before,
|
len(connection.queries) - queries_before,
|
||||||
group_group_count + group_host_count)
|
group_group_count + group_host_count)
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
def _update_inventory(self):
|
def _update_inventory(self):
|
||||||
'''
|
'''
|
||||||
Update/overwrite variables from "all" group. If importing from a
|
Update/overwrite variables from "all" group. If importing from a
|
||||||
@@ -578,6 +582,7 @@ class Command(NoArgsCommand):
|
|||||||
else:
|
else:
|
||||||
logger.info('%s variables unmodified', all_name.capitalize())
|
logger.info('%s variables unmodified', all_name.capitalize())
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
def _create_update_groups(self):
|
def _create_update_groups(self):
|
||||||
'''
|
'''
|
||||||
For each group in the local list, create it if it doesn't exist in the
|
For each group in the local list, create it if it doesn't exist in the
|
||||||
@@ -619,7 +624,7 @@ class Command(NoArgsCommand):
|
|||||||
if group_name in existing_group_names:
|
if group_name in existing_group_names:
|
||||||
continue
|
continue
|
||||||
mem_group = self.all_group.all_groups[group_name]
|
mem_group = self.all_group.all_groups[group_name]
|
||||||
group = self.inventory.groups.create(name=group_name, variables=json.dumps(mem_group.variables), description='imported')
|
group, createdGroup = self.inventory.groups.get_or_create(name=group_name, variables=json.dumps(mem_group.variables), description='imported')
|
||||||
logger.info('Group "%s" added', group.name)
|
logger.info('Group "%s" added', group.name)
|
||||||
self._batch_add_m2m(self.inventory_source.groups, group)
|
self._batch_add_m2m(self.inventory_source.groups, group)
|
||||||
self._batch_add_m2m(self.inventory_source.groups, flush=True)
|
self._batch_add_m2m(self.inventory_source.groups, flush=True)
|
||||||
@@ -628,6 +633,7 @@ class Command(NoArgsCommand):
|
|||||||
len(connection.queries) - queries_before,
|
len(connection.queries) - queries_before,
|
||||||
len(self.all_group.all_groups))
|
len(self.all_group.all_groups))
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
def _update_db_host_from_mem_host(self, db_host, mem_host):
|
def _update_db_host_from_mem_host(self, db_host, mem_host):
|
||||||
# Update host variables.
|
# Update host variables.
|
||||||
db_variables = db_host.variables_dict
|
db_variables = db_host.variables_dict
|
||||||
@@ -763,6 +769,7 @@ class Command(NoArgsCommand):
|
|||||||
len(connection.queries) - queries_before,
|
len(connection.queries) - queries_before,
|
||||||
len(self.all_group.all_hosts))
|
len(self.all_group.all_hosts))
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
def _create_update_group_children(self):
|
def _create_update_group_children(self):
|
||||||
'''
|
'''
|
||||||
For each imported group, create all parent-child group relationships.
|
For each imported group, create all parent-child group relationships.
|
||||||
@@ -790,6 +797,7 @@ class Command(NoArgsCommand):
|
|||||||
logger.warning('Group-group updates took %d queries for %d group-group relationships',
|
logger.warning('Group-group updates took %d queries for %d group-group relationships',
|
||||||
len(connection.queries) - queries_before, group_group_count)
|
len(connection.queries) - queries_before, group_group_count)
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
def _create_update_group_hosts(self):
|
def _create_update_group_hosts(self):
|
||||||
# For each host in a mem group, add it to the parent(s) to which it
|
# For each host in a mem group, add it to the parent(s) to which it
|
||||||
# belongs.
|
# belongs.
|
||||||
|
|||||||
Reference in New Issue
Block a user