Add protection from tailing spaces on mac field
Change-Id: I42c5c92b7aaa350995441a74b9e441d3dbc0cdf3
This commit is contained in:
parent
00749e404d
commit
f2b4eeef68
|
@ -291,9 +291,9 @@ class OVNBGPDriver(driver_api.AgentDriverBase):
|
|||
"removed", port.logical_port, port.datapath)
|
||||
return
|
||||
else:
|
||||
if len(port.mac[0].split(' ')) < 2:
|
||||
if len(port.mac[0].strip().split(' ')) < 2:
|
||||
return
|
||||
port_ips = port.mac[0].split(' ')[1:]
|
||||
port_ips = port.mac[0].strip().split(' ')[1:]
|
||||
|
||||
ips_adv = self._expose_ip(port_ips, port)
|
||||
|
||||
|
@ -486,7 +486,7 @@ class OVNBGPDriver(driver_api.AgentDriverBase):
|
|||
n_cidrs = port.external_ids.get(constants.OVN_CIDRS_EXT_ID_KEY)
|
||||
port_ips = [ip.split("/")[0] for ip in n_cidrs.split(" ")]
|
||||
else:
|
||||
port_ips = port.mac[0].split(' ')[1:]
|
||||
port_ips = port.mac[0].strip().split(' ')[1:]
|
||||
except IndexError:
|
||||
return
|
||||
|
||||
|
@ -683,7 +683,7 @@ class OVNBGPDriver(driver_api.AgentDriverBase):
|
|||
|
||||
bridge_device, bridge_vlan = self._get_bridge_for_datapath(
|
||||
cr_lrp_datapath)
|
||||
mac = row.mac[0].split(' ')[0]
|
||||
mac = row.mac[0].strip().split(' ')[0]
|
||||
# Keeping information about the associated network for
|
||||
# tenant network advertisement
|
||||
self.ovn_local_cr_lrps[row.logical_port] = {
|
||||
|
@ -802,7 +802,7 @@ class OVNBGPDriver(driver_api.AgentDriverBase):
|
|||
'bridge_vlan')
|
||||
bridge_device = self.ovn_local_cr_lrps[row.logical_port].get(
|
||||
'bridge_device')
|
||||
mac = row.mac[0].split(' ')[0]
|
||||
mac = row.mac[0].strip().split(' ')[0]
|
||||
self._withdraw_cr_lrp_port(ips, mac, bridge_device, bridge_vlan,
|
||||
provider_datapath=cr_lrp_datapath,
|
||||
cr_lrp_port=row.logical_port)
|
||||
|
@ -902,7 +902,7 @@ class OVNBGPDriver(driver_api.AgentDriverBase):
|
|||
# add missing route/ips for tenant network VMs
|
||||
if self._expose_tenant_networks:
|
||||
try:
|
||||
lrp_ip = lrp.mac[0].split(' ')[1]
|
||||
lrp_ip = lrp.mac[0].strip().split(' ')[1]
|
||||
except IndexError:
|
||||
# This should not happen: subnet without CIDR
|
||||
return
|
||||
|
|
|
@ -146,7 +146,7 @@ class OVNEVPNDriver(driver_api.AgentDriverBase):
|
|||
|
||||
gateway_ips = [ip.split('/')[0] for ip in gateway['ips']]
|
||||
try:
|
||||
router_port_ip = router_port.mac[0].split(' ')[1]
|
||||
router_port_ip = router_port.mac[0].strip().split(' ')[1]
|
||||
except IndexError:
|
||||
return
|
||||
router_ip = router_port_ip.split('/')[0]
|
||||
|
@ -203,9 +203,9 @@ class OVNEVPNDriver(driver_api.AgentDriverBase):
|
|||
if not cr_lrp_datapath:
|
||||
return
|
||||
|
||||
if len(cr_lrp_port.mac[0].split(' ')) < 2:
|
||||
if len(cr_lrp_port.mac[0].strip().split(' ')) < 2:
|
||||
return
|
||||
ips = cr_lrp_port.mac[0].split(' ')[1:]
|
||||
ips = cr_lrp_port.mac[0].strip().split(' ')[1:]
|
||||
|
||||
if cr_lrp:
|
||||
evpn_info = self.sb_idl.get_evpn_info_from_port_name(
|
||||
|
@ -232,7 +232,7 @@ class OVNEVPNDriver(driver_api.AgentDriverBase):
|
|||
'router_datapath': cr_lrp_port.datapath,
|
||||
'provider_datapath': cr_lrp_datapath,
|
||||
'ips': ips,
|
||||
'mac': cr_lrp_port.mac[0].split(' ')[0],
|
||||
'mac': cr_lrp_port.mac[0].strip().split(' ')[0],
|
||||
'vni': int(evpn_info['vni']),
|
||||
'bgp_as': evpn_info['bgp_as'],
|
||||
'lo': evpn_devices.lo_name,
|
||||
|
@ -478,7 +478,7 @@ class OVNEVPNDriver(driver_api.AgentDriverBase):
|
|||
not port.chassis)):
|
||||
continue
|
||||
try:
|
||||
port_ips = port.mac[0].split(' ')[1:]
|
||||
port_ips = port.mac[0].strip().split(' ')[1:]
|
||||
except IndexError:
|
||||
continue
|
||||
|
||||
|
|
|
@ -146,10 +146,12 @@ class OVNBGPStretchedL2Driver(driver_api.AgentDriverBase):
|
|||
vrf_routes = linux_net.get_routes_on_tables([CONF.bgp_vrf_table_id])
|
||||
|
||||
for cr_lrp_port in self.sb_idl.get_cr_lrp_ports():
|
||||
if not cr_lrp_port.mac or len(cr_lrp_port.mac[0].split(" ")) <= 1:
|
||||
if (not cr_lrp_port.mac or
|
||||
len(cr_lrp_port.mac[0].strip().split(" ")) <= 1):
|
||||
continue
|
||||
|
||||
self._expose_cr_lrp(cr_lrp_port.mac[0].split(" ")[1:], cr_lrp_port)
|
||||
self._expose_cr_lrp(cr_lrp_port.mac[0].strip().split(" ")[1:],
|
||||
cr_lrp_port)
|
||||
|
||||
# remove all left over routes
|
||||
delete_routes = []
|
||||
|
@ -232,13 +234,14 @@ class OVNBGPStretchedL2Driver(driver_api.AgentDriverBase):
|
|||
@lockutils.synchronized("bgp")
|
||||
def update_subnet(self, old, row):
|
||||
cr_lrp = self.sb_idl.is_router_gateway_on_any_chassis(row.datapath)
|
||||
if not cr_lrp or not cr_lrp.mac or len(cr_lrp.mac[0].split(" ")) <= 1:
|
||||
if (not cr_lrp or not cr_lrp.mac or
|
||||
len(cr_lrp.mac[0].strip().split(" ")) <= 1):
|
||||
return
|
||||
|
||||
current_ips = row.mac[0].split(" ")[1:]
|
||||
current_ips = row.mac[0].strip().split(" ")[1:]
|
||||
previous_ips = (
|
||||
old.mac[0].split(" ")[1:]
|
||||
if old.mac or len(old.mac[0].split(" ")) > 1
|
||||
old.mac[0].strip().split(" ")[1:]
|
||||
if old.mac or len(old.mac[0].strip().split(" ")) > 1
|
||||
else []
|
||||
)
|
||||
add_ips = list(
|
||||
|
@ -378,7 +381,8 @@ class OVNBGPStretchedL2Driver(driver_api.AgentDriverBase):
|
|||
# function can fix.
|
||||
return
|
||||
gateway_ips = gateway["ips"]
|
||||
if not router_port.mac or len(router_port.mac[0].split(" ")) <= 1:
|
||||
if (not router_port.mac or
|
||||
len(router_port.mac[0].strip().split(" ")) <= 1):
|
||||
return
|
||||
|
||||
# get all ips from the router port
|
||||
|
@ -473,13 +477,14 @@ class OVNBGPStretchedL2Driver(driver_api.AgentDriverBase):
|
|||
# function can fix.
|
||||
return
|
||||
gateway_ips = gateway["ips"]
|
||||
if not router_port.mac or len(router_port.mac[0].split(" ")) <= 1:
|
||||
if (not router_port.mac or
|
||||
len(router_port.mac[0].strip().split(" ")) <= 1):
|
||||
return
|
||||
|
||||
# get all ips from the router port
|
||||
router_ips = [
|
||||
ipaddress.ip_interface(ip)
|
||||
for ip in router_port.mac[0].split(" ")[1:]]
|
||||
for ip in router_port.mac[0].strip().split(" ")[1:]]
|
||||
|
||||
for router_ip in router_ips:
|
||||
if router_ip in gateway_ips:
|
||||
|
|
|
@ -24,7 +24,7 @@ class PortBindingChassisEvent(row_event.RowEvent):
|
|||
self.event_name = self.__class__.__name__
|
||||
|
||||
def _check_ip_associated(self, mac):
|
||||
return len(mac.split(' ')) > 1
|
||||
return len(mac.strip().split(' ')) > 1
|
||||
|
||||
|
||||
class OVNLBMemberEvent(row_event.RowEvent):
|
||||
|
|
|
@ -100,12 +100,12 @@ class FIPSetEvent(base_watcher.PortBindingChassisEvent):
|
|||
# cr-lrp-add962d2-21ab-4733-b6ef-35538eff25a8\")"]
|
||||
old_cr_lrps = {}
|
||||
for nat in old.nat_addresses:
|
||||
ips = nat.split(" ")[1:-1]
|
||||
port = nat.split(" ")[-1].split("\"")[1]
|
||||
ips = nat.strip().split(" ")[1:-1]
|
||||
port = nat.strip().split(" ")[-1].split("\"")[1]
|
||||
old_cr_lrps.setdefault(port, set()).update(ips)
|
||||
for nat in row.nat_addresses:
|
||||
ips = nat.split(" ")[1:-1]
|
||||
port = nat.split(" ")[-1].split("\"")[1]
|
||||
ips = nat.strip().split(" ")[1:-1]
|
||||
port = nat.strip().split(" ")[-1].split("\"")[1]
|
||||
ips_to_expose = [ip for ip in ips
|
||||
if ip not in old_cr_lrps.get(port, set())]
|
||||
if ips_to_expose:
|
||||
|
@ -138,12 +138,12 @@ class FIPUnsetEvent(base_watcher.PortBindingChassisEvent):
|
|||
# cr-lrp-add962d2-21ab-4733-b6ef-35538eff25a8\")"]
|
||||
current_cr_lrps = {}
|
||||
for nat in row.nat_addresses:
|
||||
ips = nat.split(" ")[1:-1]
|
||||
port = nat.split(" ")[-1].split("\"")[1]
|
||||
ips = nat.strip().split(" ")[1:-1]
|
||||
port = nat.strip().split(" ")[-1].split("\"")[1]
|
||||
current_cr_lrps.setdefault(port, set()).update(ips)
|
||||
for nat in old.nat_addresses:
|
||||
ips = nat.split(" ")[1:-1]
|
||||
port = nat.split(" ")[-1].split("\"")[1]
|
||||
ips = nat.strip().split(" ")[1:-1]
|
||||
port = nat.strip().split(" ")[-1].split("\"")[1]
|
||||
ips_to_withdraw = [ip for ip in ips
|
||||
if ip not in current_cr_lrps.get(port,
|
||||
set())]
|
||||
|
@ -346,7 +346,7 @@ class OVNLBVIPPortEvent(base_watcher.PortBindingChassisEvent):
|
|||
if not ext_n_cidr:
|
||||
return
|
||||
|
||||
ovn_lb_ip = ext_n_cidr.split(" ")[0].split("/")[0]
|
||||
ovn_lb_ip = ext_n_cidr.strip().split(" ")[0].split("/")[0]
|
||||
if event == self.ROW_DELETE:
|
||||
self.agent.withdraw_ovn_lb(ovn_lb_ip, row)
|
||||
if event == self.ROW_CREATE:
|
||||
|
@ -425,7 +425,7 @@ class OVNLBMemberCreateDeleteEvent(base_watcher.OVNLBMemberEvent):
|
|||
constants.OVN_CIDRS_EXT_ID_KEY)
|
||||
if not vip_ip:
|
||||
return
|
||||
vip_ip = vip_ip.split(" ")[0].split("/")[0]
|
||||
vip_ip = vip_ip.strip().split(" ")[0].split("/")[0]
|
||||
return self.agent.expose_ovn_lb_on_provider(
|
||||
vip_ip, vip_port.logical_port, associated_cr_lrp_port)
|
||||
|
||||
|
|
Loading…
Reference in New Issue