Imported vpnservice as a subtree
[netvirt.git] / vpnservice / interfacemgr / interfacemgr-impl / src / main / java / org / opendaylight / vpnservice / interfacemgr / renderer / hwvtep / statehelpers / HwVTEPInterfaceStateRemoveHelper.java
1 /*
2  * Copyright (c) 2016 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.vpnservice.interfacemgr.renderer.hwvtep.statehelpers;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 import java.util.ArrayList;
20 import java.util.List;
21
22 public class HwVTEPInterfaceStateRemoveHelper {
23     private static final Logger LOG = LoggerFactory.getLogger(HwVTEPInterfaceStateRemoveHelper.class);
24
25     public static List<ListenableFuture<Void>> removeExternalTunnel(DataBroker dataBroker,
26                                                                   InstanceIdentifier<Tunnels> tunnelsInstanceIdentifier) {
27         List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
28         LOG.debug("Removing HwVTEP tunnel entries for tunnel: {}", tunnelsInstanceIdentifier);
29         WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
30         transaction.delete(LogicalDatastoreType.CONFIGURATION, tunnelsInstanceIdentifier);
31         futures.add(transaction.submit());
32         return futures;
33     }
34 }