2 * Copyright (c) 2016 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.elan.l2gw.jobs;
10 import java.util.ArrayList;
11 import java.util.List;
12 import java.util.concurrent.Callable;
14 import org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepRemoteMcastMacListener;
15 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
16 import org.opendaylight.netvirt.elan.utils.ElanUtils;
17 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
18 import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices;
21 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 import com.google.common.collect.Lists;
26 import com.google.common.util.concurrent.ListenableFuture;
29 * The Class LogicalSwitchAddedWorker.
31 public class LogicalSwitchAddedJob implements Callable<List<ListenableFuture<Void>>> {
32 /** The logical switch name. */
33 private String logicalSwitchName;
35 /** The physical device. */
36 private Devices physicalDevice;
38 /** The l2 gateway device. */
39 private L2GatewayDevice elanL2GwDevice;
41 /** The default vlan id. */
42 private Integer defaultVlanId;
44 private static final Logger LOG = LoggerFactory.getLogger(LogicalSwitchAddedJob.class);
46 public LogicalSwitchAddedJob(String logicalSwitchName, Devices physicalDevice, L2GatewayDevice l2GatewayDevice,
47 Integer defaultVlanId) {
48 this.logicalSwitchName = logicalSwitchName;
49 this.physicalDevice = physicalDevice;
50 this.elanL2GwDevice = l2GatewayDevice;
51 this.defaultVlanId = defaultVlanId;
52 LOG.debug("created logical switch added job for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
55 public String getJobKey() {
56 return logicalSwitchName;
62 * @see java.util.concurrent.Callable#call()
65 public List<ListenableFuture<Void>> call() throws Exception {
67 LOG.debug("running logical switch added job for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
68 List<ListenableFuture<Void>> futures = new ArrayList<>();
69 String elan = ElanL2GatewayUtils.getElanFromLogicalSwitch(logicalSwitchName);
71 LOG.info("creating vlan bindings for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
72 futures.add(ElanL2GatewayUtils.updateVlanBindingsInL2GatewayDevice(
73 new NodeId(elanL2GwDevice.getHwvtepNodeId()), logicalSwitchName, physicalDevice, defaultVlanId));
74 LOG.info("creating mast mac entries for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
75 futures.add(ElanL2GatewayMulticastUtils.handleMcastForElanL2GwDeviceAdd(logicalSwitchName, elanL2GwDevice));
77 List<IpAddress> expectedPhyLocatorIps = Lists.newArrayList();
78 HwvtepRemoteMcastMacListener list = new HwvtepRemoteMcastMacListener(ElanUtils.getElanServiceProvider().getBroker(),
79 logicalSwitchName, elanL2GwDevice, expectedPhyLocatorIps,
80 new Callable<List<ListenableFuture<Void>>>() {
82 public List<ListenableFuture<Void>> call() {
83 LOG.info("adding remote ucast macs for {} {}", logicalSwitchName,
84 elanL2GwDevice.getHwvtepNodeId());
85 List<ListenableFuture<Void>> futures = new ArrayList<>();
86 futures.add(ElanL2GatewayUtils.installElanMacsInL2GatewayDevice(
87 logicalSwitchName, elanL2GwDevice));
93 } catch (Throwable e) {
94 LOG.error("failed to add ls ", e);