Updated L2Gw changes in "neutronvpn", "elanmanager" and "dhcpservice" modules
[vpnservice.git] / elanmanager / elanmanager-impl / src / main / java / org / opendaylight / vpnservice / elan / l2gw / jobs / LogicalSwitchDeletedJob.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.elan.l2gw.jobs;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.vpnservice.utils.hwvtep.HwvtepUtils;
14 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.concurrent.Callable;
21
22 /**
23  * The Class LogicalSwitchDeletedJob.
24  */
25 public class LogicalSwitchDeletedJob implements Callable<List<ListenableFuture<Void>>> {
26     private DataBroker broker;
27
28     /** The logical switch name. */
29     private String logicalSwitchName;
30
31     /** The physical device. */
32     private NodeId hwvtepNodeId;
33
34     private static final Logger LOG = LoggerFactory.getLogger(LogicalSwitchDeletedJob.class);
35
36     public LogicalSwitchDeletedJob(DataBroker broker, NodeId hwvtepNodeId, String logicalSwitchName) {
37         this.broker = broker;
38         this.hwvtepNodeId = hwvtepNodeId;
39         this.logicalSwitchName = logicalSwitchName;
40         LOG.debug("created logical switch deleted job for {} on {}", logicalSwitchName, hwvtepNodeId);
41     }
42
43     public String getJobKey() {
44         return logicalSwitchName;
45     }
46
47     /*
48      * (non-Javadoc)
49      *
50      * @see java.util.concurrent.Callable#call()
51      */
52     @Override
53     public List<ListenableFuture<Void>> call() throws Exception {
54         try {
55             LOG.debug("running logical switch deleted job for {} in {}", logicalSwitchName, hwvtepNodeId);
56             List<ListenableFuture<Void>> futures = new ArrayList<>();
57             futures.add(HwvtepUtils.deleteLogicalSwitch(broker, hwvtepNodeId, logicalSwitchName));
58             return futures;
59         } catch (Throwable e) {
60             LOG.error("failed to delete ls ", e);
61             return null;
62         }
63     }
64 }