X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=interfacemgr%2Finterfacemgr-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Finterfacemgr%2Frpcservice%2FInterfaceManagerRpcService.java;h=53523c7b8f4af3fcb6e30ea01f97d3b98c268020;hb=9c0e16907ffb4d6c79ea397885f9dfed738dc848;hp=14070ed0c960d8e455fb574a33d24e9469322b35;hpb=6a77580a6058d5a21de4a22852ac2ab38e2fea6c;p=vpnservice.git diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/rpcservice/InterfaceManagerRpcService.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/rpcservice/InterfaceManagerRpcService.java index 14070ed0..53523c7b 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/rpcservice/InterfaceManagerRpcService.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/rpcservice/InterfaceManagerRpcService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. + * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -20,12 +20,19 @@ import org.opendaylight.vpnservice.interfacemgr.IfmConstants; import org.opendaylight.vpnservice.interfacemgr.IfmUtil; import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils; import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils; -import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils; -import org.opendaylight.vpnservice.mdsalutil.*; +import org.opendaylight.vpnservice.mdsalutil.ActionInfo; +import org.opendaylight.vpnservice.mdsalutil.ActionType; +import org.opendaylight.vpnservice.mdsalutil.InstructionInfo; +import org.opendaylight.vpnservice.mdsalutil.InstructionType; +import org.opendaylight.vpnservice.mdsalutil.MDSALUtil; +import org.opendaylight.vpnservice.mdsalutil.MatchFieldType; +import org.opendaylight.vpnservice.mdsalutil.MatchInfo; +import org.opendaylight.vpnservice.mdsalutil.NwConstants; import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action; @@ -38,7 +45,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.met import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntryKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntry; -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; @@ -61,6 +67,8 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { private static final Logger LOG = LoggerFactory.getLogger(InterfaceManagerRpcService.class); DataBroker dataBroker; IMdsalApiManager mdsalMgr; + + public InterfaceManagerRpcService(DataBroker dataBroker, IMdsalApiManager mdsalMgr) { this.dataBroker = dataBroker; this.mdsalMgr = mdsalMgr; @@ -206,7 +214,10 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { RpcResultBuilder rpcResultBuilder; try { List instructionInfo = new ArrayList(); - List actionInfo = getEgressActionInfosForInterface(input.getIntfName()); + List actionInfo = IfmUtil.getEgressActionInfosForInterface(input.getIntfName(), + input.getTunnelKey(), + 0, /* ActionKey starting value */ + dataBroker); instructionInfo.add(new InstructionInfo(InstructionType.write_actions, actionInfo)); GetEgressInstructionsForInterfaceOutputBuilder output = new GetEgressInstructionsForInterfaceOutputBuilder(). setInstruction(buildInstructions(instructionInfo)); @@ -266,7 +277,10 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { public Future> getEgressActionsForInterface(GetEgressActionsForInterfaceInput input) { RpcResultBuilder rpcResultBuilder; try { - List actionsList = getEgressActionsForInterface(input.getIntfName()); + LOG.debug("Get Egress Action for interface {} with key {}", input.getIntfName(), input.getTunnelKey()); + List actionsList = IfmUtil.getEgressActionsForInterface(input.getIntfName(), + input.getTunnelKey(), + dataBroker); GetEgressActionsForInterfaceOutputBuilder output = new GetEgressActionsForInterfaceOutputBuilder(). setAction(actionsList); rpcResultBuilder = RpcResultBuilder.success(); @@ -278,6 +292,7 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { return Futures.immediateFuture(rpcResultBuilder.build()); } + @Override public Future> getPortFromInterface(GetPortFromInterfaceInput input) { RpcResultBuilder rpcResultBuilder; @@ -343,42 +358,6 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { return Futures.immediateFuture(rpcResultBuilder.build()); } - public List getEgressActionInfosForInterface(String interfaceName) { - Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName), - dataBroker); - List listActionInfo = new ArrayList(); - 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 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) })); - } - 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; - } - - public List getEgressActionsForInterface(String interfaceName) { - List listActionInfo = getEgressActionInfosForInterface(interfaceName); - List actionsList = new ArrayList<>(); - for (ActionInfo actionInfo : listActionInfo) { - actionsList.add(actionInfo.buildAction()); - } - return actionsList; - } - protected static List buildInstructions(List listInstructionInfo) { if (listInstructionInfo != null) { List instructions = new ArrayList(); @@ -397,8 +376,8 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { private ListenableFuture makeTerminatingServiceFlow(IfTunnel tunnelInfo, BigInteger dpnId, BigInteger tunnelKey, List instruction, int addOrRemove) { List mkMatches = new ArrayList(); 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, @@ -416,9 +395,9 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService { 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) {