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
| ... | ... |
@@ -18,6 +18,7 @@ |
| 18 | 18 |
|
| 19 | 19 |
import argparse |
| 20 | 20 |
import datetime |
| 21 |
+from distutils import spawn |
|
| 21 | 22 |
import fnmatch |
| 22 | 23 |
import os |
| 23 | 24 |
import os.path |
| ... | ... |
@@ -61,6 +62,13 @@ def _dump_cmd(cmd): |
| 61 | 61 |
print "*** Failed to run: %s" % cmd |
| 62 | 62 |
|
| 63 | 63 |
|
| 64 |
+def _find_cmd(cmd): |
|
| 65 |
+ if not spawn.find_executable(cmd): |
|
| 66 |
+ print "*** %s not found: skipping" % cmd |
|
| 67 |
+ return False |
|
| 68 |
+ return True |
|
| 69 |
+ |
|
| 70 |
+ |
|
| 64 | 71 |
def _header(name): |
| 65 | 72 |
|
| 66 | 73 |
print name |
| ... | ... |
@@ -89,6 +97,8 @@ def disk_space(): |
| 89 | 89 |
def ebtables_dump(): |
| 90 | 90 |
tables = ['filter', 'nat', 'broute'] |
| 91 | 91 |
_header("EB Tables Dump")
|
| 92 |
+ if not _find_cmd('ebtables'):
|
|
| 93 |
+ return |
|
| 92 | 94 |
for table in tables: |
| 93 | 95 |
_dump_cmd("sudo ebtables -t %s -L" % table)
|
| 94 | 96 |
|
| ... | ... |
@@ -124,6 +134,11 @@ def network_dump(): |
| 124 | 124 |
def ovs_dump(): |
| 125 | 125 |
_header("Open vSwitch Dump")
|
| 126 | 126 |
|
| 127 |
+ # NOTE(cdent): If we're not using neutron + ovs these commands |
|
| 128 |
+ # will not be present so |
|
| 129 |
+ if not _find_cmd('ovs-vsctl'):
|
|
| 130 |
+ return |
|
| 131 |
+ |
|
| 127 | 132 |
# NOTE(ihrachys): worlddump is used outside of devstack context (f.e. in |
| 128 | 133 |
# grenade), so there is no single place to determine the bridge names from. |
| 129 | 134 |
# Hardcode for now. |