2 # Bacula Python interface script for the Storage Daemon
4 # You must import both sys and bacula
7 # This is the list of Bacula daemon events that you
11 # Called here when a new Bacula Events class is
12 # is created. Normally not used
15 def JobStart(self, job):
17 Called here when a new job is started. If you want
18 to do anything with the Job, you must register
19 events you want to receive.
21 events = JobEvents() # create instance of Job class
22 events.job = job # save Bacula's job pointer
23 job.set_events(events) # register events desired
24 sys.stderr = events # send error output to Bacula
25 sys.stdout = events # send stdout to Bacula
26 jobid = job.get("JobId")
27 client = job.get("Client")
28 job.set(JobReport="Python SD StartJob: JobId=%d Client=%s \n" % (jobid,client))
31 # Bacula Job is going to terminate
32 def JobEnd(self, job):
33 jobid = job.get("JobId")
34 client = job.get("Client")
35 job.set(JobReport="Python SD EndJob output: JobId=%d Client=%s.\n" % (jobid, client))
36 print "Python SD JobEnd\n"
39 # Called here when the Bacula daemon is going to exit
43 bacula.set_events(BaculaEvents()) # register daemon events desired
46 There are the Job events that you can receive.
50 # Called here when you instantiate the Job. Not
54 # Pass output back to Bacula
55 def write(self, text):