Skip to content

Commit

Permalink
added pool structure
Browse files Browse the repository at this point in the history
  • Loading branch information
joergsteffens committed Oct 30, 2015
1 parent ccc5b9a commit 0b34c5b
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 8 deletions.
2 changes: 1 addition & 1 deletion 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', 'status', 'volume', 'volumes', 'volumestatus']
files = ['backups', 'base', 'bvfsdir', 'bvfsfile', 'client', 'clients', 'directory', 'file', 'job', 'joblog', 'jobs', 'jobslist', 'jobsname', 'pool', 'pools', 'status', 'volume', 'volumelist', 'volumestatus']

for i in files:
module = __import__( "bareos.fuse.node." + i, globals(), locals(), ['*'])
Expand Down
34 changes: 34 additions & 0 deletions bareos/fuse/node/pool.py
@@ -0,0 +1,34 @@
"""
Bareos specific Fuse node.
"""

from bareos.fuse.node.directory import Directory
from bareos.fuse.node.file import File
from bareos.fuse.node.volumelist import VolumeList
from pprint import pformat

class Pool(Directory):
def __init__(self, root, name, pool):
super(Pool, self).__init__(root, name)
self.pool = pool

@classmethod
def get_id(cls, name, pool):
return name

def do_update_stat(self):
data = self.bsock.call("llist pools count" % (self.selector))
self.subnode_count = int(data['pools'][0]['count'])

def do_update(self):
data = self.bsock.call("llist pools")
pools = data['pools']
for i in pools:
self.add_subnode(Pool, i['name'])

def do_update_stat(self):
self.subnode_count = 2

def do_update(self):
self.add_subnode(File, name="info.txt", content=pformat(self.pool) + "\n")
self.add_subnode(VolumeList, name="volumes", selector="pool=%s" % (self.name))
21 changes: 21 additions & 0 deletions bareos/fuse/node/pools.py
@@ -0,0 +1,21 @@
"""
Bareos specific Fuse node.
"""

from bareos.fuse.node.directory import Directory
from bareos.fuse.node.pool import Pool

class Pools(Directory):
def __init__(self, root, name):
super(Pools, self).__init__(root, name)
self.static = True

@classmethod
def get_id(cls, name):
return "unique"

def do_update(self):
data = self.bsock.call("llist pools")
pools = data['pools']
for i in pools:
self.add_subnode(Pool, i['name'], i)
13 changes: 7 additions & 6 deletions bareos/fuse/node/volumes.py → bareos/fuse/node/volumelist.py
Expand Up @@ -6,16 +6,17 @@
from bareos.fuse.node.volume import Volume
from bareos.fuse.node.volumestatus import VolumeStatus

class Volumes(Directory):
def __init__(self, root, name):
super(Volumes, self).__init__(root, name)
class VolumeList(Directory):
def __init__(self, root, name, selector = 'all'):
super(VolumeList, self).__init__(root, name)
self.selector = selector

@classmethod
def get_id(cls, name):
return "unique"
def get_id(cls, name, selector = 'all'):
return selector

def do_update(self):
data = self.bsock.call("llist volumes all")
data = self.bsock.call("llist volumes %s" % (self.selector))
volumes = data['volumes']
for i in volumes:
volumename = i['volumename']
Expand Down
3 changes: 2 additions & 1 deletion bareos/fuse/root.py
Expand Up @@ -22,6 +22,7 @@ def __init__(self, bsock, restoreclient, restorepath):
super(Root, self).__init__(self, None)
self.factory = NodeFactory(self)
self.add_subnode(Jobs, "jobs")
self.add_subnode(Volumes, "volumes")
self.add_subnode(VolumeList, "volumes")
self.add_subnode(Pools, "pools")
self.add_subnode(Clients, "clients")
self.add_subnode(Status, ".bareosfs-status.txt")

0 comments on commit 0b34c5b

Please sign in to comment.