Merge pull request #107 from jangsutsr/7334_make_up_missing_create_kwargs_for_inv_import

Make up missing create kwargs in inventory import
This commit is contained in:
Aaron Tan 2017-08-01 20:32:26 -04:00 committed by GitHub
commit c44fe85fe2

View File

@ -619,7 +619,13 @@ class Command(NoArgsCommand):
if group_name in existing_group_names:
continue
mem_group = self.all_group.all_groups[group_name]
group = self.inventory.groups.update_or_create(name=group_name, defaults={'variables':json.dumps(mem_group.variables), 'description':'imported'})[0]
group = self.inventory.groups.update_or_create(
name=group_name,
defaults={
'variables':json.dumps(mem_group.variables),
'description':'imported'
}
)[0]
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)
@ -748,8 +754,7 @@ class Command(NoArgsCommand):
if self.instance_id_var:
instance_id = self._get_instance_id(mem_host.variables)
host_attrs['instance_id'] = instance_id
db_host = self.inventory.hosts.update_or_create(name=mem_host_name,
defaults={'variables':host_attrs['variables'], 'description':host_attrs['description']})[0]
db_host = self.inventory.hosts.update_or_create(name=mem_host_name, defaults=host_attrs)[0]
if enabled is False:
logger.info('Host "%s" added (disabled)', mem_host_name)
else: