Skip to content

Commit

Permalink
Upgrade azure-mgmt-trafficmanager to 1.0.0 (#886)
Browse files Browse the repository at this point in the history
* upgrade azure-mgmt-trafficmanager to 1.0.0

* change version to 1.0.0b1
  • Loading branch information
Fred-sun authored Jul 19, 2022
1 parent dfe66e1 commit d3f5935
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 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 @@ -363,7 +363,7 @@ def normalize_location_name(name):
},
'TrafficManagerManagementClient': {
'package_name': 'trafficmanager',
'expected_version': '0.50.0'
'expected_version': '1.0.0'
},
'EventHubManagementClient': {
'package_name': 'azure-mgmt-eventhub',
Expand Down Expand Up @@ -1236,6 +1236,7 @@ def traffic_manager_management_client(self):
self.log('Getting traffic manager client')
if not self._traffic_manager_management_client:
self._traffic_manager_management_client = self.get_mgmt_svc_client(TrafficManagerManagementClient,
is_track2=True,
base_url=self._cloud_environment.endpoints.resource_manager)
return self._traffic_manager_management_client

Expand Down
8 changes: 4 additions & 4 deletions plugins/modules/azure_rm_trafficmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase

try:
from msrestazure.azure_exceptions import CloudError
from azure.core.exceptions import ResourceNotFoundError
from azure.mgmt.trafficmanager.models import (
Profile, Endpoint, DnsConfig, MonitorConfig
)
Expand Down Expand Up @@ -488,7 +488,7 @@ def get_traffic_manager_profile(self):
self.log("Response : {0}".format(response))
self.log("Traffic Manager profile : {0} found".format(response.name))
return traffic_manager_profile_to_dict(response)
except CloudError:
except ResourceNotFoundError:
self.log('Did not find the Traffic Manager profile.')
return False

Expand All @@ -502,7 +502,7 @@ def delete_traffic_manager_profile(self):
try:
operation_result = self.traffic_manager_management_client.profiles.delete(self.resource_group, self.name)
return True
except CloudError as e:
except Exception as e:
self.log('Error attempting to delete the Traffic Manager profile.')
self.fail("Error deleting the Traffic Manager profile: {0}".format(e.message))
return False
Expand All @@ -527,7 +527,7 @@ def ceate_update_traffic_manager_profile(self):
try:
response = self.traffic_manager_management_client.profiles.create_or_update(self.resource_group, self.name, parameters)
return traffic_manager_profile_to_dict(response)
except CloudError as exc:
except Exception as exc:
self.log('Error attempting to create the Traffic Manager.')
self.fail("Error creating the Traffic Manager: {0}".format(exc.message))

Expand Down
8 changes: 4 additions & 4 deletions plugins/modules/azure_rm_trafficmanagerendpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
from ansible.module_utils.common.dict_transformations import _snake_to_camel

try:
from msrestazure.azure_exceptions import CloudError
from azure.core.exceptions import ResourceNotFoundError
from azure.mgmt.trafficmanager.models import (
Endpoint, DnsConfig, MonitorConfig
)
Expand Down Expand Up @@ -279,7 +279,7 @@ def get_traffic_manager_endpoint(self):
response = self.traffic_manager_management_client.endpoints.get(self.resource_group, self.profile_name, self.type, self.name)
self.log("Response : {0}".format(response))
return traffic_manager_endpoint_to_dict(response)
except CloudError:
except ResourceNotFoundError:
self.log('Did not find the Traffic Manager endpoint.')
return False

Expand All @@ -293,7 +293,7 @@ def delete_traffic_manager_endpoint(self):
try:
operation_result = self.traffic_manager_management_client.endpoints.delete(self.resource_group, self.profile_name, self.type, self.name)
return True
except CloudError as exc:
except Exception as exc:
request_id = exc.request_id if exc.request_id else ''
self.fail("Error deleting the Traffic Manager endpoint {0}, request id {1} - {2}".format(self.name, request_id, str(exc)))
return False
Expand Down Expand Up @@ -322,7 +322,7 @@ def create_update_traffic_manager_endpoint(self):
self.name,
parameters)
return traffic_manager_endpoint_to_dict(response)
except CloudError as exc:
except Exception as exc:
request_id = exc.request_id if exc.request_id else ''
self.fail("Error creating the Traffic Manager endpoint {0}, request id {1} - {2}".format(self.name, request_id, str(exc)))

