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.List;
13 import java.util.concurrent.Callable;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.genius.itm.impl.ItmUtils;
16 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class ItmTepAddWorker implements Callable<List<ListenableFuture<Void>>> {
25 private static final Logger LOG = LoggerFactory.getLogger(ItmTepAddWorker.class);
27 private final DataBroker dataBroker;
28 private final IdManagerService idManagerService;
29 private List<DPNTEPsInfo> meshedDpnList;
30 private final List<DPNTEPsInfo> cfgdDpnList ;
31 private final IMdsalApiManager mdsalManager;
32 private final List<HwVtep> cfgdHwVteps;
34 public ItmTepAddWorker(List<DPNTEPsInfo> cfgdDpnList, List<HwVtep> hwVtepList, DataBroker broker,
35 IdManagerService idManagerService, IMdsalApiManager mdsalManager) {
36 this.cfgdDpnList = cfgdDpnList ;
37 this.dataBroker = broker ;
38 this.idManagerService = idManagerService;
39 this.mdsalManager = mdsalManager;
40 this.cfgdHwVteps = hwVtepList;
41 LOG.trace("ItmTepAddWorker initialized with DpnList {}",cfgdDpnList);
42 LOG.trace("ItmTepAddWorker initialized with hwvteplist {}",hwVtepList);
46 public List<ListenableFuture<Void>> call() {
47 List<ListenableFuture<Void>> futures = new ArrayList<>() ;
48 this.meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker) ;
49 LOG.debug("Invoking Internal Tunnel build method with Configured DpnList {} ; Meshed DpnList {} ",
50 cfgdDpnList, meshedDpnList);
51 futures.addAll(ItmInternalTunnelAddWorker.build_all_tunnels(dataBroker, idManagerService, mdsalManager,
52 cfgdDpnList, meshedDpnList)) ;
53 // IF EXTERNAL TUNNELS NEEDS TO BE BUILT, DO IT HERE. IT COULD BE TO DC GATEWAY OR TOR SWITCH
54 List<DcGatewayIp> dcGatewayIpList = ItmUtils.getDcGatewayIpList(dataBroker);
55 if (dcGatewayIpList != null && !dcGatewayIpList.isEmpty()) {
56 for (DcGatewayIp dcGatewayIp : dcGatewayIpList) {
57 futures.addAll(ItmExternalTunnelAddWorker.buildTunnelsToExternalEndPoint(dataBroker, idManagerService,
58 cfgdDpnList, dcGatewayIp.getIpAddress(), dcGatewayIp.getTunnnelType()));
61 //futures.addAll(ItmExternalTunnelAddWorker.buildTunnelsToExternalEndPoint(dataBroker,meshedDpnList, extIp) ;
62 LOG.debug("invoking build hwVtepTunnels with hwVteplist {}", cfgdHwVteps);
63 futures.addAll(ItmExternalTunnelAddWorker.buildHwVtepsTunnels(dataBroker, idManagerService,
64 cfgdDpnList,cfgdHwVteps));
69 public String toString() {
70 return "ItmTepAddWorker { "
71 + "Configured Dpn List : " + cfgdDpnList
72 + " Meshed Dpn List : " + meshedDpnList + " }" ;