Skip to content

Commit

Permalink
Upgrade azure-mgmt-privatedns to 1.0.0 (#880)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred-sun authored Jul 18, 2022
1 parent 9ad8a0c commit 1f47a0c
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 33 deletions.
3 changes: 2 additions & 1 deletion plugins/module_utils/azure_rm_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/azure_rm_privatednsrecordset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions plugins/modules/azure_rm_privatednsrecordset_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -195,7 +194,7 @@ def get_item(self):
self.zone_name,
self.record_type,
self.relative_name)
except CloudError:
except ResourceNotFoundError:
pass

results = [item]
Expand All @@ -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 = []
Expand All @@ -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 = []
Expand Down
10 changes: 5 additions & 5 deletions plugins/modules/azure_rm_privatednszone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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:
Expand Down
9 changes: 4 additions & 5 deletions plugins/modules/azure_rm_privatednszone_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)))

Expand All @@ -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 = []
Expand Down
20 changes: 10 additions & 10 deletions plugins/modules/azure_rm_privatednszonelink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
7 changes: 3 additions & 4 deletions plugins/modules/azure_rm_privatednszonelink_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion requirements-azure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f47a0c

Please sign in to comment.