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.hwvtep.confighelpers;
10 import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.util.ArrayList;
14 import java.util.Collections;
15 import java.util.List;
16 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
17 import org.opendaylight.genius.interfacemanager.renderer.hwvtep.utilities.SouthboundUtils;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsKey;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.tunnel.attributes.BfdParams;
25 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
26 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 public final class HwVTEPInterfaceConfigUpdateHelper {
32 private static final Logger LOG = LoggerFactory.getLogger(HwVTEPInterfaceConfigUpdateHelper.class);
34 private HwVTEPInterfaceConfigUpdateHelper() {
37 public static List<ListenableFuture<Void>> updateConfiguration(ManagedNewTransactionRunner txRunner,
38 InstanceIdentifier<Node> physicalSwitchNodeId, InstanceIdentifier<Node> globalNodeId,
39 Interface interfaceNew, IfTunnel ifTunnel) {
40 LOG.info("updating hwvtep configuration for {}", interfaceNew.getName());
42 // Create hwvtep through OVSDB plugin
43 if (globalNodeId != null) {
44 return updateBfdMonitoring(txRunner, globalNodeId, physicalSwitchNodeId, ifTunnel);
46 LOG.debug("specified physical switch is not connected {}", physicalSwitchNodeId);
47 return Collections.emptyList();
52 * BFD monitoring interval and enable/disable attributes can be modified
54 public static List<ListenableFuture<Void>> updateBfdMonitoring(ManagedNewTransactionRunner txRunner,
55 InstanceIdentifier<Node> globalNodeId, InstanceIdentifier<Node> physicalSwitchId, IfTunnel ifTunnel) {
56 TunnelsBuilder tunnelsBuilder = new TunnelsBuilder();
57 InstanceIdentifier<TerminationPoint> localTEPInstanceIdentifier = SouthboundUtils
58 .createTEPInstanceIdentifier(globalNodeId, ifTunnel.getTunnelSource());
59 InstanceIdentifier<TerminationPoint> remoteTEPInstanceIdentifier = SouthboundUtils
60 .createTEPInstanceIdentifier(globalNodeId, ifTunnel.getTunnelDestination());
61 InstanceIdentifier<Tunnels> tunnelsInstanceIdentifier = SouthboundUtils.createTunnelsInstanceIdentifier(
62 physicalSwitchId, localTEPInstanceIdentifier, remoteTEPInstanceIdentifier);
64 LOG.debug("updating bfd monitoring parameters for the hwvtep {}", tunnelsInstanceIdentifier);
65 tunnelsBuilder.withKey(new TunnelsKey(new HwvtepPhysicalLocatorRef(localTEPInstanceIdentifier),
66 new HwvtepPhysicalLocatorRef(remoteTEPInstanceIdentifier)));
67 List<BfdParams> bfdParams = new ArrayList<>();
68 SouthboundUtils.fillBfdParameters(bfdParams, ifTunnel);
69 tunnelsBuilder.setBfdParams(bfdParams);
70 return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
71 tx -> tx.mergeParentStructureMerge(tunnelsInstanceIdentifier, tunnelsBuilder.build())));