⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_bgp_config.py

📁 xorp源码hg
💻 PY
📖 第 1 页 / 共 2 页
字号:
#!/usr/bin/env python# Copyright (c) 2001-2007 International Computer Science Institute## Permission is hereby granted, free of charge, to any person obtaining a# copy of this software and associated documentation files (the "Software")# to deal in the Software without restriction, subject to the conditions# listed in the XORP LICENSE file. These conditions include: you must# preserve this copyright notice, and you cannot mention the copyright# holders in advertising related to the Software without their permission.# The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This# notice is a summary of the XORP LICENSE file; the license in that file is# legally binding.# $XORP: xorp/tests/bgp/test_bgp_config.py,v 1.19 2007/02/16 22:47:32 pavlin Exp $import syssys.path.append("..")from test_xorpsh import xorpshLOCALHOST="127.0.0.1"AS=65000# IBGPAS_LOCAL_1=ASAS_PEER_1=ASPORT_LOCAL_1=10001PORT_PEER_1=20001def conf_interfaces(builddir):    """    Configure an interface    """    # Configure the xorpsh    xorpsh_commands = \"""configurecreate interfacesedit interfacescreate interface fxp0edit interface fxp0create vif fxp0edit vif fxp0create address 127.0.0.1edit address 127.0.0.1set prefix-length 16commit"""    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_tracing_state(builddir):    """    Enable the tracing of state changes, assume that BGP is already configured.    """    # Configure the xorpsh    xorpsh_commands = \"""configureedit protocols bgpcreate traceoptionsedit traceoptionscreate flagedit flagcreate state-changecommit"""    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_set_holdtime(builddir, peer, holdtime):    """    Set the holdtime on the specified peer.    """    # Configure the xorpsh    xorpsh_commands = \"""configureset protocols bgp peer %s holdtime %scommit""" % (peer, holdtime)    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_set_prefix_limit(builddir, peer, maximum):    """    Set the prefix limit on a peer    """    # Configure the xorpsh    xorpsh_commands = \"""configurecreate protocols bgp peer %s prefix-limitedit  protocols bgp peer %s prefix-limitset maximum %scommit""" % (peer, peer, maximum)    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_IBGP(builddir):    """    Configure ONE IBGP peering    """    # Configure the xorpsh    xorpsh_commands = \"""configureload empty.bootcreate protocol bgpedit protocol bgpset bgp-id 1.2.3.4set local-as 65000create peer peer1edit peer peer1set local-port 10001set peer-port 20001set next-hop 127.0.0.1set local-ip 127.0.0.1set as 65000commit"""    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_EBGP(builddir):    """    Configure ONE EBGP peering    """    # Configure the xorpsh    xorpsh_commands = \"""configureload empty.bootcreate protocol bgpedit protocol bgpset bgp-id 1.2.3.4set local-as 65000create peer peer1edit peer peer1set local-port 10001set peer-port 20001set next-hop 127.0.0.1set local-ip 127.0.0.1set as 65001commit"""    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_bug_360(builddir):    """    Configure ONE EBGP peering    """    # Configure the xorpsh    xorpsh_commands = \"""configureload empty.bootcreate protocol bgpedit protocol bgpset bgp-id 1.2.3.4set local-as 65001create peer peer1edit peer peer1set local-port 10001set peer-port 20001set next-hop 127.0.0.1set local-ip 127.0.0.1set as 75commit"""    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_EBGP_EBGP(builddir):    """    Configure two EBGP peerings    """    # Configure the xorpsh    xorpsh_commands = \"""configureload empty.bootcreate protocol bgpedit protocol bgpset bgp-id 1.2.3.4set local-as 65000create peer peer1edit peer peer1set local-port 10001set peer-port 20001set next-hop 127.0.0.1set local-ip 127.0.0.1set as 65001upcreate peer peer2edit peer peer2set local-port 10002set peer-port 20002set next-hop 127.0.0.1set local-ip 127.0.0.1set as 65002commit"""    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_EBGP_IBGP_IBGP(builddir):    """    Configure One EBGP peering and two IBGP peerings    """    # Configure the xorpsh    xorpsh_commands = \"""configureload empty.bootcreate protocol bgpedit protocol bgpset bgp-id 1.2.3.4set local-as 65000create peer peer1edit peer peer1set local-port 10001set peer-port 20001set next-hop 127.0.0.1set local-ip 127.0.0.1set as 65001upcreate peer peer2edit peer peer2set local-port 10002set peer-port 20002set next-hop 127.0.0.1set local-ip 127.0.0.1set as 65000upcreate peer peer3edit peer peer3set local-port 10003set peer-port 20003set next-hop 127.0.0.1set local-ip 127.0.0.1set as 65000upcommit"""    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_RUT_as2_TR1_as1(builddir):    """    Configure One EBGP peering    """    # Configure the xorpsh    xorpsh_commands = \"""configureload empty.bootcreate protocol bgpedit protocol bgpset bgp-id 1.2.3.4set local-as 2create peer peer1edit peer peer1set local-port 10001set peer-port 20001set next-hop 127.0.0.1set local-ip 127.0.0.1set as 1upcommit"""    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_RUT_as2_TR1_as1_TR2_as2(builddir):    """    Configure One EBGP peering and one IBGP peerings    """    # Configure the xorpsh    xorpsh_commands = \"""configureload empty.bootcreate protocol bgpedit protocol bgpset bgp-id 1.2.3.4set local-as 2create peer peer1edit peer peer1set local-port 10001set peer-port 20001set next-hop 127.0.0.1set local-ip 127.0.0.1set as 1upcreate peer peer2edit peer peer2set local-port 10002set peer-port 20002set next-hop 127.0.0.1set local-ip 127.0.0.1set as 2upcommit"""    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_RUT_as2_TR1_as1_TR2_as1_TR3_as3(builddir):    """    Configure One EBGP peering and two IBGP peerings    """    # Configure the xorpsh    xorpsh_commands = \"""configureload empty.bootcreate protocol bgpedit protocol bgpset bgp-id 1.2.3.4set local-as 2create peer peer1edit peer peer1set local-port 10001set peer-port 20001set next-hop 127.0.0.1set local-ip 127.0.0.1set as 1upcreate peer peer2edit peer peer2set local-port 10002set peer-port 20002set next-hop 127.0.0.1set local-ip 127.0.0.1set as 1upcreate peer peer3edit peer peer3set local-port 10003set peer-port 20003set next-hop 127.0.0.1set local-ip 127.0.0.1set as 3upcommit"""    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_RUT_as2_TR1_as1_TR2_as3(builddir):    """    Configure One EBGP peering and two IBGP peerings    """    # Configure the xorpsh    xorpsh_commands = \"""configureload empty.bootcreate protocol bgpedit protocol bgpset bgp-id 1.2.3.4set local-as 2create peer peer1edit peer peer1set local-port 10001set peer-port 20001set next-hop 127.0.0.1set local-ip 127.0.0.1set as 1upcreate peer peer2edit peer peer2set local-port 10002set peer-port 20002set next-hop 127.0.0.1set local-ip 127.0.0.1set as 3commit"""    if not xorpsh(builddir, xorpsh_commands):        return False    return Truedef conf_RUT_as3_TR1_as1_TR2_as2_TR3_as4(builddir):    """    Configure three EBGP peerings    """    # Configure the xorpsh    xorpsh_commands = \"""configureload empty.bootcreate protocol bgpedit protocol bgpset bgp-id 1.2.3.4set local-as 3create peer peer1edit peer peer1set local-port 10001set peer-port 20001set next-hop 127.0.0.1set local-ip 127.0.0.1set as 1upcreate peer peer2edit peer peer2set local-port 10002set peer-port 20002set next-hop 127.0.0.1set local-ip 127.0.0.1set as 2upcreate peer peer3edit peer peer3set local-port 10003set peer-port 20003set next-hop 127.0.0.1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -