Merge "Remove re-typing lists to sets at initialization"
This commit is contained in:
commit
e65c0a88ab
@ -142,20 +142,20 @@ class NBOVNBGPDriver(driver_api.AgentDriverBase):
|
||||
self._post_start_event.set()
|
||||
|
||||
def _get_events(self):
|
||||
events = set(["LogicalSwitchPortProviderCreateEvent",
|
||||
"LogicalSwitchPortProviderDeleteEvent",
|
||||
"LogicalSwitchPortFIPCreateEvent",
|
||||
"LogicalSwitchPortFIPDeleteEvent",
|
||||
"LocalnetCreateDeleteEvent",
|
||||
"OVNLBCreateEvent",
|
||||
"OVNLBDeleteEvent"])
|
||||
events = {"LogicalSwitchPortProviderCreateEvent",
|
||||
"LogicalSwitchPortProviderDeleteEvent",
|
||||
"LogicalSwitchPortFIPCreateEvent",
|
||||
"LogicalSwitchPortFIPDeleteEvent",
|
||||
"LocalnetCreateDeleteEvent",
|
||||
"OVNLBCreateEvent",
|
||||
"OVNLBDeleteEvent"}
|
||||
if self._expose_tenant_networks:
|
||||
events.update(["ChassisRedirectCreateEvent",
|
||||
events.update({"ChassisRedirectCreateEvent",
|
||||
"ChassisRedirectDeleteEvent",
|
||||
"LogicalSwitchPortSubnetAttachEvent",
|
||||
"LogicalSwitchPortSubnetDetachEvent",
|
||||
"LogicalSwitchPortTenantCreateEvent",
|
||||
"LogicalSwitchPortTenantDeleteEvent"])
|
||||
"LogicalSwitchPortTenantDeleteEvent"})
|
||||
return events
|
||||
|
||||
@lockutils.synchronized('nbbgp')
|
||||
|
@ -99,16 +99,15 @@ class OVNEVPNDriver(driver_api.AgentDriverBase):
|
||||
self._post_fork_event.set()
|
||||
|
||||
def _get_events(self):
|
||||
events = set(["PortBindingChassisCreatedEvent",
|
||||
"PortBindingChassisDeletedEvent",
|
||||
"SubnetRouterAttachedEvent",
|
||||
"SubnetRouterDetachedEvent",
|
||||
"TenantPortCreatedEvent",
|
||||
"TenantPortDeletedEvent",
|
||||
"ChassisCreateEvent",
|
||||
"ChassisPrivateCreateEvent",
|
||||
"LocalnetCreateDeleteEvent"])
|
||||
return events
|
||||
return {"PortBindingChassisCreatedEvent",
|
||||
"PortBindingChassisDeletedEvent",
|
||||
"SubnetRouterAttachedEvent",
|
||||
"SubnetRouterDetachedEvent",
|
||||
"TenantPortCreatedEvent",
|
||||
"TenantPortDeletedEvent",
|
||||
"ChassisCreateEvent",
|
||||
"ChassisPrivateCreateEvent",
|
||||
"LocalnetCreateDeleteEvent"}
|
||||
|
||||
@lockutils.synchronized('evpn')
|
||||
def frr_sync(self):
|
||||
|
@ -59,7 +59,7 @@ def _ensure_base_wiring_config_underlay(idl, ovs_idl, routing_tables):
|
||||
vlan_tags)
|
||||
if not flows_info.get(bridge):
|
||||
mac = linux_net.get_interface_address(bridge)
|
||||
flows_info[bridge] = {'mac': mac, 'in_port': set([])}
|
||||
flows_info[bridge] = {'mac': mac, 'in_port': set()}
|
||||
flows_info[bridge]['in_port'] = ovs.get_ovs_patch_ports_info(
|
||||
bridge)
|
||||
ovs.ensure_mac_tweak_flows(bridge, mac,
|
||||
@ -107,7 +107,7 @@ def _ensure_base_wiring_config_ovn(ovs_idl, ovn_idl):
|
||||
|
||||
if not flows_info.get(bridge):
|
||||
mac = linux_net.get_interface_address(bridge)
|
||||
flows_info[bridge] = {'mac': mac, 'in_port': set([])}
|
||||
flows_info[bridge] = {'mac': mac, 'in_port': set()}
|
||||
flows_info[bridge]['in_port'] = ovs.get_ovs_patch_ports_info(
|
||||
bridge)
|
||||
_ensure_egress_flows(bridge, flows_info[bridge]['in_port'])
|
||||
|
@ -2272,7 +2272,7 @@ class TestOVNBGPDriver(test_base.TestCase):
|
||||
|
||||
@mock.patch.object(driver_utils, 'get_addr_scopes')
|
||||
def test__address_scope_allowed(self, m_addr_scopes):
|
||||
self.bgp_driver.allowed_address_scopes = set(["fake_address_scope"])
|
||||
self.bgp_driver.allowed_address_scopes = {"fake_address_scope"}
|
||||
port_ip = self.ipv4
|
||||
port_name = "fake-port"
|
||||
sb_port = "fake-sb-port"
|
||||
@ -2288,7 +2288,7 @@ class TestOVNBGPDriver(test_base.TestCase):
|
||||
m_addr_scopes.assert_called_once_with(sb_port)
|
||||
|
||||
def test__address_scope_allowed_not_configured(self):
|
||||
self.bgp_driver.allowed_address_scopes = set([])
|
||||
self.bgp_driver.allowed_address_scopes = set()
|
||||
port_ip = self.ipv4
|
||||
port_name = "fake-port"
|
||||
sb_port = "fake-sb-port"
|
||||
@ -2300,7 +2300,7 @@ class TestOVNBGPDriver(test_base.TestCase):
|
||||
|
||||
@mock.patch.object(driver_utils, 'get_addr_scopes')
|
||||
def test__address_scope_allowed_no_match(self, m_addr_scopes):
|
||||
self.bgp_driver.allowed_address_scopes = set(["fake_address_scope"])
|
||||
self.bgp_driver.allowed_address_scopes = {"fake_address_scope"}
|
||||
port_ip = self.ipv4
|
||||
port_name = "fake-port"
|
||||
sb_port = "fake-sb-port"
|
||||
@ -2317,7 +2317,7 @@ class TestOVNBGPDriver(test_base.TestCase):
|
||||
|
||||
@mock.patch.object(driver_utils, 'get_addr_scopes')
|
||||
def test__address_scope_allowed_no_port(self, m_addr_scopes):
|
||||
self.bgp_driver.allowed_address_scopes = set(["fake_address_scope"])
|
||||
self.bgp_driver.allowed_address_scopes = {"fake_address_scope"}
|
||||
port_ip = self.ipv4
|
||||
port_name = "fake-port"
|
||||
self.sb_idl.get_port_by_name.return_value = []
|
||||
@ -2329,7 +2329,7 @@ class TestOVNBGPDriver(test_base.TestCase):
|
||||
|
||||
@mock.patch.object(driver_utils, 'get_addr_scopes')
|
||||
def test__address_scope_allowed_no_address_scope(self, m_addr_scopes):
|
||||
self.bgp_driver.allowed_address_scopes = set(["fake_address_scope"])
|
||||
self.bgp_driver.allowed_address_scopes = {"fake_address_scope"}
|
||||
port_ip = self.ipv4
|
||||
port_name = "fake-port"
|
||||
sb_port = "fake-sb-port"
|
||||
|
@ -610,7 +610,7 @@ class TestOVNBGPStretchedL2Driver(test_base.TestCase):
|
||||
}
|
||||
self.bgp_driver.ovn_local_cr_lrps = {
|
||||
self.cr_lrp0.logical_port: {
|
||||
"lrp_ports": set([row.logical_port, "another_lrp_port"])
|
||||
"lrp_ports": {row.logical_port, "another_lrp_port"}
|
||||
}
|
||||
}
|
||||
|
||||
@ -629,7 +629,7 @@ class TestOVNBGPStretchedL2Driver(test_base.TestCase):
|
||||
self.bgp_driver.ovn_local_cr_lrps,
|
||||
{
|
||||
self.cr_lrp0.logical_port: {
|
||||
"lrp_ports": set(["another_lrp_port"])
|
||||
"lrp_ports": {"another_lrp_port"}
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -879,7 +879,7 @@ class TestOVNBGPStretchedL2Driver(test_base.TestCase):
|
||||
for ip in ["10.0.0.10/26", "fd51:f4b3:872:eda::10/64"]
|
||||
]
|
||||
gateway["address_scopes"] = self.addr_scope
|
||||
gateway["lrp_ports"] = set([""])
|
||||
gateway["lrp_ports"] = {""}
|
||||
self.bgp_driver.ovn_local_cr_lrps = {"gateway_port": gateway}
|
||||
port_info = {
|
||||
"cr_lrp": self.cr_lrp0.logical_port,
|
||||
@ -1020,23 +1020,23 @@ class TestOVNBGPStretchedL2Driver(test_base.TestCase):
|
||||
self.bgp_driver.ovn_local_cr_lrps = {
|
||||
self.cr_lrp0.logical_port: gateway
|
||||
}
|
||||
gateway["lrp_ports"] = set([
|
||||
gateway["lrp_ports"] = {
|
||||
"lrp-lrp_port0",
|
||||
"lrp-lrp_port1",
|
||||
"lrp-lrp_port2",
|
||||
])
|
||||
}
|
||||
|
||||
lrp_port0 = {
|
||||
"cr_lrp": self.cr_lrp0.logical_port,
|
||||
"subnets": set([
|
||||
"subnets": {
|
||||
"fdcc:8cf2:d40c:1::/64",
|
||||
"192.168.0.0/24"])
|
||||
"192.168.0.0/24"}
|
||||
}
|
||||
lrp_port1 = {
|
||||
"cr_lrp": self.cr_lrp0.logical_port,
|
||||
"subnets": set([
|
||||
"subnets": {
|
||||
"fdcc:8cf2:d40c:2::/64",
|
||||
"192.168.1.0/24"])
|
||||
"192.168.1.0/24"}
|
||||
}
|
||||
|
||||
self.bgp_driver.propagated_lrp_ports = {
|
||||
@ -1075,11 +1075,11 @@ class TestOVNBGPStretchedL2Driver(test_base.TestCase):
|
||||
constants.IP_VERSION_6: '',
|
||||
}
|
||||
}
|
||||
gateway["lrp_ports"] = set([
|
||||
gateway["lrp_ports"] = {
|
||||
"lrp-lrp_port0",
|
||||
"lrp-lrp_port1",
|
||||
"lrp-lrp_port2",
|
||||
])
|
||||
}
|
||||
self.bgp_driver.propagated_lrp_ports = {
|
||||
"lrp-lrp_port0": {},
|
||||
"lrp-lrp_port1": {},
|
||||
|
@ -182,9 +182,8 @@ def ensure_routing_table_for_bridge(ovn_routing_tables, bridge, vrf_table):
|
||||
# pick a number between 1 and 252
|
||||
try:
|
||||
table_number = random.choice(list(
|
||||
set([x for x in range(1, 253)
|
||||
if x != int(vrf_table)]).difference(
|
||||
set(existing_routes))))
|
||||
{x for x in range(1, 253) if x != int(vrf_table)}.difference(
|
||||
set(existing_routes))))
|
||||
except IndexError:
|
||||
LOG.error("No more routing tables available for bridge %s "
|
||||
"at /etc/iproute2/rt_tables", bridge)
|
||||
@ -211,12 +210,10 @@ def _ensure_routing_table_routes(ovn_routing_tables, bridge):
|
||||
bridge_idx = get_interface_index(bridge)
|
||||
|
||||
with pyroute2.IPRoute() as ip:
|
||||
table_route_dsts = set(
|
||||
[
|
||||
(r.get_attr('RTA_DST'), r['dst_len'])
|
||||
for r in ip.get_routes(table=ovn_routing_tables[bridge])
|
||||
]
|
||||
)
|
||||
table_route_dsts = {
|
||||
(r.get_attr('RTA_DST'), r['dst_len'])
|
||||
for r in ip.get_routes(table=ovn_routing_tables[bridge])
|
||||
}
|
||||
|
||||
if not table_route_dsts:
|
||||
r1 = {'dst': 'default', 'oif': bridge_idx,
|
||||
@ -296,12 +293,10 @@ def get_extra_routing_table_for_bridge(ovn_routing_tables, bridge):
|
||||
extra_routes = []
|
||||
bridge_idx = get_interface_index(bridge)
|
||||
with pyroute2.IPRoute() as ip:
|
||||
table_route_dsts = set(
|
||||
[
|
||||
(r.get_attr('RTA_DST'), r['dst_len'])
|
||||
for r in ip.get_routes(table=ovn_routing_tables[bridge])
|
||||
]
|
||||
)
|
||||
table_route_dsts = {
|
||||
(r.get_attr('RTA_DST'), r['dst_len'])
|
||||
for r in ip.get_routes(table=ovn_routing_tables[bridge])
|
||||
}
|
||||
|
||||
if not table_route_dsts:
|
||||
return extra_routes
|
||||
|
Loading…
Reference in New Issue
Block a user