From bc97d6a13da5d6081c4b34f21b3e71c40ac5f6b2 Mon Sep 17 00:00:00 2001 From: xintli <986222045@qq.com> Date: Thu, 7 Apr 2022 14:05:06 +0800 Subject: [PATCH] New parser Ql2xmqSupport (#3374) Signed-off-by: Xinting Li Co-authored-by: Xinting Li (cherry picked from commit c9793667fa118fad0092cb5c074ff5faf0ffa836) --- insights/parsers/sys_module.py | 20 +++++++++++++++++++ insights/parsers/tests/test_sys_module.py | 24 ++++++++++++++++++++++- insights/specs/__init__.py | 1 + insights/specs/default.py | 1 + 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/insights/parsers/sys_module.py b/insights/parsers/sys_module.py index 7cb41b5ef3..757f22bc40 100755 --- a/insights/parsers/sys_module.py +++ b/insights/parsers/sys_module.py @@ -18,6 +18,8 @@ --------------------------------------------------------------------- VHostNetZeroCopyTx - file ``/sys/module/vhost_net/parameters/experimental_zcopytx`` ----------------------------------------------------------------------------------- +Ql2xMaxLUN - file ``/sys/module/qla2xxx/parameters/ql2xmqsupport`` +------------------------------------------------------------------ """ from insights import parser, Parser from insights.parsers import SkipException @@ -173,3 +175,21 @@ class SCSIModMaxReportLUNs(MaxLUNs): 512 """ pass + + +@parser(Specs.ql2xmqsupport) +class Ql2xmqSupport(XModUseBlkMq): + """ + This file `/sys/module/qla2xxx/parameters/ql2xmqsupport` shows if ql2xmqsupport + parameter is on. + + Examples:: + + >>> type(qla2xxx_ql2xmqsupport) + + >>> qla2xxx_ql2xmqsupport.val + '1' + >>> qla2xxx_ql2xmqsupport.is_on + True + """ + pass diff --git a/insights/parsers/tests/test_sys_module.py b/insights/parsers/tests/test_sys_module.py index b0e9043b0b..4ccaf22892 100644 --- a/insights/parsers/tests/test_sys_module.py +++ b/insights/parsers/tests/test_sys_module.py @@ -1,7 +1,7 @@ import doctest import pytest from insights.parsers import sys_module, SkipException -from insights.parsers.sys_module import DMModUseBlkMq, SCSIModUseBlkMq, VHostNetZeroCopyTx, MaxLUNs, LpfcMaxLUNs, Ql2xMaxLUN, SCSIModMaxReportLUNs +from insights.parsers.sys_module import DMModUseBlkMq, SCSIModUseBlkMq, VHostNetZeroCopyTx, MaxLUNs, LpfcMaxLUNs, Ql2xMaxLUN, SCSIModMaxReportLUNs, Ql2xmqSupport from insights.tests import context_wrap @@ -11,6 +11,10 @@ SCSI_DM_MOD_USE_BLK_MQ_N = """ N """.strip() +QLA2XXX_QL2XMQSUPPORT = """ +1 +""".strip() + SCSI_DM_MOD_USE_BLK_MQ_UNKNOW_CASE = """ unknow_case """.strip() @@ -37,6 +41,7 @@ def test_doc_examples(): 'lpfc_max_luns': LpfcMaxLUNs(context_wrap(MAX_LUNS)), 'ql2xmaxlun': Ql2xMaxLUN(context_wrap(MAX_LUNS)), 'scsi_mod_max_report_luns': SCSIModMaxReportLUNs(context_wrap(MAX_LUNS)), + 'qla2xxx_ql2xmqsupport': Ql2xmqSupport(context_wrap(QLA2XXX_QL2XMQSUPPORT)) } failed, total = doctest.testmod(sys_module, globs=env) assert failed == 0 @@ -62,6 +67,14 @@ def test_XModUseBlkMq(): assert zero_copy_1.is_on is True assert zero_copy_1.val == '1' + ql2xmqsuppor_copy_0 = Ql2xmqSupport(context_wrap(ZERO_COPY)) + assert ql2xmqsuppor_copy_0.is_on is False + assert ql2xmqsuppor_copy_0.val == '0' + + ql2xmqsuppor_copy_1 = Ql2xmqSupport(context_wrap(QLA2XXX_QL2XMQSUPPORT)) + assert ql2xmqsuppor_copy_1.is_on is True + assert ql2xmqsuppor_copy_1.val == '1' + def test_MaxLUNs(): max_luns = MaxLUNs(context_wrap(MAX_LUNS)) @@ -95,3 +108,12 @@ def test_class_exceptions(): max_luns_not_digit = MaxLUNs(context_wrap(SCSI_DM_MOD_USE_BLK_MQ_UNKNOW_CASE)) max_luns_not_digit.val assert "Unexpected content: unknow_case" in str(e) + + with pytest.raises(SkipException): + ql2xmqsuppor_empty = Ql2xmqSupport(context_wrap(SCSI_DM_MOD_USE_BLK_MQ_EMPTY)) + assert ql2xmqsuppor_empty is None + + with pytest.raises(ValueError) as e: + ql2xmqsuppor_unknow = Ql2xmqSupport(context_wrap(SCSI_DM_MOD_USE_BLK_MQ_UNKNOW_CASE)) + ql2xmqsuppor_unknow.is_on + assert "Unexpected value unknow_case, please get raw data from attribute 'val' and tell is_on by yourself." in str(e) diff --git a/insights/specs/__init__.py b/insights/specs/__init__.py index 3bf9deeb7e..7690a8edba 100644 --- a/insights/specs/__init__.py +++ b/insights/specs/__init__.py @@ -540,6 +540,7 @@ class Specs(SpecSet): qemu_conf = RegistryPoint() qemu_xml = RegistryPoint(multi_output=True) ql2xmaxlun = RegistryPoint() + ql2xmqsupport = RegistryPoint() qpid_stat_g = RegistryPoint() qpid_stat_q = RegistryPoint() qpid_stat_u = RegistryPoint() diff --git a/insights/specs/default.py b/insights/specs/default.py index b6dce6323c..53c2db77e4 100644 --- a/insights/specs/default.py +++ b/insights/specs/default.py @@ -560,6 +560,7 @@ def md5chk_file_list(broker): qemu_conf = simple_file("/etc/libvirt/qemu.conf") qemu_xml = glob_file(r"/etc/libvirt/qemu/*.xml") ql2xmaxlun = simple_file("/sys/module/qla2xxx/parameters/ql2xmaxlun") + ql2xmqsupport = simple_file("/sys/module/qla2xxx/parameters/ql2xmqsupport") qpidd_conf = simple_file("/etc/qpid/qpidd.conf") rabbitmq_env = simple_file("/etc/rabbitmq/rabbitmq-env.conf") rabbitmq_report = simple_command("/usr/sbin/rabbitmqctl report")