use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.OperationResult in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method triggerSynchronization.
private ListenableFuture<OperationResult> triggerSynchronization(final TriggerSyncArgs input) {
LOG.trace("Trigger Initial Synchronization {}", input);
final PcupdMessageBuilder pcupdMessageBuilder = new PcupdMessageBuilder(MESSAGE_HEADER);
final SrpIdNumber srpIdNumber = createUpdateMessageSync(pcupdMessageBuilder);
final Message msg = new PcupdBuilder().setPcupdMessage(pcupdMessageBuilder.build()).build();
return sendMessage(msg, srpIdNumber, null);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.OperationResult in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method removeLsp.
@Override
public synchronized ListenableFuture<OperationResult> removeLsp(@Nonnull final RemoveLspArgs input) {
Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null, MISSING_XML_TAG);
LOG.trace("RemoveLspArgs {}", input);
// Make sure the LSP exists, we need it for PLSP-ID
final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName());
final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
if (f == null) {
return OperationResults.createUnsent(PCEPErrors.LSP_INTERNAL_ERROR).future();
}
return Futures.transformAsync(f, rep -> {
final Lsp reportedLsp = validateReportedLsp(rep, input);
if (reportedLsp == null) {
return OperationResults.createUnsent(PCEPErrors.UNKNOWN_PLSP_ID).future();
}
final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
final Requests rb = buildRequest(rep, reportedLsp);
ib.setRequests(Collections.singletonList(rb));
return sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(), rb.getSrp().getOperationId(), null);
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.OperationResult 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 (ReadTransaction t = this.dataProvider.newReadOnlyTransaction()) {
final Node node;
final Link link;
try {
// The link has to exist
link = t.read(LogicalDatastoreType.OPERATIONAL, lii).get().get();
// The source node has to exist
node = TunelProgrammingUtil.sourceNode(t, tii, link).get();
} catch (final InterruptedException | ExecutionException e) {
LOG.debug("Link or node does not exist.", e);
return TunelProgrammingUtil.RESULT;
}
final RemoveLspInputBuilder ab = new RemoveLspInputBuilder();
ab.setName(link.augmentation(Link1.class).getSymbolicPathName());
ab.setNode(node.nonnullSupportingNode().values().iterator().next().key().getNodeRef());
return Futures.transform(this.topologyService.removeLsp(ab.build()), RpcResult::getResult, MoreExecutors.directExecutor());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.OperationResult in project bgpcep by opendaylight.
the class UpdateTunnelInstructionExecutor method invokeOperation.
@Override
protected ListenableFuture<OperationResult> invokeOperation() {
final InstanceIdentifier<Topology> tii = TopologyProgrammingUtil.topologyForInput(this.updateTunnelInput);
final InstanceIdentifier<Link> lii = TunnelProgrammingUtil.linkIdentifier(tii, this.updateTunnelInput);
try (ReadTransaction t = this.dataProvider.newReadOnlyTransaction()) {
final Link link;
final Node node;
try {
// The link has to exist
link = t.read(LogicalDatastoreType.OPERATIONAL, lii).get().get();
// The source node has to exist
node = TunelProgrammingUtil.sourceNode(t, tii, link).get();
} catch (final InterruptedException | ExecutionException e) {
LOG.debug("Link or node does not exist.", e);
return TunelProgrammingUtil.RESULT;
}
return Futures.transform(this.topologyService.updateLsp(buildUpdateInput(link, node)), RpcResult::getResult, MoreExecutors.directExecutor());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.OperationResult in project bgpcep by opendaylight.
the class TopologyProgramming method submitRemoveLsp.
@Override
public ListenableFuture<RpcResult<SubmitRemoveLspOutput>> submitRemoveLsp(final SubmitRemoveLspInput input) {
Preconditions.checkArgument(input.getNode() != null);
Preconditions.checkArgument(input.getName() != null);
final SubmitRemoveLspOutputBuilder b = new SubmitRemoveLspOutputBuilder();
b.setResult(AbstractInstructionExecutor.schedule(this.scheduler, new AbstractInstructionExecutor(input) {
@Override
protected ListenableFuture<OperationResult> invokeOperation() {
return TopologyProgramming.this.manager.removeLsp(input);
}
}));
final RpcResult<SubmitRemoveLspOutput> res = SuccessfulRpcResult.create(b.build());
return Futures.immediateFuture(res);
}
Aggregations