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-09-29 01:21:42 +0300
committerJoerg Steffens <joerg.steffens@bareos.com>2015-09-29 01:29:23 +0300
commitec031449f1b8035c7ad607128ce0047db5ea42cc (patch)
treed445e85528295435105162ce777dfcdb911d4fd0
parent1be46db0dffe6b76dcf2b875b4bc31bd8dd8668f (diff)
bvfs: include job object
to know client where the data came from on restore.
-rw-r--r--bareos/fuse/node/bvfscommon.py5
-rw-r--r--bareos/fuse/node/bvfsdir.py13
-rw-r--r--bareos/fuse/node/bvfsfile.py7
-rw-r--r--bareos/fuse/node/job.py7
4 files changed, 20 insertions, 12 deletions
diff --git a/bareos/fuse/node/bvfscommon.py b/bareos/fuse/node/bvfscommon.py
index ad84e86..d20c7dd 100644
--- a/bareos/fuse/node/bvfscommon.py
+++ b/bareos/fuse/node/bvfscommon.py
@@ -46,7 +46,7 @@ class BvfsCommon(Base):
dirId='dirid=' + ",".join(map(str, pathIds))
fileId=''
if fileIds:
- fileId='fileid=' + ",".join(map(str, fileIds))
+ fileId='fileid=' + ",".join(map(str, fileIds))
select = self.bsock.call(
'.bvfs_restore jobid={jobid} {dirid} {fileid} path={bvfs_restore_id}'.format(
jobid = self.jobid,
@@ -54,7 +54,8 @@ class BvfsCommon(Base):
fileid = fileId,
bvfs_restore_id = bvfs_restore_id))
restore = self.bsock.call(
- 'restore file=?{bvfs_restore_id} restoreclient={restoreclient} where="{where}" yes'.format(
+ 'restore file=?{bvfs_restore_id} client={client} restoreclient={restoreclient} where="{where}" yes'.format(
+ client = self.job.job['client'],
restoreclient = self.root.restoreclient,
where = self.restorepath,
bvfs_restore_id = bvfs_restore_id))
diff --git a/bareos/fuse/node/bvfsdir.py b/bareos/fuse/node/bvfsdir.py
index 40b7cc6..056c8ec 100644
--- a/bareos/fuse/node/bvfsdir.py
+++ b/bareos/fuse/node/bvfsdir.py
@@ -11,9 +11,10 @@ import errno
import logging
class BvfsDir(Directory, BvfsCommon):
- def __init__(self, root, name, jobid, pathid, directory = None):
+ def __init__(self, root, name, job, pathid, directory = None):
super(BvfsDir, self).__init__(root, name)
- self.jobid = jobid
+ self.job = job
+ self.jobid = job.job['jobid']
self.pathid = pathid
self.static = True
self.directory = directory
@@ -22,10 +23,10 @@ class BvfsDir(Directory, BvfsCommon):
BvfsCommon.init(self, self.root, self.jobid, self.directory['fullpath'], None, self.directory['stat'])
@classmethod
- def get_id(cls, name, jobid, pathid, directory = None):
+ def get_id(cls, name, job, pathid, directory = None):
id = None
if pathid == None:
- id = "jobid=%s" % (str(jobid))
+ id = "jobid=%s" % (str(job.job['jobid']))
else:
id = "pathid=%s" % (str(pathid))
return id
@@ -50,9 +51,9 @@ class BvfsDir(Directory, BvfsCommon):
if i['name'] != "." and i['name'] != "..":
name = i['name'].rstrip('/')
pathid = i['pathid']
- self.add_subnode(BvfsDir, name, self.jobid, pathid, i)
+ self.add_subnode(BvfsDir, name, self.job, pathid, i)
for i in files:
- self.add_subnode(BvfsFile, i, self.directory['fullpath'])
+ self.add_subnode(BvfsFile, i, self.job, self.directory['fullpath'])
def get_directories(self, pathid):
if pathid == None:
diff --git a/bareos/fuse/node/bvfsfile.py b/bareos/fuse/node/bvfsfile.py
index 06e7fc4..636b336 100644
--- a/bareos/fuse/node/bvfsfile.py
+++ b/bareos/fuse/node/bvfsfile.py
@@ -8,15 +8,16 @@ import errno
import os
class BvfsFile(File, BvfsCommon):
- def __init__(self, root, file, bvfspath):
+ def __init__(self, root, file, job, bvfspath):
super(BvfsFile, self).__init__(root, file['name'], content = None)
self.file = file
+ self.job = job
self.bvfspath = bvfspath
- self.id = self.get_id(file, bvfspath)
+ self.id = self.get_id(file, job, bvfspath)
BvfsCommon.init(self, self.root, self.file['jobid'], self.bvfspath, self.file['name'], self.file['stat'])
@classmethod
- def get_id(cls, file, bvfspath):
+ def get_id(cls, file, job, bvfspath):
return str(file['fileid'])
# Filesystem methods
diff --git a/bareos/fuse/node/job.py b/bareos/fuse/node/job.py
index 6bbc2cb..407afae 100644
--- a/bareos/fuse/node/job.py
+++ b/bareos/fuse/node/job.py
@@ -16,6 +16,11 @@ class Job(Directory):
self.job = job
super(Job, self).__init__(root, self.get_name())
try:
+ if not job.has_key('client'):
+ job['client'] = job['clientname']
+ except KeyError:
+ pass
+ try:
self.stat.st_ctime = self._convert_date_bareos_unix(self.job['starttime'])
except KeyError:
pass
@@ -43,4 +48,4 @@ class Job(Directory):
def do_update(self):
self.add_subnode(File, name="info.txt", content = pformat(self.job) + "\n")
self.add_subnode(JobLog, name="job.log", job=self.job)
- self.add_subnode(BvfsDir, "data", self.job['jobid'], None)
+ self.add_subnode(BvfsDir, "data", self, None)