From 0fc80fd9722c02766f691a8f23402a2488fda678 Mon Sep 17 00:00:00 2001 From: Laura Nguyen Date: Tue, 24 Aug 2021 18:37:27 -0400 Subject: [PATCH] Created Ceph mirror status checker --- ceph.py | 21 +++++++++++++++++++++ main.py | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ceph.py diff --git a/ceph.py b/ceph.py new file mode 100644 index 0000000..fe8f28b --- /dev/null +++ b/ceph.py @@ -0,0 +1,21 @@ +""" +Contains Ceph class +""" + +from distro import Distro +from shared import CSC_MIRROR, get_sec + +class Ceph(Distro): + """Ceph class""" + @staticmethod + def name(): + """Get name of Ceph""" + return "Ceph" + + @staticmethod + def check(): + """Check if Ceph packages are up-to-date""" + official_sec = get_sec("https://download.ceph.com/timestamp") + csc_sec = get_sec(f"{CSC_MIRROR}ceph/timestamp") + # Out-of-sync by 1 day maximum + return official_sec < csc_sec + 86400 diff --git a/main.py b/main.py index 9d71151..5172d61 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,7 @@ This mirror status checker determines whether CSC mirror is up-to-date with upst import requests from arch import Arch +from ceph import Ceph from debian import Debian from eclipse import Eclipse from gnu import GNU @@ -13,7 +14,7 @@ from kernel import Kernel from openbsd import OpenBSD if __name__ == "__main__": - for distro in [Arch, Debian, Eclipse, GNU, Kernel, OpenBSD]: + for distro in [Arch, Ceph, Debian, Eclipse, GNU, Kernel, OpenBSD]: try: distro.print_output(distro.check()) except requests.exceptions.RequestException as err: