def test_validate_ip_addr_with_integer_ip(self): with self.assertRaisesRegex( bgp_driver_exc.InvalidParamType, EXC_INV_PARAMTYPE % { 'param': '12345', 'param_type': 'ip-address' }): bgp_driver_utils.validate_ip_addr(12345)
def test_validate_ip_addr_with_invalid_ipv6_type(self): with self.assertRaisesRegex( bgp_driver_exc.InvalidParamType, EXC_INV_PARAMTYPE % { 'param': '2001:db8::ggg', 'param_type': 'ip-address' }): bgp_driver_utils.validate_ip_addr('2001:db8::ggg')
def add_bgp_peer(self, speaker_as, peer_ip, peer_as, auth_type='none', password=None): curr_speaker = self.cache.get_bgp_speaker(speaker_as) if not curr_speaker: raise bgp_driver_exc.BgpSpeakerNotAdded(local_as=speaker_as, rtid=self.routerid) # Validate peer_ip and peer_as. utils.validate_as_num('remote_as', peer_as) utils.validate_ip_addr(peer_ip) utils.validate_auth(auth_type, password) if password is not None: password = encodeutils.to_utf8(password) curr_speaker.neighbor_add(address=peer_ip, remote_as=peer_as, enable_ipv4=True, enable_ipv6=True, password=password, connect_mode=CONNECT_MODE_ACTIVE) LOG.info( _LI('Added BGP Peer %(peer)s for remote_as=%(as)d to ' 'BGP Speaker running for local_as=%(local_as)d.'), { 'peer': peer_ip, 'as': peer_as, 'local_as': speaker_as })
def delete_bgp_peer(self, speaker_as, peer_ip): curr_speaker = self.cache.get_bgp_speaker(speaker_as) if not curr_speaker: raise bgp_driver_exc.BgpSpeakerNotAdded(local_as=speaker_as, rtid=self.routerid) # Validate peer_ip. It must be a string. utils.validate_ip_addr(peer_ip) # Notify Ryu about BGP Peer removal curr_speaker.neighbor_del(address=peer_ip) LOG.info( _LI('Removed BGP Peer %(peer)s from BGP Speaker ' 'running for local_as=%(local_as)d.'), { 'peer': peer_ip, 'local_as': speaker_as })
def add_bgp_peer(self, speaker_as, peer_ip, peer_as, auth_type='none', password=None, enable_evpn=None, hold_time=None, connect_mode=CONNECT_MODE_ACTIVE): curr_speaker = self.cache.get_bgp_speaker(speaker_as) if not curr_speaker: raise bgp_driver_exc.BgpSpeakerNotAdded(local_as=speaker_as, rtid=self.routerid) # Validate peer_ip and peer_as. utils.validate_as_num('remote_as', peer_as) ip_version = utils.validate_ip_addr(peer_ip) utils.validate_auth(auth_type, password) if password is not None: password = encodeutils.to_utf8(password) kwargs = {} if enable_evpn is not None: kwargs['enable_evpn'] = enable_evpn if hold_time is not None: kwargs['hold_time'] = hold_time # Notify Ryu about BGP Peer addition if ip_version == lib_consts.IP_VERSION_4: enable_ipv4 = True enable_ipv6 = False else: enable_ipv4 = False enable_ipv6 = True curr_speaker.neighbor_add(address=peer_ip, remote_as=peer_as, enable_ipv4=enable_ipv4, enable_ipv6=enable_ipv6, password=password, connect_mode=connect_mode, **kwargs) LOG.info( _LI('Added BGP Peer %(peer)s for remote_as=%(as)d to ' 'BGP Speaker running for local_as=%(local_as)d.'), { 'peer': peer_ip, 'as': peer_as, 'local_as': speaker_as })
def test_validate_ip_addr_with_ipv6_address(self): self.assertEqual(lib_consts.IP_VERSION_6, bgp_driver_utils.validate_ip_addr(FAKE_IPV6))
def test_validate_ip_addr_with_invalid_ipv6_type(self): with self.assertRaisesRegex( bgp_driver_exc.InvalidParamType, EXC_INV_PARAMTYPE % {'param': '2001:db8::ggg', 'param_type': 'ip-address'}): bgp_driver_utils.validate_ip_addr('2001:db8::ggg')
def test_validate_ip_addr_with_integer_ip(self): with self.assertRaisesRegex( bgp_driver_exc.InvalidParamType, EXC_INV_PARAMTYPE % {'param': '12345', 'param_type': 'ip-address'}): bgp_driver_utils.validate_ip_addr(12345)
def test_validate_ip_addr_with_ipv6_address(self): self.assertEqual(lib_consts.IP_VERSION_6, bgp_driver_utils.validate_ip_addr(FAKE_IPV6))