mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
versionadded and more efficient checks
This commit is contained in:
parent
a3ac8e7008
commit
bc21094ea0
1 changed files with 5 additions and 3 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue