X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=vpnservice.git;a=blobdiff_plain;f=elanmanager%2Felanmanager-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Felan%2Fl2gw%2Fjobs%2FLogicalSwitchAddedJob.java;fp=elanmanager%2Felanmanager-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Felan%2Fl2gw%2Fjobs%2FLogicalSwitchAddedJob.java;h=7ad1c45dceaa4dab721402fb06a8626f1db23224;hp=0000000000000000000000000000000000000000;hb=d89e5915c691b50d173c44f9d09e3038838957a9;hpb=2718ef3baf8e42e48743fbae515c152aa017e51f diff --git a/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/vpnservice/elan/l2gw/jobs/LogicalSwitchAddedJob.java b/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/vpnservice/elan/l2gw/jobs/LogicalSwitchAddedJob.java new file mode 100644 index 00000000..7ad1c45d --- /dev/null +++ b/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/vpnservice/elan/l2gw/jobs/LogicalSwitchAddedJob.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.vpnservice.elan.l2gw.jobs; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; + +import org.opendaylight.vpnservice.elan.l2gw.listeners.HwvtepRemoteMcastMacListener; +import org.opendaylight.vpnservice.elan.l2gw.utils.ElanL2GatewayMulticastUtils; +import org.opendaylight.vpnservice.elan.l2gw.utils.ElanL2GatewayUtils; +import org.opendaylight.vpnservice.elan.utils.ElanUtils; +import org.opendaylight.vpnservice.neutronvpn.api.l2gw.L2GatewayDevice; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.collect.Lists; +import com.google.common.util.concurrent.ListenableFuture; + +/** + * The Class LogicalSwitchAddedWorker. + */ +public class LogicalSwitchAddedJob implements Callable>> { + /** The logical switch name. */ + private String logicalSwitchName; + + /** The physical device. */ + private Devices physicalDevice; + + /** The l2 gateway device. */ + private L2GatewayDevice elanL2GwDevice; + + /** The default vlan id. */ + private Integer defaultVlanId; + + private static final Logger LOG = LoggerFactory.getLogger(LogicalSwitchAddedJob.class); + + public LogicalSwitchAddedJob(String logicalSwitchName, Devices physicalDevice, L2GatewayDevice l2GatewayDevice, + Integer defaultVlanId) { + this.logicalSwitchName = logicalSwitchName; + this.physicalDevice = physicalDevice; + this.elanL2GwDevice = l2GatewayDevice; + this.defaultVlanId = defaultVlanId; + LOG.debug("created logical switch added job for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId()); + } + + public String getJobKey() { + return logicalSwitchName; + } + + /* + * (non-Javadoc) + * + * @see java.util.concurrent.Callable#call() + */ + @Override + public List> call() throws Exception { + try { + LOG.debug("running logical switch added job for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId()); + List> futures = new ArrayList<>(); + String elan = ElanL2GatewayUtils.getElanFromLogicalSwitch(logicalSwitchName); + + LOG.info("creating vlan bindings for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId()); + futures.add(ElanL2GatewayUtils.updateVlanBindingsInL2GatewayDevice( + new NodeId(elanL2GwDevice.getHwvtepNodeId()), logicalSwitchName, physicalDevice, defaultVlanId)); + LOG.info("creating mast mac entries for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId()); + futures.add(ElanL2GatewayMulticastUtils.handleMcastForElanL2GwDeviceAdd(logicalSwitchName, elanL2GwDevice)); + + List expectedPhyLocatorIps = Lists.newArrayList(); + HwvtepRemoteMcastMacListener list = new HwvtepRemoteMcastMacListener(ElanUtils.getDataBroker(), + logicalSwitchName, elanL2GwDevice, expectedPhyLocatorIps, + new Callable>>() { + @Override + public List> call() { + LOG.info("adding remote ucast macs for {} {}", logicalSwitchName, + elanL2GwDevice.getHwvtepNodeId()); + List> futures = new ArrayList<>(); + futures.add(ElanL2GatewayUtils.installElanMacsInL2GatewayDevice( + logicalSwitchName, elanL2GwDevice)); + return futures; + } + }); + + return futures; + } catch (Throwable e) { + LOG.error("failed to add ls ", e); + return null; + } + } + +}