diff --git a/awx/main/tasks.py b/awx/main/tasks.py index a263f9ed61..f6eaed39d6 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -938,7 +938,8 @@ class RunInventoryUpdate(BaseTask): username=credential.username, password=decrypt_field(credential, "password"), project_name=credential.project) - openstack_data = {"clouds": {"devstack": {"auth": openstack_auth}}} + private_state = str(inventory_update.source_vars_dict.get("private", "true")) + openstack_data = {"clouds": {"devstack": {"private": private_state, "auth": openstack_auth}}} return yaml.safe_dump(openstack_data, default_flow_style=False, allow_unicode=True) cp = ConfigParser.ConfigParser() diff --git a/awx/main/tests/inventory.py b/awx/main/tests/inventory.py index a24ac68859..ef35c407ae 100644 --- a/awx/main/tests/inventory.py +++ b/awx/main/tests/inventory.py @@ -1898,3 +1898,19 @@ class InventoryUpdatesTest(BaseTransactionTest): other_inv_src_opts = {'source': 'custom', 'source_script': script_data['id']} with self.current_user(self.super_django_user): self.put(other_inv_src, other_inv_src_opts, expect=400) + + def test_update_from_openstack(self): + api_url = getattr(settings, 'TEST_OPENSTACK_HOST', '') + api_user = getattr(settings, 'TEST_OPENSTACK_USER', '') + api_password = getattr(settings, 'TEST_OPENSTACK_PASSWORD', '') + api_project = getattr(settings, 'TEST_OPENSTACK_PROJECT', '') + if not all([api_url, api_user, api_password, api_project]): + self.skipTest("No test openstack credentials defined") + self.create_test_license_file() + credential = Credential.objects.create(kind='openstack', + host=api_url, + username=api_user, + password=api_password, + project=api_project) + inventory_source = self.update_inventory_source(self.group, source='openstack', credential=credential) + self.check_inventory_source(inventory_source) diff --git a/awx/plugins/inventory/openstack.py b/awx/plugins/inventory/openstack.py index 54309007b6..b3cfc54444 100755 --- a/awx/plugins/inventory/openstack.py +++ b/awx/plugins/inventory/openstack.py @@ -56,7 +56,7 @@ class OpenStackInventory(object): self.openstack_config = os_client_config.config.OpenStackConfig( config_files) self.clouds = shade.openstack_clouds(self.openstack_config) - self.refresh = refresh + self.refresh = True self.cache_max_age = self.openstack_config.get_cache_max_age() cache_path = self.openstack_config.get_cache_path() @@ -101,9 +101,9 @@ class OpenStackInventory(object): continue server_vars = meta['server_vars'] - hostvars[server.name][ - 'ansible_ssh_host'] = server_vars['interface_ip'] + hostvars[server.name]['ansible_ssh_host'] = server_vars['interface_ip'] hostvars[server.name]['openstack'] = server_vars + hostvars[server.name]['hostId'] = server_vars['hostId'] for group in meta['groups']: groups[group].append(server.name) diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index 1d85ecac19..016b662885 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -531,7 +531,7 @@ OPENSTACK_ENABLED_VALUE = 'ACTIVE' OPENSTACK_GROUP_FILTER = r'^.+$' OPENSTACK_HOST_FILTER = r'^.+$' OPENSTACK_EXCLUDE_EMPTY_GROUPS = True -OPENSTACK_INSTANCE_ID_VAR = None +OPENSTACK_INSTANCE_ID_VAR = "hostId" # --------------------- # -- Activity Stream --