elanmanager dead code removal
[netvirt.git] / elanmanager / impl / src / main / java / org / opendaylight / netvirt / elan / l2gw / jobs / LogicalSwitchAddedJob.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.netvirt.elan.l2gw.jobs;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.ArrayList;
12 import java.util.List;
13 import java.util.concurrent.Callable;
14 import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
15 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
16 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
17 import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices;
19 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 /**
24  * The Class LogicalSwitchAddedWorker.
25  */
26 public class LogicalSwitchAddedJob implements Callable<List<ListenableFuture<Void>>> {
27     private static final Logger LOG = LoggerFactory.getLogger(LogicalSwitchAddedJob.class);
28
29     /** The logical switch name. */
30     private final String logicalSwitchName;
31
32     /** The physical device. */
33     private final Devices physicalDevice;
34
35     /** The l2 gateway device. */
36     private final L2GatewayDevice elanL2GwDevice;
37
38     /** The default vlan id. */
39     private final Integer defaultVlanId;
40
41     private final ElanL2GatewayUtils elanL2GatewayUtils;
42     private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
43
44     public LogicalSwitchAddedJob(ElanL2GatewayUtils elanL2GatewayUtils,
45                                  ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils, String logicalSwitchName,
46                                  Devices physicalDevice, L2GatewayDevice l2GatewayDevice, Integer defaultVlanId) {
47         this.elanL2GatewayUtils = elanL2GatewayUtils;
48         this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
49         this.logicalSwitchName = logicalSwitchName;
50         this.physicalDevice = physicalDevice;
51         this.elanL2GwDevice = l2GatewayDevice;
52         this.defaultVlanId = defaultVlanId;
53         LOG.debug("created logical switch added job for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
54     }
55
56     public String getJobKey() {
57         return logicalSwitchName + HwvtepHAUtil.L2GW_JOB_KEY;
58     }
59
60     @Override
61     public List<ListenableFuture<Void>> call() {
62         elanL2GatewayUtils.cancelDeleteLogicalSwitch(new NodeId(elanL2GwDevice.getHwvtepNodeId()), logicalSwitchName);
63         LOG.debug("running logical switch added job for {} {}", logicalSwitchName,
64                 elanL2GwDevice.getHwvtepNodeId());
65         List<ListenableFuture<Void>> futures = new ArrayList<>();
66
67         LOG.info("creating vlan bindings for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
68         futures.add(elanL2GatewayUtils.updateVlanBindingsInL2GatewayDevice(
69             new NodeId(elanL2GwDevice.getHwvtepNodeId()), logicalSwitchName, physicalDevice, defaultVlanId));
70         LOG.info("creating mast mac entries for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
71         elanL2GatewayMulticastUtils.handleMcastForElanL2GwDeviceAdd(logicalSwitchName, elanL2GwDevice);
72         futures.add(elanL2GatewayUtils.installElanMacsInL2GatewayDevice(
73                 logicalSwitchName, elanL2GwDevice));
74         return futures;
75     }
76
77 }