76f6cc0024fe88444f8431f1addda8bcc97ffa9c
[genius.git] / interfacemanager / interfacemanager-impl / src / main / java / org / opendaylight / genius / interfacemanager / servicebindings / flowbased / config / helpers / AbstractFlowBasedServicesConfigUnbindHelper.java
1 /*
2  * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.genius.interfacemanager.servicebindings.flowbased.config.helpers;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.List;
12 import org.opendaylight.genius.interfacemanager.servicebindings.flowbased.config.factory.FlowBasedServicesConfigRemovable;
13 import org.opendaylight.genius.interfacemanager.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.bound.services.state.list.BoundServicesState;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices;
18
19 /**
20  * AbstractFlowBasedServicesConfigBindHelper to enable flow based ingress/egress service binding for interfaces.
21  */
22 public abstract class AbstractFlowBasedServicesConfigUnbindHelper implements FlowBasedServicesConfigRemovable {
23
24     @Override
25     public final void unbindService(List<ListenableFuture<Void>> futures, String interfaceName,
26                                     BoundServices boundServiceOld, List<BoundServices> boundServices,
27                                     BoundServicesState boundServicesState) {
28
29         if (FlowBasedServicesUtils.isInterfaceTypeBasedServiceBinding(interfaceName)) {
30             unbindServiceOnInterfaceType(futures, boundServiceOld, boundServices);
31         } else if (L2vlan.class.equals(boundServicesState.getInterfaceType())
32             || Tunnel.class.equals(boundServicesState.getInterfaceType())) {
33             unbindServiceOnInterface(futures, boundServiceOld, boundServices, boundServicesState);
34         }
35     }
36
37
38     protected abstract void unbindServiceOnInterface(List<ListenableFuture<Void>> futures,
39                                                      BoundServices boundServiceOld, List<BoundServices> allServices,
40                                                      BoundServicesState boundServicesState);
41
42     protected abstract void unbindServiceOnInterfaceType(List<ListenableFuture<Void>> futures,
43                                                          BoundServices boundServiceOld,
44                                                          List<BoundServices> allServices);
45 }
46
47