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 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.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
16 import org.opendaylight.netvirt.dhcpservice.DhcpServiceUtils;
18 public class DhcpAllocationPoolRemoveJob implements Callable<List<ListenableFuture<Void>>> {
20 private final DataBroker dataBroker;
21 private final String interfaceName;
23 public DhcpAllocationPoolRemoveJob(DataBroker dataBroker, String interfaceName) {
25 this.dataBroker = dataBroker;
26 this.interfaceName = interfaceName;
30 public List<ListenableFuture<Void>> call() throws Exception {
31 return unInstallDhcpEntries(interfaceName);
34 private List<ListenableFuture<Void>> unInstallDhcpEntries(String interfaceName) {
35 WriteTransaction unbindServiceTx = dataBroker.newWriteOnlyTransaction();
36 DhcpServiceUtils.unbindDhcpService(interfaceName, unbindServiceTx);
37 return Collections.singletonList(unbindServiceTx.submit());