Skip to content

Commit

Permalink
[masakari] Add masakari plugin
Browse files Browse the repository at this point in the history
Resolves: #3348

Signed-off-by: Arif Ali <[email protected]>
  • Loading branch information
arif-ali committed Sep 6, 2023
1 parent 7cd6f61 commit b107634
Showing 1 changed file with 116 additions and 0 deletions.
116 changes: 116 additions & 0 deletions sos/report/plugins/openstack_masakari.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin


class OpenStackMasakari(Plugin):

short_desc = 'OpenStack Masakari'
plugin_name = "openstack_masakari"
profiles = ('openstack', 'openstack_controller')
containers = ('.*masakari_api',)
var_puppet_gen = "/var/lib/config-data/puppet-generated/masakari"

def setup(self):

config_dir = "%s/etc/masakari" % (
self.var_puppet_gen if self.container_exists('.*masakari_api') else
''
)
masakari_cmd = "masakari-manage --config-dir %s db version" % config_dir
self.add_cmd_output(masakari_cmd, suggest_filename="masakari_db_version")

self.add_copy_spec([
"/etc/masakari/",
"/etc/masakarimonitors/",
self.var_puppet_gen + "/etc/masakari/",
self.var_puppet_gen + "/etc/my.cnf.d/tripleo.cnf",
self.var_puppet_gen + "/etc/httpd/conf/",
self.var_puppet_gen + "/etc/httpd/conf.d/",
self.var_puppet_gen + "/etc/httpd/conf.modules.d/*.conf",
])

if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/masakari/*",
])
else:
self.add_copy_spec([
"/var/log/masakari/*.log",
])

self.add_file_tags({
".*/etc/masakari/masakari.conf": "masakari_conf"
})

def apply_regex_sub(self, regexp, subst):
self.do_path_regex_sub("/etc/masakari/*", regexp, subst)
self.do_path_regex_sub(
self.var_puppet_gen + "/etc/masakari/*",
regexp, subst
)

def postproc(self):
protect_keys = [".*password.*", "transport_url",
"memcache_secret_key", "rabbit_password"]
connection_keys = ["connection", "sql_connection"]

self.apply_regex_sub(
r"(^\s*(%s)\s*=\s*)(.*)" % "|".join(protect_keys),
r"\1*********"
)
self.apply_regex_sub(
r"(^\s*(%s)\s*=\s*(.*)://(\w*):)(.*)(@(.*))" %
"|".join(connection_keys),
r"\1*********\6"
)


class DebianMasakari(OpenStackMasakari, DebianPlugin, UbuntuPlugin):

short_desc = 'OpenStack Masakari information for Debian based distributions'
packages = (
'masakari-engine',
'masakari-api',
)

services = ( 'masakari-engine', )

def setup(self):
super(DebianMasakari, self).setup()
if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/apache2/masakari*",
])
else:
self.add_copy_spec([
"/var/log/apache2/masakari*.log",
])


class RedHatMasakari(OpenStackMasakari, RedHatPlugin):

short_desc = 'OpenStack Masakari information for Red Hat distributions'
packages = ('openstack-selinux',)

def setup(self):`

Check failure

Code scanning / CodeQL

Syntax error Error

Syntax Error (in Python 3).
super(RedHatMasakari, self).setup()
self.add_copy_spec("/etc/sudoers.d/masakari")

if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/containers/masakari/*"
])
else:
self.add_copy_spec([
"/var/log/containers/masakari/*.log"
])


# vim: et ts=4 sw=4

0 comments on commit b107634

Please sign in to comment.