2 * Copyright (c) 2017 Hewlett Packard Enterprise, Co. 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.netvirt.dhcpservice.jobs;
10 import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.util.Collections;
14 import java.util.List;
15 import java.util.concurrent.Callable;
16 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
17 import org.opendaylight.genius.mdsalutil.NwConstants;
18 import org.opendaylight.netvirt.dhcpservice.DhcpServiceUtils;
20 public class DhcpAllocationPoolAddJob implements Callable<List<ListenableFuture<Void>>> {
22 private final ManagedNewTransactionRunner txRunner;
23 private final String interfaceName;
25 public DhcpAllocationPoolAddJob(ManagedNewTransactionRunner txRunner, String interfaceName) {
26 this.txRunner = txRunner;
27 this.interfaceName = interfaceName;
31 public List<ListenableFuture<Void>> call() {
32 return installDhcpEntries();
35 private List<ListenableFuture<Void>> installDhcpEntries() {
36 return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
37 tx -> DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx)));