import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeMplsOverGre;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.*;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
return Futures.immediateFuture(rpcResultBuilder.build());
}
+ @Override
+ public Future<RpcResult<GetTunnelTypeOutput>> getTunnelType(GetTunnelTypeInput input) {
+ String interfaceName = input.getIntfName();
+ RpcResultBuilder<GetTunnelTypeOutput> rpcResultBuilder;
+ try {
+ InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
+ Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
+
+ if (Tunnel.class.equals(interfaceInfo.getType())) {
+ IfTunnel tnl = interfaceInfo.getAugmentation(IfTunnel.class);
+ Class <? extends TunnelTypeBase> tun_type = tnl.getTunnelInterfaceType();
+ GetTunnelTypeOutputBuilder output = new GetTunnelTypeOutputBuilder().setTunnelType(tun_type);
+ rpcResultBuilder = RpcResultBuilder.success();
+ rpcResultBuilder.withResult(output.build());
+ } else {
+ LOG.error("Retrieval of interface type for the key {} failed", interfaceName);
+ rpcResultBuilder = RpcResultBuilder.failed();
+ }
+ } catch (Exception e) {
+ LOG.error("Retrieval of interface type for the key {} failed due to {}", interfaceName, e);
+ rpcResultBuilder = RpcResultBuilder.failed();
+ }
+ return Futures.immediateFuture(rpcResultBuilder.build());
+ }
+
@Override
public Future<RpcResult<GetEgressActionsForInterfaceOutput>> getEgressActionsForInterface(GetEgressActionsForInterfaceInput input) {
RpcResultBuilder<GetEgressActionsForInterfaceOutput> rpcResultBuilder;
List<ActionInfo> listActionInfo = new ArrayList<ActionInfo>();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
-
- String lowerLayerIf = ifState.getLowerLayerIf().get(0);
- NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
- String portNo = IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId);
- Class<? extends InterfaceType> ifType = interfaceInfo.getType();
- if(L2vlan.class.equals(ifType)){
- IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
- LOG.trace("L2Vlan: {}",vlanIface);
- long vlanVid = (vlanIface == null) ? 0 : vlanIface.getVlanId().getValue();
- if (vlanVid != 0) {
- listActionInfo.add(new ActionInfo(ActionType.push_vlan, new String[] {}));
- listActionInfo.add(new ActionInfo(ActionType.set_field_vlan_vid,
- new String[] { Long.toString(vlanVid) }));
+ if(ifState != null) {
+ String lowerLayerIf = ifState.getLowerLayerIf().get(0);
+ NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
+ String portNo = IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId);
+ Class<? extends InterfaceType> ifType = interfaceInfo.getType();
+ if (L2vlan.class.equals(ifType)) {
+ IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
+ LOG.trace("L2Vlan: {}", vlanIface);
+ long vlanVid = 0;
+ boolean isVlanTransparent = false;
+ if (vlanIface != null) {
+ vlanVid = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
+ isVlanTransparent = vlanIface.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
+ }
+ if (vlanVid != 0 && !isVlanTransparent) {
+ listActionInfo.add(new ActionInfo(ActionType.push_vlan, new String[]{}));
+ listActionInfo.add(new ActionInfo(ActionType.set_field_vlan_vid,
+ new String[]{Long.toString(vlanVid)}));
+ }
+ listActionInfo.add(new ActionInfo(ActionType.output, new String[]{portNo}));
+ } else if (Tunnel.class.equals(ifType)) {
+ listActionInfo.add(new ActionInfo(ActionType.output, new String[]{portNo}));
}
- listActionInfo.add(new ActionInfo(ActionType.output, new String[] {portNo}));
- }else if(Tunnel.class.equals(ifType)){
- listActionInfo.add(new ActionInfo(ActionType.output, new String[] { portNo}));
}
return listActionInfo;
}
private ListenableFuture<Void> makeTerminatingServiceFlow(IfTunnel tunnelInfo, BigInteger dpnId, BigInteger tunnelKey, List<Instruction> instruction, int addOrRemove) {
List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
mkMatches.add(new MatchInfo(MatchFieldType.tunnel_id, new BigInteger[] {tunnelKey}));
- short tableId = tunnelInfo.isInternal() ? IfmConstants.INTERNAL_TUNNEL_TABLE :
- IfmConstants.EXTERNAL_TUNNEL_TABLE;
+ short tableId = tunnelInfo.isInternal() ? NwConstants.INTERNAL_TUNNEL_TABLE :
+ NwConstants.EXTERNAL_TUNNEL_TABLE;
final String flowRef = getFlowRef(dpnId,tableId, tunnelKey);
Flow terminatingSerFlow = MDSALUtil.buildFlowNew(tableId, flowRef,
5, "TST Flow Entry", 0, 0,
new long[]{0x8847L}));
mkMatches.add(new MatchInfo(MatchFieldType.mpls_label, new String[]{Long.toString(tunnelKey.longValue())}));
// Install the flow entry in L3_LFIB_TABLE
- String flowRef = getFlowRef(dpnId, IfmConstants.LFIB_TABLE, tunnelKey);
+ String flowRef = getFlowRef(dpnId, NwConstants.L3_LFIB_TABLE, tunnelKey);
- Flow lfibFlow = MDSALUtil.buildFlowNew(IfmConstants.LFIB_TABLE, flowRef,
+ Flow lfibFlow = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef,
IfmConstants.DEFAULT_FLOW_PRIORITY, "LFIB Entry", 0, 0,
IfmConstants.COOKIE_VM_LFIB_TABLE, mkMatches, instruction);
if (addOrRemove == NwConstants.ADD_FLOW) {