def main(argv):
    'main method for standalone run'
    config_generator = FaucetConfigGenerator()
    filepath = '/tmp/faucet_config_dump'
    egress = 2
    access = 3
    devices = 1
    topo_type = STACK
    argv = argv[1:]
    help_msg = '\n    <python3> build_config.py -e <egress_switches> -a <access_switches> -d <devices per switch>\n    -p <config path> -t <topology type (flat, corp, stack)>\n    '
    try:
        (opts, _) = getopt.getopt(argv, 'he:a:d:p:t:', ['egress=', 'access=', 'devices=', 'path=', 'type='])
    except getopt.GetoptError:
        print(help_msg)
        sys.exit(2)
    for (opt, arg) in opts:
        if (opt == '-h'):
            print(help_msg)
            sys.exit()
        elif (opt in ('-e', '--egress')):
            egress = int(arg)
        elif (opt in ('-a', '--access')):
            access = int(arg)
        elif (opt in ('-d', '--devices')):
            devices = int(arg)
        elif (opt in ('-p', '--path')):
            filepath = arg
        elif (opt in ('-t', '--type')):
            topo_type = arg
    if (topo_type == FLAT):
        faucet_config = config_generator.create_flat_faucet_config(access, devices)
    elif (topo_type == CORP):
        faucet_config = config_generator.create_corp_faucet_config()
    elif (topo_type == STACK):
        faucet_config = config_generator.create_scale_faucet_config(egress, access, devices)
    else:
        raise Exception(('Unkown topology type: %s' % topo_type))
    config_map = proto_dict(faucet_config)
    with open(filepath, 'w') as config_file:
        yaml.dump(config_map, config_file)
main method for standalone run
def main(argv):
    
    config_generator = FaucetConfigGenerator()
    filepath = '/tmp/faucet_config_dump'
    egress = 2
    access = 3
    devices = 1
    topo_type = STACK
    argv = argv[1:]
    help_msg = '\n    <python3> build_config.py -e <egress_switches> -a <access_switches> -d <devices per switch>\n    -p <config path> -t <topology type (flat, corp, stack)>\n    '
    try:
        (opts, _) = getopt.getopt(argv, 'he:a:d:p:t:', ['egress=', 'access=', 'devices=', 'path=', 'type='])
    except getopt.GetoptError:
        print(help_msg)
        sys.exit(2)
    for (opt, arg) in opts:
        if (opt == '-h'):
            print(help_msg)
            sys.exit()
        elif (opt in ('-e', '--egress')):
            egress = int(arg)
        elif (opt in ('-a', '--access')):
            access = int(arg)
        elif (opt in ('-d', '--devices')):
            devices = int(arg)
        elif (opt in ('-p', '--path')):
            filepath = arg
        elif (opt in ('-t', '--type')):
            topo_type = arg
    if (topo_type == FLAT):
        faucet_config = config_generator.create_flat_faucet_config(access, devices)
    elif (topo_type == CORP):
        faucet_config = config_generator.create_corp_faucet_config()
    elif (topo_type == STACK):
        faucet_config = config_generator.create_scale_faucet_config(egress, access, devices)
    else:
        raise Exception(('Unkown topology type: %s' % topo_type))
    config_map = proto_dict(faucet_config)
    with open(filepath, 'w') as config_file:
        yaml.dump(config_map, config_file)