use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.te.lsp._case.address.family.Ipv4Case in project bgpcep by opendaylight.
the class PathComputationImpl method getSourceVertexKey.
private VertexKey getSourceVertexKey(final EndpointsObj endPoints) {
IpAddress address = null;
if (endPoints.getAddressFamily() instanceof Ipv4Case) {
address = new IpAddress(((Ipv4Case) endPoints.getAddressFamily()).getIpv4().getSourceIpv4Address());
}
if (endPoints.getAddressFamily() instanceof Ipv6Case) {
address = new IpAddress(((Ipv6Case) endPoints.getAddressFamily()).getIpv6().getSourceIpv6Address());
}
if (address == null) {
return null;
}
ConnectedVertex vertex = tedGraph.getConnectedVertex(address);
LOG.debug("Compute path from Source {}", vertex != null ? vertex : "Unknown");
return vertex != null ? vertex.getVertex().key() : null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.te.lsp._case.address.family.Ipv4Case in project bgpcep by opendaylight.
the class NodeChangedListener method create.
private void create(final ReadWriteTransaction trans, final InstanceIdentifier<ReportedLsp> identifier, final ReportedLsp value) throws ExecutionException, InterruptedException {
final InstanceIdentifier<Node> ni = identifier.firstIdentifierOf(Node.class);
final Path1 rl = value.nonnullPath().values().iterator().next().augmentation(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.implementedInterface());
}
final Path path0 = value.nonnullPath().values().iterator().next();
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().getDelegate());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Link1Builder slab = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Link1Builder();
slab.setOperationalStatus(rl.getLsp().getOperational());
slab.setAdministrativeStatus(rl.getLsp().getAdministrative() ? 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(lab.build());
lb.addAugmentation(slab.build());
trans.put(LogicalDatastoreType.OPERATIONAL, linkForLsp(id), lb.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.te.lsp._case.address.family.Ipv4Case in project bgpcep by opendaylight.
the class Stateful07LSPIdentifierIpv4TlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
Preconditions.checkArgument(tlv instanceof LspIdentifiers, "LspIdentifiersTlv is mandatory.");
final LspIdentifiers lsp = (LspIdentifiers) tlv;
final AddressFamily afi = lsp.getAddressFamily();
final ByteBuf body = Unpooled.buffer();
if (afi.getImplementedInterface().equals(Ipv6Case.class)) {
new Stateful07LSPIdentifierIpv6TlvParser().serializeTlv(tlv, buffer);
}
final Ipv4 ipv4 = ((Ipv4Case) afi).getIpv4();
Preconditions.checkArgument(ipv4.getIpv4TunnelSenderAddress() != null, "Ipv4TunnelSenderAddress is mandatory.");
writeIpv4Address(ipv4.getIpv4TunnelSenderAddress(), body);
Preconditions.checkArgument(lsp.getLspId() != null, "LspId is mandatory.");
writeShort(lsp.getLspId().getValue().shortValue(), body);
Preconditions.checkArgument(lsp.getTunnelId() != null, "TunnelId is mandatory.");
writeUnsignedShort(lsp.getTunnelId().getValue(), body);
Preconditions.checkArgument(ipv4.getIpv4ExtendedTunnelId() != null, "Ipv4ExtendedTunnelId is mandatory.");
writeIpv4Address(ipv4.getIpv4ExtendedTunnelId(), body);
Preconditions.checkArgument(ipv4.getIpv4TunnelEndpointAddress() != null, "Ipv4TunnelEndpointAddress is mandatory.");
writeIpv4Address(ipv4.getIpv4TunnelEndpointAddress(), body);
TlvUtil.formatTlv(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.te.lsp._case.address.family.Ipv4Case in project bgpcep by opendaylight.
the class TunnelProgrammingTest method testTunnelProgramming.
@Test
public void testTunnelProgramming() throws InterruptedException, ExecutionException {
final Bandwidth bwd = new Bandwidth(new byte[] { 0x00, 0x00, 0x00, (byte) 0xff });
final ClassType classType = new ClassType(Uint8.ONE);
final String tunnelName = "create-tunnel";
final NetworkTopologyRef topologyRef = new NetworkTopologyRef(TOPO_IID);
// create tunnel
tunnelProgramming.pcepCreateP2pTunnel(new PcepCreateP2pTunnelInputBuilder().setDestination(new DestinationBuilder().setNode(NODE2_ID).setTp(TP2_ID).build()).setSource(new SourceBuilder().setNode(NODE1_ID).setTp(TP1_ID).build()).setNetworkTopologyRef(topologyRef).setBandwidth(bwd).setClassType(classType).setSymbolicPathName(tunnelName).addAugmentation(new PcepCreateP2pTunnelInput1Builder().setAdministrativeStatus(AdministrativeStatus.Active).build()).build());
// check add-lsp input
assertNotNull(addLspInput);
assertEquals(tunnelName, addLspInput.getName());
final Arguments agrs = addLspInput.getArguments();
assertNotNull(agrs);
assertEquals(bwd, agrs.getBandwidth().getBandwidth());
assertEquals(classType, agrs.getClassType().getClassType());
final Ipv4 ipv4Endpoints = ((Ipv4Case) agrs.getEndpointsObj().getAddressFamily()).getIpv4();
assertEquals(NODE1_IPV4, ipv4Endpoints.getSourceIpv4Address().getValue());
assertEquals(NODE2_IPV4, ipv4Endpoints.getDestinationIpv4Address().getValue());
assertEquals(NODE1_ID.getValue(), addLspInput.getNode().getValue());
createLink();
// update tunnel
tunnelProgramming.pcepUpdateTunnel(new PcepUpdateTunnelInputBuilder().setNetworkTopologyRef(topologyRef).setBandwidth(bwd).setClassType(classType).setExplicitHops(BindingMap.ordered(createExplicitHop(IPV4_PREFIX1, Uint32.ONE), createExplicitHop(IPV4_PREFIX2, Uint32.TWO))).setLinkId(LINK1_ID).addAugmentation(new PcepUpdateTunnelInput1Builder().setAdministrativeStatus(AdministrativeStatus.Active).build()).build());
// check update-lsp input
assertNotNull(updateLspInput);
assertEquals(LINK1_ID.getValue(), updateLspInput.getName());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.update.lsp.args.Arguments updArgs = updateLspInput.getArguments();
assertEquals(2, updArgs.getEro().nonnullSubobject().size());
final List<Subobject> subObjects = updArgs.getEro().nonnullSubobject();
final IpPrefixCase prefix1 = (IpPrefixCase) subObjects.get(0).getSubobjectType();
final IpPrefixCase prefix2 = (IpPrefixCase) subObjects.get(1).getSubobjectType();
assertEquals(IPV4_PREFIX1, prefix1.getIpPrefix().getIpPrefix().getIpv4Prefix().getValue());
assertEquals(IPV4_PREFIX2, prefix2.getIpPrefix().getIpPrefix().getIpv4Prefix().getValue());
// delete tunnel
final PcepDestroyTunnelInputBuilder destroyInputBuilder = new PcepDestroyTunnelInputBuilder();
destroyInputBuilder.setLinkId(LINK1_ID);
destroyInputBuilder.setNetworkTopologyRef(topologyRef);
tunnelProgramming.pcepDestroyTunnel(destroyInputBuilder.build());
assertNotNull(removeLspInput);
assertEquals(LINK1_ID.getValue(), removeLspInput.getName());
assertEquals(NODE1_ID, removeLspInput.getNode());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.te.lsp._case.address.family.Ipv4Case in project bgpcep by opendaylight.
the class DetourObjectIpv4Parser method localParseObject.
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) {
final Ipv4DetourObjectBuilder ipv4Case = new Ipv4DetourObjectBuilder();
final List<Plr> plrList = new ArrayList<>();
while (byteBuf.isReadable()) {
final PlrBuilder plr = new PlrBuilder();
plr.setPlrId(Ipv4Util.addressForByteBuf(byteBuf));
plr.setAvoidNode(Ipv4Util.addressForByteBuf(byteBuf));
plrList.add(plr.build());
}
return ipv4Case.setPlr(plrList).build();
}
Aggregations