From 1dabb4aa3d7b305e664808beed41d04b8e925b3b Mon Sep 17 00:00:00 2001 From: Cedric Zhuang Date: Tue, 17 Jan 2017 17:23:30 +0800 Subject: [PATCH] [GH-84] Error parsing VNX storage group output. When the HBA uid is too long, the table format of storage group output is messed up. There is no space between each column. Luckly, the format for storage processor is fixed. We could use it as the token. Modify the regular expression to parse the HBA and verify the parsing of storage group with the messed output. Bump version to 0.4.4. --- README.rst | 2 +- storops/vnx/parser_configs.yaml | 2 +- test/vnx/resource/test_sg.py | 12 ++++++ ...es_-gname_wcmsc2-l-rh-cmp-2.hqplan.lab.txt | 41 +++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 test/vnx/testdata/block_output/storagegroup_-messner_-list_-host_-iscsiAttributes_-gname_wcmsc2-l-rh-cmp-2.hqplan.lab.txt diff --git a/README.rst b/README.rst index 103e1331..8b0d239d 100644 --- a/README.rst +++ b/README.rst @@ -13,7 +13,7 @@ StorOps: The Python Library for VNX & Unity .. image:: https://landscape.io/github/emc-openstack/storops/master/landscape.svg?style=flat :target: https://landscape.io/github/emc-openstack/storops/ -VERSION: 0.4.3 +VERSION: 0.4.4 A minimalist Python library to manage VNX/Unity systems. This document lies in the source code and go with the release. diff --git a/storops/vnx/parser_configs.yaml b/storops/vnx/parser_configs.yaml index 0582e253..6b7b3d44 100644 --- a/storops/vnx/parser_configs.yaml +++ b/storops/vnx/parser_configs.yaml @@ -461,7 +461,7 @@ VNXStorageGroupHBA: data_src: cli properties: - label: | - ^\s*(\S+)\s+(SP \w)\s+(\d+)\s*$ + ^\s*(\S+)\s*(SP \w)\s*(\d+)\s*$ is_index: True is_regex: True key: hba diff --git a/test/vnx/resource/test_sg.py b/test/vnx/resource/test_sg.py index 90cc7265..d327ae61 100644 --- a/test/vnx/resource/test_sg.py +++ b/test/vnx/resource/test_sg.py @@ -108,6 +108,18 @@ def test_properties(self): assert_that(sg.has_hlu(11), equal_to(False)) assert_that(sg.existed, equal_to(True)) + @patch_cli + def test_missing_tab(self): + name = 'wcmsc2-l-rh-cmp-2.hqplan.lab' + sg = VNXStorageGroup(name=name, cli=t_cli()) + assert_that(len(sg.alu_hlu_map), equal_to(1)) + assert_that(len(sg.hba_sp_pairs), equal_to(4)) + uid = 'iqn.1994-05.com.abcdef:ghijk2-l-mn-opq-2.rstuvw.xyz:c3bf2f4cca' + port = list(filter(lambda i: i[0] == uid, sg.hba_port_list))[0][1] + assert_that(port.sp, equal_to(VNXSPEnum.SP_A)) + assert_that(port.port_id, equal_to(1)) + assert_that(port.host_initiator_list, has_item(uid)) + @patch_cli def test_property_hosts(self): hosts = get_sg('~management').hosts diff --git a/test/vnx/testdata/block_output/storagegroup_-messner_-list_-host_-iscsiAttributes_-gname_wcmsc2-l-rh-cmp-2.hqplan.lab.txt b/test/vnx/testdata/block_output/storagegroup_-messner_-list_-host_-iscsiAttributes_-gname_wcmsc2-l-rh-cmp-2.hqplan.lab.txt new file mode 100644 index 00000000..78e4a021 --- /dev/null +++ b/test/vnx/testdata/block_output/storagegroup_-messner_-list_-host_-iscsiAttributes_-gname_wcmsc2-l-rh-cmp-2.hqplan.lab.txt @@ -0,0 +1,41 @@ +Storage Group Name: wcmsc2-l-rh-cmp-2.hqplan.lab +Storage Group UID: BB:CD:9D:89:12:D9:E6:11:8D:24:82:E6:BF:48:3A:C7 +HBA/SP Pairs: + + HBA UID SP Name SPPort + ------- ------- ------ยท + iqn.1994-05.com.abcdef:ghijk2-l-mn-opq-2.rstuvw.xyz:c3bf2f4ccaSP A1 +Host name: wcmsc2-l-rh-cmp-2.hqplan.lab +SPPort: A-1v0 +Initiator IP: N/A +TPGT: 6 +ISID: N/A + + iqn.1994-05.com.abcdef:ghijk2-l-mn-opq-2.rstuvw.xyz:c3bf2f4ccbSP B1 +Host name: wcmsc2-l-rh-cmp-2.hqplan.lab +SPPort: B-1v0 +Initiator IP: N/A +TPGT: 10 +ISID: N/A + + iqn.1994-05.com.abcdef:ghijk2-l-mn-opq-2.rstuvw.xyz:c3bf2f4ccbSP A3 +Host name: wcmsc2-l-rh-cmp-2.hqplan.lab +SPPort: A-3v0 +Initiator IP: N/A +TPGT: 8 +ISID: N/A + + iqn.1994-05.com.abcdef:ghijk2-l-mn-opq-2.rstuvw.xyz:c3bf2f4ccbSP B3 +Host name: wcmsc2-l-rh-cmp-2.hqplan.lab +SPPort: B-3v0 +Initiator IP: N/A +TPGT: 12 +ISID: N/A + + +HLU/ALU Pairs: + + HLU Number ALU Number + ---------- ---------- + 196 24 +Shareable: YES \ No newline at end of file