def get(self, computerName): computerName = computerName.lower() try: rendernode = self.getDispatchTree().renderNodes[computerName] except KeyError: return Http404("RenderNode not found") content = rendernode.to_json() content = json.dumps(content) self.writeCallback(content)
def put(self, computerName): computerName = computerName.lower() rns = self.getDispatchTree().renderNodes if not computerName in rns: return Http404("RenderNode not found") dct = self.getBodyAsJSON() renderNode = rns[computerName] noMoreCmd = int(dct["nomorecmd"]) if noMoreCmd: renderNode.reset()
def delete(self, computerName): computerName = computerName.lower() try: renderNode = self.getDispatchTree().renderNodes[computerName] except KeyError: return Http404("RenderNode not found") if renderNode.status in [RN_ASSIGNED, RN_WORKING]: renderNode.reset() for pool in self.getDispatchTree().pools.values(): pool.removeRenderNode(renderNode) renderNode.remove()
def put(self, computerName): dct = self.getBodyAsJSON() paused = dct['paused'] killproc = dct['killproc'] computerName = computerName.lower() rns = self.getDispatchTree().renderNodes if not computerName in rns: return Http404("RenderNode not found") renderNode = rns[computerName] if paused: renderNode.status = RN_PAUSED if killproc: renderNode.reset(paused=True) else: # FIXME maybe set this to RN_FINISHING ? renderNode.status = RN_IDLE renderNode.excluded = False
def post(self): """ """ self.logger = logging.getLogger('main.query') filters = self.getBodyAsJSON() self.logger.debug('filters: %s' % filters) try: start_time = time.time() resultData = [] renderNodes = self.getDispatchTree().renderNodes.values() totalNodes = len(renderNodes) # # --- filtering # filteredNodes = self.match(filters, renderNodes) # # --- Prepare the result json object # for currNode in filteredNodes: tmp = self.createRenderNodeRepr(currNode) resultData.append(tmp.encode()) content = { 'summary': { 'count': len(filteredNodes), 'totalInDispatcher': totalNodes, 'requestTime': time.time() - start_time, 'requestDate': time.ctime() }, 'items': resultData } # Create response and callback self.writeCallback(json.dumps(content)) except KeyError: raise Http404('Error unknown key') except HTTPError, e: raise e
def put(self, computerName): computerName = computerName.lower() try: renderNode = self.getDispatchTree().renderNodes[computerName] except KeyError: return Http404("RenderNode %s not found" % computerName) dct = self.getBodyAsJSON() for key in dct: if key == "cores": renderNode.coresNumber = int(dct["cores"]) elif key == "speed": renderNode.speed = float(dct["speed"]) elif key == "ram": renderNode.ramSize = int(dct["ram"]) else: return Http403("Modifying %r attribute is not authorized." % key) self.writeCallback(json.dumps(renderNode.to_json()))
def put(self, computerName): computerName = computerName.lower() rns = self.getDispatchTree().renderNodes if not computerName in rns: raise Http404("RenderNode not found") dct = self.getBodyAsJSON() renderNode = rns[computerName] if "puliversion" in dct: renderNode.puliversion = dct.get('puliversion', "unknown") if "caracteristics" in dct: renderNode.caracteristics = eval(str(dct["caracteristics"])) if "cores" in dct: renderNode.cores = int(dct["cores"]) if "createDate" in dct: renderNode.createDate = int(dct["createDate"]) if "ram" in dct: renderNode.ram = int(dct["ram"]) if "systemFreeRam" in dct: renderNode.systemFreeRam = int(dct["systemFreeRam"]) if "systemSwapPercentage" in dct: renderNode.systemSwapPercentage = float( dct["systemSwapPercentage"]) if "speed" in dct: renderNode.speed = float(dct["speed"]) if "performance" in dct: renderNode.performance = float(dct["performance"]) if "status" in dct: if renderNode.status == RN_UNKNOWN: renderNode.status = int(dct["status"]) logger.info("status reported is %d" % renderNode.status) # if renderNode.status != int(dct["status"]): # logger.warning("The status reported by %s = %r is different from the status on dispatcher %r" % (renderNode.name, RN_STATUS_NAMES[dct["status"]],RN_STATUS_NAMES[renderNode.status])) if "isPaused" in dct and "status" in dct: logger.debug("reported for %r: remoteStatus=%r remoteIsPaused=%r" % (renderNode.name, RN_STATUS_NAMES[dct["status"]], dct['isPaused'])) renderNode.lastAliveTime = time.time() renderNode.isRegistered = True
def put(self, computerName, commandId): '''Update command `commandId` running on rendernode `renderNodeId`. Returns "200 OK" on success, or "404 Bad Request" if the provided json data is not valid. ''' if singletonconfig.get('CORE', 'GET_STATS'): singletonstats.theStats.cycleCounts['update_commands'] += 1 computerName = computerName.lower() # try: # updateDict = self.sanitizeUpdateDict(self.getBodyAsJSON()) # except TypeError, e: # return Http400(repr(e.args)) updateDict = self.getBodyAsJSON() updateDict['renderNodeName'] = computerName try: self.framework.application.updateCommandApply(updateDict) except (KeyError, IndexError) as e: raise Http404(str(e)) except Exception, e: raise Http500("Exception during command update")