diff --git a/plugins/module_utils/azure_rm_common.py b/plugins/module_utils/azure_rm_common.py index a994cc9c4..36dbac4a5 100644 --- a/plugins/module_utils/azure_rm_common.py +++ b/plugins/module_utils/azure_rm_common.py @@ -355,7 +355,7 @@ def normalize_location_name(name): }, 'PrivateDnsManagementClient': { 'package_name': 'privatedns', - 'expected_version': '0.1.0' + 'expected_version': '1.0.0' }, 'WebSiteManagementClient': { 'package_name': 'web', @@ -1121,6 +1121,7 @@ def private_dns_client(self): if not self._private_dns_client: self._private_dns_client = self.get_mgmt_svc_client( PrivateDnsManagementClient, + is_track2=True, base_url=self._cloud_environment.endpoints.resource_manager) return self._private_dns_client diff --git a/plugins/modules/azure_rm_privatednsrecordset.py b/plugins/modules/azure_rm_privatednsrecordset.py index 17965c249..64fccaf6f 100644 --- a/plugins/modules/azure_rm_privatednsrecordset.py +++ b/plugins/modules/azure_rm_privatednsrecordset.py @@ -243,7 +243,7 @@ from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase, HAS_AZURE try: - from msrestazure.azure_exceptions import CloudError + from azure.core.exceptions import ResourceNotFoundError except ImportError: # This is handled in azure_rm_common pass @@ -368,7 +368,7 @@ def exec_module(self, **kwargs): self.record_type, self.relative_name) self.results['state'] = self.recordset_to_dict(record_set) - except CloudError: + except ResourceNotFoundError: record_set = None record_type_metadata = RECORDSET_VALUE_MAP.get(self.record_type) diff --git a/plugins/modules/azure_rm_privatednsrecordset_info.py b/plugins/modules/azure_rm_privatednsrecordset_info.py index 00fea2861..d4c33f2fd 100644 --- a/plugins/modules/azure_rm_privatednsrecordset_info.py +++ b/plugins/modules/azure_rm_privatednsrecordset_info.py @@ -108,8 +108,7 @@ from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase try: - from msrestazure.azure_exceptions import CloudError - from azure.common import AzureMissingResourceHttpError, AzureHttpError + from azure.core.exceptions import ResourceNotFoundError except Exception: # This is handled in azure_rm_common pass @@ -195,7 +194,7 @@ def get_item(self): self.zone_name, self.record_type, self.relative_name) - except CloudError: + except ResourceNotFoundError: pass results = [item] @@ -208,7 +207,7 @@ def list_type(self): self.zone_name, self.record_type, top=self.top) - except AzureHttpError as exc: + except Exception as exc: self.fail("Failed to list for record type {0} - {1}".format(self.record_type, str(exc))) results = [] @@ -220,7 +219,7 @@ def list_zone(self): self.log('Lists all record sets in a Private DNS zone') try: response = self.private_dns_client.record_sets.list(self.resource_group, self.zone_name, top=self.top) - except AzureHttpError as exc: + except Exception as exc: self.fail("Failed to list for zone {0} - {1}".format(self.zone_name, str(exc))) results = [] diff --git a/plugins/modules/azure_rm_privatednszone.py b/plugins/modules/azure_rm_privatednszone.py index 42863c2e7..4a84cdbce 100644 --- a/plugins/modules/azure_rm_privatednszone.py +++ b/plugins/modules/azure_rm_privatednszone.py @@ -85,8 +85,8 @@ from ansible.module_utils._text import to_native try: - from msrestazure.azure_exceptions import CloudError - from msrest.polling import LROPoller + from azure.core.exceptions import ResourceNotFoundError + from azure.core.polling import LROPoller except ImportError: # This is handled in azure_rm_common pass @@ -149,7 +149,7 @@ def exec_module(self, **kwargs): elif self.state == 'absent': changed = True - except CloudError: + except ResourceNotFoundError: # the zone does not exist so create it if self.state == 'present': changed = True @@ -181,7 +181,7 @@ def exec_module(self, **kwargs): def create_or_update_zone(self, zone): try: # create or update the new Zone object we created - new_zone = self.private_dns_client.private_zones.create_or_update( + new_zone = self.private_dns_client.private_zones.begin_create_or_update( self.resource_group, self.name, zone) if isinstance(new_zone, LROPoller): @@ -195,7 +195,7 @@ def create_or_update_zone(self, zone): def delete_zone(self): try: # delete the Zone - poller = self.private_dns_client.private_zones.delete( + poller = self.private_dns_client.private_zones.begin_delete( self.resource_group, self.name) result = self.get_poller_result(poller) except Exception as exc: diff --git a/plugins/modules/azure_rm_privatednszone_info.py b/plugins/modules/azure_rm_privatednszone_info.py index 35ee63429..5a5730e4c 100644 --- a/plugins/modules/azure_rm_privatednszone_info.py +++ b/plugins/modules/azure_rm_privatednszone_info.py @@ -114,8 +114,7 @@ from ansible.module_utils._text import to_native try: - from msrestazure.azure_exceptions import CloudError - from azure.common import AzureMissingResourceHttpError, AzureHttpError + from azure.core.exceptions import ResourceNotFoundError except Exception: # This is handled in azure_rm_common pass @@ -183,7 +182,7 @@ def get_item(self): try: item = self.private_dns_client.private_zones.get( self.resource_group, self.name) - except CloudError: + except ResourceNotFoundError: pass # serialize result @@ -196,7 +195,7 @@ def list_resource_group(self): try: response = self.private_dns_client.private_zones.list_by_resource_group( self.resource_group) - except AzureHttpError as exc: + except Exception as exc: self.fail("Failed to list for resource group {0} - {1}".format( self.resource_group, str(exc))) @@ -210,7 +209,7 @@ def list_items(self): self.log('List all items') try: response = self.private_dns_client.private_zones.list() - except AzureHttpError as exc: + except Exception as exc: self.fail("Failed to list all items - {0}".format(str(exc))) results = [] diff --git a/plugins/modules/azure_rm_privatednszonelink.py b/plugins/modules/azure_rm_privatednszonelink.py index 38be917c6..b87b54a6b 100644 --- a/plugins/modules/azure_rm_privatednszonelink.py +++ b/plugins/modules/azure_rm_privatednszonelink.py @@ -160,8 +160,8 @@ format_resource_id try: - from msrestazure.azure_exceptions import CloudError - from msrest.polling import LROPoller + from azure.core.exceptions import ResourceNotFoundError + from azure.core.polling import LROPoller except ImportError: # This is handled in azure_rm_common pass @@ -252,7 +252,7 @@ def exec_module(self, **kwargs): elif self.state == 'absent': changed = True - except CloudError: + except ResourceNotFoundError: if self.state == 'present': changed = True else: @@ -288,10 +288,10 @@ def create_or_update_network_link(self, virtual_network_link): try: # create the virtual network link response = \ - self.private_dns_client.virtual_network_links.create_or_update(resource_group_name=self.resource_group, - private_zone_name=self.zone_name, - virtual_network_link_name=self.name, - parameters=virtual_network_link) + self.private_dns_client.virtual_network_links.begin_create_or_update(resource_group_name=self.resource_group, + private_zone_name=self.zone_name, + virtual_network_link_name=self.name, + parameters=virtual_network_link) if isinstance(response, LROPoller): response = self.get_poller_result(response) except Exception as exc: @@ -301,9 +301,9 @@ def create_or_update_network_link(self, virtual_network_link): def delete_network_link(self): try: # delete the virtual network link - response = self.private_dns_client.virtual_network_links.delete(resource_group_name=self.resource_group, - private_zone_name=self.zone_name, - virtual_network_link_name=self.name) + response = self.private_dns_client.virtual_network_links.begin_delete(resource_group_name=self.resource_group, + private_zone_name=self.zone_name, + virtual_network_link_name=self.name) if isinstance(response, LROPoller): response = self.get_poller_result(response) except Exception as exc: diff --git a/plugins/modules/azure_rm_privatednszonelink_info.py b/plugins/modules/azure_rm_privatednszonelink_info.py index d5c5adc9a..5907ea701 100644 --- a/plugins/modules/azure_rm_privatednszonelink_info.py +++ b/plugins/modules/azure_rm_privatednszonelink_info.py @@ -89,8 +89,7 @@ from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase try: - from msrestazure.azure_exceptions import CloudError - from azure.common import AzureMissingResourceHttpError, AzureHttpError + from azure.core.exceptions import ResourceNotFoundError except Exception: # This is handled in azure_rm_common pass @@ -151,7 +150,7 @@ def get_item(self): item = self.private_dns_client.virtual_network_links.get(self.resource_group, self.zone_name, self.name) - except CloudError: + except ResourceNotFoundError: pass # serialize result @@ -163,7 +162,7 @@ def list_items(self): self.log('List all virtual network links for private DNS zone - {0}'.format(self.zone_name)) try: response = self.private_dns_client.virtual_network_links.list(self.resource_group, self.zone_name) - except AzureHttpError as exc: + except Exception as exc: self.fail("Failed to list all items - {0}".format(str(exc))) results = [] diff --git a/requirements-azure.txt b/requirements-azure.txt index 9ba457502..93d92e05f 100644 --- a/requirements-azure.txt +++ b/requirements-azure.txt @@ -24,7 +24,7 @@ azure-mgmt-managedservices==1.0.0 azure-mgmt-managementgroups==0.2.0 azure-mgmt-network==19.1.0 azure-mgmt-nspkg==2.0.0 -azure-mgmt-privatedns==0.1.0 +azure-mgmt-privatedns==1.0.0 azure-mgmt-redis==13.0.0 azure-mgmt-resource==10.2.0 azure-mgmt-rdbms==1.9.0