/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 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,
return bridgeRefEntryInstanceIdentifierBuilder.build();
}
+
public static BridgeRefEntry getBridgeRefEntryFromOperDS(InstanceIdentifier<BridgeRefEntry> dpnBridgeEntryIid,
DataBroker dataBroker) {
Optional<BridgeRefEntry> bridgeRefEntryOptional =
return bridgeEntryIdBuilder.build();
}
+ public static BridgeEntry getBridgeEntryFromConfigDS(BigInteger dpnId,
+ DataBroker dataBroker) {
+ BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpnId);
+ InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier =
+ InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
+ return getBridgeEntryFromConfigDS(bridgeEntryInstanceIdentifier,
+ dataBroker);
+ }
+
public static BridgeEntry getBridgeEntryFromConfigDS(InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier,
DataBroker dataBroker) {
Optional<BridgeEntry> bridgeEntryOptional =
public static void createBridgeRefEntry(BigInteger dpnId, InstanceIdentifier<?> bridgeIid,
WriteTransaction tx){
+ LOG.debug("Creating bridge ref entry for dpn: {} bridge: {}",
+ dpnId, bridgeIid);
BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
.setBridgeReference(new OvsdbBridgeRef(bridgeIid));
tx.put(LogicalDatastoreType.OPERATIONAL, bridgeEntryId, tunnelDpnBridgeEntryBuilder.build(), true);
}
+
+ public static void deleteBridgeRefEntry(BigInteger dpnId,
+ WriteTransaction tx) {
+ LOG.debug("Deleting bridge ref entry for dpn: {}",
+ dpnId);
+ BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
+ InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
+ InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
+ tx.delete(LogicalDatastoreType.OPERATIONAL, bridgeEntryId);
+ }
}
\ No newline at end of file
import org.opendaylight.vpnservice.datastoreutils.DataStoreJobCoordinator;
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers.OvsInterfaceTopologyStateAddHelper;
import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers.OvsInterfaceTopologyStateRemoveHelper;
+import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers.OvsInterfaceTopologyStateUpdateHelper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
if(bridgeOld.getDatapathId()== null && bridgeNew.getDatapathId()!= null){
DataStoreJobCoordinator jobCoordinator = DataStoreJobCoordinator.getInstance();
RendererStateAddWorker rendererStateAddWorker = new RendererStateAddWorker(identifier, bridgeNew);
- jobCoordinator.enqueueJob(bridgeNew.getBridgeName().getValue() + bridgeNew.getDatapathId(), rendererStateAddWorker);
+ jobCoordinator.enqueueJob(bridgeNew.getBridgeName().getValue(), rendererStateAddWorker);
+ } else if(bridgeOld.getDatapathId() != bridgeNew.getDatapathId()){
+ DataStoreJobCoordinator jobCoordinator = DataStoreJobCoordinator.getInstance();
+ RendererStateUpdateWorker rendererStateAddWorker = new RendererStateUpdateWorker(identifier, bridgeNew, bridgeOld);
+ jobCoordinator.enqueueJob(bridgeNew.getBridgeName().getValue(), rendererStateAddWorker);
}
}
bridgeNew, dataBroker);
}
}
+ private class RendererStateUpdateWorker implements Callable<List<ListenableFuture<Void>>> {
+ InstanceIdentifier<OvsdbBridgeAugmentation> instanceIdentifier;
+ OvsdbBridgeAugmentation bridgeNew;
+ OvsdbBridgeAugmentation bridgeOld;
+
+
+ public RendererStateUpdateWorker(InstanceIdentifier<OvsdbBridgeAugmentation> instanceIdentifier,
+ OvsdbBridgeAugmentation bridgeNew, OvsdbBridgeAugmentation bridgeOld) {
+ this.instanceIdentifier = instanceIdentifier;
+ this.bridgeNew = bridgeNew;
+ this.bridgeOld = bridgeOld;
+ }
+
+ @Override
+ public List<ListenableFuture<Void>> call() throws Exception {
+ // If another renderer(for eg : CSS) needs to be supported, check can be performed here
+ // to call the respective helpers.
+ return OvsInterfaceTopologyStateUpdateHelper.updateBridgeRefEntry(instanceIdentifier,
+ bridgeNew, bridgeOld, dataBroker);
+ }
+ }
}
\ No newline at end of file
LOG.warn("DataPathId found as null for Bridge Augmentation: {}... returning...", bridgeNew);
return futures;
}
- String bridgeName = bridgeNew.getBridgeName().getValue();
BigInteger dpnId = IfmUtil.getDpnId(bridgeNew.getDatapathId());
// create bridge reference entry in interface meta operational DS
// FIX for OVSDB Bug - manually copying the bridge info from topology operational DS to config DS
SouthboundUtils.addBridge(bridgeIid, bridgeNew, dataBroker, futures);
- BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpnId);
- InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier =
- InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
- BridgeEntry bridgeEntry =
- InterfaceMetaUtils.getBridgeEntryFromConfigDS(bridgeEntryInstanceIdentifier,
- dataBroker);
+ // handle pre-provisioning of tunnels for the newly connected dpn
+ BridgeEntry bridgeEntry = InterfaceMetaUtils.getBridgeEntryFromConfigDS(dpnId, dataBroker);
if (bridgeEntry == null) {
futures.add(writeTransaction.submit());
return futures;
}
-
- List<BridgeInterfaceEntry> bridgeInterfaceEntries = bridgeEntry.getBridgeInterfaceEntry();
- for (BridgeInterfaceEntry bridgeInterfaceEntry : bridgeInterfaceEntries) {
- String portName = bridgeInterfaceEntry.getInterfaceName();
- InterfaceKey interfaceKey = new InterfaceKey(portName);
- Interface iface = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
- if (iface.getAugmentation(IfTunnel.class) != null) {
- SouthboundUtils.addPortToBridge(bridgeIid, iface, bridgeNew, bridgeName, portName, dataBroker, futures);
- }
- }
+ SouthboundUtils.addAllPortsToBridge(bridgeEntry, dataBroker, bridgeIid, bridgeNew, writeTransaction);
futures.add(writeTransaction.submit());
return futures;
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 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,
public static List<ListenableFuture<Void>> removePortFromBridge(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
OvsdbBridgeAugmentation bridgeOld, DataBroker dataBroker) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
- WriteTransaction t = dataBroker.newWriteOnlyTransaction();;
+ WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();;
BigInteger dpnId = IfmUtil.getDpnId(bridgeOld.getDatapathId());
if (dpnId == null) {
LOG.warn("Got Null DPID for Bridge: {}", bridgeOld);
return futures;
}
- BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
- InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
- InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
- t.delete(LogicalDatastoreType.OPERATIONAL, bridgeEntryId);
+
+ //delete bridge reference entry in interface meta operational DS
+ InterfaceMetaUtils.deleteBridgeRefEntry(dpnId, transaction);
// FIX for ovsdb bug for delete TEP
SouthboundUtils.deleteBridge(bridgeIid, dataBroker, futures);
- futures.add(t.submit());
+ futures.add(transaction.submit());
return futures;
}
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
+import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
+import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
+import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.utilities.SouthboundUtils;
+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.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+public class OvsInterfaceTopologyStateUpdateHelper {
+ private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceTopologyStateUpdateHelper.class);
+ /*
+ * This code is used to handle only a dpnId change scenario for a particular change,
+ * which is not expected to happen in usual cases.
+ */
+ public static List<ListenableFuture<Void>> updateBridgeRefEntry(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
+ OvsdbBridgeAugmentation bridgeNew,
+ OvsdbBridgeAugmentation bridgeOld,
+ DataBroker dataBroker) {
+ List<ListenableFuture<Void>> futures = new ArrayList<>();
+ WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
+
+ BigInteger dpnIdNew = IfmUtil.getDpnId(bridgeNew.getDatapathId());
+ BigInteger dpnIdOld = IfmUtil.getDpnId(bridgeOld.getDatapathId());
+
+ //delete bridge reference entry for the old dpn in interface meta operational DS
+ InterfaceMetaUtils.deleteBridgeRefEntry(dpnIdOld, writeTransaction);
+
+ // create bridge reference entry in interface meta operational DS
+ InterfaceMetaUtils.createBridgeRefEntry(dpnIdNew, bridgeIid, writeTransaction);
+
+ // handle pre-provisioning of tunnels for the newly connected dpn
+ BridgeEntry bridgeEntry = InterfaceMetaUtils.getBridgeEntryFromConfigDS(dpnIdNew, dataBroker);
+ if (bridgeEntry == null) {
+ futures.add(writeTransaction.submit());
+ return futures;
+ }
+ SouthboundUtils.addAllPortsToBridge(bridgeEntry, dataBroker, bridgeIid, bridgeNew, writeTransaction);
+
+ futures.add(writeTransaction.submit());
+ return futures;
+ }
+}
\ No newline at end of file
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 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,
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
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.l2.types.rev130827.VlanId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.*;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.*;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
futures.add(tx.submit());
}
+ /*
+ * add all tunnels ports corresponding to the bridge to the topology config DS
+ */
+ public static void addAllPortsToBridge(BridgeEntry bridgeEntry, DataBroker dataBroker,
+ InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
+ OvsdbBridgeAugmentation bridgeNew,
+ WriteTransaction writeTransaction){
+ String bridgeName = bridgeNew.getBridgeName().getValue();
+ LOG.debug("adding all ports to bridge: {}", bridgeName);
+ List<BridgeInterfaceEntry> bridgeInterfaceEntries = bridgeEntry.getBridgeInterfaceEntry();
+ for (BridgeInterfaceEntry bridgeInterfaceEntry : bridgeInterfaceEntries) {
+ String portName = bridgeInterfaceEntry.getInterfaceName();
+ InterfaceKey interfaceKey = new InterfaceKey(portName);
+ Interface iface = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
+ IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
+ if (ifTunnel != null) {
+ addTunnelPortToBridge(ifTunnel, bridgeIid, iface, bridgeNew, bridgeName, portName, dataBroker, writeTransaction);
+ }
+ }
+ }
+
public static void addBridge(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
OvsdbBridgeAugmentation bridgeAugmentation,
DataBroker dataBroker, List<ListenableFuture<Void>> futures){