Skip to content

Commit

Permalink
Support cib.xml in sosreport (#2640)
Browse files Browse the repository at this point in the history
* Support cib.xml in sosreport

* The localtion of cib.xml in sosreport is at "sos_commands/pacemaker/crm_report/<hostname>/cib.xml"
* And there is only one cib.xml path under sos_commands
* since hostname is unknown, so use glob here and then the first one is
the expected
Signed-off-by: Huanhuan Li <[email protected]>

* Move the cib changes to sos_archive

Signed-off-by: Huanhuan Li <[email protected]>
  • Loading branch information
huali027 authored Jul 6, 2020
1 parent cf47c19 commit 9034541
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion insights/parsers/tests/test_cib.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@


def test_cib():
cib = CIB(context_wrap(CIB_CONFIG))
cib = CIB(context_wrap(CIB_CONFIG, path="/var/lib/pacemaker/cib/cib.xml"))
assert cib is not None
assert cib.nodes == ['foo', 'bar', 'baz']


def test_cib_in_sosreport():
cib = CIB(context_wrap(CIB_CONFIG, path="sos_commands/pacemaker/crm_report/abc/cib.xml"))
assert cib is not None
assert cib.nodes == ['foo', 'bar', 'baz']
10 changes: 9 additions & 1 deletion insights/specs/sos_archive.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from functools import partial
from insights.specs import Specs
from insights.core.context import SosArchiveContext
from insights.core.spec_factory import simple_file, first_of, first_file, glob_file
from insights.core.spec_factory import simple_file, first_of, first_file, glob_file, head

first_file = partial(first_file, context=SosArchiveContext)
glob_file = partial(glob_file, context=SosArchiveContext)
Expand All @@ -25,6 +25,14 @@ class SosSpecs(Specs):
ceph_report = simple_file("sos_commands/ceph/ceph_report")
ceph_health_detail = simple_file("sos_commands/ceph/ceph_health_detail_--format_json-pretty")
chkconfig = first_file(["sos_commands/startup/chkconfig_--list", "sos_commands/services/chkconfig_--list"])
cib_xml = first_of(
[
simple_file("/var/lib/pacemaker/cib/cib.xml"),
head(
glob_file("sos_commands/pacemaker/crm_report/*/cib.xml")
)
]
)
cpupower_frequency_info = simple_file("sos_commands/processor/cpupower_frequency-info")
date = first_of([simple_file("sos_commands/general/date"), simple_file("sos_commands/date/date")])
df__al = first_file(["sos_commands/filesys/df_-al", "sos_commands/filesys/df_-al_-x_autofs"])
Expand Down

0 comments on commit 9034541

Please sign in to comment.