From 57d79673d9f80b96e4bddc99bd8cfe95abea0103 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Tue, 23 Feb 2016 15:38:43 +0000 Subject: [PATCH] Skip ovs_ and ebtables_dump if needed commands not present Skip with a notification that a command was not found when trying to run a dump that relies on optional external command. Otherwise we produce noise in the error output that is misleading. Change-Id: I0e3d99da8c54d2912463ecba7c1783864a7c7fc7 Closes-Bug: #1548833 Closes-Bug: #1506873 --- tools/worlddump.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/worlddump.py b/tools/worlddump.py index d129374253..01f601cea8 100755 --- a/tools/worlddump.py +++ b/tools/worlddump.py @@ -18,6 +18,7 @@ import argparse import datetime +from distutils import spawn import fnmatch import os import os.path @@ -61,6 +62,13 @@ def _dump_cmd(cmd): print "*** Failed to run: %s" % cmd +def _find_cmd(cmd): + if not spawn.find_executable(cmd): + print "*** %s not found: skipping" % cmd + return False + return True + + def _header(name): print print name @@ -89,6 +97,8 @@ def disk_space(): def ebtables_dump(): tables = ['filter', 'nat', 'broute'] _header("EB Tables Dump") + if not _find_cmd('ebtables'): + return for table in tables: _dump_cmd("sudo ebtables -t %s -L" % table) @@ -124,6 +134,11 @@ def network_dump(): def ovs_dump(): _header("Open vSwitch Dump") + # NOTE(cdent): If we're not using neutron + ovs these commands + # will not be present so + if not _find_cmd('ovs-vsctl'): + return + # NOTE(ihrachys): worlddump is used outside of devstack context (f.e. in # grenade), so there is no single place to determine the bridge names from. # Hardcode for now.