Ignore non-existent ports during OVS intf list

A recent commit[1] to pass the list of port names directly to
ovs-vsctl during a list operation introduced a new possible
failure condition where one of the names might refer to a port
which no longer exists. By default this causes ovs-vsctl to quit
in a fit of rage[2].

Previously, all interfaces were retrieved and the ones that were a
subset of the name list were processed. The name list could contain
extra non-existent names (e.g. recently deleted interfaces).

This patch just passes the '--if-exists' flag to the 'list Interface'
command to match the same previous behavior.

1. 3f0bf6cfac
2. Example: Stderr: 'ovs-vsctl: no row "tap80664420-ea" in table Interface\n'

Closes-Bug: #1407190
Change-Id: I8f359981386d13fb455281a72b8bb245395c0909
This commit is contained in:
Kevin Benton 2015-01-04 01:47:01 -08:00 committed by Kevin Benton
parent b88f9df733
commit 5de1d2ed67
2 changed files with 6 additions and 4 deletions

View File

@ -363,7 +363,8 @@ class OVSBridge(BaseOVS):
def get_vif_port_set(self):
edge_ports = set()
args = ['--format=json', '--', '--columns=external_ids,ofport',
'list', 'Interface'] + self.get_port_name_list()
'--if-exists', 'list', 'Interface']
args += self.get_port_name_list()
result = self.run_vsctl(args, check_error=True)
if not result:
return edge_ports
@ -404,7 +405,8 @@ class OVSBridge(BaseOVS):
in the "Interface" table queried by the get_vif_port_set() method.
"""
args = ['--format=json', '--', '--columns=name,tag', 'list', 'Port']
args = ['--format=json', '--', '--columns=name,tag', '--if-exists',
'list', 'Port']
args += self.get_port_name_list()
result = self.run_vsctl(args, check_error=True)
port_tag_dict = {}

View File

@ -655,7 +655,7 @@ class OVS_Lib_Test(base.BaseTestCase):
root_helper=self.root_helper),
'tap99\ntun22'),
(mock.call(["ovs-vsctl", self.TO, "--format=json",
"--", "--columns=external_ids,ofport",
"--", "--columns=external_ids,ofport", '--if-exists',
"list", "Interface", 'tap99', 'tun22'],
root_helper=self.root_helper),
self._encode_ovs_json(headings, data)),
@ -711,7 +711,7 @@ class OVS_Lib_Test(base.BaseTestCase):
root_helper=self.root_helper),
'tap99\n'),
(mock.call(["ovs-vsctl", self.TO, "--format=json",
"--", "--columns=external_ids,ofport",
"--", "--columns=external_ids,ofport", '--if-exists',
"list", "Interface", "tap99"],
root_helper=self.root_helper),
RuntimeError()),