From a8059c68d02b8410d1882725eaae69b9d4c7f0bd Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Wed, 6 Jul 2016 17:29:42 -0400 Subject: [PATCH] Remove object name validation. --- .../modules/cloud/azure/azure_rm_networkinterface.py | 6 ------ .../modules/cloud/azure/azure_rm_publicipaddress.py | 6 ------ lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py | 7 ------- .../modules/cloud/azure/azure_rm_storageaccount.py | 5 ----- lib/ansible/modules/cloud/azure/azure_rm_storageblob.py | 8 -------- lib/ansible/modules/cloud/azure/azure_rm_subnet.py | 6 ------ .../modules/cloud/azure/azure_rm_virtualnetwork.py | 6 ------ 7 files changed, 44 deletions(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py index 2701881e10..742306ddb9 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py @@ -234,8 +234,6 @@ except ImportError: pass -NAME_PATTERN = re.compile(r"^[a-z][a-z0-9-]{1,61}[a-z0-9]$") - def nic_to_dict(nic): result = dict( @@ -349,10 +347,6 @@ class AzureRMNetworkInterface(AzureRMModuleBase): # Set default location self.location = resource_group.location - if not NAME_PATTERN.match(self.name): - self.fail("Parameter error: name must begin with a letter or number, end with a letter or number " - "and contain at least one number.") - if self.state == 'present': if self.virtual_network_name and not self.subnet_name: self.fail("Parameter error: a subnet is required when passing a virtual_network_name.") diff --git a/lib/ansible/modules/cloud/azure/azure_rm_publicipaddress.py b/lib/ansible/modules/cloud/azure/azure_rm_publicipaddress.py index 39a671f2d4..ae50054ff3 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_publicipaddress.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_publicipaddress.py @@ -125,8 +125,6 @@ except ImportError: # This is handled in azure_rm_common pass -NAME_PATTERN = re.compile(r"^[a-z][a-z0-9-]{1,61}[a-z0-9]$") - def pip_to_dict(pip): result = dict( @@ -191,10 +189,6 @@ class AzureRMPublicIPAddress(AzureRMModuleBase): # Set default location self.location = resource_group.location - if not NAME_PATTERN.match(self.name): - self.fail("Parameter error: name must begin with a letter or number, end with a letter or number " - "and contain at least one number.") - try: self.log("Fetch public ip {0}".format(self.name)) pip = self.network_client.public_ip_addresses.get(self.resource_group, self.name) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py b/lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py index 1491032806..db24bacd40 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py @@ -338,8 +338,6 @@ except ImportError: # This is handled in azure_rm_common pass -NAME_PATTERN = re.compile(r"^[a-zA-Z0-9._-]+$") - def validate_rule(rule, rule_type=None): ''' @@ -352,8 +350,6 @@ def validate_rule(rule, rule_type=None): if not rule.get('name'): raise Exception("Rule name value is required.") - if not NAME_PATTERN.match(rule.get('name')): - raise Exception("Rule name must contain only word characters plus '.','-','_'") priority = rule.get('priority', None) if not priority: @@ -551,9 +547,6 @@ class AzureRMSecurityGroup(AzureRMModuleBase): # Set default location self.location = resource_group.location - if not NAME_PATTERN.match(self.name): - self.fail("Parameter error: name must contain only word characters and '.','-','_'") - if self.rules: for rule in self.rules: try: diff --git a/lib/ansible/modules/cloud/azure/azure_rm_storageaccount.py b/lib/ansible/modules/cloud/azure/azure_rm_storageaccount.py index 7f17a8b44f..5fee11dd7d 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_storageaccount.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_storageaccount.py @@ -160,8 +160,6 @@ except ImportError: pass -NAME_PATTERN = re.compile(r"^[a-z0-9]+$") - class AzureRMStorageAccount(AzureRMModuleBase): @@ -211,9 +209,6 @@ class AzureRMStorageAccount(AzureRMModuleBase): # Set default location self.location = resource_group.location - if not NAME_PATTERN.match(self.name): - self.fail("Parameter error: name must contain numbers and lowercase letters only.") - if len(self.name) < 3 or len(self.name) > 24: self.fail("Parameter error: name length must be between 3 and 24 characters.") diff --git a/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py b/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py index 2479de71f7..3e5bd85ee6 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py @@ -210,9 +210,6 @@ except ImportError: pass -NAME_PATTERN = re.compile(r"^(?!-)(?!.*--)[a-z0-9\-]+$") - - class AzureRMStorageBlob(AzureRMModuleBase): def __init__(self): @@ -270,11 +267,6 @@ class AzureRMStorageBlob(AzureRMModuleBase): self.results['check_mode'] = self.check_mode - if not NAME_PATTERN.match(self.container): - self.fail("Parameter error: container_name must consist of lowercase letters, " - "numbers and hyphens. It must begin with a letter or number. It may " - "not contain two consecutive hyphens.") - # add file path validation self.blob_client = self.get_blob_client(self.resource_group, self.storage_account_name) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_subnet.py b/lib/ansible/modules/cloud/azure/azure_rm_subnet.py index 75738962f2..d11c35f2e5 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_subnet.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_subnet.py @@ -139,8 +139,6 @@ except ImportError: pass -NAME_PATTERN = re.compile(r"^[a-zA-Z0-9][a-zA-Z0-9.-_]+[a-zA-Z0-9_]$") - def subnet_to_dict(subnet): result = dict( @@ -198,10 +196,6 @@ class AzureRMSubnet(AzureRMModuleBase): for key in self.module_arg_spec: setattr(self, key, kwargs[key]) - if not NAME_PATTERN.match(self.name): - self.fail("Parameter error: name must begin with a letter or number, end with a letter, number " - "or underscore and may contain only letters, numbers, periods, underscores or hyphens.") - if self.state == 'present' and not CIDR_PATTERN.match(self.address_prefix_cidr): self.fail("Invalid address_prefix_cidr value {0}".format(self.address_prefix_cidr)) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py index d7bbdd00d8..417e999b63 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py @@ -145,8 +145,6 @@ except ImportError: pass -NAME_PATTERN = re.compile(r"^[a-zA-Z0-9]+[a-zA-Z0-9\._-]+[a-zA-Z0-9_]+$") - def virtual_network_to_dict(vnet): ''' @@ -228,10 +226,6 @@ class AzureRMVirtualNetwork(AzureRMModuleBase): # Set default location self.location = resource_group.location - if not NAME_PATTERN.match(self.name): - self.fail("Parameter error: name must begin with a letter or number, end with a letter, number " - "or underscore and may contain only letters, numbers, periods, underscores or hyphens.") - if self.state == 'present' and self.purge_address_prefixes: for prefix in self.address_prefixes_cidr: if not CIDR_PATTERN.match(prefix):