Ejemplo n.º 1
0
    def handle_plugin_event(self, event):
        """
        This method is called for each of the above registered events
        Overload this method to implement your actions for the events,
        You may first call this method in your derived class to get the
        job attributes read and then only adjust where useful.
        """
        if event == bareossd.bsdEventJobStart:
            self.jobStartTime = time.time()
            bareossd.DebugMessage(
                100,
                "bsdEventJobStart event triggered at Unix time %s\n" %
                (self.jobStartTime),
            )

        elif event == bareossd.bsdEventJobEnd:
            self.jobEndTime = time.time()
            bareossd.DebugMessage(
                100,
                "bsdEventJobEnd event triggered at Unix time %s\n" %
                (self.jobEndTime),
            )
            self.jobBytes = int(bareossd.GetValue(bareossd.bsdVarJobBytes))
            self.jobFiles = int(bareossd.GetValue(bareossd.bsdVarJobFiles))
            self.jobRunningTime = self.jobEndTime - self.jobStartTime
            self.throughput = 0
            if self.jobRunningTime > 0:
                self.throughput = self.jobBytes / self.jobRunningTime
                bareossd.DebugMessage(
                    100,
                    "jobRunningTime: %s s, Throughput: %s Bytes/s\n" %
                    (self.jobRunningTime, self.throughput),
                )

        return bareossd.bRC_OK
Ejemplo n.º 2
0
    def __init__(self, plugindef):
        bareossd.DebugMessage(
            100,
            "Constructor called in module %s with plugindef=%s\n" %
            (__name__, plugindef),
        )
        bareossd.DebugMessage(
            100,
            "Python Version: %s.%s.%s\n" %
            (version_info.major, version_info.minor, version_info.micro),
        )
        super(BareosSdTest, self).__init__(plugindef)

        self.outputfile = None

        events = []
        events.append(bareossd.bsdEventJobStart)
        events.append(bareossd.bsdEventDeviceReserve)
        events.append(bareossd.bsdEventVolumeUnload)
        events.append(bareossd.bsdEventVolumeLoad)
        events.append(bareossd.bsdEventDeviceOpen)
        events.append(bareossd.bsdEventDeviceMount)
        events.append(bareossd.bsdEventLabelRead)
        events.append(bareossd.bsdEventLabelVerified)
        events.append(bareossd.bsdEventLabelWrite)
        events.append(bareossd.bsdEventSetupRecordTranslation)
        events.append(bareossd.bsdEventWriteRecordTranslation)
        events.append(bareossd.bsdEventDeviceUnmount)
        events.append(bareossd.bsdEventDeviceClose)
        events.append(bareossd.bsdEventJobEnd)
        bareossd.RegisterEvents(events)
Ejemplo n.º 3
0
    def __init__(self, plugindef):
        bareossd.DebugMessage(100, "Constructor called in module %s\n" % (__name__))
        events = []

        events.append(bsdEventType["bsdEventJobStart"])
        events.append(bsdEventType["bsdEventJobEnd"])
        bareossd.RegisterEvents(events)

        # get some static Bareos values
        self.jobName = bareossd.GetValue(bsdrVariable["bsdVarJobName"])
        self.jobLevel = chr(bareossd.GetValue(bsdrVariable["bsdVarLevel"]))
        self.jobId = int(bareossd.GetValue(bsdrVariable["bsdVarJobId"]))

        bareossd.DebugMessage(
            100,
            "JobName = %s - Level = %s - Id = %s - BareosSdPluginBaseclass\n"
            % (self.jobName, self.jobLevel, self.jobId),
        )
Ejemplo n.º 4
0
 def parse_plugin_definition(self, plugindef):
     """
     Called with the plugin options from the bareos configfiles
     You should overload this method with your own and do option checking
     here, return bRCs['bRC_Error'], if options are not ok
     or better call super.parse_plugin_definition in your own class and
     make sanity check on self.options afterwards
     """
     bareossd.DebugMessage(100, "plugin def parser called with %s\n" % (plugindef))
     # Parse plugin options into a dict
     self.options = dict()
     plugin_options = plugindef.split(":")
     for current_option in plugin_options:
         key, sep, val = current_option.partition("=")
         bareossd.DebugMessage(100, "key:val = %s:%s" % (key, val))
         if val == "":
             continue
         else:
             self.options[key] = val
     return bRCs["bRC_OK"]
Ejemplo n.º 5
0
    def handle_plugin_event(self, event):
        super(BareosSdTest, self).handle_plugin_event(event)
        bareossd.DebugMessage(
            100,
            "%s: bsdEventJobStart event %d triggered\n" % (__name__, event),
        )
        if event == bareossd.bsdEventJobStart:
            self.toFile("bareossd.bsdEventJobStart\n")
        elif event == bareossd.bsdEventDeviceReserve:
            self.toFile("bareossd.bsdEventDeviceReserve\n")
        elif event == bareossd.bsdEventVolumeUnload:
            self.toFile("bareossd.bsdEventVolumeUnload\n")
        elif event == bareossd.bsdEventVolumeLoad:
            self.toFile("bareossd.bsdEventVolumeLoad\n")
        elif event == bareossd.bsdEventDeviceOpen:
            self.toFile("bareossd.bsdEventDeviceOpen\n")
        elif event == bareossd.bsdEventDeviceMount:
            self.toFile("bareossd.bsdEventDeviceMount\n")
        elif event == bareossd.bsdEventLabelRead:
            self.toFile("bareossd.bsdEventLabelRead\n")
        elif event == bareossd.bsdEventLabelVerified:
            self.toFile("bareossd.bsdEventLabelVerified\n")
        elif event == bareossd.bsdEventLabelWrite:
            self.toFile("bareossd.bsdEventLabelWrite\n")
        elif event == bareossd.bsdEventSetupRecordTranslation:
            self.toFile("bareossd.bsdEventSetupRecordTranslation\n")
        elif event == bareossd.bsdEventWriteRecordTranslation:
            self.toFile("bareossd.bsdEventWriteRecordTranslation\n")
        elif event == bareossd.bsdEventDeviceUnmount:
            self.toFile("bareossd.bsdEventDeviceUnmount\n")
        elif event == bareossd.bsdEventDeviceClose:
            self.toFile("bareossd.bsdEventDeviceClose\n")
        elif event == bareossd.bsdEventJobEnd:
            self.toFile("bareossd.bsdEventJobEnd\n")

        return bareossd.bRC_OK