当前位置: 首页>>代码示例>>Python>>正文


Python gobgp.GoBGPContainer类代码示例

本文整理汇总了Python中lib.gobgp.GoBGPContainer的典型用法代码示例。如果您正苦于以下问题:Python GoBGPContainer类的具体用法?Python GoBGPContainer怎么用?Python GoBGPContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GoBGPContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUpClass

    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)

        rs_clients = [
            QuaggaBGPContainer(name='q{0}'.format(i + 1), asn=(65001 + i),
                               router_id='192.168.0.{0}'.format(i + 2))
            for i in range(3)]
        ctns = [g1] + rs_clients
        q1 = rs_clients[0]
        q2 = rs_clients[1]
        q3 = rs_clients[2]

        initial_wait_time = max(ctn.run() for ctn in ctns)
        time.sleep(initial_wait_time)

        for rs_client in rs_clients:
            g1.add_peer(rs_client, is_rs_client=True, passwd='passwd', passive=True, prefix_limit=10)
            rs_client.add_peer(g1, passwd='passwd')

        # advertise a route from route-server-clients
        routes = []
        for idx, rs_client in enumerate(rs_clients):
            route = '10.0.{0}.0/24'.format(idx + 1)
            rs_client.add_route(route)
            routes.append(route)

        cls.gobgp = g1
        cls.quaggas = {'q1': q1, 'q2': q2, 'q3': q3}
开发者ID:sapcc,项目名称:kube-parrot,代码行数:33,代码来源:route_server_test.py

示例2: setUpClass

    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)

        rs_clients = [
            ExaBGPContainer(name='q{0}'.format(i + 1), asn=(65001 + i),
                            router_id='192.168.0.{0}'.format(i + 2))
            for i in range(4)]
        ctns = [g1] + rs_clients

        initial_wait_time = max(ctn.run() for ctn in ctns)
        time.sleep(initial_wait_time)

        for i, rs_client in enumerate(rs_clients):
            g1.add_peer(rs_client, is_rs_client=True)
            as2 = False
            if i > 1:
                as2 = True
            rs_client.add_peer(g1, as2=as2)

        # advertise a route from route-server-clients
        for idx, rs_client in enumerate(rs_clients):
            route = '10.0.{0}.0/24'.format(idx + 1)
            rs_client.add_route(route)
            if idx < 2:
                route = '10.0.10.0/24'
            rs_client.add_route(route)

        cls.gobgp = g1
        cls.quaggas = {x.name: x for x in rs_clients}
开发者ID:sapcc,项目名称:kube-parrot,代码行数:34,代码来源:route_server_as2_test.py

示例3: test_05_check_remove_private_as_peer_all

    def test_05_check_remove_private_as_peer_all(self):
        g3 = GoBGPContainer(name='g3', asn=100, router_id='192.168.0.4',
                            ctn_image_name=parser_option.gobgp_image,
                            log_level=parser_option.gobgp_log_level)
        g4 = GoBGPContainer(name='g4', asn=200, router_id='192.168.0.5',
                            ctn_image_name=parser_option.gobgp_image,
                            log_level=parser_option.gobgp_log_level)
        time.sleep(max(ctn.run() for ctn in [g3, g4]))

        self.ctns['g3'] = g3
        self.ctns['g4'] = g4

        self.g2.add_peer(g3)
        g3.add_peer(self.g2)

        g3.add_peer(g4, remove_private_as='all')
        g4.add_peer(g3)

        self.g2.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g3)
        g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g4)

        def f():
            rib = g4.get_global_rib()
            self.assertEqual(len(rib), 1)
            self.assertEqual(len(rib[0]['paths']), 1)
            self.assertEqual(rib[0]['paths'][0]['aspath'], [100])

        assert_several_times(f)
开发者ID:a16,项目名称:gobgp,代码行数:28,代码来源:aspath_test.py

