diff --git a/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py b/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py index 53c4c588e17..70f159be796 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py +++ b/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py @@ -47,6 +47,7 @@ qlps = {} ifas = {} parsed_raw_zoneinfo = "" random_no = '' +auth_version = '' session = None active_cfg = 'openstack_cfg' activate = True @@ -62,15 +63,14 @@ nameserver_info = """
---BEGIN NS INFO
-
-2;8;020800;N    ;10:00:00:05:1e:7c:64:96;20:00:00:05:1e:7c:64:96;[89]""" \
-"""Brocade-825 | 3.0.4.09 | DCM-X3650-94 | Microsoft Windows Server 2003 R2"""\
-    """| Service Pack 2";FCP ;      3;20:08:00:05:1e:89:54:a0;"""\
-    """0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0;000000;port8"""\
-    """
---END NS INFO
-
+--BEGIN DEVICEPORT 10:00:00:05:1e:7c:64:96
+node.wwn=20:00:00:05:1e:7c:64:96
+deviceport.portnum=9
+deviceport.portid=300900
+deviceport.portIndex=9
+deviceport.porttype=N
+deviceport.portwwn=10:00:00:05:1e:7c:64:96
+--END DEVICEPORT 10:00:00:05:1e:7c:64:96
 
@@ -472,6 +472,7 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase): self.ifas = {} self.parsed_raw_zoneinfo = "" self.random_no = '' + self.auth_version = '' self.session = None super(TestBrcdHttpFCZoneClient, self).setUp() diff --git a/cinder/zonemanager/drivers/brocade/brcd_http_fc_zone_client.py b/cinder/zonemanager/drivers/brocade/brcd_http_fc_zone_client.py index ca5cd33d85e..5d6d1d20cdf 100644 --- a/cinder/zonemanager/drivers/brocade/brcd_http_fc_zone_client.py +++ b/cinder/zonemanager/drivers/brocade/brcd_http_fc_zone_client.py @@ -63,6 +63,7 @@ class BrcdHTTPFCZoneClient(object): self.active_cfg = '' self.parsed_raw_zoneinfo = "" self.random_no = '' + self.auth_version = '' self.session = None # Create and assign the authentication header based on the credentials @@ -99,7 +100,7 @@ class BrcdHTTPFCZoneClient(object): adapter = requests.adapters.HTTPAdapter(pool_connections=1, pool_maxsize=1) self.session.mount(protocol + '://', adapter) - url = protocol + "://" + self.switch_ip + requestURL + url = '%s://%s%s' % (protocol, self.switch_ip, requestURL) response = None if requestType == zone_constant.GET_METHOD: response = self.session.get(url, @@ -155,12 +156,19 @@ class BrcdHTTPFCZoneClient(object): zone_constant.SECINFO_BEGIN, zone_constant.SECINFO_END) - # Extract the random no from secinfo.html response - self.random_no = self.get_nvp_value(parsed_data, - zone_constant.RANDOM) - # Form the authentication string - auth_string = (self.switch_user + ":" + self.switch_pwd + - ":" + self.random_no) + # Get the auth version for 8.1.0b+ switches + self.auth_version = self.get_nvp_value(parsed_data, + zone_constant.AUTHVERSION) + + if self.auth_version == "1": + # Extract the random no from secinfo.html response + self.random_no = self.get_nvp_value(parsed_data, + zone_constant.RANDOM) + # Form the authentication string + auth_string = '%s:%s:%s' % (self.switch_user, self.switch_pwd, + self.random_no) + else: + auth_string = '%s:%s' % (self.switch_user, self.switch_pwd) auth_token = base64.encode_as_text(auth_string).strip() auth_header = (zone_constant.AUTH_STRING + auth_token) # Build the proper header @@ -192,9 +200,14 @@ class BrcdHTTPFCZoneClient(object): isauthenticated = self.get_nvp_value( parsed_data, zone_constant.AUTHENTICATED) if isauthenticated == "yes": - # Replace password in the authentication string with xxx - auth_string = (self.switch_user + - ":" + "xxx" + ":" + self.random_no) + if self.auth_version == "3": + auth_id = self.get_nvp_value(parsed_data, + zone_constant.IDENTIFIER) + auth_string = '%s:xxx:%s' % (self.switch_user, auth_id) + else: + # Replace password in the authentication string with xxx + auth_string = '%s:xxx:%s' % (self.switch_user, + self.random_no) auth_token = base64.encode_as_text(auth_string).strip() auth_header = zone_constant.AUTH_STRING + auth_token return True, auth_header @@ -764,15 +777,9 @@ class BrcdHTTPFCZoneClient(object): response = self.connect(zone_constant.GET_METHOD, zone_constant.NS_PAGE, header=headers) # GET request to nsinfo.html - parsed_raw_zoneinfo = self.get_parsed_data( - response, - zone_constant.NSINFO_BEGIN, - zone_constant.NSINFO_END).strip("\t\n\r") - # build the name server information in the correct format - for line in parsed_raw_zoneinfo.splitlines(): - start_index = line.find(zone_constant.NS_DELIM) + 7 - if start_index != -1: - nsinfo.extend([line[start_index:start_index + 23].strip()]) + for line in response.splitlines(): + if line.startswith(zone_constant.NS_DELIM): + nsinfo.append(line.split('=')[-1]) return nsinfo def delete_zones_cfgs( diff --git a/cinder/zonemanager/drivers/brocade/fc_zone_constants.py b/cinder/zonemanager/drivers/brocade/fc_zone_constants.py index 1c781a39233..14759baa8b3 100644 --- a/cinder/zonemanager/drivers/brocade/fc_zone_constants.py +++ b/cinder/zonemanager/drivers/brocade/fc_zone_constants.py @@ -58,6 +58,8 @@ POST_METHOD = "POST" SECINFO_BEGIN = "--BEGIN SECINFO" SECINFO_END = "--END SECINFO" RANDOM = "RANDOM" +AUTHVERSION = "AUTHVERSION" +IDENTIFIER = "Identifier" AUTH_STRING = "Custom_Basic " # Trailing space is required, do not remove AUTHEN_BEGIN = "--BEGIN AUTHENTICATE" AUTHEN_END = "--END AUTHENTICATE" @@ -86,10 +88,8 @@ ZONE_END_DELIM = "\x05&saveonly=" IFA_DELIM = "\x06" ACTIVE_CFG_DELIM = "\x07" DEFAULT_CFG = "d__efault__Cfg" -NS_PAGE = "/nsinfo.htm" -NSINFO_BEGIN = "--BEGIN NS INFO" -NSINFO_END = "--END NS INFO" -NS_DELIM = ";N ;" +NS_PAGE = "/nsinfo.htm?format=1&type=all" +NS_DELIM = "deviceport.portwwn=" ZONE_TX_BEGIN = "--BEGIN ZONE_TXN_INFO" ZONE_TX_END = "--END ZONE_TXN_INFO" ZONE_ERROR_CODE = "errorCode"