use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project bgpcep by opendaylight.
the class LUNlriParser method parseNlri.
@Override
public void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpUnreachNlriBuilder builder, @Nullable final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final Class<? extends AddressFamily> afi = builder.getAfi();
final boolean mPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
final List<CLabeledUnicastDestination> dst = parseNlri(nlri, afi, mPathSupported);
DestinationType destination = null;
if (afi == Ipv4AddressFamily.class) {
destination = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(dst).build()).build();
} else if (afi == Ipv6AddressFamily.class) {
destination = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder().setCLabeledUnicastDestination(dst).build()).build();
}
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(destination).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project bgpcep by opendaylight.
the class LinkstateNlriParser method parseNlri.
@Override
public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final List<CLinkstateDestination> dst = parseNlri(nlri);
builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationLinkstateCaseBuilder().setDestinationLinkstate(new DestinationLinkstateBuilder().setCLinkstateDestination(dst).build()).build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project bgpcep by opendaylight.
the class LinkstateNlriParser method parseNlri.
@Override
public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final List<CLinkstateDestination> dst = parseNlri(nlri);
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder().setDestinationLinkstate(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.linkstate._case.DestinationLinkstateBuilder().setCLinkstateDestination(dst).build()).build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project bgpcep by opendaylight.
the class NodeChangedListenerTest method testNodeChangedListener.
@Test
public void testNodeChangedListener() throws ReadFailedException, TransactionCommitFailedException {
// add node -> create two nodes with TPs and link
createNode(NODE1_ID, NODE1_IPV4, LSP1_NAME, LSP1_ID, NODE2_IPV4);
final Topology tunnelTopo = readDataOperational(getDataBroker(), TUNNEL_TOPO_IID, tunnelTopo1 -> {
assertNotNull(tunnelTopo1.getNode());
assertEquals(2, tunnelTopo1.getNode().size());
return tunnelTopo1;
});
final NodeId srcId = new NodeId("ip://" + new IpAddress(new Ipv4Address(NODE1_IPV4)));
final NodeId dstId = new NodeId("ip://" + new IpAddress(new Ipv4Address(NODE2_IPV4)));
final Node dst;
final Node src;
if (tunnelTopo.getNode().get(0).getNodeId().equals(srcId)) {
src = tunnelTopo.getNode().get(0);
dst = tunnelTopo.getNode().get(1);
} else {
src = tunnelTopo.getNode().get(1);
dst = tunnelTopo.getNode().get(0);
}
Assert.assertEquals(srcId, src.getNodeId());
Assert.assertEquals(dstId, dst.getNodeId());
Assert.assertEquals(1, dst.getTerminationPoint().size());
Assert.assertEquals(1, src.getTerminationPoint().size());
final TerminationPoint dstTp = dst.getTerminationPoint().get(0);
final TerminationPoint srcTp = src.getTerminationPoint().get(0);
final TpId dstNodeTpId = new TpId(dstId.getValue());
final TpId srcNodeTpId = new TpId(srcId.getValue());
Assert.assertEquals(dstNodeTpId, dstTp.getTpId());
Assert.assertEquals(srcNodeTpId, srcTp.getTpId());
Assert.assertEquals(1, src.getSupportingNode().size());
Assert.assertNull(dst.getSupportingNode());
final SupportingNode sNode = src.getSupportingNode().get(0);
Assert.assertEquals(NODE1_ID, sNode.getKey().getNodeRef());
Assert.assertEquals(1, tunnelTopo.getLink().size());
final Link link = tunnelTopo.getLink().get(0);
Assert.assertEquals(srcId, link.getSource().getSourceNode());
Assert.assertEquals(srcNodeTpId, link.getSource().getSourceTp());
Assert.assertEquals(dstId, link.getDestination().getDestNode());
Assert.assertEquals(dstNodeTpId, link.getDestination().getDestTp());
// update second node -> adds supporting node and second link
createNode(NODE2_ID, NODE2_IPV4, LSP2_NAME, LSP2_ID, NODE1_IPV4);
readDataOperational(getDataBroker(), TUNNEL_TOPO_IID, updatedNodeTopo -> {
assertNotNull(updatedNodeTopo.getNode());
Assert.assertEquals(2, updatedNodeTopo.getNode().size());
final Node updatedNode;
if (updatedNodeTopo.getNode().get(0).getNodeId().equals(srcId)) {
updatedNode = updatedNodeTopo.getNode().get(1);
} else {
updatedNode = updatedNodeTopo.getNode().get(0);
}
assertNotNull(updatedNode.getSupportingNode());
Assert.assertEquals(1, updatedNode.getSupportingNode().size());
final SupportingNode sNode2 = updatedNode.getSupportingNode().get(0);
Assert.assertEquals(NODE2_ID, sNode2.getNodeRef());
Assert.assertEquals(2, updatedNodeTopo.getLink().size());
return updatedNodeTopo;
});
readDataOperational(getDataBroker(), TUNNEL_TOPO_IID, updatedNodeTopo -> {
final Link link2;
if (updatedNodeTopo.getLink().get(0).getSource().getSourceNode().equals(srcId)) {
link2 = updatedNodeTopo.getLink().get(1);
} else {
link2 = updatedNodeTopo.getLink().get(0);
}
assertEquals(dstId, link2.getSource().getSourceNode());
assertEquals(dstNodeTpId, link2.getSource().getSourceTp());
assertEquals(srcId, link2.getDestination().getDestNode());
assertEquals(srcNodeTpId, link2.getDestination().getDestTp());
return updatedNodeTopo;
});
// remove nodes -> remove link
removeNode(NODE1_ID);
removeNode(NODE2_ID);
readDataOperational(getDataBroker(), TUNNEL_TOPO_IID, removedNodeTopo -> {
assertEquals(0, removedNodeTopo.getNode().size());
assertEquals(0, removedNodeTopo.getLink().size());
return removedNodeTopo;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project bgpcep by opendaylight.
the class NodeChangedListener method create.
private void create(final ReadWriteTransaction trans, final InstanceIdentifier<ReportedLsp> identifier, final ReportedLsp value) throws ReadFailedException {
final InstanceIdentifier<Node> ni = identifier.firstIdentifierOf(Node.class);
final Path1 rl = value.getPath().get(0).getAugmentation(Path1.class);
final AddressFamily af = rl.getLsp().getTlvs().getLspIdentifiers().getAddressFamily();
/*
* We are trying to ensure we have source and destination nodes.
*/
final IpAddress srcIp;
final IpAddress dstIp;
if (af instanceof Ipv4Case) {
final Ipv4 ipv4 = ((Ipv4Case) af).getIpv4();
srcIp = new IpAddress(ipv4.getIpv4TunnelSenderAddress());
dstIp = new IpAddress(ipv4.getIpv4TunnelEndpointAddress());
} else if (af instanceof Ipv6Case) {
final Ipv6 ipv6 = ((Ipv6Case) af).getIpv6();
srcIp = new IpAddress(ipv6.getIpv6TunnelSenderAddress());
dstIp = new IpAddress(ipv6.getIpv6TunnelSenderAddress());
} else {
throw new IllegalArgumentException("Unsupported address family: " + af.getImplementedInterface());
}
final Path path0 = value.getPath().get(0);
final Link1Builder lab = new Link1Builder();
if (path0.getBandwidth() != null) {
lab.setBandwidth(path0.getBandwidth().getBandwidth());
}
if (path0.getClassType() != null) {
lab.setClassType(path0.getClassType().getClassType());
}
lab.setSymbolicPathName(value.getName());
final InstanceIdentifier<TerminationPoint> dst = getIpTerminationPoint(trans, dstIp, null, Boolean.FALSE);
final InstanceIdentifier<TerminationPoint> src = getIpTerminationPoint(trans, srcIp, ni, rl.getLsp().isDelegate());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Link1Builder slab = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Link1Builder();
slab.setOperationalStatus(rl.getLsp().getOperational());
slab.setAdministrativeStatus(rl.getLsp().isAdministrative() ? AdministrativeStatus.Active : AdministrativeStatus.Inactive);
final LinkId id = linkIdForLsp(identifier, value);
final LinkBuilder lb = new LinkBuilder();
lb.setLinkId(id);
lb.setSource(new SourceBuilder().setSourceNode(src.firstKeyOf(Node.class).getNodeId()).setSourceTp(src.firstKeyOf(TerminationPoint.class).getTpId()).build());
lb.setDestination(new DestinationBuilder().setDestNode(dst.firstKeyOf(Node.class).getNodeId()).setDestTp(dst.firstKeyOf(TerminationPoint.class).getTpId()).build());
lb.addAugmentation(Link1.class, lab.build());
lb.addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Link1.class, slab.build());
trans.put(LogicalDatastoreType.OPERATIONAL, linkForLsp(id), lb.build());
}
Aggregations