Ensure ovsdb_connection enabled before calling monitor

ovsdb-client monitor attempts to connect to ovs via the
ovsdb_connection if it is set. Since it is set by default, we need
to ensure that OVS is listening on the socket before calling
ovsdb-client monitor.

Closes-Bug: #1669893
Depends-On: Ibde5417d005265d27e939ca29788c21f73b38980
Change-Id: Ia34b9d599b522dd12ef088100c2b68a75a78d797
(cherry picked from commit 6975e2a48e)
This commit is contained in:
Terry Wilson 2017-03-03 14:00:39 -06:00 committed by Ihar Hrachyshka
parent 5a0700ee9f
commit ae20437e98
4 changed files with 15 additions and 0 deletions

View File

@ -18,6 +18,7 @@ from oslo_serialization import jsonutils
from neutron._i18n import _LE
from neutron.agent.linux import async_process
from neutron.agent.ovsdb import api as ovsdb
from neutron.agent.ovsdb.native import helpers
from neutron.common import utils
@ -37,6 +38,7 @@ class OvsdbMonitor(async_process.AsyncProcess):
if ovsdb_connection:
# if ovsdb connection is configured (e.g. tcp:ip:port), use it,
# and there is no need to run as root
helpers.enable_connection_uri(ovsdb_connection)
cmd = ['ovsdb-client', 'monitor', ovsdb_connection, table_name]
run_as_root = False
else:

View File

@ -16,11 +16,16 @@ import mock
from neutron.agent.common import ovs_lib
from neutron.agent.linux import ovsdb_monitor
from neutron.agent.ovsdb.native import helpers
from neutron.tests import base
class TestOvsdbMonitor(base.BaseTestCase):
def setUp(self):
super(TestOvsdbMonitor, self).setUp()
mock.patch.object(helpers, 'enable_connection_uri').start()
def test___init__(self):
ovsdb_monitor.OvsdbMonitor('Interface')

View File

@ -16,11 +16,16 @@ import mock
from neutron.agent.common import base_polling
from neutron.agent.linux import polling
from neutron.agent.ovsdb.native import helpers
from neutron.tests import base
class TestGetPollingManager(base.BaseTestCase):
def setUp(self):
super(TestGetPollingManager, self).setUp()
mock.patch.object(helpers, 'enable_connection_uri').start()
def test_return_always_poll_by_default(self):
with polling.get_polling_manager() as pm:
self.assertEqual(pm.__class__, base_polling.AlwaysPoll)
@ -40,6 +45,7 @@ class TestInterfacePollingMinimizer(base.BaseTestCase):
def setUp(self):
super(TestInterfacePollingMinimizer, self).setUp()
mock.patch.object(helpers, 'enable_connection_uri').start()
self.pm = polling.InterfacePollingMinimizer()
def test_start_calls_monitor_start(self):

View File

@ -113,6 +113,8 @@ class TestOvsNeutronAgent(object):
cfg.CONF.set_default('quitting_rpc_timeout', 10, 'AGENT')
cfg.CONF.set_default('prevent_arp_spoofing', False, 'AGENT')
cfg.CONF.set_default('local_ip', '127.0.0.1', 'OVS')
mock.patch(
'neutron.agent.ovsdb.native.helpers.enable_connection_uri').start()
mock.patch(
'neutron.agent.common.ovs_lib.OVSBridge.get_ports_attributes',
return_value=[]).start()