示例4: setUpClass

    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,
                            config_format=parser_option.config_format)
        q1 = ExaBGPContainer(name='q1', asn=65001, router_id='192.168.0.2')
        q2 = ExaBGPContainer(name='q2', asn=65002, router_id='192.168.0.3')
        q3 = ExaBGPContainer(name='q3', asn=65003, router_id='192.168.0.4')

        qs = [q1, q2, q3]
        ctns = [g1, q1, q2, q3]

        # advertise a route from q1, q2, q3
        for idx, q in enumerate(qs):
            route = '10.0.{0}.0/24'.format(idx + 1)
            q.add_route(route)

        initial_wait_time = max(ctn.run() for ctn in ctns)

        time.sleep(initial_wait_time)

        g1.local('gobgp global policy export add default reject')

        for q in qs:
            g1.add_peer(q)
            q.add_peer(g1)

        cls.gobgp = g1
        cls.quaggas = {'q1': q1, 'q2': q2, 'q3': q3}
开发者ID:cherry-hyx,项目名称:kube-router,代码行数:32,代码来源:global_policy_test.py

示例5: setUpClass

    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]

        # advertise a route from route-server-clients
        cls.clients = {}
        for idx, cli in enumerate((g2, e1)):
            route = '10.0.{0}.0/24'.format(idx)
            cli.add_route(route)
            cls.clients[cli.name] = cli

        initial_wait_time = max(ctn.run() for ctn in ctns)

        time.sleep(initial_wait_time)

        for cli in cls.clients.itervalues():
            g1.add_peer(cli, is_rs_client=True, passwd='passwd', passive=True, prefix_limit=10)
            cli.add_peer(g1, passwd='passwd')

        cls.gobgp = g1
开发者ID:cherry-hyx,项目名称:kube-router,代码行数:29,代码来源:route_server_test2.py

示例6: setUpClass

    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)
        q1 = QuaggaBGPContainer(name='q1', asn=65001, router_id='192.168.0.2')
        q2 = QuaggaBGPContainer(name='q2', asn=65002, router_id='192.168.0.3')
        q3 = QuaggaBGPContainer(name='q3', asn=65003, router_id='192.168.0.4')

        qs = [q1, q2, q3]
        ctns = [g1, q1, q2, q3]

        initial_wait_time = max(ctn.run() for ctn in ctns)
        time.sleep(initial_wait_time)

        for q in qs:
            g1.add_peer(q, passwd='passwd')
            q.add_peer(g1, passwd='passwd', passive=True)

        # advertise a route from q1, q2, q3
        for idx, q in enumerate(qs):
            route = '10.0.{0}.0/24'.format(idx + 1)
            q.add_route(route)

        cls.gobgp = g1
        cls.quaggas = {'q1': q1, 'q2': q2, 'q3': q3}
开发者ID:sapcc,项目名称:kube-parrot,代码行数:28,代码来源:bgp_router_test.py

示例7: setUpClass

    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)
        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)
        g4 = GoBGPContainer(name='g4', asn=65003, router_id='192.168.0.4',
                            ctn_image_name=gobgp_ctn_image_name,
                            log_level=parser_option.gobgp_log_level)
        ctns = [g1, g2, g3, g4]

        # advertise a route from route-server-clients
        cls.clients = {}
        for cli in [g2, g3, g4]:
            cls.clients[cli.name] = cli
        initial_wait_time = max(ctn.run() for ctn in ctns)

        time.sleep(initial_wait_time)

        for cli in cls.clients.itervalues():
            g1.add_peer(cli, is_rs_client=True, passwd='passwd', passive=True, prefix_limit=10)
            cli.add_peer(g1, passwd='passwd')

        cls.gobgp = g1
开发者ID:cherry-hyx,项目名称:kube-router,代码行数:31,代码来源:route_server_softreset_test.py

示例8: setUpClass

    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=65000, router_id='192.168.0.2',
                            ctn_image_name=gobgp_ctn_image_name,
                            log_level=parser_option.gobgp_log_level)

        ctns = {ctn.name: ctn for ctn in [g1, g2]}

        initial_wait_time = max(ctn.run() for ctn in ctns.values())

        time.sleep(initial_wait_time)

        g1.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
        g1.local("gobgp vrf add vrf2 rd 200:200 rt both 200:200")
        g2.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100")
        g2.local("gobgp vrf add vrf3 rd 300:300 rt both 300:300")

        g1.local("gobgp vrf vrf1 rib add 10.0.0.0/24")
        g1.local("gobgp vrf vrf2 rib add 10.0.0.0/24")
        g2.local("gobgp vrf vrf1 rib add 20.0.0.0/24")
        g2.local("gobgp vrf vrf3 rib add 20.0.0.0/24")

        for a, b in combinations(ctns.values(), 2):
            a.add_peer(b, vpn=True, passwd='rtc', graceful_restart=True)
            b.add_peer(a, vpn=True, passwd='rtc', graceful_restart=True)

        cls.g1 = g1
        cls.g2 = g2
        cls.ctns = ctns
