]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
l3-agent: move check if ext-net bridge exists within daemon loop
authorDan Wendlandt <dan@nicira.com>
Fri, 21 Sep 2012 06:52:52 +0000 (23:52 -0700)
committerDan Wendlandt <dan@nicira.com>
Fri, 21 Sep 2012 06:52:52 +0000 (23:52 -0700)
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
quantum/tests/unit/test_l3_agent.py

index 5527ea12c67e539d855b1a50afcd1c71d5dcffce..0630824dfa34c8af6b8589e97c8234724645e772 100644 (file)
@@ -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()
 
index 810b6edf066a689efc555baba5fc01a081592361..f7383c3453be7f3997fb6fb768a377282ee3f642 100644 (file)
@@ -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()