Exemple #1
0
    def _removeFile(filename):
        """Remove file, umounting ovirt config files if needed."""

        mounts = open("/proc/mounts").read()
        if " /config ext3" in mounts and " %s ext3" % filename in mounts:
            subprocess.call([constants.EXT_UMOUNT, "-n", filename])
        utils.rmFile(filename)
Exemple #2
0
    def _removeFile(filename):
        """Remove file, umounting ovirt config files if needed."""

        mounts = open('/proc/mounts').read()
        if ' /config ext3' in mounts and ' %s ext3' % filename in mounts:
            subprocess.call([constants.EXT_UMOUNT, '-n', filename])
        utils.rmFile(filename)
Exemple #3
0
    def _cleanup(self):
        with self._volPrepareLock:
            for drive in self._preparedDrives.keys():
                self.log.debug("Drive %s cleanup" % drive)
                self._teardownVolumePath(drive)

        if self.conf.get("volatileFloppy"):
            try:
                self.log.debug("Floppy %s cleanup" % self.conf["floppy"])
                utils.rmFile(self.conf["floppy"])
            except:
                pass
        try:
            self.guestAgent.stop()
        except:
            pass
        utils.rmFile(self._guestSocektFile)
        utils.rmFile(self._recoveryFile)
Exemple #4
0
        
        utils.createDaemon(True)
        file(RHEV_AGENT_PIDFILE, "w").write("%s\n" % (os.getpid()))
        os.chmod(RHEV_AGENT_PIDFILE, 0x1b4) # rw-rw-r-- (664)
        
        self.register_signal_handler()
        self.agent.run()

        logging.info("RHEV-Agent daemon is down.")

    def register_signal_handler(self):
        
        def sigterm_handler(signum, frame):
            logging.debug("Handling signal %d" % (signum))
            if signum == signal.SIGTERM:
                logging.info("Stopping RHEV-Agent daemon")
                self.agent.stop()
 
        signal.signal(signal.SIGTERM, sigterm_handler)

if __name__ == '__main__':
    try:
        try:
            agent = RHEVAgentDaemon()
            agent.run()
        except:
            logging.exception("Unhandled exception in RHEV-Agent daemon!")
            sys.exit(1)
    finally:
        utils.rmFile(RHEV_AGENT_PIDFILE)