use of org.opendaylight.yangtools.yang.common.RpcResult in project netvirt by opendaylight.
the class ElanL2GatewayUtils method getDpidFromInterface.
/**
* Gets the dpid from interface.
*
* @param interfaceName
* the interface name
* @return the dpid from interface
*/
public BigInteger getDpidFromInterface(String interfaceName) {
BigInteger dpId = null;
Future<RpcResult<GetDpidFromInterfaceOutput>> output = interfaceManagerRpcService.getDpidFromInterface(new GetDpidFromInterfaceInputBuilder().setIntfName(interfaceName).build());
try {
RpcResult<GetDpidFromInterfaceOutput> rpcResult = output.get();
if (rpcResult != null && rpcResult.isSuccessful()) {
dpId = rpcResult.getResult().getDpid();
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed to get the DPN ID for interface {}", interfaceName, e);
}
return dpId;
}
use of org.opendaylight.yangtools.yang.common.RpcResult in project netvirt by opendaylight.
the class ElanItmUtils method getExternalTunnelItmEgressAction.
/**
* Builds the list of actions to be taken when sending the packet over an
* external VxLan tunnel interface, such as stamping the VNI on the VxLAN
* header, setting the vlanId if it proceeds and output the packet over the
* right port.
*
* @param srcDpnId
* Dpn where the tunnelInterface is located
* @param torNode
* NodeId of the ExternalDevice where the packet must be sent to.
* @param vni
* Vni to be stamped on the VxLAN Header.
* @return the external itm egress action
*/
public List<Action> getExternalTunnelItmEgressAction(BigInteger srcDpnId, NodeId torNode, long vni) {
List<Action> result = Collections.emptyList();
GetExternalTunnelInterfaceNameInput input = new GetExternalTunnelInterfaceNameInputBuilder().setDestinationNode(torNode.getValue()).setSourceNode(srcDpnId.toString()).setTunnelType(TunnelTypeVxlan.class).build();
Future<RpcResult<GetExternalTunnelInterfaceNameOutput>> output = itmRpcService.getExternalTunnelInterfaceName(input);
try {
if (output.get().isSuccessful()) {
GetExternalTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult();
String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
LOG.debug("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
result = buildTunnelItmEgressActions(tunnelIfaceName, vni);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error in RPC call getTunnelInterfaceName {}", e);
}
return result;
}
use of org.opendaylight.yangtools.yang.common.RpcResult in project netvirt by opendaylight.
the class ElanItmUtils method getExternalTunnelItmEgressAction.
public List<Action> getExternalTunnelItmEgressAction(BigInteger srcDpnId, String nexthopIP, long vni) {
List<Action> result = Collections.emptyList();
GetExternalTunnelInterfaceNameInput input = new GetExternalTunnelInterfaceNameInputBuilder().setDestinationNode(nexthopIP).setSourceNode(srcDpnId.toString()).setTunnelType(TunnelTypeVxlan.class).build();
Future<RpcResult<GetExternalTunnelInterfaceNameOutput>> output = itmRpcService.getExternalTunnelInterfaceName(input);
try {
if (output.get().isSuccessful()) {
GetExternalTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult();
String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
LOG.debug("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
result = buildTunnelItmEgressActions(tunnelIfaceName, vni);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error in RPC call getTunnelInterfaceName {}", e);
}
return result;
}
use of org.opendaylight.yangtools.yang.common.RpcResult in project netvirt by opendaylight.
the class ElanItmUtils method getInternalTunnelItmEgressAction.
/**
* Builds the list of actions to be taken when sending the packet over an internal VxLAN tunnel interface, such
* as setting the serviceTag/segmentationID on the VNI field of the VxLAN header, setting the vlanId if it proceeds
* and output the packet over the right port.
*
* @param sourceDpnId
* Dpn where the tunnelInterface is located
* @param destinationDpnId
* Dpn where the packet must be sent to. It is used here in order
* to select the right tunnel interface.
* @param tunnelKey
* Tunnel key to be sent on the VxLAN header.
* @return the internal itm egress action
*/
public List<Action> getInternalTunnelItmEgressAction(BigInteger sourceDpnId, BigInteger destinationDpnId, long tunnelKey) {
List<Action> result = Collections.emptyList();
LOG.trace("In getInternalItmEgressAction Action source {}, destination {}, serviceTag/Vni {}", sourceDpnId, destinationDpnId, tunnelKey);
Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
GetTunnelInterfaceNameInput input = new GetTunnelInterfaceNameInputBuilder().setDestinationDpid(destinationDpnId).setSourceDpid(sourceDpnId).setTunnelType(tunType).build();
Future<RpcResult<GetTunnelInterfaceNameOutput>> output = itmRpcService.getTunnelInterfaceName(input);
try {
if (output.get().isSuccessful()) {
GetTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult();
String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
LOG.info("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
result = buildTunnelItmEgressActions(tunnelIfaceName, tunnelKey);
} else {
LOG.trace("Tunnel interface doesn't exist between srcDpId {} dstDpId {}", sourceDpnId, destinationDpnId);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error in RPC call getTunnelInterfaceName {}", e);
}
return result;
}
use of org.opendaylight.yangtools.yang.common.RpcResult in project netvirt by opendaylight.
the class ElanUtils method retrieveNewElanTag.
/**
* Uses the IdManager to retrieve a brand new ElanTag.
*
* @param idManager
* the id manager
* @param idKey
* the id key
* @return the integer
*/
public static Long retrieveNewElanTag(IdManagerService idManager, String idKey) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(ElanConstants.ELAN_ID_POOL_NAME).setIdKey(idKey).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
return rpcResult.getResult().getIdValue();
} else {
LOG.warn("RPC Call to Allocate Id returned with Errors {}", rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when Allocating Id", e);
}
return 0L;
}
Aggregations