diff options
| author | Loic Guegan <loic.guegan@mailbox.org> | 2023-10-26 14:39:46 +0200 |
|---|---|---|
| committer | Loic Guegan <loic.guegan@mailbox.org> | 2023-10-26 14:39:46 +0200 |
| commit | 3e670642781b33825eee01f17cf79906e1e20897 (patch) | |
| tree | 58f0b9bfa068acd50cdea27aa8dd25708aac6fb2 | |
| parent | 20d4f6f28fcaafe8b10bf82e5302180d6d3bc115 (diff) | |
Minor changes
| -rw-r--r-- | clusterman/commands/node.py | 6 | ||||
| -rw-r--r-- | clusterman/config.py | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/clusterman/commands/node.py b/clusterman/commands/node.py index eb32d50..280cb2e 100644 --- a/clusterman/commands/node.py +++ b/clusterman/commands/node.py @@ -1,4 +1,4 @@ -import os, json +import os, json, time from clusterman.config import CONF @@ -37,7 +37,9 @@ def scan(timeout): else: print("") with open(CONF["paths"]["nodes"], "w") as f: - f.write(json.dumps(nodes)) + f.write(json.dumps(nodes,indent=4)) + CONF["cluster"]["last_scan"]=int(time.time()) + CONF.save() def check(timeout): nodes_path=CONF["paths"]["nodes"] diff --git a/clusterman/config.py b/clusterman/config.py index 2a9b95b..db63778 100644 --- a/clusterman/config.py +++ b/clusterman/config.py @@ -12,7 +12,8 @@ class Config: "cluster": { "ip4_from": "10.128.0.133", "ip4_to": "10.128.0.140", - "ip4_ignore": ["10.0.0.5", "10.0.0.1"] + "ip4_ignore": ["10.0.0.5", "10.0.0.1"], + "last_scan": None }, "timeout": 0.5 } @@ -31,7 +32,7 @@ class Config: def save(self): with open(self.CONF_FILE, "w") as f: - f.write(json.dumps(self.config)) + f.write(json.dumps(self.config,indent=4, sort_keys=True)) def __getitem__(self, key): return self.config[key] |
