summaryrefslogtreecommitdiff
path: root/clusterman/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'clusterman/config.py')
-rw-r--r--clusterman/config.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/clusterman/config.py b/clusterman/config.py
index db63778..804a2cc 100644
--- a/clusterman/config.py
+++ b/clusterman/config.py
@@ -5,22 +5,22 @@ import os, json
class Config:
CONF_DIR=os.path.join(os.environ['HOME'],".clusterman/")
CONF_FILE=os.path.join(CONF_DIR,"clusterman.json")
+ CACHE_FILE=os.path.join(CONF_DIR,"cache.json")
+ NODE_FILE=os.path.join(CONF_DIR,"nodeslist.json")
DEFAULT_CONFIG = {
- "paths": {
- "nodes": os.path.join(CONF_DIR,"nodeslist.json")
- },
"cluster": {
"ip4_from": "10.128.0.133",
"ip4_to": "10.128.0.140",
"ip4_ignore": ["10.0.0.5", "10.0.0.1"],
- "last_scan": None
},
+ "plugins": [],
"timeout": 0.5
}
def __init__(self):
Path(self.CONF_DIR).mkdir(parents=True, exist_ok=True)
self.config=self.DEFAULT_CONFIG
+ self.cache=dict()
self.load()
def load(self):
@@ -29,12 +29,23 @@ class Config:
self.config=json.load(f)
else:
self.save()
+
+ if os.path.exists(self.CACHE_FILE):
+ with open(self.CACHE_FILE) as f:
+ self.cache=json.load(f)
+ else:
+ self.save()
def save(self):
with open(self.CONF_FILE, "w") as f:
f.write(json.dumps(self.config,indent=4, sort_keys=True))
+ with open(self.CACHE_FILE, "w") as f:
+ f.write(json.dumps(self.cache,indent=4, sort_keys=True))
+
def __getitem__(self, key):
+ if key=="cache":
+ return self.cache;
return self.config[key]
def __setitem__(self, key, value):