From 2daaf4eedd694180281be33a3721be65bc0c2c7a Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Mon, 18 Feb 2019 13:54:41 +0800 Subject: [PATCH] fix non location error (#52312) --- lib/ansible/modules/cloud/azure/azure_rm_subnet.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_subnet.py b/lib/ansible/modules/cloud/azure/azure_rm_subnet.py index bbc7e1ce6c6..9a692002c2b 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_subnet.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_subnet.py @@ -184,7 +184,7 @@ def subnet_to_dict(subnet): result['route_table']['name'] = id_keys['routeTables'] result['route_table']['resource_group'] = id_keys['resourceGroups'] if subnet.service_endpoints: - result['service_endpoints'] = [{'service': item.service, 'locations': item.locations} for item in subnet.service_endpoints] + result['service_endpoints'] = [{'service': item.service, 'locations': item.locations or []} for item in subnet.service_endpoints] return result @@ -283,12 +283,14 @@ class AzureRMSubnet(AzureRMModuleBase): oldd = {} for item in self.service_endpoints: name = item['service'] - oldd[name] = {'service': name, 'locations': item['locations'].sort()} + locations = item.get('locations') or [] + oldd[name] = {'service': name, 'locations': locations.sort()} newd = {} if 'service_endpoints' in results: for item in results['service_endpoints']: name = item['service'] - newd[name] = {'service': name, 'locations': item['locations'].sort()} + locations = item.get('locations') or [] + newd[name] = {'service': name, 'locations': locations.sort()} if newd != oldd: changed = True results['service_endpoints'] = self.service_endpoints