示例#1
0
 def test_unschedule_deleted_speaker(self):
     self.bgp_peer_args[0]['peer_ip'] = self.r_as_ip[0].split('/')[0]
     num, subnet = six.next(self.tnet_gen)
     mask = '/' + str(self.TPool.prefixlen)
     TNet = s_base.Net(name='',
                       net=subnet,
                       mask=self.TPool.prefixlen,
                       cidr=subnet + mask,
                       router=None)
     TSubNet = s_base.SubNet(name='', cidr=TNet.cidr, mask=TNet.mask)
     MyRouter = s_base.Router(name='my-router' + str(num), gw='')
     ext_net_id = self.create_bgp_network(4, self.MyScope, self.PNet,
                                          self.PPool, self.PSubNet,
                                          self.TPool,
                                          [[TNet, TSubNet, MyRouter]])
     speaker_id, peers_ids = self.create_and_add_peers_to_speaker(
         ext_net_id,
         self.bgp_speaker_args, [self.bgp_peer_args[0]],
         auto_delete=False)
     self.check_remote_as_state(self.dr, self.r_ass[0],
                                ctn_base.BGP_FSM_ESTABLISHED)
     self.delete_bgp_speaker(speaker_id)
     self.delete_bgp_peer(peers_ids[0])
     self.check_remote_as_state(self.dr,
                                self.r_ass[0],
                                ctn_base.BGP_FSM_ACTIVE,
                                init_state=ctn_base.BGP_FSM_ESTABLISHED)
示例#2
0
 def _test_check_advertised_multiple_tenant_network(self, ip_version):
     self.bgp_peer_args[0]['peer_ip'] = self.r_as_ip[0].split('/')[0]
     tnets = []
     tnets_cidr = []
     for i in range(0, 3):
         num, subnet = six.next(self.tnet_gen)
         mask = '/' + str(self.TPool.prefixlen)
         TNet = base.Net(name='',
                         net=subnet,
                         mask=self.TPool.prefixlen,
                         cidr=subnet + mask,
                         router=None)
         TSubNet = base.SubNet(name='', cidr=TNet.cidr, mask=TNet.mask)
         MyRouter = base.Router(name='my-router' + str(num), gw='')
         tnets.append([TNet, TSubNet, MyRouter])
         tnets_cidr.append(TNet.cidr)
     ext_net_id = self.create_bgp_network(ip_version, self.MyScope,
                                          self.PNet, self.PPool,
                                          self.PSubNet, self.TPool, tnets)
     speaker_id, peers_ids = self.create_and_add_peers_to_speaker(
         ext_net_id, self.bgp_speaker_args, [self.bgp_peer_args[0]])
     self.check_remote_as_state(self.dr, self.r_ass[0],
                                ctn_base.BGP_FSM_ESTABLISHED)
     rf = 'ipv' + str(ip_version)
     for cidr in tnets_cidr:
         self.check_remote_as_rib(self.r_ass[0], cidr, rf, 'nexthop',
                                  self.get_next_hop(speaker_id, cidr))
示例#3
0
 def _test_check_advertised_tenant_network_with_multiple_peers(
         self, ip_version):
     for (bgp_peer_args, r_as_ip) in zip(self.bgp_peer_args, self.r_as_ip):
         bgp_peer_args['peer_ip'] = r_as_ip.split('/')[0]
     num, subnet = six.next(self.tnet_gen)
     mask = '/' + str(self.TPool.prefixlen)
     TNet = base.Net(name='',
                     net=subnet,
                     mask=self.TPool.prefixlen,
                     cidr=subnet + mask,
                     router=None)
     TSubNet = base.SubNet(name='', cidr=TNet.cidr, mask=TNet.mask)
     MyRouter = base.Router(name='my-router' + str(num), gw='')
     ext_net_id = self.create_bgp_network(ip_version, self.MyScope,
                                          self.PNet, self.PPool,
                                          self.PSubNet, self.TPool,
                                          [[TNet, TSubNet, MyRouter]])
     speaker_id, peers_ids = self.create_and_add_peers_to_speaker(
         ext_net_id, self.bgp_speaker_args, self.bgp_peer_args)
     self.check_multi_remote_as_state(self.dr, self.r_ass,
                                      ctn_base.BGP_FSM_ESTABLISHED)
     rf = 'ipv' + str(ip_version)
     next_hop = self.get_next_hop(speaker_id, TNet.cidr)
     self.check_multi_remote_as_rib(self.r_ass, TNet.cidr, rf, 'nexthop',
                                    next_hop)
