From da1cf7c27014182033b86a156e829d096459d9f0 Mon Sep 17 00:00:00 2001 From: Dan Wendlandt Date: Thu, 20 Sep 2012 23:52:52 -0700 Subject: [PATCH] l3-agent: move check if ext-net bridge exists within daemon loop bug 1052522 the l3 agent checked if the external network bridge exists in its constructor, raising an uncaught exception if it did not. this does not make much sense when running the l3-agent as a deamon, especially since it can be the case that the l3-agent starts before open vswitch. Change-Id: Ie1717b2c02c9f0bc0caf34a6fdb0dc3a930123c0 --- quantum/agent/l3_agent.py | 12 +++++++----- quantum/tests/unit/test_l3_agent.py | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/quantum/agent/l3_agent.py b/quantum/agent/l3_agent.py index 5527ea12c..0630824df 100644 --- a/quantum/agent/l3_agent.py +++ b/quantum/agent/l3_agent.py @@ -117,11 +117,6 @@ class L3NATAgent(object): self.polling_interval = conf.polling_interval - if (self.conf.external_network_bridge and - not ip_lib.device_exists(self.conf.external_network_bridge)): - raise Exception("external network bridge '%s' does not exist" - % self.conf.external_network_bridge) - self.qclient = client.Client( username=self.conf.admin_user, password=self.conf.admin_password, @@ -193,6 +188,13 @@ class L3NATAgent(object): return ex_nets[0]['id'] def do_single_loop(self): + + if (self.conf.external_network_bridge and + not ip_lib.device_exists(self.conf.external_network_bridge)): + LOG.error("external network bridge '%s' does not exist" + % self.conf.external_network_bridge) + return + prev_router_ids = set(self.router_info) cur_router_ids = set() diff --git a/quantum/tests/unit/test_l3_agent.py b/quantum/tests/unit/test_l3_agent.py index 810b6edf0..f7383c345 100644 --- a/quantum/tests/unit/test_l3_agent.py +++ b/quantum/tests/unit/test_l3_agent.py @@ -81,9 +81,6 @@ class TestBasicRouterOperations(unittest.TestCase): def testAgentCreate(self): agent = l3_agent.L3NATAgent(self.conf) - self.device_exists.assert_has_calls( - [mock.call(self.conf.external_network_bridge)]) - def _test_internal_network_action(self, action): port_id = _uuid() router_id = _uuid() @@ -251,6 +248,9 @@ class TestBasicRouterOperations(unittest.TestCase): # verify that remove is called self.assertEquals(self.mock_ip.get_devices.call_count, 1) + self.device_exists.assert_has_calls( + [mock.call(self.conf.external_network_bridge)]) + def testDaemonLoop(self): # just take a pass through the loop, then raise on time.sleep() -- 2.45.2