Skip to content

Commit

Permalink
Dev: crm_report: Move hb_report directory to crmsh/report
Browse files Browse the repository at this point in the history
  • Loading branch information
liangxin1300 committed Dec 22, 2021
1 parent 9360f96 commit bfb14d0
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 66 deletions.
5 changes: 0 additions & 5 deletions Makefile.am
Expand Up @@ -55,11 +55,6 @@ install-data-hook:
mv $(DESTDIR)$(datadir)/@PACKAGE@/test $(DESTDIR)$(datadir)/@PACKAGE@/tests; \
cp test/testcases/xmlonly.sh $(DESTDIR)$(datadir)/@PACKAGE@/tests/testcases/configbasic-xml.filter

hanoarchdir = $(datadir)/@PACKAGE@/hb_report
hanoarch_DATA = hb_report/constants.py hb_report/utillib.py hb_report/collect.py
hanoarch_SCRIPTS = hb_report/hb_report
EXTRA_DIST = $(hanoarch_DATA)

# Python module installation
all-local:
(cd $(srcdir); $(PYTHON) setup.py build \
Expand Down
1 change: 0 additions & 1 deletion configure.ac
Expand Up @@ -54,7 +54,6 @@ AC_PATH_PROGS(ASCIIDOC, asciidoc)
AM_CONDITIONAL(BUILD_ASCIIDOC, test x"${ASCIIDOC}" != x"")

AC_CONFIG_FILES(Makefile \
hb_report/hb_report \
etc/crm.conf \
version \
crmsh.spec \
Expand Down
5 changes: 3 additions & 2 deletions crmsh/config.py
Expand Up @@ -294,7 +294,8 @@ def get(self, value):
'collect_extra_logs': opt_string('/var/log/messages /var/log/pacemaker/pacemaker.log /var/log/pacemaker.log /var/log/crmsh/crmsh.log'),
'remove_exist_dest': opt_boolean('no'),
'single_node': opt_boolean('no'),
'sanitize_rule': opt_string('passw.*')
'sanitize_rule': opt_string('passw.*'),
'verbosity': opt_string('0')
}
}

Expand Down Expand Up @@ -370,7 +371,7 @@ def get(self, section, name, raw=False):
return DEFAULTS[section][name].get(self.get_impl(section, name))

def set(self, section, name, value):
if section not in ('core', 'path', 'color'):
if section not in ('core', 'path', 'color', 'report'):
raise ValueError("Setting invalid section " + str(section))
if not self._defaults.has_option(section, name):
raise ValueError("Setting invalid option %s.%s" % (section, name))
Expand Down
19 changes: 7 additions & 12 deletions crmsh/history.py
Expand Up @@ -24,9 +24,9 @@


#
# hb_report interface
# crm report interface
#
# read hb_report generated report, show interesting stuff, search
# read crm report generated report, show interesting stuff, search
# through logs, get PE input files, get log slices (perhaps even
# coloured nicely!)
#
Expand Down Expand Up @@ -122,9 +122,9 @@ def mkarchive(idir):