示例#4
0
 def _test_check_neighbor_established(self, ip_version):
     self.bgp_peer_args[0]['peer_ip'] = self.r_as_ip[0].split('/')[0]
     num, subnet = six.next(self.tnet_gen)
     mask = '/' + str(self.TPool.prefixlen)
     TNet = base.Net(name='',
                     net=subnet,
                     mask=self.TPool.prefixlen,
                     cidr=subnet + mask,
                     router=None)
     TSubNet = base.SubNet(name='', cidr=TNet.cidr, mask=TNet.mask)
     MyRouter = base.Router(name='my-router' + str(num), gw='')
     ext_net_id = self.create_bgp_network(ip_version, self.MyScope,
                                          self.PNet, self.PPool,
                                          self.PSubNet, self.TPool,
                                          [[TNet, TSubNet, MyRouter]])
     speaker_id, peers_ids = self.create_and_add_peers_to_speaker(
         ext_net_id, self.bgp_speaker_args, [self.bgp_peer_args[0]])
     self.check_remote_as_state(self.dr, self.r_ass[0],
                                ctn_base.BGP_FSM_ESTABLISHED)
示例#5
0
    def test_remove_add_speaker_agent(self):
        self.bgp_peer_args[0]['peer_ip'] = self.r_as_ip[0].split('/')[0]
        num, subnet = six.next(self.tnet_gen)
        mask = '/' + str(self.TPool.prefixlen)
        TNet = s_base.Net(name='',
                          net=subnet,
                          mask=self.TPool.prefixlen,
                          cidr=subnet + mask,
                          router=None)
        TSubNet = s_base.SubNet(name='', cidr=TNet.cidr, mask=TNet.mask)
        MyRouter = s_base.Router(name='my-router' + str(num), gw='')
        ext_net_id = self.create_bgp_network(4, self.MyScope, self.PNet,
                                             self.PPool, self.PSubNet,
                                             self.TPool,
                                             [[TNet, TSubNet, MyRouter]])
        speaker_id, peers_ids = self.create_and_add_peers_to_speaker(
            ext_net_id, self.bgp_speaker_args, [self.bgp_peer_args[0]])
        self.check_remote_as_state(self.dr, self.r_ass[0],
                                   ctn_base.BGP_FSM_ESTABLISHED)
        agent_list = self.bgp_client.list_dragents_for_bgp_speaker(
            speaker_id)['agents']
        self.assertEqual(1, len(agent_list))
        agent_id = agent_list[0]['id']
        self.bgp_client.remove_bgp_speaker_from_dragent(agent_id, speaker_id)
        # NOTE(tidwellr) This assertion can fail due to the fact that BGP
        # speakers are auto-scheduled. The BGP process can quickly return to
        # ACTIVE status before this gets asserted. Let's see how it goes with
        # this commented out.
        # self.check_remote_as_state(self.dr, self.r_ass[0],
        #                           ctn_base.BGP_FSM_ACTIVE,
        #                           init_state=ctn_base.BGP_FSM_ESTABLISHED)

        # Ignore errors re-associating the BGP speaker, auto-scheduling may
        # have already added it to an agent. The next assertion is what
        # matters.
        self.bgp_client.add_bgp_speaker_to_dragent(agent_id,
                                                   speaker_id,
                                                   ignore_errors=True)
        self.check_remote_as_state(self.dr, self.r_ass[0],
                                   ctn_base.BGP_FSM_ESTABLISHED)