def testFreezeProcUtil(self): m = procutil.MachineInformation() m.update() d = m.__freeze__() xx = procutil.MachineInformation.__thaw__(d) assert(xx == m) xx.update() assert(xx != m)
def _serveLoopHook(self): # Called every .1 seconds or so when polling for # new requests. # Sends status update about the machine. if not self.client.isConnected(): self.client.connect() return if (time.time() - self.lastStatusSent) > self.statusPeriod: if self.client: self.lastStatusSent = time.time() info = procutil.MachineInformation() commandIds = [x.getCommandId() for x in self.commands] commandIds += [x[2][0] for x in self._queuedCommands] self.client.updateStatus(info, commandIds) worker.Worker._serveLoopHook(self)
def makeRegisterNodeMessage(self, slots=1, jobTypes=None, buildFlavors=None, loadThreshold=10, loadavg=0.5, chrootLimit=4): if jobTypes is None: jobTypes = self.getNodeCfg().jobTypes if buildFlavors is None: buildFlavors = [deps.parseFlavor('is:x86')] else: buildFlavors = [ parseFlavor(x, raiseError=True) for x in buildFlavors] nodeInfo = procutil.MachineInformation() nodeInfo.loadavg = (loadavg, loadavg, loadavg) node = nodetypes.WorkerNode('name', 'localhost', slots, jobTypes, buildFlavors, loadThreshold, nodeInfo, [], chrootLimit) return mnmessages.RegisterNodeMessage(node)
def __init__(self, cfg, messageBusInfo=None): serverLogger = logger.Logger('rmake-node', logPath=cfg.logDir + '/rmake-node.log') try: serverLogger.info('Starting rMake Node (pid %s)' % os.getpid()) worker.Worker.__init__(self, cfg, serverLogger, slots=cfg.slots) #calculates current state of the rmake chroot directory. chroots = self.listChroots() self.client = WorkerNodeClient(cfg, self, procutil.MachineInformation(), chroots=chroots, messageBusInfo=messageBusInfo) self.lastStatusSent = 0 self.statusPeriod = 60 except Exception, err: self.error('Error initializing Node Server:\n %s\n%s', err, traceback.format_exc()) raise
def makeMachineInfo(self, loadavg=1): info = procutil.MachineInformation() info.loadavg = (loadavg, loadavg, loadavg) return info
def testProcUtil(self): m = procutil.MachineInformation() m.update() assert(str(m))