Merge "Skip ovsdb_monitor events for ports with ofport=-1"

This commit is contained in:
Zuul 2019-01-19 00:32:47 +00:00 committed by Gerrit Code Review
commit 8c0e2edb98
2 changed files with 15 additions and 0 deletions

View File

@ -16,6 +16,7 @@ from oslo_log import log as logging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from neutron.agent.common import async_process from neutron.agent.common import async_process
from neutron.agent.common import ovs_lib
from neutron.agent.ovsdb import api as ovsdb from neutron.agent.ovsdb import api as ovsdb
from neutron.agent.ovsdb.native import helpers from neutron.agent.ovsdb.native import helpers
from neutron.common import utils from neutron.common import utils
@ -108,6 +109,11 @@ class SimpleInterfaceMonitor(OvsdbMonitor):
external_ids = ovsdb.val_to_py(external_ids) external_ids = ovsdb.val_to_py(external_ids)
if ofport: if ofport:
ofport = ovsdb.val_to_py(ofport) ofport = ovsdb.val_to_py(ofport)
if ofport == ovs_lib.INVALID_OFPORT:
LOG.debug("Ofport of port %(name)s is %(ofport)s. "
"Skipping its event.",
{'name': name, 'ofport': ofport})
continue
device = {'name': name, device = {'name': name,
'ofport': ofport, 'ofport': ofport,
'external_ids': external_ids} 'external_ids': external_ids}

View File

@ -85,3 +85,12 @@ class TestSimpleInterfaceMonitor(base.BaseTestCase):
self.monitor.process_events() self.monitor.process_events()
self.assertEqual(self.monitor.new_events['added'][0]['ofport'], self.assertEqual(self.monitor.new_events['added'][0]['ofport'],
ovs_lib.UNASSIGNED_OFPORT) ovs_lib.UNASSIGNED_OFPORT)
def process_event_invalid_of_port(self):
output = '{"data":[["e040fbec-0579-4990-8324-d338da33ae88","insert",'
output += '"m50",-1,["map",[]]]],"headings":["row","action",'
output += '"name","ofport","external_ids"]}'
with mock.patch.object(
self.monitor, 'iter_stdout', return_value=[output]):
self.monitor.process_events()
self.assertEqual([], self.monitor.new_events['added'])