|
|
83967c |
From 2b22a14a128b87214bfb1ece221274aac78ba81b Mon Sep 17 00:00:00 2001
|
|
|
83967c |
From: Reid Wahl <nrwahl@protonmail.com>
|
|
|
83967c |
Date: Tue, 18 Aug 2020 18:43:13 -0700
|
|
|
83967c |
Subject: [PATCH] gcp-vpc-move-vip: Fix sort for list of dicts in python3
|
|
|
83967c |
|
|
|
83967c |
python2 sorts a list of dicts of `{'ipCidrRange': <alias>}` correctly by
|
|
|
83967c |
default. python3 fails with a TypeError:
|
|
|
83967c |
|
|
|
83967c |
`TypeError: '<' not supported between instances of 'dict' and 'dict'`
|
|
|
83967c |
|
|
|
83967c |
Fix this by using the key parameter of sorted(). python2 also supports
|
|
|
83967c |
this.
|
|
|
83967c |
|
|
|
83967c |
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
|
|
|
83967c |
---
|
|
|
83967c |
heartbeat/gcp-vpc-move-vip.in | 3 ++-
|
|
|
83967c |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
83967c |
|
|
|
83967c |
diff --git a/heartbeat/gcp-vpc-move-vip.in b/heartbeat/gcp-vpc-move-vip.in
|
|
|
83967c |
index 85d59f6bb..01d91a59d 100755
|
|
|
83967c |
--- a/heartbeat/gcp-vpc-move-vip.in
|
|
|
83967c |
+++ b/heartbeat/gcp-vpc-move-vip.in
|
|
|
83967c |
@@ -200,7 +200,8 @@ def add_rm_alias(mode, project, zone, instance, alias, alias_range_name=None):
|
|
|
83967c |
else:
|
|
|
83967c |
raise ValueError('Invalid value for mode: {}'.format(mode))
|
|
|
83967c |
|
|
|
83967c |
- if (sorted(new_aliases) != sorted(old_aliases)):
|
|
|
83967c |
+ if (sorted(new_aliases, key=lambda item: item.get('ipCidrRange'))
|
|
|
83967c |
+ != sorted(old_aliases, key=lambda item: item.get('ipCidrRange'))):
|
|
|
83967c |
set_aliases(project, zone, instance, new_aliases, fingerprint)
|
|
|
83967c |
return True
|
|
|
83967c |
else:
|