Esempio n. 1
0
    def runZfs(self):
        """ Kill previously running zfsd instances and run our own zfsd. """

        self.killall()  # destroy previous zfsd instances
        if self.zfs:
            self.zfs.wait()

        self.makeDirs()
        self.unpackData()
        self.installModules()
        loglevel = pysyplog.LOG_LOOPS
        if self.logger:
            loglevel = pysyplog.get_log_level(self.logger)
        self.coreDumpSettings = allowCoreDumps()

        # NOTE: this could grow big, but current outputs are not big enough
        # to care about. Piping Popen outputs creates bigger problems than
        # few kilobytes on disk (there should be NO output at all)
        self.stdout = open(os.path.join(self.tempDir, "zfsd.stdout"), "wb+")
        self.stderr = open(os.path.join(self.tempDir, "zfsd.stderr"), "wb+")

        self.zfs = Popen(
            args=(
                "zfsd",
                "-d",
                "--" + str(pysyplog.PARAM_MEDIUM_TYPE_LONG) + "=" + str(pysyplog.FILE_MEDIUM_NAME),
                "--" + str(pysyplog.PARAM_MEDIUM_FMT_LONG) + "=" + str(pysyplog.USER_READABLE_FORMATTER_NAME),
                "--" + str(pysyplog.PARAM_MEDIUM_SIZE_LONG) + "=" + self.maxZfsLogSize,
                "--" + str(pysyplog.PARAM_MEDIUM_FN_LONG) + "=" + os.path.join(self.tempDir, ZfsProxy.logFileName),
                "-o",
                "loglevel=" + str(loglevel) + ",config=" + os.path.join(self.tempDir, self.config),
                self.zfsRoot,
            ),
            bufsize=0,
            cwd=self.tempDir,
            stdout=self.stdout,
            stderr=self.stderr,
            close_fds=True,
            universal_newlines=True,
        )

        for i in [0.2, 0.5, 1, 3, 5, 100]:
            time.sleep(i)
            if zfsd_status.ping_zfsd() == zfsd_status.ZFSD_STATE_RUNNING:
                break
        if zfsd_status.ping_zfsd() != zfsd_status.ZFSD_STATE_RUNNING:
            self.killall()  # be sure that we don't leave orphans
            if self.coreDumpSettings:
                setCoreDumpSettings(self.coreDumpSettings)
                self.coreDumpSettings = None
            raise ZfsRuntimeException("Zfsd doesn't start")
        self.running = True
        self.connectControl()
Esempio n. 2
0
 def runZfs(self):
     """ Kill previously running zfsd instances and run our own zfsd. """
     
     self.killall() #destroy previous zfsd instances
     if self.zfs:
         self.zfs.wait()
         
     self.makeDirs()
     self.unpackData()
     self.installModules()
     loglevel = pysyplog.LOG_LOOPS
     if self.logger:
         loglevel = pysyplog.get_log_level(self.logger)
     self.coreDumpSettings = allowCoreDumps()
     
     # NOTE: this could grow big, but current outputs are not big enough
     # to care about. Piping Popen outputs creates bigger problems than
     # few kilobytes on disk (there should be NO output at all)
     self.stdout = open(os.path.join(self.tempDir, 'zfsd.stdout'), 'wb+')
     self.stderr = open(os.path.join(self.tempDir, 'zfsd.stderr'), 'wb+')
     
     self.zfs = Popen(args=('zfsd',
         '-d',
         "--" + str(pysyplog.PARAM_MEDIUM_TYPE_LONG) + "=" + \
             str(pysyplog.FILE_MEDIUM_NAME),
         "--" + str(pysyplog.PARAM_MEDIUM_FMT_LONG) + "=" + \
             str(pysyplog.USER_READABLE_FORMATTER_NAME),
         "--" + str(pysyplog.PARAM_MEDIUM_SIZE_LONG) + "=" + \
             self.maxZfsLogSize,
         "--" + str(pysyplog.PARAM_MEDIUM_FN_LONG) + "=" + \
             os.path.join(self.tempDir, ZfsProxy.logFileName),
         '-o', 'loglevel=' + str(loglevel) +
         ',config=' + os.path.join(self.tempDir, self.config), 
         self.zfsRoot), bufsize=0,
         cwd = self.tempDir,
         stdout = self.stdout, stderr = self.stderr, close_fds = True, 
             universal_newlines=True)
     
     for i in [0.2, 0.5, 1, 3, 5, 100]:
         time.sleep(i)
         if zfsd_status.ping_zfsd() == zfsd_status.ZFSD_STATE_RUNNING:
             break
     if zfsd_status.ping_zfsd() != zfsd_status.ZFSD_STATE_RUNNING:
         self.killall() #be sure that we don't leave orphans
         if self.coreDumpSettings:
             setCoreDumpSettings(self.coreDumpSettings)
             self.coreDumpSettings = None
         raise ZfsRuntimeException("Zfsd doesn't start")
     self.running = True
     self.connectControl()
Esempio n. 3
0
    def hasDied(self):
        """ Check if zfs has died.
            
            :Return:
                True: if we thinks that zfs is running, but zfsd process is not alive
        """

        return self.running and (self.zfs.poll() or zfsd_status.ping_zfsd() != zfsd_status.ZFSD_STATE_RUNNING)
Esempio n. 4
0
    def isRunning(self):
        """ Check if zfs is really running.
            
            :Return:
                True: if we thinks that zfs is running and zfsd proccess is alive.
        """

        return self.running and self.zfs.poll() is None and zfsd_status.ping_zfsd() == zfsd_status.ZFSD_STATE_RUNNING
Esempio n. 5
0
 def hasDied(self):
     """ Check if zfs has died.
         
         :Return:
             True: if we thinks that zfs is running, but zfsd process is not alive
     """
     
     return self.running and (self.zfs.poll() \
         or zfsd_status.ping_zfsd() != zfsd_status.ZFSD_STATE_RUNNING)
Esempio n. 6
0
 def isRunning(self):
     """ Check if zfs is really running.
         
         :Return:
             True: if we thinks that zfs is running and zfsd proccess is alive.
     """
     
     return self.running and self.zfs.poll() is None \
         and zfsd_status.ping_zfsd() == zfsd_status.ZFSD_STATE_RUNNING