location name (#40055)

This commit is contained in:
Yuwei Zhou 2018-05-14 11:46:45 +08:00 committed by Zim Kalinowski
parent 57f6abdb84
commit c84e3e70ab
2 changed files with 7 additions and 2 deletions

View file

@ -176,6 +176,11 @@ def format_resource_id(val, subscription_id, namespace, types, resource_group):
type=types, type=types,
subscription=subscription_id) if not is_valid_resource_id(val) else val subscription=subscription_id) if not is_valid_resource_id(val) else val
def normalize_location_name(name):
return name.replace(' ', '').lower()
# FUTURE: either get this from the requirements file (if we can be sure it's always available at runtime) # FUTURE: either get this from the requirements file (if we can be sure it's always available at runtime)
# or generate the requirements files from this so we only have one source of truth to maintain... # or generate the requirements files from this so we only have one source of truth to maintain...
AZURE_PKG_VERSIONS = { AZURE_PKG_VERSIONS = {

View file

@ -96,7 +96,7 @@ try:
except ImportError: except ImportError:
pass pass
from ansible.module_utils.azure_rm_common import AzureRMModuleBase from ansible.module_utils.azure_rm_common import AzureRMModuleBase, normalize_location_name
def resource_group_to_dict(rg): def resource_group_to_dict(rg):
@ -162,7 +162,7 @@ class AzureRMResourceGroup(AzureRMModuleBase):
if update_tags: if update_tags:
changed = True changed = True
if self.location and self.location != results['location']: if self.location and normalize_location_name(self.location) != results['location']:
self.fail("Resource group '{0}' already exists in location '{1}' and cannot be " self.fail("Resource group '{0}' already exists in location '{1}' and cannot be "
"moved.".format(self.name, results['location'])) "moved.".format(self.name, results['location']))
except CloudError: except CloudError: