}
grouping ovsdb-node-attributes {
- description "";
+ description "Plugin will not allow multiple connections to the same device.
+ If an application attempts to make more than one connection to the device by
+ putting multiple entries in the config data store, then it is the responsibility
+ of the application to clean the config data store";
container connection-info{
uses ovsdb-connection-info-attributes;
}
import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactCommandAggregator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
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;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
public void onDataChanged(
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
LOG.trace("onDataChanged: {}", changes);
+ for (Entry<InstanceIdentifier<?>, DataObject> created : changes.getCreatedData().entrySet()) {
+ // TODO validate we have the correct kind of InstanceIdentifier
+ if (created.getValue() instanceof OvsdbNodeAugmentation) {
+ OvsdbNodeAugmentation ovsdbNode = (OvsdbNodeAugmentation)created.getValue();
+ ConnectionInfo key = ovsdbNode.getConnectionInfo();
+ InstanceIdentifier<Node> iid = cm.getInstanceIdentifier(key);
+ if ( iid != null) {
+ LOG.warn("Connection to device {} already exists. Plugin does not allow multiple connections "
+ + "to same device, hence dropping the request {}", key, ovsdbNode);
+ return;
+ }
+ }
+ }
// Connect first if we have to:
connect(changes);