use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.OperationResult in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testRemoveUnknownLsp.
@Test
public void testRemoveUnknownLsp() throws InterruptedException, ExecutionException {
this.listener.onSessionUp(this.session);
final RemoveLspInput remove = new RemoveLspInputBuilder().setName(this.tunnelName).setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID)).setNode(this.nodeId).build();
final OperationResult result = this.topologyRpcs.removeLsp(remove).get().getResult();
assertEquals(FailureType.Unsent, result.getFailure());
assertEquals(1, result.getError().size());
final ErrorObject errorObject = result.getError().get(0).getErrorObject();
assertNotNull(errorObject);
assertEquals(PCEPErrors.UNKNOWN_PLSP_ID, PCEPErrors.forValue(errorObject.getType(), errorObject.getValue()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.OperationResult in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method ensureLspOperational.
@Override
public synchronized ListenableFuture<OperationResult> ensureLspOperational(@Nonnull final EnsureLspOperationalInput input) {
Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null && input.getArguments() != null, MISSING_XML_TAG);
final OperationalStatus op;
final Arguments1 aa = input.getArguments().getAugmentation(Arguments1.class);
if (aa != null) {
op = aa.getOperational();
} else {
op = null;
}
// Make sure the LSP exists
final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName());
LOG.debug("Checking if LSP {} has operational state {}", lsp, op);
final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
if (f == null) {
return OperationResults.createUnsent(PCEPErrors.LSP_INTERNAL_ERROR).future();
}
return listenableFuture(f, input, op);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.OperationResult in project bgpcep by opendaylight.
the class TopologyProgramming method submitAddLsp.
@Override
public ListenableFuture<RpcResult<SubmitAddLspOutput>> submitAddLsp(final SubmitAddLspInput input) {
Preconditions.checkArgument(input.getNode() != null);
Preconditions.checkArgument(input.getName() != null);
final SubmitAddLspOutputBuilder b = new SubmitAddLspOutputBuilder();
b.setResult(AbstractInstructionExecutor.schedule(this.scheduler, new AbstractInstructionExecutor(input) {
@Override
protected ListenableFuture<OperationResult> invokeOperation() {
return TopologyProgramming.this.manager.addLsp(input);
}
}));
final RpcResult<SubmitAddLspOutput> res = SuccessfulRpcResult.create(b.build());
return Futures.immediateFuture(res);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.OperationResult in project bgpcep by opendaylight.
the class TopologyProgramming method submitEnsureLspOperational.
@Override
public ListenableFuture<RpcResult<SubmitEnsureLspOperationalOutput>> submitEnsureLspOperational(final SubmitEnsureLspOperationalInput input) {
Preconditions.checkArgument(input.getNode() != null);
Preconditions.checkArgument(input.getName() != null);
Preconditions.checkArgument(input.getArguments() != null);
// FIXME: can we validate this early?
// Preconditions.checkArgument(input.getArguments().getOperational() != null);
final SubmitEnsureLspOperationalOutputBuilder b = new SubmitEnsureLspOperationalOutputBuilder();
b.setResult(AbstractInstructionExecutor.schedule(this.scheduler, new AbstractInstructionExecutor(input) {
@Override
protected ListenableFuture<OperationResult> invokeOperation() {
EnsureLspOperationalInputBuilder ensureLspOperationalInputBuilder = new EnsureLspOperationalInputBuilder();
ensureLspOperationalInputBuilder.fieldsFrom(input);
return TopologyProgramming.this.manager.ensureLspOperational(ensureLspOperationalInputBuilder.build());
}
}));
final RpcResult<SubmitEnsureLspOperationalOutput> res = SuccessfulRpcResult.create(b.build());
return Futures.immediateFuture(res);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.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 (ReadOnlyTransaction t = this.dataProvider.newReadOnlyTransaction()) {
final Link link;
final Node node;
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;
}
return Futures.transform((ListenableFuture<RpcResult<UpdateLspOutput>>) this.topologyService.updateLsp(buildUpdateInput(link, node)), RpcResult::getResult, MoreExecutors.directExecutor());
}
}
Aggregations