开发者ID:cherry-hyx,项目名称:kube-router,代码行数:34,代码来源:rtc_test.py

示例9: test_15_check_active_connection

 def test_15_check_active_connection(self):
     g1 = self.gobgp
     g2 = GoBGPContainer(name='g2', asn=65000, router_id='192.168.0.7',
                         ctn_image_name=self.gobgp.image,
                         log_level=parser_option.gobgp_log_level)
     time.sleep(g2.run())
     self.quaggas['g2'] = g2
     g2.add_peer(g1, passive=True)
     g1.add_peer(g2)
     g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g2)
开发者ID:sapcc,项目名称:kube-parrot,代码行数:10,代码来源:bgp_router_test.py

示例10: setUpClass

    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}
开发者ID:a16,项目名称:gobgp,代码行数:29,代码来源:aspath_test.py

示例11: test_07_check_replace_peer_as

    def test_07_check_replace_peer_as(self):
        g5 = GoBGPContainer(name='g5', asn=100, router_id='192.168.0.6',
                            ctn_image_name=parser_option.gobgp_image,
                            log_level=parser_option.gobgp_log_level)
        time.sleep(g5.run())

        g4 = self.ctns['g4']
        g4.add_peer(g5, replace_peer_as=True)
        g5.add_peer(g4)

        g4.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g5)

        time.sleep(1)
        self.assertTrue(g5.get_global_rib()[0]['paths'][0]['aspath'] == [200, 200, 200, 200, 200])
开发者ID:cherry-hyx,项目名称:kube-router,代码行数:14,代码来源:aspath_test.py

示例12: setUpClass

    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=65001, router_id='192.168.0.2')

        ctns = [g1, e1]
        initial_wait_time = max(ctn.run() for ctn in ctns)
        time.sleep(initial_wait_time)

        g1.add_peer(e1, treat_as_withdraw=True)
        e1.add_peer(g1)

        cls.g1 = g1
        cls.e1 = e1
开发者ID:a16,项目名称:gobgp,代码行数:18,代码来源:bgp_malformed_msg_handling_test.py

示例13: boot

    def boot(env):
        gobgp_ctn_image_name = env.parser_option.gobgp_image
        log_level = env.parser_option.gobgp_log_level
        g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1',
                            ctn_image_name=gobgp_ctn_image_name,
                            log_level=log_level)
        e1 = ExaBGPContainer(name='e1', asn=65001, router_id='192.168.0.2')
        e2 = ExaBGPContainer(name='e2', asn=65001, router_id='192.168.0.2')

        ctns = [g1, e1, e2]
        initial_wait_time = max(ctn.run() for ctn in ctns)
        time.sleep(initial_wait_time)

        for q in [e1, e2]:
            g1.add_peer(q, is_rs_client=True)
            q.add_peer(g1)

        env.g1 = g1
        env.e1 = e1
        env.e2 = e2
开发者ID:a16,项目名称:gobgp,代码行数:20,代码来源:route_server_malformed_test.py

