use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class CreateTunnelInstructionExecutor method createAddLspInput.
private AddLspInput createAddLspInput(final ReadOnlyTransaction transaction) {
final InstanceIdentifier<Topology> tii = TopologyProgrammingUtil.topologyForInput(this.p2pTunnelInput);
final TpReader dr = new TpReader(transaction, tii, this.p2pTunnelInput.getDestination());
final TerminationPoint dp = requireNonNull(dr.getTp());
final TpReader sr = new TpReader(transaction, tii, this.p2pTunnelInput.getSource());
final TerminationPoint sp = requireNonNull(sr.getTp());
final Node sn = requireNonNull(sr.getNode());
final AddLspInputBuilder ab = new AddLspInputBuilder();
ab.setNode(requireNonNull(TunelProgrammingUtil.supportingNode(sn)));
ab.setName(this.p2pTunnelInput.getSymbolicPathName());
checkLinkIsnotExistent(tii, ab, transaction);
ab.setArguments(buildArguments(sp, dp));
return ab.build();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class DestroyTunnelInstructionExecutor method invokeOperation.
@Override
protected ListenableFuture<OperationResult> invokeOperation() {
final InstanceIdentifier<Topology> tii = TopologyProgrammingUtil.topologyForInput(this.pcepDestroyTunnelInput);
final InstanceIdentifier<Link> lii = TunnelProgrammingUtil.linkIdentifier(tii, this.pcepDestroyTunnelInput);
try (ReadOnlyTransaction t = this.dataProvider.newReadOnlyTransaction()) {
final Node node;
final Link link;
try {
// The link has to exist
link = t.read(LogicalDatastoreType.OPERATIONAL, lii).checkedGet().get();
// The source node has to exist
node = TunelProgrammingUtil.sourceNode(t, tii, link).get();
} catch (IllegalStateException | ReadFailedException e) {
LOG.debug("Link or node does not exist.", e);
return TunelProgrammingUtil.RESULT;
}
final RemoveLspInputBuilder ab = new RemoveLspInputBuilder();
ab.setName(link.getAugmentation(Link1.class).getSymbolicPathName());
ab.setNode(node.getSupportingNode().get(0).getKey().getNodeRef());
return Futures.transform((ListenableFuture<RpcResult<RemoveLspOutput>>) this.topologyService.removeLsp(ab.build()), RpcResult::getResult, MoreExecutors.directExecutor());
}
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology 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.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnServerSessionManagerRestartAndSessionRecovery.
@Test
public void testOnServerSessionManagerRestartAndSessionRecovery() throws Exception {
// close server session manager first
stopSessionManager();
assertFalse(this.session.isClosed());
this.listener.onSessionUp(this.session);
// verify the session was NOT added to topology
checkNotPresentOperational(getDataBroker(), TOPO_IID);
// verify the session is closed due to server session manager is closed
assertTrue(this.session.isClosed());
// send request
final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
final AddLspOutput output = futureOutput.get().getResult();
// deal with unsent request after session down
assertEquals(FailureType.Unsent, output.getFailure());
// PCC client is not there
checkNotPresentOperational(getDataBroker(), this.pathComputationClientIId);
// reset received message queue
this.receivedMsgs.clear();
// now we restart the session manager
startSessionManager();
// try to start the session again
// notice since the session was terminated before, it is not usable anymore.
// we need to get a new session instance. the new session will have the same local / remote preference
this.session = getPCEPSession(getLocalPref(), getRemotePref());
assertFalse(this.session.isClosed());
this.listener.onSessionUp(this.session);
assertFalse(this.session.isClosed());
// create node
this.topologyRpcs.addLsp(createAddLspInput());
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
final long srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setSync(true).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
this.listener.onMessage(this.session, pcRpt);
readDataOperational(getDataBroker(), TOPO_IID, topology -> {
assertEquals(1, topology.getNode().size());
return topology;
});
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testDuplicatedSession.
/**
* When a session is somehow duplicated in controller, the controller should drop existing session.
*/
@Test
public void testDuplicatedSession() throws ReadFailedException {
this.listener.onSessionUp(this.session);
// create node
this.topologyRpcs.addLsp(createAddLspInput());
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
final long srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setSync(true).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
this.listener.onMessage(this.session, pcRpt);
readDataOperational(getDataBroker(), TOPO_IID, topology -> {
assertEquals(1, topology.getNode().size());
return topology;
});
// now we do session up again
this.listener.onSessionUp(this.session);
assertTrue(this.session.isClosed());
// node should be removed after termination
checkNotPresentOperational(getDataBroker(), this.pathComputationClientIId);
assertFalse(this.receivedMsgs.isEmpty());
// the last message should be a Close message
assertTrue(this.receivedMsgs.get(this.receivedMsgs.size() - 1) instanceof Close);
}
Aggregations