use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project bgpcep by opendaylight.
the class PMSITunnelAttributeHandler method serializeAttribute.
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
final PmsiTunnelAugmentation pmsiTunnelAugmentation = ((Attributes) attribute).getAugmentation(PmsiTunnelAugmentation.class);
if (pmsiTunnelAugmentation == null) {
return;
}
final PmsiTunnel pmsiTunnelAttribute = pmsiTunnelAugmentation.getPmsiTunnel();
final TunnelIdentifier tunnel = pmsiTunnelAttribute.getTunnelIdentifier();
final ByteBuf tunnelBuffer = Unpooled.buffer();
final int tunnelType = this.tunnelIdentifierHandler.serialize(tunnel, tunnelBuffer);
final ByteBuf body = Unpooled.buffer();
serializeFlag(pmsiTunnelAttribute, body);
body.writeByte(tunnelType);
serializeMpls(pmsiTunnelAttribute.getMplsLabel(), body);
body.writeBytes(tunnelBuffer);
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, getType(), body, byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project bgpcep by opendaylight.
the class TunnelProgrammingTest method testTunnelProgramming.
@Test
public void testTunnelProgramming() throws TransactionCommitFailedException {
final Bandwidth bwd = new Bandwidth(new byte[] { 0x00, 0x00, 0x00, (byte) 0xff });
final ClassType classType = new ClassType((short) 1);
final String tunnelName = "create-tunnel";
final NetworkTopologyRef topologyRef = new NetworkTopologyRef(TOPO_IID);
// create tunnel
final PcepCreateP2pTunnelInputBuilder createInputBuilder = new PcepCreateP2pTunnelInputBuilder();
createInputBuilder.setDestination(new DestinationBuilder().setNode(NODE2_ID).setTp(TP2_ID).build());
createInputBuilder.setSource(new SourceBuilder().setNode(NODE1_ID).setTp(TP1_ID).build());
createInputBuilder.setNetworkTopologyRef(topologyRef);
createInputBuilder.setBandwidth(bwd);
createInputBuilder.setClassType(classType);
createInputBuilder.setSymbolicPathName(tunnelName);
createInputBuilder.setExplicitHops(Lists.newArrayList());
createInputBuilder.addAugmentation(PcepCreateP2pTunnelInput1.class, new PcepCreateP2pTunnelInput1Builder().setAdministrativeStatus(AdministrativeStatus.Active).build());
this.tunnelProgramming.pcepCreateP2pTunnel(createInputBuilder.build());
// check add-lsp input
Assert.assertNotNull(this.addLspInput);
Assert.assertEquals(tunnelName, this.addLspInput.getName());
final Arguments agrs = this.addLspInput.getArguments();
Assert.assertNotNull(agrs);
Assert.assertEquals(bwd, agrs.getBandwidth().getBandwidth());
Assert.assertEquals(classType, agrs.getClassType().getClassType());
final Ipv4 ipv4Endpoints = ((Ipv4Case) agrs.getEndpointsObj().getAddressFamily()).getIpv4();
Assert.assertEquals(NODE1_IPV4, ipv4Endpoints.getSourceIpv4Address().getValue());
Assert.assertEquals(NODE2_IPV4, ipv4Endpoints.getDestinationIpv4Address().getValue());
Assert.assertEquals(NODE1_ID.getValue(), this.addLspInput.getNode().getValue());
createLink();
// update tunnel
final PcepUpdateTunnelInputBuilder updateInputBuilder = new PcepUpdateTunnelInputBuilder();
updateInputBuilder.setNetworkTopologyRef(topologyRef);
updateInputBuilder.setBandwidth(bwd);
updateInputBuilder.setClassType(classType);
updateInputBuilder.setExplicitHops(Lists.newArrayList(createExplicitHop(IPV4_PREFIX1), createExplicitHop(IPV4_PREFIX2)));
updateInputBuilder.setLinkId(LINK1_ID);
updateInputBuilder.addAugmentation(PcepUpdateTunnelInput1.class, new PcepUpdateTunnelInput1Builder().setAdministrativeStatus(AdministrativeStatus.Active).build());
this.tunnelProgramming.pcepUpdateTunnel(updateInputBuilder.build());
// check update-lsp input
Assert.assertNotNull(this.updateLspInput);
Assert.assertEquals(LINK1_ID.getValue(), this.updateLspInput.getName());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.update.lsp.args.Arguments updArgs = this.updateLspInput.getArguments();
Assert.assertEquals(2, updArgs.getEro().getSubobject().size());
final List<Subobject> subObjects = updArgs.getEro().getSubobject();
final IpPrefixCase prefix1 = (IpPrefixCase) subObjects.get(0).getSubobjectType();
final IpPrefixCase prefix2 = (IpPrefixCase) subObjects.get(1).getSubobjectType();
Assert.assertEquals(IPV4_PREFIX1, prefix1.getIpPrefix().getIpPrefix().getIpv4Prefix().getValue());
Assert.assertEquals(IPV4_PREFIX2, prefix2.getIpPrefix().getIpPrefix().getIpv4Prefix().getValue());
// delete tunnel
final PcepDestroyTunnelInputBuilder destroyInputBuilder = new PcepDestroyTunnelInputBuilder();
destroyInputBuilder.setLinkId(LINK1_ID);
destroyInputBuilder.setNetworkTopologyRef(topologyRef);
this.tunnelProgramming.pcepDestroyTunnel(destroyInputBuilder.build());
Assert.assertNotNull(this.removeLspInput);
Assert.assertEquals(LINK1_ID.getValue(), this.removeLspInput.getName());
Assert.assertEquals(NODE1_ID.getValue(), this.removeLspInput.getNode().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project bgpcep by opendaylight.
the class PCEPTunnelTopologyProvider method init.
synchronized void init() {
final WriteTransaction tx = this.dataBroker.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.OPERATIONAL, getTopologyReference().getInstanceIdentifier(), new TopologyBuilder().setTopologyId(this.tunneltopologyId).setTopologyTypes(new TopologyTypesBuilder().addAugmentation(TopologyTypes1.class, new TopologyTypes1Builder().setTopologyTunnelPcep(new TopologyTunnelPcepBuilder().build()).build()).build()).setNode(new ArrayList<>()).build(), true);
try {
tx.submit().get();
} catch (final InterruptedException | ExecutionException e) {
LOG.error("Failed to create Tunnel Topology root", e);
}
this.reg = this.ncl.getDataProvider().registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, this.src), this.ncl);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method returnDelegation.
private void returnDelegation(final Updates update, final PCCSession session) {
final PlspId plspId = update.getLsp().getPlspId();
final PCCTunnel tunnel = this.tunnels.get(plspId);
final long srpId = update.getSrp().getOperationId().getValue();
if (tunnel != null) {
// check if session really has a delegation
if (hasDelegation(tunnel, session)) {
// send report D=0
final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.absent());
final Pcrpt pcrtp = createPcRtpMessage(new LspBuilder(update.getLsp()).setSync(true).setOperational(OperationalStatus.Up).setDelegate(false).setTlvs(tlvs).build(), Optional.of(createSrp(srpId)), tunnel.getLspState());
session.sendReport(pcrtp);
// start state timer
startStateTimeout(tunnel, plspId);
// if PCC's LSP, start re-delegation timer
if (tunnel.getType() == LspType.PCC_LSP) {
startRedelegationTimer(tunnel, plspId, session);
} else {
// if PCE-initiated LSP, revoke delegation instantly
setDelegation(plspId, null);
}
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UPDATE_REQ_FOR_NON_LSP, srpId));
}
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UNKNOWN_PLSP_ID, srpId));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method removeTunnel.
protected void removeTunnel(final Requests request, final PCCSession session) {
final PlspId plspId = request.getLsp().getPlspId();
final PCCTunnel tunnel = this.tunnels.get(plspId);
final long srpId = request.getSrp().getOperationId().getValue();
if (tunnel != null) {
if (tunnel.getType() == LspType.PCE_LSP) {
if (hasDelegation(tunnel, session)) {
this.tunnels.remove(plspId);
sendToAll(tunnel, plspId, tunnel.getLspState().getEro().getSubobject(), new SrpBuilder(request.getSrp()).addAugmentation(Srp1.class, new Srp1Builder().setRemove(true).build()).build(), reqToRptPath(request), request.getLsp());
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UPDATE_REQ_FOR_NON_LSP, srpId));
}
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.LSP_NOT_PCE_INITIATED, srpId));
}
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UNKNOWN_PLSP_ID, srpId));
}
}
Aggregations