/** * Method invoked when the open flow switch is Added. * * @param transaction Read-write transaction for MD-SAL datastore. * @param type The type of the logical datastore. */ private void initializeTopology(ReadWriteTransaction transaction, LogicalDatastoreType type) { InstanceIdentifier<NetworkTopology> path = InstanceIdentifier.create(NetworkTopology.class); CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = transaction.read(type, path); try { if (!topology.get().isPresent()) { NetworkTopologyBuilder ntb = new NetworkTopologyBuilder(); transaction.put(type, path, ntb.build()); } } catch (Exception e) { LOG.error("Error initializing ovsdb topology {}", e); } } }
private void createNetworkTopologyIfNotPresent(final WriteTransaction writeTx, final LogicalDatastoreType datastoreType) { final NetworkTopology networkTopology = new NetworkTopologyBuilder().build(); LOG.trace("{}: Merging {} container to ensure its presence", topologyId, NetworkTopology.QNAME, writeTx.getIdentifier()); writeTx.merge(datastoreType, networkTopologyPath, networkTopology); final Topology topology = new TopologyBuilder().setTopologyId(new TopologyId(topologyId)).build(); LOG.trace("{}: Merging {} container to ensure its presence", topologyId, Topology.QNAME, writeTx.getIdentifier()); writeTx.merge(datastoreType, topologyListPath, topology); } }
private void initializeTopology(LogicalDatastoreType type) { ReadWriteTransaction transaction = db.newReadWriteTransaction(); InstanceIdentifier<NetworkTopology> path = InstanceIdentifier.create(NetworkTopology.class); CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = transaction.read(type,path); try { if (!topology.get().isPresent()) { NetworkTopologyBuilder ntb = new NetworkTopologyBuilder(); transaction.put(type,path,ntb.build()); transaction.submit(); } else { transaction.cancel(); } } catch (InterruptedException | ExecutionException e) { LOG.error("Error initializing ovsdb topology", e); } }
private void initializeTopology(final LogicalDatastoreType type) { final ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction(); final InstanceIdentifier<NetworkTopology> path = InstanceIdentifier.create(NetworkTopology.class); final CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = transaction.read(type,path); try { if (!topology.get().isPresent()) { final NetworkTopologyBuilder ntb = new NetworkTopologyBuilder(); transaction.put(type,path,ntb.build()); transaction.submit().get(); } else { transaction.cancel(); } } catch (final Exception e) { LOG.error("Error initializing unimgr topology {}", e); } }
private void createNetworkTopologyIfNotPresent(final WriteTransaction writeTx) { final NetworkTopology networkTopology = new NetworkTopologyBuilder().build(); logger.trace("{}: Merging {} container to ensure its presence", id, networkTopology.QNAME, writeTx.getIdentifier()); writeTx.merge(LogicalDatastoreType.CONFIGURATION, networkTopologyPath, networkTopology); writeTx.merge(LogicalDatastoreType.OPERATIONAL, networkTopologyPath, networkTopology); final Topology topology = new TopologyBuilder().setTopologyId(new TopologyId(TopologyNetconf.QNAME.getLocalName())).build(); logger.trace("{}: Merging {} container to ensure its presence", id, topology.QNAME, writeTx.getIdentifier()); writeTx.merge(LogicalDatastoreType.CONFIGURATION, topologyListPath, topology); writeTx.merge(LogicalDatastoreType.OPERATIONAL, topologyListPath, topology); }
/** * {@inheritDoc} */ @Override protected void execute(ReadWriteTransaction tx) { LogicalDatastoreType oper = LogicalDatastoreType.OPERATIONAL; InstanceIdentifier<Nodes> npath = InstanceIdentifier.create(Nodes.class); Nodes nodes = new NodesBuilder().build(); tx.merge(oper, npath, nodes, true); InstanceIdentifier<NetworkTopology> tpath = InstanceIdentifier.create(NetworkTopology.class); NetworkTopology topo = new NetworkTopologyBuilder().build(); tx.merge(oper, tpath, topo, true); }
private void initTopology(final WriteTransaction wtx, final LogicalDatastoreType datastoreType) { final NetworkTopology networkTopology = new NetworkTopologyBuilder().build(); final InstanceIdentifier<NetworkTopology> networkTopologyId = InstanceIdentifier.builder(NetworkTopology.class).build(); wtx.merge(datastoreType, networkTopologyId, networkTopology); final Topology topology = new TopologyBuilder().setTopologyId(new TopologyId(topologyId)).build(); wtx.merge(datastoreType, networkTopologyId.child(Topology.class, new TopologyKey(new TopologyId(topologyId))), topology); }
private boolean initTopology(final DatastoreAccess datastoreAccess, final LogicalDatastoreType datastoreType) { InstanceIdentifier<NetworkTopology> networkTopologyIndentifier = InstanceIdentifier.builder(NetworkTopology.class).build(); if (datastoreAccess.readSynchronous(networkTopologyIndentifier, datastoreType) == null) { datastoreAccess.putSynchronous(networkTopologyIndentifier, new NetworkTopologyBuilder().build(), datastoreType); } if (datastoreAccess.readSynchronous(NodeIdentityListener.SUBSCRIBED_PATH, datastoreType) == null) { datastoreAccess.putSynchronous(NodeIdentityListener.SUBSCRIBED_PATH, new TopologyBuilder().setKey(new TopologyKey(new TopologyId(Configuration.TOPOLOGY_NAME))).build(), datastoreType); return true; } return false; }