Skip to content

Commit

Permalink
Be resilient with broken response from swapExtIps
Browse files Browse the repository at this point in the history
  • Loading branch information
OdyX committed Jul 27, 2021
1 parent 93dec9f commit 2a6eab5
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions jelapi/classes/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,20 @@ def swap_ip_with(
sourceIP=sourceIP,
targetIP=targetIP,
)
try:
# Now fix the extIPs in both
self_node_response = next(
n for n in response["nodes"] if n["id"] == self.id
)
target_node_response = next(
n for n in response["nodes"] if n["id"] == target_node.id
)

# Now fix the extIPs in both
self_node_response = next(n for n in response["nodes"] if n["id"] == self.id)
target_node_response = next(
n for n in response["nodes"] if n["id"] == target_node.id
)

self._extIPs = self._extIPs_check_from_list(self_node_response["extIPs"])
target_node._extIPs = self._extIPs_check_from_list(
target_node_response["extIPs"]
)
self._extIPs = self._extIPs_check_from_list(self_node_response["extIPs"])
target_node._extIPs = self._extIPs_check_from_list(
target_node_response["extIPs"]
)
except KeyError as e:
raise JelasticObjectException(
f"response not in expected format (missing {','.join(e.args)})"
)

0 comments on commit 2a6eab5

Please sign in to comment.