Always run iptables-save as root
When there is a failure and we run commands to collect
network information, the iptables-save command always
fails in the root namespace:
Executing command 'iptables-save' on local host (timeout=None)...
Command 'iptables-save' failed (exit_status=4):
stderr:
iptables-save v1.8.7 (nf_tables): Could not fetch rule set
generation id: Permission denied (you must be root)
Change list_iptables() to always use sudo fixes the issue.
Trivialfix
Change-Id: I656569cb333e98f5f55b51b0cfec8e99922424b3
diff --git a/neutron_tempest_plugin/common/ip.py b/neutron_tempest_plugin/common/ip.py
index e2f6a4a..07bbe69 100644
--- a/neutron_tempest_plugin/common/ip.py
+++ b/neutron_tempest_plugin/common/ip.py
@@ -391,9 +391,9 @@
def list_iptables(version=constants.IP_VERSION_4, namespace=None):
- cmd = ''
+ cmd = 'sudo '
if namespace:
- cmd = 'sudo ip netns exec %s ' % namespace
+ cmd += 'ip netns exec %s ' % namespace
cmd += ('iptables-save' if version == constants.IP_VERSION_4 else
'ip6tables-save')
return shell.execute(cmd).stdout