2 * Copyright (c) 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.Collections;
12 import java.util.List;
13 import java.util.concurrent.Callable;
14 import org.opendaylight.genius.infra.Datastore;
15 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
16 import org.opendaylight.mdsal.binding.api.DataBroker;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class ItmTepsNotHostedAddWorker implements Callable<List<? extends ListenableFuture<?>>> {
23 private static final Logger LOG = LoggerFactory.getLogger(ItmTepsNotHostedAddWorker.class);
24 private final List<UnknownVteps> vtepsList;
25 private final String tzName;
26 private final ManagedNewTransactionRunner txRunner;
28 public ItmTepsNotHostedAddWorker(List<UnknownVteps> vtepsList, String tzName, DataBroker broker,
29 ManagedNewTransactionRunner txRunner) {
30 this.vtepsList = vtepsList;
32 this.txRunner = txRunner;
36 public List<ListenableFuture<Void>> call() throws Exception {
37 LOG.trace("Add TEP into TepsNotHosted list task is picked from DataStoreJobCoordinator for execution.");
39 // Add TEP to TepsNotHosted list.
40 return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(Datastore.OPERATIONAL,
41 tx -> OvsdbTepAddConfigHelper
42 .addVtepIntoTepsNotHosted(vtepsList, tzName, tx)));