2 * Copyright (c) 2016, 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.interfacemanager.renderer.ovs.confighelpers;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.ArrayList;
12 import java.util.List;
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
15 import org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public class OvsVlanMemberConfigAddHelper {
25 private static final Logger LOG = LoggerFactory.getLogger(OvsVlanMemberConfigAddHelper.class);
27 public static List<ListenableFuture<Void>> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
28 Interface interfaceNew, IfL2vlan ifL2vlan, IdManagerService idManager) {
29 LOG.debug("add vlan member configuration {}", interfaceNew.getName());
30 List<ListenableFuture<Void>> futures = new ArrayList<>();
31 WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
32 InterfaceManagerCommonUtils.createInterfaceChildEntry(parentRefs.getParentInterface(), interfaceNew.getName(),
34 futures.add(writeTransaction.submit());
36 InterfaceKey interfaceKey = new InterfaceKey(parentRefs.getParentInterface());
37 Interface ifaceParent = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
38 if (ifaceParent == null) {
39 LOG.info("Parent Interface: {} not found when adding child interface: {}", parentRefs.getParentInterface(),
40 interfaceNew.getName());
44 IfL2vlan parentIfL2Vlan = ifaceParent.getAugmentation(IfL2vlan.class);
45 if (parentIfL2Vlan == null || parentIfL2Vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
46 LOG.error("Parent Interface: {} not of trunk Type when adding trunk-member: {}", ifaceParent, interfaceNew);
50 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
51 .ietf.interfaces.rev140508.interfaces.state.Interface ifState = InterfaceManagerCommonUtils
52 .getInterfaceState(parentRefs.getParentInterface(), dataBroker);
53 LOG.debug("add interface state info for vlan member {}, with ifState for parent {}", interfaceNew.getName(),
55 InterfaceManagerCommonUtils.addStateEntry(interfaceNew.getName(), dataBroker, idManager, futures, ifState);