示例14: setUpClass

    def setUpClass(cls):
        #                  +-----Confederation(AS30)-----+
        #  AS21     AS20   | +-AS65002-+     +-AS65001-+ |   AS10
        # +----+   +----+  | | +-----+ |     | +-----+ | |  +----+
        # | q3 |---| q2 |--+-+-| g1  |-+-----+-| q11 |-+-+--| q1 |
        # +----+   +----+  | | +-----+ |     | +-----+ | |  +----+
        #                  | |    |    |     |    |    | |
        #                  | |    |    |     |    |    | |
        #                  | |    |    |     |    |    | |
        #                  | | +-----+ |     | +-----+ | |
        #                  | | | q22 | |     | | q12 | | |
        #                  | | +-----+ |     | +-----+ | |
        #                  | +---------+     +---------+ |
        #                  +-----------------------------+

        gobgp_ctn_image_name = parser_option.gobgp_image
        base.TEST_PREFIX = parser_option.test_prefix

        bgp_conf_1 = {'global': {'confederation': {'config': {
            'enabled': True, 'identifier': 30, 'member-as-list': [65002]}}}}
        bgp_conf_2 = {'global': {'confederation': {'config': {
            'enabled': True, 'identifier': 30, 'member-as-list': [65001]}}}}

        g1 = GoBGPContainer(name='g1', asn=65002, router_id='192.168.2.1',
                            ctn_image_name=gobgp_ctn_image_name,
                            log_level=parser_option.gobgp_log_level,
                            bgp_config=bgp_conf_2)

        q1 = QuaggaBGPContainer(name='q1', asn=10, router_id='1.1.1.1')
        q2 = QuaggaBGPContainer(name='q2', asn=20, router_id='2.2.2.2')
        q3 = QuaggaBGPContainer(name='q3', asn=21, router_id='3.3.3.3')
        q11 = QuaggaBGPContainer(name='q11', asn=65001, router_id='192.168.1.1', bgpd_config=bgp_conf_1)
        q12 = QuaggaBGPContainer(name='q12', asn=65001, router_id='192.168.1.2', bgpd_config=bgp_conf_1)
        q22 = QuaggaBGPContainer(name='q22', asn=65002, router_id='192.168.2.2', bgpd_config=bgp_conf_2)

        ctns = [g1, q1, q2, q3, q11, q12, q22]

        cls.initial_wait_time = max(ctn.run() for ctn in ctns)

        time.sleep(cls.initial_wait_time)

        q1.add_peer(q11, remote_as=30)
        q11.add_peer(q1)
        q11.add_peer(q12)
        q12.add_peer(q11)
        g1.add_peer(q11)
        q11.add_peer(g1)
        g1.add_peer(q22)
        q22.add_peer(g1)
        g1.add_peer(q2)
        q2.add_peer(g1, remote_as=30)
        q3.add_peer(q2)
        q2.add_peer(q3)
        cls.gobgp = g1
        cls.quaggas = {'q1': q1, 'q2': q2, 'q3': q3, 'q11': q11, 'q12': q12, 'q22': q22}
开发者ID:a16,项目名称:gobgp,代码行数:55,代码来源:bgp_confederation_test.py

示例15: setUpClass

    def setUpClass(cls):
        gobgp_ctn_image_name = parser_option.gobgp_image
        base.TEST_PREFIX = parser_option.test_prefix

        g1 = GoBGPContainer(name='g1', asn=65002, router_id='192.168.0.2',
                            ctn_image_name=gobgp_ctn_image_name,
                            log_level=parser_option.gobgp_log_level)
        q1 = QuaggaBGPContainer(name='q1', asn=65003, router_id='192.168.0.3')
        q2 = QuaggaBGPContainer(name='q2', asn=65004, router_id='192.168.0.4')
        q3 = QuaggaBGPContainer(name='q3', asn=65005, router_id='192.168.0.5')
        q4 = QuaggaBGPContainer(name='q4', asn=65006, router_id='192.168.0.6')

        ctns = [g1, q1, q2, q3, q4]
        v4 = [q1, q2]
        v6 = [q3, q4]

        for idx, q in enumerate(v4):
            route = '10.0.{0}.0/24'.format(idx + 1)
            q.add_route(route)

        for idx, q in enumerate(v6):
            route = '2001:{0}::/96'.format(idx + 1)
            q.add_route(route, rf='ipv6')

        initial_wait_time = max(ctn.run() for ctn in ctns)

        time.sleep(initial_wait_time)

        for ctn in v4:
            g1.add_peer(ctn, is_rs_client=True)
            ctn.add_peer(g1)

        for ctn in v6:
            g1.add_peer(ctn, is_rs_client=True, v6=True)
            ctn.add_peer(g1, v6=True)

        cls.gobgp = g1
        cls.quaggas = {'q1': q1, 'q2': q2, 'q3': q3, 'q4': q4}
        cls.ipv4s = {'q1': q1, 'q2': q2}
        cls.ipv6s = {'q3': q3, 'q4': q4}
开发者ID:cherry-hyx,项目名称:kube-router,代码行数:40,代码来源:route_server_ipv4_v6_test.py


注:本文中的lib.gobgp.GoBGPContainer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。