From 727c345bd18137c424e4fba62bfab7bcfabfc024 Mon Sep 17 00:00:00 2001 From: Chris Boot Date: Wed, 17 Dec 2014 21:52:28 +0000 Subject: [PATCH] Add qla2xxx_wwn WWN type The qla2xxx_wwn type is used in policy/fabric_qla2xxx.lio but is not a valid type in rtslib.config.Config.validate_val(). This commit adds validation for this type in rtslib.config.Config.validate_val() and rtslib.utils.is_valid_wwn(). This allows a system with existing targets (created by an older targetcli/lio-utils) to be validated by rtslib and for the configuration to be saved. Signed-off-by: Chris Boot --- rtslib/config.py | 3 +++ rtslib/utils.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/rtslib/config.py b/rtslib/config.py index 0420f20..ae08f8a 100644 --- a/rtslib/config.py +++ b/rtslib/config.py @@ -347,6 +347,9 @@ def validate_val(self, value, val_type, parent=None): elif val_type == 'naa': if is_valid_wwn('naa', value): valid_value = value + elif val_type == 'qla2xxx_wwn': + if is_valid_wwn('qla2xxx_wwn', value): + valid_value = value elif val_type == 'backend': if is_valid_backend(value, parent): valid_value = value diff --git a/rtslib/utils.py b/rtslib/utils.py index 6974235..1a21b43 100644 --- a/rtslib/utils.py +++ b/rtslib/utils.py @@ -560,6 +560,10 @@ def is_valid_wwn(wwn_type, wwn, wwn_list=None): and re.match( "[0-9A-Fa-f]{8}(-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$", wwn): return True + elif wwn_type == 'qla2xxx_wwn' \ + and re.match( + "[0-9A-Fa-f]{2}(:[0-9A-Fa-f]{2}){7}$", wwn): + return True else: return False