Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update azure_rm_appgateway_info to use track2 dependencies #817

Merged
merged 3 commits into from
Apr 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions plugins/modules/azure_rm_appgateway_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,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.network import NetworkManagementClient
from msrestazure.tools import parse_resource_id
except ImportError:
Expand All @@ -117,7 +117,6 @@ def __init__(self):

self.name = None
self.resource_group = None
self.mgmt_client = None

super(AzureRMApplicationGatewayInfo, self).__init__(self.module_arg_spec,
supports_check_mode=True,
Expand All @@ -128,9 +127,6 @@ def exec_module(self, **kwargs):
for key in self.module_arg_spec:
setattr(self, key, kwargs[key])

self.mgmt_client = self.get_mgmt_svc_client(NetworkManagementClient,
base_url=self._cloud_environment.endpoints.resource_manager)

if self.name is not None:
self.results["gateways"] = self.get()
elif self.resource_group is not None:
Expand All @@ -144,8 +140,8 @@ def get(self):
response = None
results = []
try:
response = self.mgmt_client.application_gateways.get(resource_group_name=self.resource_group, application_gateway_name=self.name)
except CloudError:
response = self.network_client.application_gateways.get(resource_group_name=self.resource_group, application_gateway_name=self.name)
except ResourceNotFoundError:
pass

if response is not None:
Expand All @@ -157,8 +153,8 @@ def list_by_rg(self):
response = None
results = []
try:
response = self.mgmt_client.application_gateways.list(resource_group_name=self.resource_group)
except CloudError as exc:
response = self.network_client.application_gateways.list(resource_group_name=self.resource_group)
except Exception as exc:
request_id = exc.request_id if exc.request_id else ''
self.fail("Error listing application gateways in resource groups {0}: {1} - {2}".format(self.resource_group, request_id, str(exc)))

Expand All @@ -171,8 +167,8 @@ def list_all(self):
response = None
results = []
try:
response = self.mgmt_client.application_gateways.list_all()
except CloudError as exc:
response = self.network_client.application_gateways.list_all()
except Exception as exc:
request_id = exc.request_id if exc.request_id else ''
self.fail("Error listing all application gateways: {0} - {1}".format(request_id, str(exc)))

Expand Down