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
diff --git a/tools/worlddump.py b/tools/worlddump.py
index d129374..01f601c 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 @@
         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 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 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.