def verify(doc):
    mng=XMLJobManager()
    slist=StoreList()
    llist=LocalStoreList()
    mng.registerPlugins()
    workflow=XMLWorkflow(doc.documentElement)
    for task in workflow.tasks:
        exc=getTaskExecutor(mng, task)
        if task.attributes.has_key("destStore"):
            store=llist.getByUuid(task.attributes["destStore"])
            if store<>None: continue
            store=slist.getByUuid(task.attributes["destStore"])
            if store==None: raise Exception("Unknown destination store")
            # oops, requested remote destination store and executor does not support it
            # change destination store to local one and add MOVE task after that
            if  not exc.supportsRemoteDestination:
                task.element.setAttribute("destStore", task.attributes["srcStore"])
                extra=doc.createElement("task")
                extra.setAttribute("guid",  uuid4().get_hex())
                extra.setAttribute("action", "MOVE")
                extra.setAttribute("srcStore", task.attributes["srcStore"])
                if task.attributes.has_key("destAssetItem"):  extra.setAttribute("srcAssetItem", task.attributes["destAssetItem"])
                else: extra.setAttribute("srcAssetItem", task.attributes["srcAssetItem"])
                extra.setAttribute("destStore", store.uuid)
                doc.documentElement.insertBefore(extra, task.element.nextSibling)
Example #2
0
def main_menu():
    cls()
    a=XMLJobManager()
    status=a.listByStatus()
    running=processtools.is_running()
    if running==False: idle=""
    elif status[1]==0: idle="(idle)"
    else: idle="(processing)"
    
    httprunning=processtools.is_http_running()
    
    print "(c) 2011 Node Styk.Tv v0.2 ", version.commit, " (", version.date+")"
    print "Node ID:",  version.nodeid
    print "IP: ", pwdtools.getMainIp(), "  (", pwdtools.getIfaceType()+")"
    print
    print "Node is running: ",   running,  idle,  " HTTP server is running: ", httprunning
    print "WORKFLOWS: ", status[0], " pending, ", status[1], " processing, ", status[2], " finished, ",  status[3], " failed"
    print
    print "1) Network settings"
    print "2) Change root password"
    print "3) Change node password"
    if running:
        print "4) Stop node"
    else:
        print "5) Start node"
    if os.path.exists("/home/node/styk.tv/update.sh"): print "6) Update node"
    if os.path.exists(Config.CONFIGDIR+"/node.log"): print "7) Show current log"
    print "0) Exit"
    print
    sys.stdout.write("Enter choice: ")
    
    return sys.stdin.readline().strip()
Example #3
0
def printStatus(out, checkcpu):
    doc=getDOMImplementation().createDocument(None, "status", None)
    node=doc.createElement("node")
    a=XMLJobManager()
    status=a.listByStatus()
    node.setAttribute("running", str(is_running()))
    node.setAttribute("pending", str(status[0]))
    node.setAttribute("processing", str(status[1]))
    node.setAttribute("finished", str(status[2]))
    node.setAttribute("failed", str(status[3]))
    doc.documentElement.appendChild(node)
    mem=doc.createElement("memory")
    phy=psutil.phymem_usage()
    virt=psutil.virtmem_usage()
    mem.setAttribute("total_physical", str(phy.total))
    mem.setAttribute("avail_physical", str(phy.total-phy.used))
    mem.setAttribute("total_virtual", str(virt.total))
    mem.setAttribute("avail_virtual", str(virt.total-virt.used))
    doc.documentElement.appendChild(mem)
    if checkcpu:
        cpu=doc.createElement("cpu")
        cpu.setAttribute("usage", str(psutil.cpu_percent(3)))
        doc.documentElement.appendChild(cpu)
    lsl=LocalStoreList()
    for disk in lsl.disks:
        d=doc.createElement("disk")
        d.setAttribute("guid", disk.uuid)
        d.setAttribute("online", str(disk.online))
        d.setAttribute('freespace', str(disk.freespace))
        doc.documentElement.appendChild(d)
    doc.writexml(out)
Example #4
0
def main():
  drop_privileges(Config.USER)
  setupLogging()
  with PIDLockFile(Config.CONFIGDIR+"/node.pid"):
      jman=XMLJobManager()
      jman.registerPlugins()
      queue=Queue(jman)
      
      linkthread=Thread(target=linkschecker)
      linkthread.daemon=True
      linkthread.start()
      
      # remove old interrupted tasks
      jman.unfinishedToError()
      queue.run()
Example #5
0
def main():
    try:
        if len(sys.argv) < 2:
            raise Exception("Usage: queue.py <list>|<clear>|<remove>|<retry>")
        action = sys.argv[1]
        queue = XMLJobManager()
        if action == "list":  # list  <status> <task guid>
            status = None
            startTask = None
            try:
                if len(sys.argv) > 2:
                    status = int(sys.argv[2])
            except Exception, e:
                pass
            if len(sys.argv) > 3:
                startTask = sys.argv[3]
            queue.list(sys.stdout, status, startTask)
        elif action == "remove":
            if len(sys.argv) < 3:
                raise Exception("Usage: queue.py remove <workflow>")
            ret = queue.removeWorkflow(sys.argv[2])
            return xmlmsg("result", "OK")