use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class AbstractOutboundQueueManager method onEchoRequest.
/**
* Method immediately response on Echo message.
*
* @param message incoming Echo message from device
*/
void onEchoRequest(final EchoRequestMessage message) {
final EchoReplyInput reply = new EchoReplyInputBuilder().setData(message.getData()).setVersion(message.getVersion()).setXid(message.getXid()).build();
parent.getChannel().writeAndFlush(makeMessageListenerWrapper(reply));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class RoleService method getGenerationIdFromDevice.
public Future<BigInteger> getGenerationIdFromDevice(final Short version) {
LOG.info("getGenerationIdFromDevice called for device: {}", getDeviceInfo().getNodeId().getValue());
// send a dummy no-change role request to get the generation-id of the switch
final RoleRequestInputBuilder roleRequestInputBuilder = new RoleRequestInputBuilder();
roleRequestInputBuilder.setRole(toOFJavaRole(OfpRole.NOCHANGE));
roleRequestInputBuilder.setVersion(version);
roleRequestInputBuilder.setGenerationId(BigInteger.ZERO);
final SettableFuture<BigInteger> finalFuture = SettableFuture.create();
final ListenableFuture<RpcResult<RoleRequestOutput>> genIdListenableFuture = handleServiceCall(roleRequestInputBuilder);
Futures.addCallback(genIdListenableFuture, new FutureCallback<RpcResult<RoleRequestOutput>>() {
@Override
public void onSuccess(@Nonnull final RpcResult<RoleRequestOutput> roleRequestOutputRpcResult) {
if (roleRequestOutputRpcResult.isSuccessful()) {
final RoleRequestOutput roleRequestOutput = roleRequestOutputRpcResult.getResult();
if (roleRequestOutput != null) {
LOG.debug("roleRequestOutput.getGenerationId()={}", roleRequestOutput.getGenerationId());
finalFuture.set(roleRequestOutput.getGenerationId());
} else {
LOG.info("roleRequestOutput is null in getGenerationIdFromDevice");
finalFuture.setException(new RoleChangeException("Exception in getting generationId for device:" + getDeviceInfo().getNodeId().getValue()));
}
} else {
LOG.error("getGenerationIdFromDevice RPC error " + roleRequestOutputRpcResult.getErrors().iterator().next().getInfo());
finalFuture.setException(new RoleChangeException(ErrorUtil.errorsToString(roleRequestOutputRpcResult.getErrors())));
}
}
@Override
public void onFailure(final Throwable throwable) {
LOG.info("onFailure - getGenerationIdFromDevice RPC error {}", throwable);
finalFuture.setException(new ExecutionException(throwable));
}
}, MoreExecutors.directExecutor());
return finalFuture;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class RoleService method submitRoleChange.
public Future<RpcResult<SetRoleOutput>> submitRoleChange(final OfpRole ofpRole, final Short version, final BigInteger generationId) {
LOG.info("submitRoleChange called for device:{}, role:{}", getDeviceInfo().getNodeId(), ofpRole);
final RoleRequestInputBuilder roleRequestInputBuilder = new RoleRequestInputBuilder();
roleRequestInputBuilder.setRole(toOFJavaRole(ofpRole));
roleRequestInputBuilder.setVersion(version);
roleRequestInputBuilder.setGenerationId(generationId);
final ListenableFuture<RpcResult<RoleRequestOutput>> roleListenableFuture = handleServiceCall(roleRequestInputBuilder);
final SettableFuture<RpcResult<SetRoleOutput>> finalFuture = SettableFuture.create();
Futures.addCallback(roleListenableFuture, new FutureCallback<RpcResult<RoleRequestOutput>>() {
@Override
public void onSuccess(@Nonnull final RpcResult<RoleRequestOutput> roleRequestOutputRpcResult) {
LOG.info("submitRoleChange onSuccess for device:{}, role:{}", getDeviceInfo().getNodeId(), ofpRole);
final RoleRequestOutput roleRequestOutput = roleRequestOutputRpcResult.getResult();
final Collection<RpcError> rpcErrors = roleRequestOutputRpcResult.getErrors();
if (roleRequestOutput != null) {
final SetRoleOutputBuilder setRoleOutputBuilder = new SetRoleOutputBuilder();
setRoleOutputBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(roleRequestOutput.getXid())));
finalFuture.set(RpcResultBuilder.<SetRoleOutput>success().withResult(setRoleOutputBuilder.build()).build());
} else if (rpcErrors != null) {
LOG.trace("roleRequestOutput is null , rpcErrors={}", rpcErrors);
for (RpcError rpcError : rpcErrors) {
LOG.warn("RpcError on submitRoleChange for {}: {}", deviceContext.getPrimaryConnectionContext().getNodeId(), rpcError.toString());
}
finalFuture.set(RpcResultBuilder.<SetRoleOutput>failed().withRpcErrors(rpcErrors).build());
}
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("submitRoleChange onFailure for device:{}, role:{}", getDeviceInfo().getNodeId(), ofpRole, throwable);
finalFuture.setException(throwable);
}
}, MoreExecutors.directExecutor());
return finalFuture;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class BarrierUtil method chainBarrier.
/**
* Chain a barrier message - regardless of previous result and use given {@link Function} to combine
* original result and barrier result.
*
* @param <T> type of input future
* @param input future to chain barrier to
* @param nodeRef target device
* @param transactionService barrier service
* @param compositeTransform composite transform
* @return future holding both results (input and of the barrier)
*/
public static <T> ListenableFuture<RpcResult<T>> chainBarrier(final ListenableFuture<RpcResult<T>> input, final NodeRef nodeRef, final FlowCapableTransactionService transactionService, final Function<Pair<RpcResult<T>, RpcResult<Void>>, RpcResult<T>> compositeTransform) {
final MutablePair<RpcResult<T>, RpcResult<Void>> resultPair = new MutablePair<>();
// store input result and append barrier
final ListenableFuture<RpcResult<Void>> barrierResult = Futures.transformAsync(input, interInput -> {
resultPair.setLeft(interInput);
final SendBarrierInput barrierInput = createSendBarrierInput(nodeRef);
return JdkFutureAdapters.listenInPoolThread(transactionService.sendBarrier(barrierInput));
}, MoreExecutors.directExecutor());
// store barrier result and return initiated pair
final ListenableFuture<Pair<RpcResult<T>, RpcResult<Void>>> compositeResult = Futures.transform(barrierResult, new Function<RpcResult<Void>, Pair<RpcResult<T>, RpcResult<Void>>>() {
@Nullable
@Override
public Pair<RpcResult<T>, RpcResult<Void>> apply(@Nullable final RpcResult<Void> input) {
resultPair.setRight(input);
return resultPair;
}
}, MoreExecutors.directExecutor());
// append assembling transform to barrier result
return Futures.transform(compositeResult, compositeTransform, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project netvirt by opendaylight.
the class ElanL2GatewayUtils method updateVlanBindingsInL2GatewayDevice.
/**
* Update vlan bindings in l2 gateway device.
*
* @param nodeId
* the node id
* @param logicalSwitchName
* the logical switch name
* @param hwVtepDevice
* the hardware device
* @param defaultVlanId
* the default vlan id
* @return the listenable future
*/
public FluentFuture<?> updateVlanBindingsInL2GatewayDevice(NodeId nodeId, String logicalSwitchName, Devices hwVtepDevice, Integer defaultVlanId) {
if (hwVtepDevice == null || hwVtepDevice.getInterfaces() == null || hwVtepDevice.getInterfaces().isEmpty()) {
String errMsg = "HwVtepDevice is null or interfaces are empty.";
LOG.error(errMsg);
return FluentFutures.immediateFailedFluentFuture(new RuntimeException(errMsg));
}
return txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.nonnullInterfaces().values()) {
// Removed the check for checking terminationPoint present in OP or not
// for coniguring vlan bindings
// As we are not any more dependent on it , plugin takes care of this
// with port reconcilation.
List<VlanBindings> vlanBindings = new ArrayList<>();
if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
for (Integer vlanId : deviceInterface.getSegmentationIds()) {
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, vlanId, logicalSwitchName));
}
} else {
// Use defaultVlanId (specified in L2GatewayConnection) if Vlan
// ID not specified at interface level.
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, defaultVlanId, logicalSwitchName));
}
TerminationPointKey tpKey = new TerminationPointKey(new TpId(deviceInterface.getInterfaceName()));
InstanceIdentifier<TerminationPoint> portIid = HwvtepSouthboundUtils.createTerminationPointId(HwvtepSouthboundUtils.createManagedNodeId(nodeId, hwVtepDevice.getDeviceName()), tpKey);
try {
boolean createParent = false;
if (!portsCache.get(portIid).isPresent()) {
// create port
// pass additional flag
createParent = true;
}
mergeVlanBindings(tx, nodeId, hwVtepDevice.getDeviceName(), deviceInterface.getInterfaceName(), vlanBindings, createParent);
} catch (ReadFailedException e) {
LOG.error("Read Failed for PortIid {} {}", portIid, e.getMessage());
}
}
LOG.info("Updated Hwvtep VlanBindings in config DS. NodeID: {}, LogicalSwitch: {}", nodeId.getValue(), logicalSwitchName);
});
}
Aggregations