import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.commons.lang3.BooleanUtils;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
import org.opendaylight.genius.interfacemanager.globals.VlanInterfaceInfo;
import org.opendaylight.genius.interfacemanager.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
-import org.opendaylight.genius.mdsalutil.ActionType;
import org.opendaylight.genius.mdsalutil.ActionInfo;
+import org.opendaylight.genius.mdsalutil.ActionType;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
+import org.opendaylight.genius.mdsalutil.actions.ActionOutput;
+import org.opendaylight.genius.mdsalutil.actions.ActionPushVlan;
+import org.opendaylight.genius.mdsalutil.actions.ActionRegLoad;
+import org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId;
+import org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid;
+import org.opendaylight.genius.mdsalutil.actions.ActionSetTunnelDestinationIp;
+import org.opendaylight.genius.mdsalutil.actions.ActionSetTunnelSourceIp;
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.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
return split[2];
}
+ public static Long getPortNumberFromNodeConnectorId(NodeConnectorId portId) {
+ String portNo = getPortNoFromNodeConnectorId(portId);
+ try{
+ return Long.valueOf(portNo);
+ }catch(NumberFormatException ex){
+ LOG.trace("Unable to retrieve port number from nodeconnector id for {}", portId);
+ }
+ return IfmConstants.INVALID_PORT_NO;
+ }
+
public static NodeId buildDpnNodeId(BigInteger dpnId) {
return new NodeId(IfmConstants.OF_URI_PREFIX + dpnId);
}
IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
LOG.trace("L2Vlan: {}", vlanIface);
boolean isVlanTransparent = false;
- long vlanVid = 0;
+ int vlanVid = 0;
if (vlanIface != null) {
vlanVid = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
isVlanTransparent = vlanIface.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
}
if (vlanVid != 0 && !isVlanTransparent) {
- result.add(new ActionInfo(ActionType.push_vlan, new String[]{}, actionKeyStart++));
- result.add(new ActionInfo(ActionType.set_field_vlan_vid,
- new String[]{Long.toString(vlanVid)}, actionKeyStart++));
+ result.add(new ActionPushVlan(actionKeyStart++));
+ result.add(new ActionSetFieldVlanVid(actionKeyStart++, vlanVid));
}
- result.add(new ActionInfo(ActionType.output, new String[]{portNo}, actionKeyStart++));
+ result.add(new ActionOutput(actionKeyStart++, new Uri(portNo)));
}else{
long regValue = MetaDataUtil.getReg6ValueForLPortDispatcher(ifIndex, NwConstants.DEFAULT_SERVICE_INDEX);
- result.add(new ActionInfo(ActionType.nx_load_reg_6,
- new String[]{Integer.toString(IfmConstants.REG6_START_INDEX), Integer.toString(IfmConstants.REG6_END_INDEX),
- Long.toString(regValue)}, actionKeyStart++));
+ result.add(new ActionRegLoad(actionKeyStart++, NxmNxReg6.class, IfmConstants.REG6_START_INDEX,
+ IfmConstants.REG6_END_INDEX, regValue));
result.add(new ActionInfo(ActionType.nx_resubmit,
new String[]{Short.toString(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE)}, actionKeyStart++));
}
case GRE_TRUNK_INTERFACE:
//TODO tunnel_id to encode GRE key, once it is supported
// Until then, tunnel_id should be "cleaned", otherwise it stores the value coming from a VXLAN tunnel
- if (tunnelKey == null)
+ if (tunnelKey == null) {
tunnelKey = 0L;
- result.add(new ActionInfo(ActionType.set_field_tunnel_id,
- new BigInteger[]{BigInteger.valueOf(tunnelKey)},actionKeyStart++));
- result.add(new ActionInfo(ActionType.output, new String[]{portNo}, actionKeyStart++));
+ }
+ result.add(new ActionSetFieldTunnelId(actionKeyStart++, BigInteger.valueOf(tunnelKey)));
+
+ IfTunnel ifTunnel = interfaceInfo.getAugmentation(IfTunnel.class);
+ if(BooleanUtils.isTrue(ifTunnel.isTunnelRemoteIpFlow())) {
+ result.add(new ActionSetTunnelDestinationIp(actionKeyStart++, ifTunnel.getTunnelDestination()));
+ }
+ if(BooleanUtils.isTrue(ifTunnel.isTunnelSourceIpFlow())) {
+ result.add(new ActionSetTunnelSourceIp(actionKeyStart++, ifTunnel.getTunnelSource()));
+ }
+ result.add(new ActionOutput(actionKeyStart++, new Uri(portNo)));
break;
default:
}
public static void unbindService(DataBroker dataBroker, String interfaceName, InstanceIdentifier<BoundServices>
- boundServicesInstanceIdentifier, String parentInterface){
+ boundServicesInstanceIdentifier){
LOG.info("Unbinding Service from : {}", interfaceName);
DataStoreJobCoordinator dataStoreJobCoordinator = DataStoreJobCoordinator.getInstance();
- dataStoreJobCoordinator.enqueueJob(parentInterface,
+ dataStoreJobCoordinator.enqueueJob(interfaceName,
() -> {
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
t.delete(LogicalDatastoreType.CONFIGURATION, boundServicesInstanceIdentifier);