Blame SOURCES/sos-bz1580525-ovn-plugins.patch

6fdade
From 10bb3b2d6f6817bb4ae96ba58865bff294e54f8d Mon Sep 17 00:00:00 2001
6fdade
From: Mark Michelson <mmichels@redhat.com>
6fdade
Date: Thu, 17 May 2018 16:43:58 -0400
6fdade
Subject: [PATCH 1/2] [openvswitch] Add additional logging paths.
6fdade
6fdade
Openvswitch's logs can be located in alternate paths depending on the
6fdade
installation. OpenStack installations, for instance, do not use the same
6fdade
directories for logs as typical package installations.
6fdade
6fdade
Related: #1259
6fdade
6fdade
Signed-off-by: Mark Michelson <mmichels@redhat.com>
6fdade
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
6fdade
---
6fdade
 sos/plugins/openvswitch.py | 19 ++++++++++++++++---
6fdade
 1 file changed, 16 insertions(+), 3 deletions(-)
6fdade
6fdade
diff --git a/sos/plugins/openvswitch.py b/sos/plugins/openvswitch.py
6fdade
index 6f1b41ac..ab908fbc 100644
6fdade
--- a/sos/plugins/openvswitch.py
6fdade
+++ b/sos/plugins/openvswitch.py
6fdade
@@ -16,6 +16,9 @@
6fdade
 
6fdade
 from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
6fdade
 
6fdade
+from os.path import join as path_join
6fdade
+from os import environ
6fdade
+
6fdade
 
6fdade
 class OpenVSwitch(Plugin):
