Linux Bridge, remove unnecessary logic to retrieve bridge name

In [1], the function "get_existing_bridge_name" retrieves the value of a
dict using the method get. Before this, it checks if the key value used is
"True". This check is not needed using the dictionary "get" method.

[1] https://github.com/openstack/neutron/blob/11.0.0.0rc3/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py#L155

Change-Id: Iba020c6b297228ae48bbd2a19f540b0152570317
Closes-Bug: #1719275
This commit is contained in:
Rodolfo Alonso Hernandez 2017-09-25 10:27:40 +01:00 committed by garyk
parent 0376f8fbf2
commit bb550de3d7
2 changed files with 4 additions and 9 deletions

View File

@ -152,11 +152,6 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
sys.exit(1)
return device
def get_existing_bridge_name(self, physical_network):
if not physical_network:
return None
return self.bridge_mappings.get(physical_network)
@staticmethod
def get_bridge_name(network_id):
if not network_id:
@ -463,7 +458,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
return self.ensure_vxlan_bridge(network_id, segmentation_id)
# NOTE(nick-ma-z): Obtain mappings of physical bridge and interfaces
physical_bridge = self.get_existing_bridge_name(physical_network)
physical_bridge = self.bridge_mappings.get(physical_network)
physical_interface = self.interface_mappings.get(physical_network)
if not physical_bridge and not physical_interface:
LOG.error("No bridge or interface mappings"
@ -510,7 +505,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
"this host, skipped", tap_device_name)
return False
bridge_name = self.get_existing_bridge_name(physical_network)
bridge_name = self.bridge_mappings.get(physical_network)
if not bridge_name:
bridge_name = self.get_bridge_name(network_id)

View File

@ -163,10 +163,10 @@ class TestLinuxBridgeManager(base.BaseTestCase):
def test_get_existing_bridge_name(self):
phy_net = 'physnet0'
self.assertEqual('br-eth2',
self.lbm.get_existing_bridge_name(phy_net))
self.lbm.bridge_mappings.get(phy_net))
phy_net = ''
self.assertIsNone(self.lbm.get_existing_bridge_name(phy_net))
self.assertIsNone(self.lbm.bridge_mappings.get(phy_net))
def test_get_bridge_name(self):
nw_id = "123456789101112"