Expand Down
9 changes: 4 additions & 5 deletions plugins/modules/azure_rm_trafficmanagerendpoint_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@
)

try:
from msrestazure.azure_exceptions import CloudError
from azure.common import AzureHttpError
from azure.core.exceptions import ResourceNotFoundError
except Exception:
# handled in azure_rm_common
pass
Expand Down Expand Up @@ -255,7 +254,7 @@ def get_item(self):
try:
item = self.traffic_manager_management_client.endpoints.get(
self.resource_group, self.profile_name, self.type, self.name)
except CloudError:
except ResourceNotFoundError:
pass

if item:
Expand All @@ -271,7 +270,7 @@ def list_by_profile(self):

try:
response = self.traffic_manager_management_client.profiles.get(self.resource_group, self.profile_name)
except AzureHttpError as exc:
except Exception as exc:
self.fail('Failed to list all items - {0}'.format(str(exc)))

results = []
Expand All @@ -286,7 +285,7 @@ def list_by_type(self):
self.log('List all Traffic Manager endpoints of a profile by type')
try:
response = self.traffic_manager_management_client.profiles.get(self.resource_group, self.profile_name)
except AzureHttpError as exc:
except Exception as exc:
self.fail('Failed to list all items - {0}'.format(str(exc)))

results = []
Expand Down
8 changes: 4 additions & 4 deletions plugins/modules/azure_rm_trafficmanagerprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase, normalize_location_name

try:
from msrestazure.azure_exceptions import CloudError
from azure.core.exceptions import ResourceNotFoundError
from azure.mgmt.trafficmanager.models import (
Profile, Endpoint, DnsConfig, MonitorConfig
)
Expand Down Expand Up @@ -382,7 +382,7 @@ def get_traffic_manager_profile(self):
self.log("Traffic Manager profile : {0} found".format(response.name))
self.endpoints_copy = response.endpoints if response and response.endpoints else None
return traffic_manager_profile_to_dict(response)
except CloudError:
except ResourceNotFoundError:
self.log('Did not find the Traffic Manager profile.')
return False

Expand All @@ -396,7 +396,7 @@ def delete_traffic_manager_profile(self):
try:
operation_result = self.traffic_manager_management_client.profiles.delete(self.resource_group, self.name)
return True
except CloudError as e:
except Exception as e:
self.log('Error attempting to delete the Traffic Manager profile.')
self.fail("Error deleting the Traffic Manager profile: {0}".format(e.message))
return False
Expand All @@ -421,7 +421,7 @@ def create_update_traffic_manager_profile(self):
try:
response = self.traffic_manager_management_client.profiles.create_or_update(self.resource_group, self.name, parameters)
return traffic_manager_profile_to_dict(response)
except CloudError as exc:
except Exception as exc:
self.log('Error attempting to create the Traffic Manager.')
self.fail("Error creating the Traffic Manager: {0}".format(exc.message))

Expand Down
7 changes: 3 additions & 4 deletions plugins/modules/azure_rm_trafficmanagerprofile_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@
from ansible.module_utils.common.dict_transformations import _camel_to_snake

try:
from msrestazure.azure_exceptions import CloudError
from azure.common import AzureHttpError
from azure.core.exceptions import ResourceNotFoundError
except Exception:
# handled in azure_rm_common
pass
Expand Down Expand Up @@ -337,7 +336,7 @@ def get_item(self):
try:
item = self.traffic_manager_management_client.profiles.get(
self.resource_group, self.name)
except CloudError:
except ResourceNotFoundError:
pass

if item and self.has_tags(item.tags, self.tags):
Expand All @@ -353,7 +352,7 @@ def list_resource_group(self):
try:
response = self.traffic_manager_management_client.profiles.list_by_resource_group(
self.resource_group)
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 @@ -32,7 +32,7 @@ azure-mgmt-search==8.0.0
azure-mgmt-servicebus==0.5.3
azure-mgmt-sql==3.0.1
azure-mgmt-storage==19.0.0
azure-mgmt-trafficmanager==0.50.0
azure-mgmt-trafficmanager==1.0.0b1
azure-mgmt-web==6.1.0
azure-nspkg==2.0.0
azure-storage-blob==12.11.0
Expand Down

0 comments on commit d3f5935

Please sign in to comment.