diff options
-rw-r--r-- | sos/plugins/ovn_central.py | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/sos/plugins/ovn_central.py b/sos/plugins/ovn_central.py index 7be274f7..3c564788 100644 --- a/sos/plugins/ovn_central.py +++ b/sos/plugins/ovn_central.py @@ -19,14 +19,12 @@ class OVNCentral(Plugin): """ plugin_name = "ovn_central" profiles = ('network', 'virt') - _container_runtime = None - _container_name = None def get_tables_from_schema(self, filename, skip=[]): if self._container_name: - cmd = "%s exec %s cat %s" % ( - self._container_runtime, self._container_name, filename) - res = self.exec_cmd(cmd, foreground=True) + cmd = "cat %s" % filename + res = self.exec_cmd(cmd, timeout=None, foreground=True, + container=self._container_name) if res['status'] != 0: self._log_error("Could not retrieve DB schema file from " "container %s" % self._container_name) @@ -61,23 +59,12 @@ class OVNCentral(Plugin): for table in tables: cmds.append('%s list %s' % (ovn_cmd, table)) - def running_in_container(self): - for runtime in ["podman", "docker"]: - container_status = self.exec_cmd(runtime + " ps") - if container_status['status'] == 0: - for line in container_status['output'].splitlines(): - if "ovn-dbs-bundle" in line: - self._container_name = line.split()[-1] - self._container_runtime = runtime - return True - return False - def check_enabled(self): - return (self.running_in_container() or + return (self.container_exists('ovs-dbs-bundle.*') or super(OVNCentral, self).check_enabled()) def setup(self): - containerized = self.running_in_container() + self._container_name = self.get_container_by_name('ovs-dbs-bundle.*') ovs_rundir = os.environ.get('OVS_RUNDIR') for pidfile in ['ovnnb_db.pid', 'ovnsb_db.pid', 'ovn-northd.pid']: @@ -113,10 +100,9 @@ class OVNCentral(Plugin): # If OVN is containerized, we need to run the above commands inside # the container. - if containerized: - cmds = ['%s exec %s %s' % (self._container_runtime, - self._container_name, - cmd) for cmd in cmds] + cmds = [ + self.fmt_container_cmd(self._container_name, cmd) for cmd in cmds + ] self.add_cmd_output(cmds, foreground=True) |