From 29be660d216e9c116f6d11a1a01e65d07b4e3882 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Mon, 4 Nov 2019 12:51:52 +0100 Subject: [PATCH] Ticket #216: make Server class comparable Fix "TypeError: '<' not supported between instances of 'Server' and 'Server'" class of error: File ".../Shine/Lustre/Component.py", line 424, in groupbyallservers sortlist = sorted(srvcomps, key=itemgetter(0)) TypeError: '<' not supported between instances of 'Server' and 'Server' --- lib/Shine/Lustre/Server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Shine/Lustre/Server.py b/lib/Shine/Lustre/Server.py index e4310a6..d543cea 100644 --- a/lib/Shine/Lustre/Server.py +++ b/lib/Shine/Lustre/Server.py @@ -93,6 +93,10 @@ def __init__(self, hostname, nids, hdlr=None): def __str__(self): return "%s (%s)" % (self.hostname, ','.join(self.nids)) + def __lt__(self, other): + # Cast hostname into str until NodeSet is sortable + return (str(self.hostname), self.nids) < (str(other.hostname), self.nids) + @classmethod def hostname_long(cls): """