/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.genius.interfacemanager.renderer.ovs.confighelpers;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.ArrayList;
+import java.util.List;
+import javax.inject.Inject;
+import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-
+@Singleton
public class OvsVlanMemberConfigAddHelper {
private static final Logger LOG = LoggerFactory.getLogger(OvsVlanMemberConfigAddHelper.class);
- public static List<ListenableFuture<Void>> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
- Interface interfaceNew, IfL2vlan ifL2vlan,
- IdManagerService idManager) {
- LOG.debug("add vlan member configuration {}",interfaceNew.getName());
- List<ListenableFuture<Void>> futures = new ArrayList<>();
- WriteTransaction defaultConfigShardTransaction = dataBroker.newWriteOnlyTransaction();
- InterfaceManagerCommonUtils.createInterfaceChildEntry(defaultConfigShardTransaction, parentRefs.getParentInterface(), interfaceNew.getName());
- futures.add(defaultConfigShardTransaction.submit());
+ private final DataBroker dataBroker;
+ private final InterfaceManagerCommonUtils interfaceManagerCommonUtils;
+
+ @Inject
+ public OvsVlanMemberConfigAddHelper(DataBroker dataBroker,
+ InterfaceManagerCommonUtils interfaceManagerCommonUtils) {
+ this.dataBroker = dataBroker;
+ this.interfaceManagerCommonUtils = interfaceManagerCommonUtils;
+ }
+
+ public List<ListenableFuture<Void>> addConfiguration(ParentRefs parentRefs, Interface interfaceNew) {
+ LOG.info("adding vlan member configuration for interface {}", interfaceNew.getName());
+ List<ListenableFuture<Void>> futures = new ArrayList<>();
+ WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
+ interfaceManagerCommonUtils.createInterfaceChildEntry(parentRefs.getParentInterface(), interfaceNew.getName(),
+ writeTransaction);
+ futures.add(writeTransaction.submit());
InterfaceKey interfaceKey = new InterfaceKey(parentRefs.getParentInterface());
- Interface ifaceParent = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
+ Interface ifaceParent = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
if (ifaceParent == null) {
- LOG.info("Parent Interface: {} not found when adding child interface: {}",
- parentRefs.getParentInterface(), interfaceNew.getName());
+ LOG.info("Parent Interface: {} not found when adding child interface: {}", parentRefs.getParentInterface(),
+ interfaceNew.getName());
return futures;
}
return futures;
}
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
- InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(parentRefs.getParentInterface(), dataBroker);
- LOG.debug("add interface state info for vlan member {}",interfaceNew.getName());
- InterfaceManagerCommonUtils.addStateEntry(interfaceNew.getName(), dataBroker, idManager, futures, ifState);
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
+ .ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils
+ .getInterfaceState(parentRefs.getParentInterface());
+ interfaceManagerCommonUtils.addStateEntry(interfaceNew.getName(), futures, ifState);
return futures;
}
}