From: Chris Boot <bootc@bootc.net>
Date: Wed, 17 Dec 2014 21:52:28 +0000
Subject: Add qla2xxx_wwn WWN type
Git-commit: 727c345bd18137c424e4fba62bfab7bcfabfc024

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 <bootc@bootc.net>
Acked-by: Lee Duncan <lduncan@suse.com>
---
 rtslib/config.py |    3 +++
 rtslib/utils.py  |    4 ++++
 2 files changed, 7 insertions(+)

--- a/rtslib/config.py
+++ b/rtslib/config.py
@@ -338,6 +338,9 @@ class Config(object):
         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
--- a/rtslib/utils.py
+++ b/rtslib/utils.py
@@ -562,6 +562,10 @@ def is_valid_wwn(wwn_type, wwn, wwn_list
             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
 