class Report(object):
'''
A hb_report class.
A crm report class.
'''
live_recent = 6*60*60 # recreate live hb_report once every 6 hours
live_recent = 6*60*60 # recreate live crm report once every 6 hours
short_live_recent = 60 # update once a minute
nodecolors = ("NORMAL",
"GREEN",
Expand Down Expand Up @@ -191,7 +191,7 @@ def session_list(self):

def unpack_report(self, tarball):
'''
Unpack hb_report tarball.
Unpack crm report tarball.
Don't unpack if the directory already exists!
'''
bfname = os.path.basename(tarball)
Expand Down Expand Up @@ -458,12 +458,7 @@ def new_live_report(self):
'''
Run the report command to get logs now.
'''
from . import ui_report

extcmd = ui_report.report_tool()
if extcmd is None:
self.error("No reporting tool found")
return None
extcmd = "crm report"

d = self._live_loc()
if not utils.is_path_sane(d):
Expand Down Expand Up @@ -559,7 +554,7 @@ def set_node_colors(self):

def _report_setup_source(self):
constants.pcmk_version = None
# is this an hb_report or a crm_report?
# is this an crm report or a crm_report?
for descname in ("description.txt", "report.summary"):
self.desc = os.path.join(self.loc, descname)
if os.path.isfile(self.desc):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions hb_report/hb_report.in → crmsh/report/core.py 100755 → 100644
Expand Up @@ -99,7 +99,7 @@ def get_log():

def is_collector():
"""
the instance where user runs hb_report is the master
the instance where user runs crm report is the master
the others are slaves
"""
if len(sys.argv) > 1 and sys.argv[1] == "__slave":
Expand Down Expand Up @@ -142,7 +142,7 @@ def parse_argument(argv):

if len(arg) == 0:
constants.DESTDIR = "."
constants.DEST = "hb_report-%s" % datetime.datetime.now().strftime('%a-%d-%b-%Y')
constants.DEST = "crm_report-%s" % datetime.datetime.now().strftime('%a-%d-%b-%Y')
elif len(arg) == 1:
constants.TMP = arg[0]
else:
Expand Down
8 changes: 4 additions & 4 deletions hb_report/utillib.py → crmsh/report/utillib.py
Expand Up @@ -1107,7 +1107,7 @@ def log_warning(msg):


def make_temp_dir():
dir_path = r"/tmp/.hb_report.workdir.%s" % random_string(6)
dir_path = r"/tmp/.crm_report.workdir.%s" % random_string(6)
_mkdir(dir_path)
return dir_path

Expand Down Expand Up @@ -1362,12 +1362,12 @@ def stdchannel_redirected(stdchannel, dest_filename):

def start_slave_collector(node, arg_str):
if node == constants.WE:
cmd = r"/usr/sbin/hb_report __slave".format(os.getcwd())
cmd = r"crm report __slave".format(os.getcwd())
for item in arg_str.split():
cmd += " {}".format(str(item))
_, out = crmutils.get_stdout(cmd)
else:
cmd = r'ssh {} {} "/usr/sbin/hb_report __slave"'.format(constants.SSH_OPTS, node, os.getcwd())
cmd = r'ssh {} {} "crm report __slave"'.format(constants.SSH_OPTS, node, os.getcwd())
for item in arg_str.split():
cmd += " {}".format(str(item))
code, out, err = crmutils.get_stdout_stderr(cmd)
Expand All @@ -1384,7 +1384,7 @@ def start_slave_collector(node, arg_str):
compress_data = ""
for data in out.split('\n'):
if data.startswith(constants.COMPRESS_DATA_FLAG):
# hb_report data from collector
# crm report data from collector
compress_data = data.lstrip(constants.COMPRESS_DATA_FLAG)
else:
# log data from collector
Expand Down
32 changes: 0 additions & 32 deletions crmsh/ui_report.py

This file was deleted.

7 changes: 4 additions & 3 deletions crmsh/ui_root.py
Expand Up @@ -30,7 +30,6 @@
from . import ui_node
from . import ui_options
from . import ui_ra
from . import ui_report
from . import ui_resource
from . import ui_script
from . import ui_site
Expand Down Expand Up @@ -137,8 +136,10 @@ def do_ra(self):
crmsh over the given period of time.
''')
def do_report(self, context, *args):
rc = ui_report.create_report(context, args)
return rc == 0
import sys
from crmsh.report import core
sys.argv[1:] = args
core.run()

@command.level(ui_resource.RscMgmt)
@command.help('''resources management
Expand Down
6 changes: 3 additions & 3 deletions etc/crm.conf.in
Expand Up @@ -79,7 +79,7 @@ ocf_root = @OCF_ROOT_DIR@
;
; sanitize_rule = sanitize_pattern[:options] ...
;
; This defines the way to hide sensitive data generated by hb_report.
; This defines the way to hide sensitive data generated by crm report.
;
; 'sanitize_pattern' is a RegEx string, which is used to matches 'name'
; field of CIB params. The sanitize process will hide 'value' of those
Expand All @@ -88,13 +88,13 @@ ocf_root = @OCF_ROOT_DIR@
; 'options' is the predefined, and 'raw' is the only one defined
; currently. With ':raw" option, the sanitize process will fetch
; 'value' results out of CIB 'name:value' pairs, and use them to
; hide all clear text occurence from all files hb_report collected.
; hide all clear text occurence from all files crm report collected.
;
; Example 1:
; sanitize_rule = passw.*
;
; This is the default. It will hide password nam:value pairs.
; The result of hb_report clould be like
; The result of crm report clould be like
; name="password", value=******
; @name=password @value=******
; passwd=******
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -4,12 +4,12 @@
from setuptools import setup

setup(name='crmsh',
version='4.3.0',
version='4.3.1',
description='Command-line interface for High-Availability cluster management',
author='Kristoffer Gronlund, Xin Liang',
author_email='XLiang@suse.com',
url='http://crmsh.github.io/',
packages=['crmsh', 'crmsh.crash_test'],
packages=['crmsh', 'crmsh.crash_test', 'crmsh.report'],
install_requires=['parallax', 'lxml', 'PyYAML', 'py-dateutil'],
scripts=['bin/crm'],
data_files=[('/usr/share/crmsh', ['doc/crm.8.adoc'])],
Expand Down

0 comments on commit bfb14d0

Please sign in to comment.