6fdade
     """ OpenVSwitch networking
6fdade
@@ -28,12 +31,22 @@ class OpenVSwitch(Plugin):
6fdade
         all_logs = self.get_option("all_logs")
6fdade
         limit = self.get_option("log_size")
6fdade
 
6fdade
+        log_dirs = [
6fdade
+            '/var/log/containers/openvswitch/',
6fdade
+            '/var/log/openvswitch/',
6fdade
+            '/usr/local/var/log/openvswitch/',
6fdade
+        ]
6fdade
+
6fdade
+        if environ.get('OVS_LOGDIR'):
6fdade
+            log_dirs.append(environ.get('OVS_LOGDIR'))
6fdade
+
6fdade
         if not all_logs:
6fdade
-            self.add_copy_spec("/var/log/openvswitch/*.log",
6fdade
+            self.add_copy_spec([path_join(ld, '*.log') for ld in log_dirs],
6fdade
                                sizelimit=limit)
6fdade
-        else:
6fdade
-            self.add_copy_spec("/var/log/openvswitch/",
6fdade
+            self.add_copy_spec([path_join(ld, '*.log') for ld in log_dirs],
6fdade
                                sizelimit=limit)
6fdade
+        else:
6fdade
+            self.add_copy_spec(log_dirs, sizelimit=limit)
6fdade
 
6fdade
         self.add_copy_spec([
6fdade
             "/var/run/openvswitch/ovsdb-server.pid",
6fdade
-- 
6fdade
2.13.6
6fdade
6fdade
6fdade
From ac33925bac828246229a93da0f9b4e9218bca6b8 Mon Sep 17 00:00:00 2001
6fdade
From: Mark Michelson <mmichels@redhat.com>
6fdade
Date: Thu, 17 May 2018 16:50:40 -0400
6fdade
Subject: [PATCH 2/2] [ovn] Add new plugins for Open Virtual Network
6fdade
6fdade
OVN is a sub-project of Openvswitch used to define logical networks for
6fdade
a cluster of OVS instances. The two plugins defined here are
6fdade
"ovn-central", which runs on a single server, and "ovn-host" which runs
6fdade
on each of the hypervisors running OVS.
6fdade
6fdade
These plugins gather runtime information about the configured virtual
6fdade
networks.
6fdade
6fdade
Resolves: #1259
6fdade
6fdade
Signed-off-by: Mark Michelson <mmichels@redhat.com>
6fdade
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
6fdade
---
6fdade
 sos/plugins/ovn_central.py | 105 +++++++++++++++++++++++++++++++++++++++++++++
6fdade
 sos/plugins/ovn_host.py    |  57 ++++++++++++++++++++++++
6fdade
 2 files changed, 162 insertions(+)
6fdade
 create mode 100644 sos/plugins/ovn_central.py
6fdade
 create mode 100644 sos/plugins/ovn_host.py
6fdade
6fdade
diff --git a/sos/plugins/ovn_central.py b/sos/plugins/ovn_central.py
6fdade
new file mode 100644
6fdade
index 00000000..23c1faeb
6fdade
--- /dev/null
6fdade
+++ b/sos/plugins/ovn_central.py
6fdade
@@ -0,0 +1,105 @@
6fdade
+# Copyright (C) 2018 Mark Michelson <mmichels@redhat.com>
6fdade
+
6fdade
+# This program is free software; you can redistribute it and/or modify
6fdade
+# it under the terms of the GNU General Public License as published by
6fdade
+# the Free Software Foundation; either version 2 of the License, or
6fdade
+# (at your option) any later version.
6fdade
+
6fdade
+# This program is distributed in the hope that it will be useful,
6fdade
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
6fdade
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6fdade
+# GNU General Public License for more details.
6fdade
+
6fdade
+# You should have received a copy of the GNU General Public License along
6fdade
+# with this program; if not, write to the Free Software Foundation, Inc.,
6fdade
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
6fdade
+
6fdade
+from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
6fdade
+import json
6fdade
+import os
6fdade
+import six
6fdade
+
6fdade
+
6fdade
+class OVNCentral(Plugin):
6fdade
+    """ OVN Northd
6fdade
+    """
6fdade
+    plugin_name = "ovn_central"
6fdade
+    profiles = ('network', 'virt')
6fdade
+
6fdade
+    def add_database_output(self, filename, cmds, ovn_cmd, skip=[]):
6fdade
+        try:
6fdade
+            with open(filename, 'r') as f:
6fdade
+                try:
6fdade
+                    db = json.load(f)
6fdade
+                except:
6fdade
+                    # If json can't be parsed, then exit early
6fdade
+                    self._log_error("Cannot parse JSON file %s" % filename)
6fdade
+                    return
6fdade
+                try:
6fdade
+                    for table in six.iterkeys(db['tables']):
6fdade
+                        if table not in skip:
6fdade
+                            cmds.append('%s list %s' % (ovn_cmd, table))
6fdade
+                except AttributeError:
6fdade
+                    self._log_error("DB schema %s has no 'tables' key" %
6fdade
+                                    filename)
6fdade
+                    return
6fdade
+        except IOError as ex:
6fdade
+            self._log_error("Could not open DB schema file %s: %s" % (filename,
6fdade
+                                                                      ex))
6fdade
+            return
6fdade
+
6fdade
+    def setup(self):
6fdade
+        ovs_rundir = os.environ.get('OVS_RUNDIR')
6fdade
+        for pidfile in ['ovnnb_db.pid', 'ovnsb_db.pid', 'ovn-northd.pid']:
6fdade
+            self.add_copy_spec([
6fdade
+                os.path.join('/var/lib/openvswitch/ovn', pidfile),
6fdade
+                os.path.join('/usr/local/var/run/openvswitch', pidfile),
6fdade
+                os.path.join('/var/run/openvswitch/', pidfile),
6fdade
+                os.path.join('/run/openvswitch/', pidfile),
6fdade
+            ])
6fdade
+
6fdade
+            if ovs_rundir:
6fdade
+                self.add_copy_spec(os.path.join(ovs_rundir, pidfile))
6fdade
+
6fdade
+        # Some user-friendly versions of DB output
6fdade
+        cmds = [
6fdade
+            'ovn-sbctl lflow-list',
6fdade
+            'ovn-nbctl get-ssl',
6fdade
+            'ovn-nbctl get-connection',
6fdade
+            'ovn-sbctl get-ssl',
6fdade
+            'ovn-sbctl get-connection',
6fdade
+        ]
6fdade
+
6fdade
+        schema_dir = '/usr/share/openvswitch'
6fdade
+
6fdade
+        self.add_database_output(os.path.join(schema_dir, 'ovn-nb.ovsschema'),
6fdade
+                                 cmds, 'ovn-nbctl')
6fdade
+        self.add_database_output(os.path.join(schema_dir, 'ovn-sb.ovsschema'),
6fdade
+                                 cmds, 'ovn-sbctl', ['Logical_Flow'])
6fdade
+
6fdade
+        self.add_cmd_output(cmds)
6fdade
+
6fdade
+        self.add_copy_spec("/etc/sysconfig/ovn-northd")
6fdade
+
6fdade
+        ovs_dbdir = os.environ.get('OVS_DBDIR')
6fdade
+        for dbfile in ['ovnnb_db.db', 'ovnsb_db.db']:
6fdade
+            self.add_copy_spec([
6fdade
+                os.path.join('/var/lib/openvswitch/ovn', dbfile),
6fdade
+                os.path.join('/usr/local/etc/openvswitch', dbfile),
6fdade
+                os.path.join('/etc/openvswitch', dbfile),
6fdade
+                os.path.join('/var/lib/openvswitch', dbfile),
6fdade
+            ])
6fdade
+            if ovs_dbdir:
6fdade
+                self.add_copy_spec(os.path.join(ovs_dbdir, dbfile))
6fdade
+
6fdade
+        self.add_journal(units="ovn-northd")
6fdade
+
6fdade
+
6fdade
+class RedHatOVNCentral(OVNCentral, RedHatPlugin):
6fdade
+
6fdade
+    packages = ('openvswitch-ovn-central', )
6fdade
+
6fdade
+
6fdade
+class DebianOVNCentral(OVNCentral, DebianPlugin, UbuntuPlugin):
6fdade
+
6fdade
+    packages = ('ovn-central', )
6fdade
diff --git a/sos/plugins/ovn_host.py b/sos/plugins/ovn_host.py
6fdade
new file mode 100644
6fdade
index 00000000..496f35bb
6fdade
--- /dev/null
6fdade
+++ b/sos/plugins/ovn_host.py
6fdade
@@ -0,0 +1,57 @@
6fdade
+# Copyright (C) 2018 Mark Michelson <mmichels@redhat.com>
6fdade
+
6fdade
+# This program is free software; you can redistribute it and/or modify
6fdade
+# it under the terms of the GNU General Public License as published by
6fdade
+# the Free Software Foundation; either version 2 of the License, or
6fdade
+# (at your option) any later version.
6fdade
+
6fdade
+# This program is distributed in the hope that it will be useful,
6fdade
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
6fdade
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6fdade
+# GNU General Public License for more details.
6fdade
+
6fdade
+# You should have received a copy of the GNU General Public License along
6fdade
+# with this program; if not, write to the Free Software Foundation, Inc.,
6fdade
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
6fdade
+
6fdade
+import os
6fdade
+from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
6fdade
+
6fdade
+
6fdade
+class OVNHost(Plugin):
6fdade
+    """ OVN Controller
6fdade
+    """
6fdade
+    plugin_name = "ovn_host"
6fdade
+    profiles = ('network', 'virt')
6fdade
+
6fdade
+    def setup(self):
6fdade
+        pidfile = 'ovn-controller.pid'
6fdade
+        pid_paths = [
6fdade
+                '/var/lib/openvswitch/ovn',
6fdade
+                '/usr/local/var/run/openvswitch',
6fdade
+                '/var/run/openvswitch',
6fdade
+                '/run/openvswitch'
6fdade
+        ]
6fdade
+        if os.environ.get('OVS_RUNDIR'):
6fdade
+            pid_paths.append(os.environ.get('OVS_RUNDIR'))
6fdade
+        self.add_copy_spec([os.path.join(pp, pidfile) for pp in pid_paths])
6fdade
+
6fdade
+        self.add_copy_spec('/etc/sysconfig/ovn-controller')
6fdade
+
6fdade
+        self.add_cmd_output([
6fdade
+            'ovs-ofctl -O OpenFlow13 dump-flows br-int',
6fdade
+            'ovs-vsctl list-br',
6fdade
+            'ovs-vsctl list OpenVswitch',
6fdade
+        ])
6fdade
+
6fdade
+        self.add_journal(units="ovn-controller")
6fdade
+
6fdade
+
6fdade
+class RedHatOVNHost(OVNHost, RedHatPlugin):
6fdade
+
6fdade
+    packages = ('openvswitch-ovn-host', )
6fdade
+
6fdade
+
6fdade
+class DebianOVNHost(OVNHost, DebianPlugin, UbuntuPlugin):
6fdade
+
6fdade
+    packages = ('ovn-host', )
6fdade
-- 
6fdade
2.13.6
6fdade