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.genius.itm.confighelpers;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.List;
14 import java.util.concurrent.Callable;
15 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
16 import org.opendaylight.genius.itm.cache.DPNTEPsInfoCache;
17 import org.opendaylight.genius.itm.impl.ItmUtils;
18 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 public class ItmTepAddWorker implements Callable<List<ListenableFuture<Void>>> {
27 private static final Logger LOG = LoggerFactory.getLogger(ItmTepAddWorker.class);
29 private final DataBroker dataBroker;
30 private Collection<DPNTEPsInfo> meshedDpnList;
31 private final List<DPNTEPsInfo> cfgdDpnList ;
32 private final IMdsalApiManager mdsalManager;
33 private final List<HwVtep> cfgdHwVteps;
34 private final ItmConfig itmConfig;
35 private final ItmInternalTunnelAddWorker itmInternalTunnelAddWorker;
36 private final ItmExternalTunnelAddWorker externalTunnelAddWorker;
37 private final DPNTEPsInfoCache dpnTEPsInfoCache;
39 public ItmTepAddWorker(List<DPNTEPsInfo> cfgdDpnList, List<HwVtep> hwVtepList, DataBroker broker,
40 IMdsalApiManager mdsalManager, ItmConfig itmConfig, ItmInternalTunnelAddWorker itmInternalTunnelAddWorker,
41 ItmExternalTunnelAddWorker externalTunnelAddWorker, DPNTEPsInfoCache dpnTEPsInfoCache) {
42 this.cfgdDpnList = cfgdDpnList ;
43 this.dataBroker = broker ;
44 this.mdsalManager = mdsalManager;
45 this.cfgdHwVteps = hwVtepList;
46 this.itmConfig = itmConfig;
47 this.itmInternalTunnelAddWorker = itmInternalTunnelAddWorker;
48 this.externalTunnelAddWorker = externalTunnelAddWorker;
49 this.dpnTEPsInfoCache = dpnTEPsInfoCache;
50 LOG.trace("ItmTepAddWorker initialized with DpnList {}",cfgdDpnList);
51 LOG.trace("ItmTepAddWorker initialized with hwvteplist {}",hwVtepList);
55 public List<ListenableFuture<Void>> call() {
56 List<ListenableFuture<Void>> futures = new ArrayList<>() ;
57 this.meshedDpnList = ItmUtils.getDpnTEPsInfos(dataBroker);
58 LOG.debug("Invoking Internal Tunnel build method with Configured DpnList {} ; Meshed DpnList {} ",
59 cfgdDpnList, meshedDpnList);
60 futures.addAll(itmInternalTunnelAddWorker.buildAllTunnels(mdsalManager, cfgdDpnList,
62 // IF EXTERNAL TUNNELS NEEDS TO BE BUILT, DO IT HERE. IT COULD BE TO DC GATEWAY OR TOR SWITCH
63 List<DcGatewayIp> dcGatewayIpList = ItmUtils.getDcGatewayIpList(dataBroker);
64 if (dcGatewayIpList != null && !dcGatewayIpList.isEmpty()) {
65 for (DcGatewayIp dcGatewayIp : dcGatewayIpList) {
66 futures.addAll(externalTunnelAddWorker.buildTunnelsToExternalEndPoint(cfgdDpnList,
67 dcGatewayIp.getIpAddress(), dcGatewayIp.getTunnnelType()));
70 //futures.addAll(ItmExternalTunnelAddWorker.buildTunnelsToExternalEndPoint(dataBroker,meshedDpnList, extIp) ;
71 LOG.debug("invoking build hwVtepTunnels with hwVteplist {}", cfgdHwVteps);
72 futures.addAll(externalTunnelAddWorker.buildHwVtepsTunnels(cfgdDpnList,cfgdHwVteps));
77 public String toString() {
78 return "ItmTepAddWorker { "
79 + "Configured Dpn List : " + cfgdDpnList
80 + " Meshed Dpn List : " + meshedDpnList + " }" ;