示例#1
0
文件: gui.py 项目: alem0lars/hassel
def main():
    parser = argparse.ArgumentParser(description='Python backend to communicate with Beacon', epilog="Report any bugs to [email protected]")
    parser.add_argument('--controller', '-c', dest='controller', default="localhost")
    parser.add_argument('--port', '-p', dest='port', default=6633)
    parser.add_argument('--verbose', '-v', dest='verbose', action='count')
    args = parser.parse_args()
    
    port = args.port
    controller = args.controller
    if args.verbose == None:
        output.set_mode("INFO")
    else:
        output.set_mode("DBG")
    
    # Main Loop here 
    app = Application(controller=controller, port=port)
    app.main()
示例#2
0
def main():
    parser = argparse.ArgumentParser(
        description='Python backend to communicate with Beacon',
        epilog="Report any bugs to [email protected]")
    parser.add_argument('--controller',
                        '-c',
                        dest='controller',
                        default="localhost")
    parser.add_argument('--port', '-p', dest='port', default=6633)
    parser.add_argument('--verbose', '-v', dest='verbose', action='count')
    args = parser.parse_args()

    port = args.port
    controller = args.controller
    if args.verbose == None:
        output.set_mode("INFO")
    else:
        output.set_mode("DBG")

    # Main Loop here
    app = Application(controller=controller, port=port)
    app.main()
    opts, args = getopt.getopt(sys.argv[1:], "hvp:",
                               ["help","verbose","port="])
except getopt.GetoptError:
    usage()
    sys.exit(2)

#Check there is only controller
if not (len(args) == 1):
    usage()
    sys.exit(2)
    
#Parse options
##Port to connect to
port = 6633
##Set output mode
output.set_mode("INFO")
for opt,arg in opts:
    if (opt in ("-h","--help")):
        usage()
        sys.exit(0)
    elif (opt in ("-v","--verbose")):
        output.set_mode("DBG")
    elif (opt in ("-p","--port")):
        port=int(arg)
    else:
        assert False,"Unhandled option :"+opt

#Connect to controller
ofmsg = openflow.messages()
parser = of_msg.parser(ofmsg)
ofsw = of_simu.switch(ofmsg, args[0], port,
示例#4
0
    opts, args = getopt.getopt(sys.argv[1:], "hvp:",
                               ["help", "verbose", "port="])
except getopt.GetoptError:
    usage()
    sys.exit(2)

#Check there is only controller
if not (len(args) == 1):
    usage()
    sys.exit(2)

#Parse options
##Port to connect to
port = 6633
##Set output mode
output.set_mode("INFO")
for opt, arg in opts:
    if (opt in ("-h", "--help")):
        usage()
        sys.exit(0)
    elif (opt in ("-v", "--verbose")):
        output.set_mode("DBG")
    elif (opt in ("-p", "--port")):
        port = int(arg)
    else:
        assert False, "Unhandled option :" + opt

#Connect to controller
ofmsg = openflow.messages()
parser = of_msg.parser(ofmsg)
ofsw = of_simu.switch(ofmsg,