mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 11:50:42 -03:30
Fixes group & host integrity error
This commit is contained in:
parent
e01d98f2a2
commit
58bd747cb1
@ -421,6 +421,7 @@ class Command(NoArgsCommand):
|
||||
mem_host.instance_id = instance_id
|
||||
self.mem_instance_id_map[instance_id] = mem_host.name
|
||||
|
||||
@transaction.atomic
|
||||
def _delete_hosts(self):
|
||||
'''
|
||||
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(all_del_pks))
|
||||
|
||||
@transaction.atomic
|
||||
def _delete_groups(self):
|
||||
'''
|
||||
# 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(all_del_pks))
|
||||
|
||||
@transaction.atomic
|
||||
def _delete_group_children_and_hosts(self):
|
||||
'''
|
||||
Clear all invalid child relationships for groups and all invalid host
|
||||
@ -554,6 +557,7 @@ class Command(NoArgsCommand):
|
||||
len(connection.queries) - queries_before,
|
||||
group_group_count + group_host_count)
|
||||
|
||||
@transaction.atomic
|
||||
def _update_inventory(self):
|
||||
'''
|
||||
Update/overwrite variables from "all" group. If importing from a
|
||||
@ -578,6 +582,7 @@ class Command(NoArgsCommand):
|
||||
else:
|
||||
logger.info('%s variables unmodified', all_name.capitalize())
|
||||
|
||||
@transaction.atomic
|
||||
def _create_update_groups(self):
|
||||
'''
|
||||
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:
|
||||
continue
|
||||
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)
|
||||
self._batch_add_m2m(self.inventory_source.groups, group)
|
||||
self._batch_add_m2m(self.inventory_source.groups, flush=True)
|
||||
@ -628,6 +633,7 @@ class Command(NoArgsCommand):
|
||||
len(connection.queries) - queries_before,
|
||||
len(self.all_group.all_groups))
|
||||
|
||||
@transaction.atomic
|
||||
def _update_db_host_from_mem_host(self, db_host, mem_host):
|
||||
# Update host variables.
|
||||
db_variables = db_host.variables_dict
|
||||
@ -763,6 +769,7 @@ class Command(NoArgsCommand):
|
||||
len(connection.queries) - queries_before,
|
||||
len(self.all_group.all_hosts))
|
||||
|
||||
@transaction.atomic
|
||||
def _create_update_group_children(self):
|
||||
'''
|
||||
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',
|
||||
len(connection.queries) - queries_before, group_group_count)
|
||||
|
||||
@transaction.atomic
|
||||
def _create_update_group_hosts(self):
|
||||
# For each host in a mem group, add it to the parent(s) to which it
|
||||
# belongs.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user