Bump versions by 0.1.0 for next dev cycle
[vpnservice.git] / itm / itm-impl / src / main / java / org / opendaylight / vpnservice / itm / confighelpers / ItmTepAddWorker.java
1 /*
2  * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.vpnservice.itm.confighelpers;
9
10 import java.util.ArrayList;
11 import java.util.List;
12 import java.util.concurrent.Callable;
13
14 import com.google.common.util.concurrent.ListenableFuture;
15
16 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
17 import org.opendaylight.vpnservice.itm.impl.ItmUtils;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
19 import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
21 import org.slf4j.LoggerFactory;
22 import org.slf4j.Logger;
23
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;
32
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);
41     }
42
43     @Override
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         //futures.addAll(ItmExternalTunnelAddWorker.buildTunnelsToExternalEndPoint(dataBroker,meshedDpnList, extIp) ;
51         logger.debug("invoking build hwVtepTunnels with hwVteplist {}", cfgdHwVteps );
52         futures.addAll(ItmExternalTunnelAddWorker.buildHwVtepsTunnels(dataBroker, idManagerService,cfgdDpnList,cfgdHwVteps));
53         return futures ;
54     }
55
56     @Override
57     public String toString() {
58         return "ItmTepAddWorker  { " +
59         "Configured Dpn List : " + cfgdDpnList +
60         "  Meshed Dpn List : " + meshedDpnList + " }" ;
61     }
62 }