From 3e139af06c1503e6f05b57737913e9b0efab67cc Mon Sep 17 00:00:00 2001 From: Joerg Steffens Date: Fri, 30 Oct 2015 16:02:56 +0100 Subject: added .bareosfs.status.txt show a list of objects in the bareosfs cache --- bareos/fuse/node/__init__.py | 2 +- bareos/fuse/node/status.py | 39 +++++++++++++++++++++++++++++++++++++++ bareos/fuse/root.py | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 bareos/fuse/node/status.py 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") -- cgit v1.2.3