Esempio n. 1
0
def main():
  
  # Initialize the main database.
  maindb.init_maindb()

  # Initialize the key database.
  keydb.init_keydb()
  
  # Initialize the nodemanager.
  nodemanager.init_nodemanager()

  # Start the background thread that does vessel cleanup.
  thread.start_new_thread(cleanup_vessels, ())
  
  # Start the background thread that does vessel user key synchronization.
  thread.start_new_thread(sync_user_keys_of_vessels, ())
  
  # Register the XMLRPCServer. Use allow_none to allow allow the python None value.
  server = ThreadedXMLRPCServer(("127.0.0.1", LISTENPORT), allow_none=True)

  log.info("Backend listening on port " + str(LISTENPORT) + ".")

  server.register_instance(BackendPublicFunctions()) 
  while True:
    server.handle_request()
Esempio n. 2
0
def main():

    # Initialize the main database.
    maindb.init_maindb()

    # Initialize the key database.
    keydb.init_keydb()

    # Initialize the nodemanager.
    nodemanager.init_nodemanager()

    # Start the background thread that does vessel cleanup.
    thread.start_new_thread(cleanup_vessels, ())

    # Start the background thread that does vessel user key synchronization.
    thread.start_new_thread(sync_user_keys_of_vessels, ())

    # Register the XMLRPCServer. Use allow_none to allow allow the python None value.
    server = ThreadedXMLRPCServer(("127.0.0.1", LISTENPORT), allow_none=True)

    log.info("Backend listening on port " + str(LISTENPORT) + ".")

    server.register_instance(BackendPublicFunctions())
    while True:
        server.handle_request()
    finally:
      lockserver.unlock_node(lockserver_handle, node_id)

    print "Releases indicated. Monitoring db to see if the backend cleaned them up."
    while True:
      for vessel in vessels_on_node[:]:
        updated_vessel = maindb.get_vessel(node_id, vessel.name)
        if updated_vessel.is_dirty:
          print "Vessel %s has not been cleaned up yet." % updated_vessel
        else:
          print "Vessel %s has been cleaned up." % updated_vessel
          vessels_on_node.remove(vessel)
      if not vessels_on_node:
        print "All vessels have been cleaned up."
        break
      else:
        print "%s vessels remain to be cleaned up." % len(vessels_on_node)
      print "Sleeping 10 seconds."
      time.sleep(10)

  finally:
    lockserver.destroy_lockserver_handle(lockserver_handle)


if __name__ == "__main__":
  if len(sys.argv) != 2:
    print 'Usage: ./stop_all_vessels_on_node.py "<node_id>"'
    sys.exit(1)
  maindb.init_maindb()
  stop_all_vessels_on_node(sys.argv[1])
Esempio n. 4
0
def _prepare_newly_created_db_connection(sender, **kwargs):
    from seattlegeni.common.api import maindb
    maindb.init_maindb()
Esempio n. 5
0
            lockserver.unlock_node(lockserver_handle, node_id)

        print "Releases indicated. Monitoring db to see if the backend cleaned them up."
        while True:
            for vessel in vessels_on_node[:]:
                updated_vessel = maindb.get_vessel(node_id, vessel.name)
                if updated_vessel.is_dirty:
                    print "Vessel %s has not been cleaned up yet." % updated_vessel
                else:
                    print "Vessel %s has been cleaned up." % updated_vessel
                    vessels_on_node.remove(vessel)
            if not vessels_on_node:
                print "All vessels have been cleaned up."
                break
            else:
                print "%s vessels remain to be cleaned up." % len(
                    vessels_on_node)
            print "Sleeping 10 seconds."
            time.sleep(10)

    finally:
        lockserver.destroy_lockserver_handle(lockserver_handle)


if __name__ == "__main__":
    if len(sys.argv) != 2:
        print 'Usage: ./stop_all_vessels_on_node.py "<node_id>"'
        sys.exit(1)
    maindb.init_maindb()
    stop_all_vessels_on_node(sys.argv[1])