예제 #1
0
def main():
    parser = argparse.ArgumentParser(
        description="MaxiNet Worker which hosts a mininet instance")
    parser.add_argument("--ip", action="store", help="Frontend Server IP")
    parser.add_argument("--port",
                        action="store",
                        help="Frontend Server Port",
                        type=int)
    parser.add_argument("--password",
                        action="store",
                        help="Frontend Server Password")
    parser.add_argument("-c",
                        "--config",
                        metavar="FILE",
                        action="store",
                        help="Read configuration from FILE")
    parsed = parser.parse_args()

    ip = False
    port = False
    pw = False
    if (parsed.config or os.path.isfile("MaxiNet.cfg")
            or os.path.isfile(os.path.expanduser("~/.MaxiNet.cfg"))
            or os.path.isfile("/etc/MaxiNet.cfg")):
        if parsed.config:
            config = MaxiNetConfig(file=parsed.config, register=False)
        else:
            config = MaxiNetConfig(register=False)
        ip = config.get_nameserver_ip()
        port = config.get_nameserver_port()
        pw = config.get_nameserver_password()
    if parsed.ip:
        ip = parsed.ip
    if parsed.port:
        port = parsed.port
    if parsed.password:
        pw = parsed.password

    if os.getuid() != 0:
        print "MaxiNetWorker must run with root privileges!"
        sys.exit(1)

    if not (ip and port and pw):
        print "Please provide MaxiNet.cfg or specify ip, port and password of \
               the Frontend Server."

    else:
        workerserver = WorkerServer()

        signal.signal(signal.SIGINT, workerserver.exit_handler)

        workerserver.start(ip=ip, port=port, password=pw)
        workerserver.monitorFrontend()
예제 #2
0
def getFrontendStatus():
    config = MaxiNetConfig(register=False)
    ip = config.get_nameserver_ip()
    port = config.get_nameserver_port()
    pw = config.get_nameserver_password()
    ns = Pyro4.locateNS(ip, port, hmac_key=pw)
    manager_uri = ns.lookup("MaxiNetManager")
    if (manager_uri):
        manager = Pyro4.Proxy(manager_uri)
        manager._pyroHmacKey = pw
        print manager.print_worker_status()
    else:
        print "Could not contact Frontend server at %s:%s" % (ip, port)
예제 #3
0
파일: server.py 프로젝트: schwabe/MaxiNet
def getFrontendStatus():
    config = MaxiNetConfig(register=False)
    ip = config.get_nameserver_ip()
    port = config.get_nameserver_port()
    pw = config.get_nameserver_password()
    ns = Pyro4.locateNS(ip, port, hmac_key=pw)
    manager_uri = ns.lookup("MaxiNetManager")
    if(manager_uri):
        manager = Pyro4.Proxy(manager_uri)
        manager._pyroHmacKey=pw
        print manager.print_worker_status()
    else:
        print "Could not contact Frontend server at %s:%s" % (ip, port)
예제 #4
0
파일: server.py 프로젝트: schwabe/MaxiNet
def main():
    parser = argparse.ArgumentParser(description="MaxiNet Worker which hosts a mininet instance")
    parser.add_argument("--ip", action="store", help="Frontend Server IP")
    parser.add_argument("--port", action="store", help="Frontend Server Port", type=int)
    parser.add_argument("--password", action="store", help="Frontend Server Password")
    parser.add_argument("-c", "--config", metavar="FILE", action="store", help="Read configuration from FILE")
    parsed = parser.parse_args()

    ip = False
    port = False
    pw = False
    if (parsed.config or
            os.path.isfile("MaxiNet.cfg") or
            os.path.isfile(os.path.expanduser("~/.MaxiNet.cfg")) or
            os.path.isfile("/etc/MaxiNet.cfg")):
        if parsed.config:
            config = MaxiNetConfig(file=parsed.config,register=False)
        else:
            config = MaxiNetConfig(register=False)
        ip = config.get_nameserver_ip()
        port = config.get_nameserver_port()
        pw = config.get_nameserver_password()
    if parsed.ip:
        ip = parsed.ip
    if parsed.port:
        port = parsed.port
    if parsed.password:
        pw = parsed.password

    if os.getuid() != 0:
        print "MaxiNetWorker must run with root privileges!"
        sys.exit(1)

    if not (ip and port and pw):
        print "Please provide MaxiNet.cfg or specify ip, port and password of \
               the Frontend Server."
    else:
        workerserver = WorkerServer()

        signal.signal(signal.SIGINT, workerserver.exit_handler)

        workerserver.start(ip=ip, port=port, password=pw)
        workerserver.monitorFrontend()