Move tepsNotHosted from Config DS to Oper DS
[genius.git] / itm / itm-impl / src / main / java / org / opendaylight / genius / itm / confighelpers / ItmTepsNotHostedRemoveWorker.java
1 /*
2  * Copyright (c) 2017 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.genius.itm.confighelpers;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.math.BigInteger;
12 import java.util.Collections;
13 import java.util.List;
14 import java.util.concurrent.Callable;
15 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
16 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 public class ItmTepsNotHostedRemoveWorker implements Callable<List<ListenableFuture<Void>>> {
22
23     private static final Logger LOG = LoggerFactory.getLogger(ItmTepsNotHostedRemoveWorker.class);
24
25     private final IpAddress tepIpAddress;
26     private final String tzName;
27     private final BigInteger dpnId;
28     private final DataBroker dataBroker;
29
30     public ItmTepsNotHostedRemoveWorker(String tzName, IpAddress tepIpAddress, BigInteger dpnId, DataBroker broker) {
31         this.tepIpAddress = tepIpAddress;
32         this.tzName = tzName;
33         this.dpnId = dpnId;
34         this.dataBroker = broker ;
35     }
36
37     @Override
38     public List<ListenableFuture<Void>> call() throws Exception {
39         WriteTransaction wrTx = dataBroker.newWriteOnlyTransaction();
40
41         LOG.trace("Remove TEP from TepsNotHosted list task is picked from DataStoreJobCoordinator for execution.");
42
43         // Remove TEP from TepsNotHosted list.
44         OvsdbTepRemoveConfigHelper.removeUnknownTzTepFromTepsNotHosted(tzName, tepIpAddress, dpnId, dataBroker, wrTx);
45
46         return Collections.singletonList(wrTx.submit());
47     }
48 }