From ea276a8e5bd5eee99b411250bb881da6be97e144 Mon Sep 17 00:00:00 2001 From: Sheppy Date: Wed, 11 Jan 2023 04:21:45 +0100 Subject: [PATCH] fix: ensure consistent ordering --- icinga.py | 2 +- vm.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/icinga.py b/icinga.py index 015ddef..024294a 100644 --- a/icinga.py +++ b/icinga.py @@ -4,7 +4,7 @@ environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./te def createMasterHostConfig(vmList): template = environment.get_template("icinga_host.conf.j2") with open("ansible/files/icinga_master_hosts.conf", "w") as f: - for vmo in set(vmList): + for vmo in sorted(list(set(vmList))): if not vmo.check: continue diff --git a/vm.py b/vm.py index c6f1e42..1db9023 100644 --- a/vm.py +++ b/vm.py @@ -47,6 +47,10 @@ class VM: def __eq__(self, other): return self.hostname == other.hostname + def __gt__(self, other): + if self.hostname != other.hostname: + return self.hostname > other.hostname + return len(str(self.__dict__)) > len(str(other.__dict__)) def dumpStreamComponents(self):