Module: check_mk
Branch: master
Commit: b745d5434be1e6628b7ed34cec563d7f89f58c42
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b745d5434be1e6…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri May 11 00:01:05 2012 +0200
WATO: sort_sites, improved sort function
---
web/htdocs/wato.py | 17 +++--------------
1 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 2c44274..08058c1 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -6027,20 +6027,9 @@ def find_usage_of_timeperiod(tpname):
# Sort given sites argument by peer/local, followed by slaves
def sort_sites(sites):
def custom_sort(a,b):
- if a[1].get("replication","peer") ==
b[1].get("replication","peer"):
- # Compare by alias
- if a[1].get("alias") == b[1].get("alias"):
- return 0
- elif a[1].get("alias") > b[1].get("alias"):
- return 1
- else:
- return -1
- elif a[1].get("replication") == "slave" and
b[1].get("replication","peer") != "slave":
- return 1
- elif a[1].get("replication","peer") != "slave" and
b[1].get("replication") == "slave":
- return -1
- else:
- return 0
+ return cmp(a[1].get("replication","peer"),
b[1].get("replication","peer")) or \
+ -cmp(a[1].get("repl_priority",0),
b[1].get("repl_priority",0)) or \
+ cmp(a[1].get("alias"), b[1].get("alias"))
sites.sort(cmp = custom_sort)
def mode_sites(phase):