import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
-import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
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.interfaces.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.ServicesInfo;
return futures;
}
- InterfaceKey interfaceKey = new InterfaceKey(ifaceState.getName());
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface =
- InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
-
- if (iface.getType().isAssignableFrom(L2vlan.class)) {
- return unbindServiceOnVlan(allServices, iface, ifaceState.getIfIndex(), dataBroker);
- } else if (iface.getType().isAssignableFrom(Tunnel.class)){
- return unbindServiceOnTunnel(allServices, iface, ifaceState.getIfIndex(), dataBroker);
+ if (ifaceState.getType().isAssignableFrom(L2vlan.class)) {
+ return unbindServiceOnVlan(allServices, ifaceState, ifaceState.getIfIndex(), dataBroker);
+ } else if (ifaceState.getType().isAssignableFrom(Tunnel.class)){
+ return unbindServiceOnTunnel(allServices, ifaceState, ifaceState.getIfIndex(), dataBroker);
}
return futures;
}
private static List<ListenableFuture<Void>> unbindServiceOnTunnel(
List<BoundServices> allServices,
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface,
+ Interface iface,
Integer ifIndex, DataBroker dataBroker) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
- NodeConnectorId nodeConnectorId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(iface, dataBroker);
+ List<String> ofportIds = iface.getLowerLayerIf();
+ NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
if(nodeConnectorId == null){
return futures;
}
BoundServices highestPriorityBoundService = FlowBasedServicesUtils.getHighestPriorityService(allServices);
BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
- FlowBasedServicesUtils.removeIngressFlow(iface, highestPriorityBoundService, dpId, t);
+ FlowBasedServicesUtils.removeIngressFlow(iface.getName(), highestPriorityBoundService, dpId, t);
for (BoundServices boundService : allServices) {
if (!boundService.equals(highestPriorityBoundService)) {
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, boundService, t, boundService.getServicePriority());
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface.getName(), boundService, t, boundService.getServicePriority());
}
}
}
private static List<ListenableFuture<Void>> unbindServiceOnVlan(
- List<BoundServices> allServices,
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface,
+ List<BoundServices> allServices, Interface ifaceState,
Integer ifIndex, DataBroker dataBroker) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
- NodeConnectorId nodeConnectorId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(iface, dataBroker);
- if (nodeConnectorId == null) {
+ List<String> ofportIds = ifaceState.getLowerLayerIf();
+ NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
+ if(nodeConnectorId == null){
return futures;
}
BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
Collections.sort(allServices, new Comparator<BoundServices>() {
@Override
public int compare(BoundServices serviceInfo1, BoundServices serviceInfo2) {
- return serviceInfo2.getServicePriority().compareTo(serviceInfo1.getServicePriority());
+ return serviceInfo1.getServicePriority().compareTo(serviceInfo2.getServicePriority());
}
});
BoundServices highestPriority = allServices.remove(0);
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, highestPriority, t, IfmConstants.DEFAULT_SERVICE_INDEX);
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, ifaceState.getName(), highestPriority, t, IfmConstants.DEFAULT_SERVICE_INDEX);
for (BoundServices boundService : allServices) {
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, boundService, t, boundService.getServicePriority());
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, ifaceState.getName(), boundService, t, boundService.getServicePriority());
}
futures.add(t.submit());
return futures;