本文整理匯總了Python中lib.gobgp.GoBGPContainer.add_route方法的典型用法代碼示例。如果您正苦於以下問題:Python GoBGPContainer.add_route方法的具體用法?Python GoBGPContainer.add_route怎麽用?Python GoBGPContainer.add_route使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lib.gobgp.GoBGPContainer
的用法示例。
在下文中一共展示了GoBGPContainer.add_route方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUpClass
# 需要導入模塊: from lib.gobgp import GoBGPContainer [as 別名]
# 或者: from lib.gobgp.GoBGPContainer import add_route [as 別名]
def setUpClass(cls):
gobgp_ctn_image_name = parser_option.gobgp_image
base.TEST_PREFIX = parser_option.test_prefix
g1 = GoBGPContainer(name='g1', asn=65001, router_id='192.168.0.1',
ctn_image_name=gobgp_ctn_image_name,
log_level=parser_option.gobgp_log_level)
q1 = QuaggaBGPContainer(name='q1', asn=65002, router_id='192.168.0.2')
g2 = GoBGPContainer(name='g2', asn=65001, router_id='192.168.0.3',
ctn_image_name=gobgp_ctn_image_name,
log_level=parser_option.gobgp_log_level)
ctns = [g1, g2, q1]
initial_wait_time = max(ctn.run() for ctn in ctns)
time.sleep(initial_wait_time)
g1.add_peer(q1)
q1.add_peer(g1)
q1.add_peer(g2)
g2.add_peer(q1)
g1.add_route('10.0.0.0/24')
cls.g1 = g1
cls.g2 = g2
cls.q1 = q1
cls.ctns = {n.name: n for n in ctns}
示例2: setUpClass
# 需要導入模塊: from lib.gobgp import GoBGPContainer [as 別名]
# 或者: from lib.gobgp.GoBGPContainer import add_route [as 別名]
def setUpClass(cls):
gobgp_ctn_image_name = parser_option.gobgp_image
base.TEST_PREFIX = parser_option.test_prefix
g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1',
ctn_image_name=gobgp_ctn_image_name,
log_level=parser_option.gobgp_log_level)
g2 = GoBGPContainer(name='g2', asn=65001, router_id='192.168.0.2',
ctn_image_name=gobgp_ctn_image_name)
e1 = ExaBGPContainer(name='e1', asn=65002, router_id='192.168.0.3')
ctns = [g1, g2, e1]
cls.clients = {cli.name: cli for cli in (g2, e1)}
initial_wait_time = max(ctn.run() for ctn in ctns)
time.sleep(initial_wait_time)
for cli in cls.clients.values():
# Omit "passwd" to avoid a issue on ExaBGP version 4.0.5:
# https://github.com/Exa-Networks/exabgp/issues/766
g1.add_peer(cli, is_rs_client=True, passive=True, prefix_limit=10)
cli.add_peer(g1)
# advertise a route from route-server-clients
g2.add_route('10.0.0.0/24')
e1.add_route('10.0.1.0/24')
cls.gobgp = g1
示例3: test_07_mpath_test_setup
# 需要導入模塊: from lib.gobgp import GoBGPContainer [as 別名]
# 或者: from lib.gobgp.GoBGPContainer import add_route [as 別名]
def test_07_mpath_test_setup(self):
g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1',
ctn_image_name=parser_option.gobgp_image,
log_level=parser_option.gobgp_log_level,
config_format=parser_option.config_format,
zebra=True)
g2 = GoBGPContainer(name='g2', asn=65001, router_id='192.168.0.2',
ctn_image_name=parser_option.gobgp_image)
g3 = GoBGPContainer(name='g3', asn=65001, router_id='192.168.0.3',
ctn_image_name=parser_option.gobgp_image)
g4 = GoBGPContainer(name='g4', asn=65000, router_id='192.168.0.4',
ctn_image_name=parser_option.gobgp_image)
g5 = GoBGPContainer(name='g5', asn=65000, router_id='192.168.0.5',
ctn_image_name=parser_option.gobgp_image)
ctns = [g1, g2, g3, g4, g5]
for ctn in ctns:
self.ctns[ctn.name] = ctn
initial_wait_time = max(ctn.run() for ctn in ctns)
time.sleep(initial_wait_time)
# advertise same prefix
g2.add_route('10.0.10.0/24')
g3.add_route('10.0.10.0/24')
g4.add_route('10.0.10.0/24')
g5.add_route('10.0.10.0/24')
for g in [g2, g3, g4, g5]:
g1.add_peer(g)
g.add_peer(g1)
示例4: test_04_add_non_graceful_restart_enabled_peer
# 需要導入模塊: from lib.gobgp import GoBGPContainer [as 別名]
# 或者: from lib.gobgp.GoBGPContainer import add_route [as 別名]
def test_04_add_non_graceful_restart_enabled_peer(self):
g1 = self.bgpds['g1']
# g2 = self.bgpds['g2']
gobgp_ctn_image_name = parser_option.gobgp_image
g3 = GoBGPContainer(name='g3', asn=65002, router_id='192.168.0.3',
ctn_image_name=gobgp_ctn_image_name,
log_level=parser_option.gobgp_log_level)
self.bgpds['g3'] = g3
time.sleep(g3.run())
g3.add_route('10.10.30.0/24')
g1.add_peer(g3)
g3.add_peer(g1)
g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g3)
time.sleep(1)
self.assertTrue(len(g3.get_global_rib('10.10.20.0/24')) == 1)
示例5: setUpClass
# 需要導入模塊: from lib.gobgp import GoBGPContainer [as 別名]
# 或者: from lib.gobgp.GoBGPContainer import add_route [as 別名]
def setUpClass(cls):
gobgp_ctn_image_name = parser_option.gobgp_image
base.TEST_PREFIX = parser_option.test_prefix
g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1',
ctn_image_name=gobgp_ctn_image_name,
log_level=parser_option.gobgp_log_level)
g2 = GoBGPContainer(name='g2', asn=65001, router_id='192.168.0.2',
ctn_image_name=gobgp_ctn_image_name,
log_level=parser_option.gobgp_log_level)
ctns = [g1, g2]
initial_wait_time = max(ctn.run() for ctn in ctns)
time.sleep(initial_wait_time)
g1.add_route('10.10.10.0/24')
g1.add_route('10.10.20.0/24')
g1.add_peer(g2, graceful_restart=True)
g2.add_peer(g1, graceful_restart=True)
cls.bgpds = {'g1': g1, 'g2': g2}
示例6: setUpClass
# 需要導入模塊: from lib.gobgp import GoBGPContainer [as 別名]
# 或者: from lib.gobgp.GoBGPContainer import add_route [as 別名]
def setUpClass(cls):
gobgp_ctn_image_name = parser_option.gobgp_image
base.TEST_PREFIX = parser_option.test_prefix
g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1',
ctn_image_name=gobgp_ctn_image_name,
log_level=parser_option.gobgp_log_level)
e1 = ExaBGPContainer(name='e1', asn=65000, router_id='192.168.0.2')
ctns = [g1, e1]
# advertise a route from q1, q2
matchs = ['destination 10.0.0.0/24', 'source 20.0.0.0/24']
thens = ['discard']
e1.add_route(route='flow1', rf='ipv4-flowspec', matchs=matchs, thens=thens)
matchs2 = ['tcp-flags S', 'protocol ==tcp ==udp', "packet-length '>1000&<2000'", "source-port '!=2&!=22&!=222'"]
thens2 = ['rate-limit 9600', 'redirect 0.10:100', 'mark 20', 'action sample']
g1.add_route(route='flow1', rf='ipv4-flowspec', matchs=matchs2, thens=thens2)
matchs3 = ['destination 2001::/24/10', 'source 2002::/24/15']
thens3 = ['discard']
e1.add_route(route='flow2', rf='ipv6-flowspec', matchs=matchs3, thens=thens3)
matchs4 = ['destination 2001::/24 10', "label '==100'"]
thens4 = ['discard']
g1.add_route(route='flow2', rf='ipv6-flowspec', matchs=matchs4, thens=thens4)
initial_wait_time = max(ctn.run() for ctn in ctns)
time.sleep(initial_wait_time)
# ibgp peer. loop topology
for a, b in combinations(ctns, 2):
a.add_peer(b, flowspec=True)
b.add_peer(a, flowspec=True)
cls.gobgp = g1
cls.exabgp = e1