Change in vdsm[master]: execCmd: Make loggign when successful optional

asegurap at redhat.com asegurap at redhat.com
Thu Nov 21 15:38:07 UTC 2013


Antoni Segura Puimedon has uploaded a new change for review.

Change subject: execCmd: Make loggign when successful optional
......................................................................

execCmd: Make loggign when successful optional

Make execCmd have an option that logs to debug only when the
proc returns an error code.

Make getLinks use it so the log is not spammed anymore by
nic info getting (sorry everyone about the spam).

Change-Id: I0c550aded704dd944f4f2af88b7925f9473f1a4a
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
---
M lib/vdsm/ipwrapper.py
M lib/vdsm/utils.py
2 files changed, 7 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/15/21515/1

diff --git a/lib/vdsm/ipwrapper.py b/lib/vdsm/ipwrapper.py
index afd7f6c..9f55d82 100644
--- a/lib/vdsm/ipwrapper.py
+++ b/lib/vdsm/ipwrapper.py
@@ -475,7 +475,7 @@
     command = [_IP_BINARY.cmd, '-d', '-o', 'link']
     if dev:
         command += ['show', 'dev', dev]
-    return _execCmd(command)
+    return _execCmd(command, logWhenSuccessful=False)
 
 
 def addrAdd(dev, ipaddr, netmask):
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index 3166a92..b6edf64 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -490,7 +490,7 @@
 def execCmd(command, sudo=False, cwd=None, data=None, raw=False, logErr=True,
             printable=None, env=None, sync=True, nice=None, ioclass=None,
             ioclassdata=None, setsid=False, execCmdLogger=logging.root,
-            deathSignal=0):
+            deathSignal=0, logWhenSuccessful=True):
     """
     Executes an external command, optionally via sudo.
 
@@ -535,9 +535,11 @@
         # Prevent splitlines() from barfing later on
         out = ""
 
-    execCmdLogger.debug("%s: <err> = %s; <rc> = %d",
-                        {True: "SUCCESS", False: "FAILED"}[p.returncode == 0],
-                        repr(err), p.returncode)
+    if logWhenSuccessful or p.returncode != 0:
+        execCmdLogger.debug(
+            "%s: <err> = %s; <rc> = %d",
+            {True: "SUCCESS", False: "FAILED"}[p.returncode == 0], repr(err),
+            p.returncode)
 
     if not raw:
         out = out.splitlines(False)


-- 
To view, visit http://gerrit.ovirt.org/21515
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c550aded704dd944f4f2af88b7925f9473f1a4a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>


More information about the vdsm-patches mailing list