Ejemplo n.º 1
0
 def startChrootSession(self, nodeName, chrootPath, command, superUser, 
                        buildTrove=None):
     nodeId = self.getDispatcher().getNodeByName(nodeName)
     passed, results = self.getNode(nodeId).startChrootSession(chrootPath,
                                                  command, superUser,
                                                  buildTrove=buildTrove)
     if passed:
         return results
     else:
         results = thaw('FailureReason', results)
         raise errors.ServerError("Could not start session at %s: %s" % (nodeId, results))
Ejemplo n.º 2
0
 def logToPort(self, host, port, key=None):
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     s.connect((host, port))
     if key:
         s.send(key + '\n')
         status = s.recv(3)
         if status != 'OK\n':
             raise errors.ServerError("Could not connect to socket")
     socketFd = s.fileno()
     self.tee = Tee()
     outFile = self.tee.tee(self.fd, socketFd)
     os.close(self.fd)
     self.fd = outFile
     self.redirectOutput()
Ejemplo n.º 3
0
 def unmount(self, root, raiseError=True):
     if not os.path.exists(root):
         return True
     if self.canChroot():
         if self._lock(root, fcntl.LOCK_EX):
             self.logger.info('Running chroot helper to unmount...')
             if self.callHelper(root, ['--unmount']):
                 if raiseError:
                     raise errors.ServerError(
                         'Could not unmount old chroot')
                 return False
         else:
             self.logger.info("Not unmounting chroot because it is locked "
                              "by another process")
     self._unlock(root)
     return True
Ejemplo n.º 4
0
 def unmount(self, root, raiseError=True):
     if not os.path.exists(root):
         return True
     if self.canChroot():
         if self._lock(root, fcntl.LOCK_EX):
             self.logger.info('Running chroot helper to unmount...')
             util.mkdirChain(root + self.busyboxDir)
             rc = os.system('%s --unmount %s' %
                            (self.chrootHelperPath, root))
             if rc:
                 if raiseError:
                     raise errors.ServerError(
                         'Could not unmount old chroot')
                 return False
         else:
             self.logger.info("Not unmounting chroot because it is locked "
                              "by another process")
     self._unlock(root)
     return True
Ejemplo n.º 5
0
 def checkPid():
     checkedPid, status = os.waitpid(pid, os.WNOHANG)
     if checkedPid:
         msg = ('Chroot server failed to start - please check build log')
         raise errors.ServerError(msg)
     return True