Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/python-bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Steffens <joerg.steffens@bareos.com>2015-10-30 18:02:56 +0300
committerJoerg Steffens <joerg.steffens@bareos.com>2015-10-30 19:05:25 +0300
commit3e139af06c1503e6f05b57737913e9b0efab67cc (patch)
tree9cd494a41b02c9b9b69f807ea0712e7696699a3a
parent41b2c64e3d091435d7a3b483dfc6aae279927066 (diff)
added .bareosfs.status.txt
show a list of objects in the bareosfs cache
-rw-r--r--bareos/fuse/node/__init__.py2
-rw-r--r--bareos/fuse/node/status.py39
-rw-r--r--bareos/fuse/root.py1
3 files changed, 41 insertions, 1 deletions
diff --git a/bareos/fuse/node/__init__.py b/bareos/fuse/node/__init__.py
index 641ac87..4a96491 100644
--- a/bareos/fuse/node/__init__.py
+++ b/bareos/fuse/node/__init__.py
@@ -1,5 +1,5 @@
# ls *.py | sed -r "s/(.*)\.py/'\1', /" | tr '\n' ' '
-files = ['backups', 'base', 'bvfsdir', 'bvfsfile', 'client', 'clients', 'directory', 'file', 'job', 'joblog', 'jobs', 'jobslist', 'jobsname', 'volume', 'volumes', 'volumestatus']
+files = ['backups', 'base', 'bvfsdir', 'bvfsfile', 'client', 'clients', 'directory', 'file', 'job', 'joblog', 'jobs', 'jobslist', 'jobsname', 'status', 'volume', 'volumes', 'volumestatus']
for i in files:
module = __import__( "bareos.fuse.node." + i, globals(), locals(), ['*'])
diff --git a/bareos/fuse/node/status.py b/bareos/fuse/node/status.py
new file mode 100644
index 0000000..b2acd6a
--- /dev/null
+++ b/bareos/fuse/node/status.py
@@ -0,0 +1,39 @@
+"""
+Bareos specific Fuse node.
+"""
+
+from bareos.fuse.node.file import File
+from datetime import datetime, timedelta
+
+
+class Status(File):
+ def __init__(self, root, name):
+ super(Status, self).__init__(root, name)
+ self.cache_timeout = timedelta(seconds=0)
+ self.cache_stat_timeout = timedelta(seconds=60)
+ self.objects = 0
+
+
+ @classmethod
+ def get_id(cls, name):
+ return "unique"
+
+ def do_update(self):
+ self.objects = 0
+ self.content = "#\n"
+ self.content += "# bareosfs cache\n"
+ self.content += "#\n"
+ self.content += self.get_status(None, self.root, -1)
+ self.content += "#\n"
+ self.content += "# number objects: %i\n" % (self.objects)
+ self.content += "#\n"
+
+
+ def get_status(self, name, node, indent):
+ result = ""
+ if name:
+ result = " " * (indent*2) + "%s\n" % (name)
+ self.objects += 1
+ for i in sorted(node.subnodes.keys()):
+ result += self.get_status(i, node.subnodes[i], indent+1)
+ return result
diff --git a/bareos/fuse/root.py b/bareos/fuse/root.py
index 8e12741..a80dae4 100644
--- a/bareos/fuse/root.py
+++ b/bareos/fuse/root.py
@@ -24,3 +24,4 @@ class Root(Directory):
self.add_subnode(Jobs, "jobs")
self.add_subnode(Volumes, "volumes")
self.add_subnode(Clients, "clients")
+ self.add_subnode(Status, ".bareosfs-status.txt")