versionadded and more efficient checks

This commit is contained in:
rallytime 2015-08-27 11:50:13 -06:00
parent a3ac8e7008
commit bc21094ea0

View file

@ -1028,18 +1028,20 @@ def _validate_name(name):
'''
Checks if the provided name fits Linode's labeling parameters.
.. versionadded:: 2015.5.6
name
The VM name to validate
'''
ret = True
name_length = len(name)
regex = re.compile(r'^[a-zA-Z0-9][A-Za-z0-9_-]*[a-zA-Z0-9]$')
if name_length < 3 or name_length > 48:
ret = False
if not re.match(regex, name):
elif not re.match(regex, name):
ret = False
else:
ret = True
if ret is False:
log.warning(