Allow ipv6 address for cinder nfs backend.
Closes-Bug: rhbz#1214922 Change-Id: I7c07bb2e24b2c01670598d8492e2ab97e3900114
This commit is contained in:
committed by
Lukas Bezdicka
parent
1d54be33de
commit
144c8d1504
@@ -31,7 +31,8 @@ __all__ = ('ParamValidationError', 'validate_integer', 'validate_float',
|
|||||||
'validate_options', 'validate_multi_options', 'validate_ip',
|
'validate_options', 'validate_multi_options', 'validate_ip',
|
||||||
'validate_multi_ip', 'validate_file', 'validate_ping',
|
'validate_multi_ip', 'validate_file', 'validate_ping',
|
||||||
'validate_multi_ping', 'validate_ssh', 'validate_multi_ssh',
|
'validate_multi_ping', 'validate_ssh', 'validate_multi_ssh',
|
||||||
'validate_sshkey', 'validate_ldap_url', 'validate_ldap_dn')
|
'validate_sshkey', 'validate_ldap_url', 'validate_ldap_dn',
|
||||||
|
'validate_export', 'validate_multi_export')
|
||||||
|
|
||||||
|
|
||||||
def validate_integer(param, options=None):
|
def validate_integer(param, options=None):
|
||||||
@@ -328,3 +329,39 @@ def validate_ldap_dn(param, options=None):
|
|||||||
msg = ('The given string [%s] is not a valid LDAP DN: %s' %
|
msg = ('The given string [%s] is not a valid LDAP DN: %s' %
|
||||||
(param, de))
|
(param, de))
|
||||||
raise ParamValidationError(msg)
|
raise ParamValidationError(msg)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_export(param, options=None):
|
||||||
|
"""
|
||||||
|
Raises ParamValidationError if the nfs export is not valid.
|
||||||
|
"""
|
||||||
|
msg = ('The nfs export [%s] is not a valid export - use squares around ipv6 addresses -.' %
|
||||||
|
param)
|
||||||
|
try:
|
||||||
|
[ip, export] = param.split(':/')
|
||||||
|
except ValueError:
|
||||||
|
raise ParamValidationError(msg)
|
||||||
|
get_squares = re.search(r'\[([^]]+)\]', ip)
|
||||||
|
ip_to_test = ip
|
||||||
|
if get_squares:
|
||||||
|
# this should be a valid ipv6 address.
|
||||||
|
ip_to_test = get_squares.group(1)
|
||||||
|
if not utils.network.is_ipv6(ip_to_test):
|
||||||
|
raise ParamValidationError(msg)
|
||||||
|
else:
|
||||||
|
# this should be an ipv4. Cannot have ipv6 without square braquet
|
||||||
|
# notation here, as the mount will fail.
|
||||||
|
if not utils.network.is_ipv4(ip):
|
||||||
|
raise ParamValidationError(msg)
|
||||||
|
validate_ip(ip_to_test, options)
|
||||||
|
if not export:
|
||||||
|
raise ParamValidationError(msg)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_multi_export(param, options=None):
|
||||||
|
"""
|
||||||
|
Raises ParamValidationError if comma separated nfs export given
|
||||||
|
in param is not valid
|
||||||
|
"""
|
||||||
|
for export in param.split(","):
|
||||||
|
validate_export(export)
|
||||||
|
|||||||
@@ -133,8 +133,8 @@ def initConfig(controller):
|
|||||||
{"CMD_OPTION": "cinder-nfs-mounts",
|
{"CMD_OPTION": "cinder-nfs-mounts",
|
||||||
"PROMPT": ("Enter a single or comma seprated list of NFS exports "
|
"PROMPT": ("Enter a single or comma seprated list of NFS exports "
|
||||||
"to use with Cinder"),
|
"to use with Cinder"),
|
||||||
"OPTION_LIST": ["^([\d]{1,3}\.){3}[\d]{1,3}:/.*"],
|
"OPTION_LIST": [""],
|
||||||
"VALIDATORS": [validators.validate_multi_regexp],
|
"VALIDATORS": [validators.validate_multi_export],
|
||||||
"PROCESSORS": [],
|
"PROCESSORS": [],
|
||||||
"DEFAULT_VALUE": "",
|
"DEFAULT_VALUE": "",
|
||||||
"MASK_INPUT": False,
|
"MASK_INPUT": False,
|
||||||
|
|||||||
Reference in New Issue
Block a user