From 18bd2207b6c1977e99a93673a7be099e23f0f547 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 26 Jun 2024 08:22:20 +0200 Subject: Merging upstream version 10.1.0+dfsg. Signed-off-by: Daniel Baumann --- .../plugins/module_utils/azure_rm_common.py | 31 ++++++++++------------ 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'ansible_collections/azure/azcollection/plugins/module_utils') diff --git a/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py b/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py index 79b5167b1..c747fc72c 100644 --- a/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py +++ b/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py @@ -279,8 +279,6 @@ try: except ImportError: import azure.mgmt.recoveryservicesbackup.activestamp.models as RecoveryServicesBackupModels from azure.mgmt.search import SearchManagementClient - from azure.mgmt.datalake.store import DataLakeStoreAccountManagementClient - import azure.mgmt.datalake.store.models as DataLakeStoreAccountModel from azure.mgmt.notificationhubs import NotificationHubsManagementClient from azure.mgmt.eventhub import EventHubManagementClient from azure.mgmt.datafactory import DataFactoryManagementClient @@ -704,6 +702,12 @@ class AzureRMModuleBase(object): account = self.storage_client.storage_accounts.get_properties(resource_group_name=resource_group_name, account_name=storage_account_name) if auth_mode == 'login' and self.azure_auth.credentials.get('credential'): credential = self.azure_auth.credentials['credential'] + elif (auth_mode == 'login' and self.azure_auth.credentials.get('tenant') + and self.azure_auth.credentials.get('client_id') + and self.azure_auth.credentials.get('secret')): + credential = client_secret.ClientSecretCredential(tenant_id=self.azure_auth.credentials.get('tenant'), + client_id=self.azure_auth.credentials.get('client_id'), + client_secret=self.azure_auth.credentials.get('secret')) else: account_keys = self.storage_client.storage_accounts.list_keys(resource_group_name=resource_group_name, account_name=storage_account_name) credential = account_keys.keys[0].value @@ -947,11 +951,17 @@ class AzureRMModuleBase(object): def _ansible_get_models(self, *arg, **kwarg): return self._ansible_models - setattr(client, '_ansible_models', importlib.import_module(client_type.__module__).models) + try: + setattr(client, '_ansible_models', importlib.import_module(client_type.__module__).models) + except AttributeError: + setattr(client, '_ansible_models', importlib.import_module(client_type.__module__)._models) client.models = types.MethodType(_ansible_get_models, client) if self.azure_auth._cert_validation_mode == 'ignore': - client._config.session_configuration_callback = self._validation_ignore_callback + if hasattr(client, '_config'): + client._config.session_configuration_callback = self._validation_ignore_callback + else: + client.config.session_configuration_callback = self._validation_ignore_callback return client @@ -1360,19 +1370,6 @@ class AzureRMModuleBase(object): api_version='2020-08-01') return self._search_client - @property - def datalake_store_client(self): - self.log('Getting datalake store client...') - if not self._datalake_store_client: - self._datalake_store_client = self.get_mgmt_svc_client(DataLakeStoreAccountManagementClient, - base_url=self._cloud_environment.endpoints.resource_manager, - api_version='2016-11-01') - return self._datalake_store_client - - @property - def datalake_store_models(self): - return DataLakeStoreAccountModel - @property def notification_hub_client(self): self.log('Getting notification hub client') -- cgit v1.2.3