Avoid KeyError exception

Change-Id: I7c25cf3c9d4da1d13a3b9c3e8a47d381883ca256
This commit is contained in:
Luis Tomas Bolivar 2022-03-09 15:45:33 +01:00
parent 34e4e3431f
commit 3940e9eb4a
1 changed files with 3 additions and 2 deletions

View File

@ -114,7 +114,7 @@ class FIPSetEvent(base_watcher.PortBindingChassisEvent):
ips = nat.split(" ")[1:-1]
port = nat.split(" ")[-1].split("\"")[1]
ips_to_expose = [ip for ip in ips
if ip not in old_cr_lrps[port]]
if ip not in old_cr_lrps.get(port, set())]
self.agent.expose_ip(ips_to_expose, row, associated_port=port)
@ -150,7 +150,8 @@ class FIPUnsetEvent(base_watcher.PortBindingChassisEvent):
ips = nat.split(" ")[1:-1]
port = nat.split(" ")[-1].split("\"")[1]
ips_to_withdraw = [ip for ip in ips
if ip not in current_cr_lrps[port]]
if ip not in current_cr_lrps.get(port,
set())]
self.agent.withdraw_ip(ips_to_withdraw, row,
associated_port=port)