summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-19 21:54:56 +0000
committerGerrit Code Review <review@openstack.org>2017-06-19 21:54:56 +0000
commitc4fd0317a322b23255d509181c11e3474ed2ce1d (patch)
tree9c657f99d5403dda5c03c429c31a7f0395aa7845
parent6af12de193dc619c491c8534970ebc00bae6e653 (diff)
parentba5e8468599d5edfa0dad68457739fa03237b16a (diff)
Merge "Linuxbridge agent: detect existing IP on bridge"
-rw-r--r--neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py5
-rw-r--r--neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py14
2 files changed, 17 insertions, 2 deletions
diff --git a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
index c536f8f..61e2b6f 100644
--- a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
+++ b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
@@ -355,7 +355,10 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
355 # Append IP's to bridge if necessary 355 # Append IP's to bridge if necessary
356 if ips: 356 if ips:
357 for ip in ips: 357 for ip in ips:
358 dst_device.addr.add(cidr=ip['cidr']) 358 # If bridge ip address already exists, then don't add
359 # otherwise will report error
360 if not dst_device.addr.list(to=ip['cidr']):
361 dst_device.addr.add(cidr=ip['cidr'])
359 362
360 if gateway: 363 if gateway:
361 # Ensure that the gateway can be updated by changing the metric 364 # Ensure that the gateway can be updated by changing the metric
diff --git a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py
index b44f486..ede6dc9 100644
--- a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py
+++ b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py
@@ -415,7 +415,19 @@ class TestLinuxBridgeManager(base.BaseTestCase):
415 ip_version=4, 415 ip_version=4,
416 dynamic=False) 416 dynamic=False)
417 with mock.patch.object(ip_lib.IpAddrCommand, 'add') as add_fn,\ 417 with mock.patch.object(ip_lib.IpAddrCommand, 'add') as add_fn,\
418 mock.patch.object(ip_lib.IpAddrCommand, 'delete') as del_fn: 418 mock.patch.object(ip_lib.IpAddrCommand, 'delete') as del_fn,\
419 mock.patch.object(ip_lib.IpAddrCommand, 'list') as list_fn:
420 # 'list' actually returns a dict, but we're only simulating
421 # whether the device exists or not
422 list_fn.side_effect = [True, False]
423
424 self.lbm._update_interface_ip_details("br0", "eth0",
425 [ipdict], None)
426 self.assertFalse(add_fn.called)
427 self.assertTrue(del_fn.called)
428
429 add_fn.reset_mock()
430 del_fn.reset_mock()
419 self.lbm._update_interface_ip_details("br0", "eth0", 431 self.lbm._update_interface_ip_details("br0", "eth0",
420 [ipdict], None) 432 [ipdict], None)
421 self.assertTrue(add_fn.called) 433 self.assertTrue(add_fn.called)