Merge pull request #27147 from rallytime/fix-11669

Enforce bounds in the GCE Regex
This commit is contained in:
Mike Place 2015-09-15 15:51:55 -06:00
commit 097fcd1017

View file

@ -115,7 +115,7 @@ list_nodes = namespaced_function(list_nodes, globals())
list_nodes_full = namespaced_function(list_nodes_full, globals())
list_nodes_select = namespaced_function(list_nodes_select, globals())
GCE_VM_NAME_REGEX = re.compile(r'(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)')
GCE_VM_NAME_REGEX = re.compile(r'^(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)$')
# Only load in this module if the GCE configurations are in place
@ -2023,9 +2023,8 @@ def create(vm_=None, call=None):
if not GCE_VM_NAME_REGEX.match(vm_['name']):
raise SaltCloudSystemExit(
'The allowed VM names must match the following regular expression: {0}'.format(
GCE_VM_NAME_REGEX.pattern
)
'VM names must start with a letter, only contain letters, numbers, or dashes '
'and cannot end in a dash.'
)
conn = get_conn()