use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInputBuilder in project netvirt by opendaylight.
the class ElanItmUtils method buildItmEgressActions.
/**
* Builds the list of actions to be taken when sending the packet over external port such as tunnel, physical
* port etc.
*
* @param interfaceName
* the interface name
* @param tunnelKey
* can be VNI for VxLAN tunnel interfaces, Gre Key for GRE
* tunnels, etc.
* @return the list
*/
@SuppressWarnings("checkstyle:IllegalCatch")
public List<Action> buildItmEgressActions(String interfaceName, @Nullable Long tunnelKey, boolean internal) {
try {
if (internal && interfaceManager.isItmDirectTunnelsEnabled()) {
GetEgressActionsForTunnelInput getEgressActInputItm = new GetEgressActionsForTunnelInputBuilder().setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
Future<RpcResult<GetEgressActionsForTunnelOutput>> egressActionsOutputItm = itmRpcService.getEgressActionsForTunnel(getEgressActInputItm);
if (egressActionsOutputItm.get().isSuccessful()) {
return new ArrayList<Action>(egressActionsOutputItm.get().getResult().nonnullAction().values());
}
} else {
GetEgressActionsForInterfaceInput getEgressActInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
Future<RpcResult<GetEgressActionsForInterfaceOutput>> egressActionsOutputFuture = interfaceManagerRpcService.getEgressActionsForInterface(getEgressActInput);
if (egressActionsOutputFuture.get().isSuccessful()) {
return new ArrayList<Action>(egressActionsOutputFuture.get().getResult().nonnullAction().values());
}
}
} catch (Exception e) {
LOG.error("Error in RPC call getEgressActionsForInterface", e);
}
LOG.warn("Could not build Egress actions for interface {} and tunnelId {}", interfaceName, tunnelKey);
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInputBuilder in project netvirt by opendaylight.
the class DhcpPktHandler method getEgressAction.
private List<Action> getEgressAction(String interfaceName, Uint64 tunnelId) {
try {
if (interfaceManager.isItmDirectTunnelsEnabled() && tunnelId != null) {
GetEgressActionsForTunnelInputBuilder egressAction = new GetEgressActionsForTunnelInputBuilder().setIntfName(interfaceName);
egressAction.setTunnelKey(tunnelId.longValue());
RpcResult<GetEgressActionsForTunnelOutput> rpcResult = itmRpcService.getEgressActionsForTunnel(egressAction.build()).get();
if (!rpcResult.isSuccessful()) {
LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}", interfaceName, rpcResult.getErrors());
} else {
return new ArrayList<>(rpcResult.getResult().nonnullAction().values());
}
} else {
GetEgressActionsForInterfaceInputBuilder egressAction = new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName);
if (tunnelId != null) {
egressAction.setTunnelKey(tunnelId.longValue());
}
Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManagerRpc.getEgressActionsForInterface(egressAction.build());
RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}", interfaceName, rpcResult.getErrors());
} else {
return new ArrayList<>(rpcResult.getResult().nonnullAction().values());
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when egress actions for interface {}", interfaceName, e);
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInputBuilder in project netvirt by opendaylight.
the class NexthopManager method getEgressActionsForInterface.
protected List<ActionInfo> getEgressActionsForInterface(final String ifName, int actionKey, boolean isTunnelInterface, Uint32 vpnId, String destIpPrefix) {
List<Action> actions;
try {
if (isTunnelInterface && interfaceManager.isItmDirectTunnelsEnabled()) {
RpcResult<GetEgressActionsForTunnelOutput> rpcResult = itmManager.getEgressActionsForTunnel(new GetEgressActionsForTunnelInputBuilder().setIntfName(ifName).build()).get();
if (!rpcResult.isSuccessful()) {
LOG.error("RPC Call to Get egress tunnel actions for interface {} returned with Errors {}", ifName, rpcResult.getErrors());
return Collections.emptyList();
} else {
actions = new ArrayList<Action>(rpcResult.getResult().nonnullAction().values());
}
} else {
RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = odlInterfaceRpcService.getEgressActionsForInterface(new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName).build()).get();
if (!rpcResult.isSuccessful()) {
LOG.error("RPC Call to Get egress vm actions for interface {} vpnId {} ipPrefix {} returned with " + "Errors {}", ifName, vpnId, destIpPrefix, rpcResult.getErrors());
return Collections.emptyList();
} else {
actions = new ArrayList<Action>(rpcResult.getResult().nonnullAction().values());
}
}
List<ActionInfo> listActionInfo = new ArrayList<>();
for (Action action : actions) {
actionKey = action.key().getOrder() + actionKey;
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionClass = action.getAction();
if (actionClass instanceof OutputActionCase) {
listActionInfo.add(new ActionOutput(actionKey, ((OutputActionCase) actionClass).getOutputAction().getOutputNodeConnector()));
} else if (actionClass instanceof PushVlanActionCase) {
listActionInfo.add(new ActionPushVlan(actionKey));
} else if (actionClass instanceof SetFieldCase) {
if (((SetFieldCase) actionClass).getSetField().getVlanMatch() != null) {
int vlanVid = ((SetFieldCase) actionClass).getSetField().getVlanMatch().getVlanId().getVlanId().getValue().toJava();
listActionInfo.add(new ActionSetFieldVlanVid(actionKey, vlanVid));
}
} else if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
Short tableId = ((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable().toJava();
listActionInfo.add(new ActionNxResubmit(actionKey, tableId));
} else if (actionClass instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase) {
NxRegLoad nxRegLoad = ((NxActionRegLoadNodesNodeTableFlowApplyActionsCase) actionClass).getNxRegLoad();
listActionInfo.add(new ActionRegLoad(actionKey, NxmNxReg6.class, nxRegLoad.getDst().getStart().toJava(), nxRegLoad.getDst().getEnd().toJava(), nxRegLoad.getValue().longValue()));
}
}
return listActionInfo;
} catch (InterruptedException | ExecutionException | NullPointerException e) {
LOG.error("Exception when egress actions for interface {} isTunnel {} vpnId {} ipPrefix {}", ifName, isTunnelInterface, vpnId, destIpPrefix, e);
}
LOG.warn("Exception when egress actions for interface {}", ifName);
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInputBuilder in project netvirt by opendaylight.
the class ArpResponderUtil method getEgressActionsForInterface.
/**
* Get List of Egress Action for the VPN interface.
*
* @param ifaceMgrRpcService
* Interface Manager RPC reference that invokes API to retrieve
* Egress Action
* @param ifName
* VPN Interface for which Egress Action to be retrieved
* @param actionCounter
* Action Key
* @return List of Egress Actions
*/
public static List<Action> getEgressActionsForInterface(IInterfaceManager ifaceMgrRpcService, ItmRpcService itmRpcService, String ifName, int actionCounter, boolean isTunnelInterface) {
if (isTunnelInterface && ifaceMgrRpcService.isItmDirectTunnelsEnabled()) {
try {
RpcResult result = itmRpcService.getEgressActionsForTunnel(new GetEgressActionsForTunnelInputBuilder().setIntfName(ifName).build()).get();
Map<ActionKey, Action> listActions = new HashMap<ActionKey, Action>();
if (!result.isSuccessful()) {
LOG.error("getEgressActionsForInterface: RPC Call to Get egress actions for interface {} " + "returned with Errors {}", ifName, result.getErrors());
} else {
listActions = ((GetEgressActionsForTunnelOutput) result.getResult()).nonnullAction();
}
return new ArrayList<Action>(listActions.values());
} catch (InterruptedException | ExecutionException e) {
LOG.error("getEgressActionsForInterface: Exception when egress actions for interface {}", ifName, e);
}
} else {
List<ActionInfo> actionInfos = ifaceMgrRpcService.getInterfaceEgressActions(ifName);
AtomicInteger counter = new AtomicInteger(actionCounter);
return actionInfos.stream().map(v -> v.buildAction(counter.getAndIncrement())).collect(Collectors.toList());
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInputBuilder in project netvirt by opendaylight.
the class NatUtil method getEgressActionsForInterface.
@NonNull
public static List<ActionInfo> getEgressActionsForInterface(OdlInterfaceRpcService odlInterfaceRpcService, ItmRpcService itmRpcService, IInterfaceManager interfaceManager, String ifName, @Nullable Uint32 tunnelKey, int pos, boolean internalTunnelInterface) {
LOG.debug("getEgressActionsForInterface : called for interface {}", ifName);
GetEgressActionsForInterfaceInputBuilder egressActionsIfmBuilder = new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName);
GetEgressActionsForTunnelInputBuilder egressActionsItmBuilder = new GetEgressActionsForTunnelInputBuilder().setIntfName(ifName);
if (tunnelKey != null) {
egressActionsIfmBuilder.setTunnelKey(tunnelKey);
egressActionsItmBuilder.setTunnelKey(tunnelKey);
}
try {
List<Action> actions = emptyList();
if (interfaceManager.isItmDirectTunnelsEnabled() && internalTunnelInterface) {
RpcResult<GetEgressActionsForTunnelOutput> rpcResult = itmRpcService.getEgressActionsForTunnel(egressActionsItmBuilder.build()).get();
if (!rpcResult.isSuccessful()) {
LOG.error("getEgressActionsForTunnels : RPC Call to Get egress actions for Tunnels {} " + "returned with Errors {}", ifName, rpcResult.getErrors());
} else {
actions = new ArrayList<>(rpcResult.getResult().nonnullAction().values());
}
} else {
RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = odlInterfaceRpcService.getEgressActionsForInterface(egressActionsIfmBuilder.build()).get();
if (!rpcResult.isSuccessful()) {
LOG.error("getEgressActionsForInterface : RPC Call to Get egress actions for interface {} " + "returned with Errors {}", ifName, rpcResult.getErrors());
} else {
actions = new ArrayList<>(rpcResult.getResult().nonnullAction().values());
}
}
List<ActionInfo> listActionInfo = new ArrayList<>();
for (Action action : actions) {
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionClass = action.getAction();
if (actionClass instanceof OutputActionCase) {
listActionInfo.add(new ActionOutput(pos++, ((OutputActionCase) actionClass).getOutputAction().getOutputNodeConnector()));
} else if (actionClass instanceof PushVlanActionCase) {
listActionInfo.add(new ActionPushVlan(pos++));
} else if (actionClass instanceof SetFieldCase) {
if (((SetFieldCase) actionClass).getSetField().getVlanMatch() != null) {
int vlanVid = ((SetFieldCase) actionClass).getSetField().getVlanMatch().getVlanId().getVlanId().getValue().toJava();
listActionInfo.add(new ActionSetFieldVlanVid(pos++, vlanVid));
}
} else if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
Short tableId = ((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable().toJava();
listActionInfo.add(new ActionNxResubmit(pos++, tableId));
} else if (actionClass instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase) {
NxRegLoad nxRegLoad = ((NxActionRegLoadNodesNodeTableFlowApplyActionsCase) actionClass).getNxRegLoad();
listActionInfo.add(new ActionRegLoad(pos++, NxmNxReg6.class, nxRegLoad.getDst().getStart().toJava(), nxRegLoad.getDst().getEnd().toJava(), nxRegLoad.getValue().longValue()));
}
}
return listActionInfo;
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception when egress actions for interface {}", ifName, e);
}
LOG.error("Error when getting egress actions for interface {}", ifName);
return emptyList();
}
Aggregations