2 * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
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
8 package org.opendaylight.netvirt.vpnmanager.intervpnlink.tasks;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.Collections;
12 import java.util.List;
13 import java.util.concurrent.Callable;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
16 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 public class InterVpnLinkRemoverTask implements Callable<List<ListenableFuture<Void>>> {
23 private static final Logger LOG = LoggerFactory.getLogger(InterVpnLinkRemoverTask.class);
25 private final InstanceIdentifier<InterVpnLink> interVpnLinkIid;
26 private final String interVpnLinkName;
27 private final DataBroker dataBroker;
29 public InterVpnLinkRemoverTask(DataBroker dataBroker, InstanceIdentifier<InterVpnLink> interVpnLinkPath) {
30 this.interVpnLinkIid = interVpnLinkPath;
31 this.interVpnLinkName = interVpnLinkPath.firstKeyOf(InterVpnLink.class).getName();
32 this.dataBroker = dataBroker;
36 public List<ListenableFuture<Void>> call() throws Exception {
37 LOG.debug("Removing InterVpnLink {} from storage", interVpnLinkName);
38 WriteTransaction removeTx = dataBroker.newWriteOnlyTransaction();
39 removeTx.delete(LogicalDatastoreType.CONFIGURATION, this.interVpnLinkIid);
41 return Collections.singletonList(removeTx.submit());