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 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>>> {
24 private static final Logger logger = LoggerFactory.getLogger(ItmTepAddWorker.class ) ;
25 private DataBroker dataBroker;
26 private IdManagerService idManagerService;
27 private List<DPNTEPsInfo> meshedDpnList;
28 private List<DPNTEPsInfo> cfgdDpnList ;
29 private IMdsalApiManager mdsalManager;
30 private List<HwVtep> cfgdHwVteps;
32 public ItmTepAddWorker(List<DPNTEPsInfo> cfgdDpnList, List<HwVtep> hwVtepList, DataBroker broker, IdManagerService idManagerService, IMdsalApiManager mdsalManager) {
33 this.cfgdDpnList = cfgdDpnList ;
34 this.dataBroker = broker ;
35 this.idManagerService = idManagerService;
36 this.mdsalManager = mdsalManager;
37 this.cfgdHwVteps = hwVtepList;
38 logger.trace("ItmTepAddWorker initialized with DpnList {}",cfgdDpnList );
39 logger.trace("ItmTepAddWorker initialized with hwvteplist {}",hwVtepList);
43 public List<ListenableFuture<Void>> call() throws Exception {
44 List<ListenableFuture<Void>> futures = new ArrayList<>() ;
45 this.meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker) ;
46 logger.debug("Invoking Internal Tunnel build method with Configured DpnList {} ; Meshed DpnList {} ",cfgdDpnList, meshedDpnList );
47 futures.addAll( ItmInternalTunnelAddWorker.build_all_tunnels(dataBroker, idManagerService,mdsalManager, cfgdDpnList, meshedDpnList) ) ;
48 // IF EXTERNAL TUNNELS NEEDS TO BE BUILT, DO IT HERE. IT COULD BE TO DC GATEWAY OR TOR SWITCH
49 List<DcGatewayIp> dcGatewayIpList = ItmUtils.getDcGatewayIpList(dataBroker);
50 if(dcGatewayIpList != null && !dcGatewayIpList.isEmpty()) {
51 for (DcGatewayIp dcGatewayIp : dcGatewayIpList) {
52 futures.addAll(ItmExternalTunnelAddWorker.buildTunnelsToExternalEndPoint(dataBroker, idManagerService, cfgdDpnList, dcGatewayIp.getIpAddress(), dcGatewayIp.getTunnnelType()));
55 //futures.addAll(ItmExternalTunnelAddWorker.buildTunnelsToExternalEndPoint(dataBroker,meshedDpnList, extIp) ;
56 logger.debug("invoking build hwVtepTunnels with hwVteplist {}", cfgdHwVteps );
57 futures.addAll(ItmExternalTunnelAddWorker.buildHwVtepsTunnels(dataBroker, idManagerService,cfgdDpnList,cfgdHwVteps));
62 public String toString() {
63 return "ItmTepAddWorker { " +
64 "Configured Dpn List : " + cfgdDpnList +
65 " Meshed Dpn List : " + meshedDpnList + " }" ;