a not give for true that it will be all the time Ipv4.
Change-Id: I5cb237f422fd4246d86e9e0c44e8dfda919a7af8
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
import org.opendaylight.protocol.bgp.rib.spi.state.BGPTimersState;
import org.opendaylight.protocol.bgp.rib.spi.state.BGPTransportState;
import org.opendaylight.protocol.concepts.AbstractRegistration;
+import org.opendaylight.protocol.util.Ipv4Util;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.prefixes.DestinationIpv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.prefixes.destination.ipv4.Ipv4Prefixes;
private YangInstanceIdentifier peerIId;
private final Set<AbstractRegistration> tableRegistration = new HashSet<>();
- public BGPPeer(final String name, final RIB rib, final PeerRole role, final SimpleRoutingPolicy peerStatus,
- final RpcProviderRegistry rpcRegistry,
- @Nonnull final Set<TablesKey> afiSafisAdvertized,
- @Nonnull final Set<TablesKey> afiSafisGracefulAdvertized) {
+ public BGPPeer(final IpAddress neighborAddress, final RIB rib, final PeerRole role,
+ final SimpleRoutingPolicy peerStatus, final RpcProviderRegistry rpcRegistry,
+ @Nonnull final Set<TablesKey> afiSafisAdvertized,
+ @Nonnull final Set<TablesKey> afiSafisGracefulAdvertized) {
//FIXME BUG-6971 Once Peer Group is implemented, pass it
- super(rib.getInstanceIdentifier(), null, new IpAddress(new Ipv4Address(name)), afiSafisAdvertized,
+ super(rib.getInstanceIdentifier(), null, neighborAddress, afiSafisAdvertized,
afiSafisGracefulAdvertized);
this.peerRole = role;
this.simpleRoutingPolicy = Optional.ofNullable(peerStatus);
this.rib = Preconditions.checkNotNull(rib);
- this.name = name;
+ this.name = Ipv4Util.toStringIP(neighborAddress);
this.rpcRegistry = rpcRegistry;
this.peerStats = new BGPPeerStatsImpl(this.name, this.tables, this);
this.chain = rib.createPeerChain(this);
}
- public BGPPeer(final String name, final RIB rib, final PeerRole role,
+ public BGPPeer(final IpAddress neighborAddress, final RIB rib, final PeerRole role,
final RpcProviderRegistry rpcRegistry, @Nonnull final Set<TablesKey> afiSafisAdvertized,
@Nonnull final Set<TablesKey> afiSafisGracefulAdvertized) {
- this(name, rib, role, null, rpcRegistry, afiSafisAdvertized, afiSafisGracefulAdvertized);
+ this(neighborAddress, rib, role, null, rpcRegistry, afiSafisAdvertized, afiSafisGracefulAdvertized);
}
public void instantiateServiceInstance() {
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public final class BgpPeer implements PeerBean, BGPPeerStateConsumer, BGPPeerRuntimeMXBean {
private static final Logger LOG = LoggerFactory.getLogger(BgpPeer.class);
"Missing mandatory AFIs/SAFIs");
final Set<TablesKey> afiSafisAdvertized = OpenConfigMappingUtil
.toTableKey(afisSAfis.getAfiSafi(), tableTypeRegistry);
- this.bgpPeer = new BGPPeer(Ipv4Util.toStringIP(this.neighborAddress), rib,
+ this.bgpPeer = new BGPPeer(this.neighborAddress, rib,
OpenConfigMappingUtil.toPeerRole(neighbor), getSimpleRoutingPolicy(neighbor), BgpPeer.this.rpcRegistry,
afiSafisAdvertized, Collections.emptySet());
final List<BgpParameters> bgpParameters = getBgpParameters(neighbor, rib, tableTypeRegistry);
final BgpParameters bgpParameters, final PeerRole peerRole, final BGPPeerRegistry bgpPeerRegistry) {
final IpAddress ipAddress = new IpAddress(peerAddress);
- final BGPPeer bgpPeer = new BGPPeer(peerAddress.getValue(), ribImpl, peerRole, null,
+ final BGPPeer bgpPeer = new BGPPeer(new IpAddress(peerAddress), ribImpl, peerRole, null,
AFI_SAFIS_ADVERTIZED, Collections.emptySet());
final List<BgpParameters> tlvs = Lists.newArrayList(bgpParameters);
bgpPeerRegistry.addPeer(ipAddress, bgpPeer,
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.ExecutionException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext;
import org.opendaylight.protocol.bgp.util.HexDumpBGPFileParser;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv6.routes.ipv6.routes.Ipv6Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.LinkstateAddressFamily;
private BGPMock mock;
private AbstractRIBExtensionProviderActivator baseact, lsact;
private RIBExtensionProviderContext ext1, ext2;
- private final String localAddress = "127.0.0.1";
+ private final IpAddress localAddress = new IpAddress(new Ipv4Address("127.0.0.1"));
@Mock
private BGPDispatcher dispatcher;
}
@Test
- public void testWithLinkstate() throws InterruptedException, ExecutionException, ReadFailedException {
+ public void testWithLinkstate() throws ReadFailedException {
final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(LinkstateAddressFamily.class,
LinkstateSubsequentAddressFamily.class));
final RIBImpl rib = new RIBImpl(this.clusterSingletonServiceProvider, new RibId(TEST_RIB_ID),
}
@Test
- public void testWithoutLinkstate() throws InterruptedException, ExecutionException, ReadFailedException {
+ public void testWithoutLinkstate() throws ReadFailedException {
final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(Ipv4AddressFamily.class,
UnicastSubsequentAddressFamily.class));
final RIBImpl rib = new RIBImpl(this.clusterSingletonServiceProvider, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID,
});
}
- private void assertTablesExists(final List<BgpTableType> expectedTables)
- throws InterruptedException, ExecutionException, ReadFailedException {
+ private void assertTablesExists(final List<BgpTableType> expectedTables) throws ReadFailedException {
readDataOperational(getDataBroker(), BGP_IID, bgpRib -> {
final List<Tables> tables = bgpRib.getRib().get(0).getLocRib().getTables();
assertFalse(tables.isEmpty());
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.impl.message.update.LocalPreferenceAttributeParser;
import org.opendaylight.protocol.bgp.rib.spi.RibSupportUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4Route;
private Map<YangInstanceIdentifier, NormalizedNode<?, ?>> routes;
private BGPPeer classic;
- private final Ipv4Address neighborAddress = new Ipv4Address("127.0.0.1");
+ private final IpAddress neighborAddress = new IpAddress(new Ipv4Address("127.0.0.1"));
@Override
@Before
final Ipv4Prefix first = new Ipv4Prefix("127.0.0.2/32");
final Ipv4Prefix second = new Ipv4Prefix("127.0.0.1/32");
final Ipv4Prefix third = new Ipv4Prefix("127.0.0.3/32");
- this.peer = new ApplicationPeer(new ApplicationRibId(this.neighborAddress.getValue()), this.neighborAddress, getRib());
+ this.peer = new ApplicationPeer(new ApplicationRibId(this.neighborAddress.getIpv4Address().getValue()),
+ this.neighborAddress.getIpv4Address(), getRib());
this.peer.instantiateServiceInstance(null, null);
final YangInstanceIdentifier base = getRib().getYangRibId().node(LocRib.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(KEY));
this.peer.onDataTreeChanged(ipv4Input(base, ModificationType.WRITE, first, second, third));
@Test
public void testClassicPeer() throws Exception {
- this.classic = new BGPPeer(this.neighborAddress.getValue(), getRib(), PeerRole.Ibgp, null, Collections.emptySet(),
+ this.classic = new BGPPeer(this.neighborAddress, getRib(), PeerRole.Ibgp, null, Collections.emptySet(),
Collections.emptySet());
this.classic.instantiateServiceInstance();
this.mockSession();
- assertEquals(this.neighborAddress.getValue(), this.classic.getName());
+ assertEquals(this.neighborAddress.getIpv4Address().getValue(), this.classic.getName());
this.classic.onSessionUp(this.session);
assertEquals(1, this.classic.getBgpPeerState().getSessionEstablishedCount().getValue().intValue());
Assert.assertArrayEquals(new byte[]{1, 1, 1, 1}, this.classic.getRawIdentifier());
assertEquals(3, this.routes.size());
//create new peer so that it gets advertized routes from RIB
- final BGPPeer testingPeer = new BGPPeer(this.neighborAddress.getValue(), getRib(), PeerRole.Ibgp, null,
+ final BGPPeer testingPeer = new BGPPeer(this.neighborAddress, getRib(), PeerRole.Ibgp, null,
Collections.emptySet(), Collections.emptySet());
testingPeer.instantiateServiceInstance();
testingPeer.onSessionUp(this.session);
ribImpl.instantiateServiceInstance();
ribImpl.onGlobalContextUpdated(this.schemaContext);
- final BGPPeer bgpPeer = new BGPPeer(LOCAL_IP, ribImpl, PeerRole.Ibgp, null, AFI_SAFIS_ADVERTIZED,
+ final BGPPeer bgpPeer = new BGPPeer(neighbor, ribImpl, PeerRole.Ibgp, null, AFI_SAFIS_ADVERTIZED,
Collections.emptySet());
bgpPeer.instantiateServiceInstance();
final BGPSessionImpl bgpSession = new BGPSessionImpl(bgpPeer, this.speakerListener, this.classicOpen, this.classicOpen.getHoldTimer(), null);
ribImpl.instantiateServiceInstance();
ribImpl.onGlobalContextUpdated(this.schemaContext);
- final BGPPeer bgpPeer = new BGPPeer(LOCAL_IP, ribImpl, PeerRole.Ibgp, null, AFI_SAFIS_ADVERTIZED,
+ final BGPPeer bgpPeer = new BGPPeer(neighbor, ribImpl, PeerRole.Ibgp, null, AFI_SAFIS_ADVERTIZED,
Collections.emptySet());
bgpPeer.instantiateServiceInstance();
final BGPSessionImpl bgpSession = new BGPSessionImpl(bgpPeer, this.speakerListener, this.classicOpen, this.classicOpen.getHoldTimer(), null);