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