From 17e20bfa70d1a9ce5e6ee6687245e3e22f3633a8 Mon Sep 17 00:00:00 2001 From: "Sridhar K. N. Rao" Date: Wed, 1 Sep 2021 11:26:28 +0530 Subject: Clean Output Option. This patch adds support for clean output - displaying only final results. User has to run with --verbosity and level as error or critical. --verbosity is an existing option. Remove unnecessary spaces Signed-off-by: Sridhar K. N. Rao Change-Id: Id227a4b787c4c7e4dd97f28009946ac6a8a802d3 --- vswitches/ovs.py | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'vswitches/ovs.py') diff --git a/vswitches/ovs.py b/vswitches/ovs.py index 853bef85..a77e898e 100644 --- a/vswitches/ovs.py +++ b/vswitches/ovs.py @@ -26,9 +26,9 @@ import pexpect from conf import settings from src.ovs import OFBridge, flow_key, flow_match -from vswitches.vswitch import IVSwitch from tools import tasks from tools.module_manager import ModuleManager +from vswitches.vswitch import IVSwitch # enable caching of flows if their number exceeds given limit _CACHE_FLOWS_LIMIT = 10 @@ -100,6 +100,8 @@ class IVSwitchOvs(IVSwitch, tasks.Process): try: tasks.Process.start(self) + if settings.getValue('CLEAN_OUTPUT'): + self._disable_console_output() self.relinquish() except (pexpect.EOF, pexpect.TIMEOUT) as exc: self._logger.error("Exception during VSwitch start.") @@ -469,6 +471,15 @@ class IVSwitchOvs(IVSwitch, tasks.Process): self._logger.info('System reset after last run.') + def _disable_console_output(self): + """ + Configure vswitch to disable console output + """ + ovsappctl_tool_bin = settings.getValue('TOOLS')['ovs-appctl'] + tasks.run_task(['sudo', ovsappctl_tool_bin, 'vlog/set', ' console:off'], + self._logger, + 'Turning off the logs ...') + def _start_ovsdb(self): """Start ``ovsdb-server`` instance. @@ -483,13 +494,22 @@ class IVSwitchOvs(IVSwitch, tasks.Process): ovsdb_server_bin = settings.getValue('TOOLS')['ovsdb-server'] - tasks.run_background_task( - ['sudo', ovsdb_server_bin, - '--remote=punix:%s' % os.path.join(settings.getValue('TOOLS')['ovs_var_tmp'], 'db.sock'), - '--remote=db:Open_vSwitch,Open_vSwitch,manager_options', - '--pidfile=' + self._ovsdb_pidfile_path, '--overwrite-pidfile'], - self._logger, - 'Starting ovsdb-server...') + if settings.getValue('CLEAN_OUTPUT'): + tasks.run_background_task( + ['sudo', ovsdb_server_bin, + '--remote=punix:%s' % os.path.join(settings.getValue('TOOLS')['ovs_var_tmp'], 'db.sock'), + '--remote=db:Open_vSwitch,Open_vSwitch,manager_options', + '--pidfile=' + self._ovsdb_pidfile_path, '--overwrite-pidfile', '--verbose=off'], + self._logger, + 'Starting ovsdb-server...') + else: + tasks.run_background_task( + ['sudo', ovsdb_server_bin, + '--remote=punix:%s' % os.path.join(settings.getValue('TOOLS')['ovs_var_tmp'], 'db.sock'), + '--remote=db:Open_vSwitch,Open_vSwitch,manager_options', + '--pidfile=' + self._ovsdb_pidfile_path, '--overwrite-pidfile'], + self._logger, + 'Starting ovsdb-server...') def _kill_ovsdb(self): """Kill ``ovsdb-server`` instance. -- cgit 1.2.3-korg