Java源码示例:org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey
示例1
private InstanceIdentifier<TerminationPoint> createTP(final IpAddress addr, final InstanceIdentifier<Node> sni,
final Boolean inControl, final ReadWriteTransaction trans) {
final String url = "ip://" + addr.toString();
final TerminationPointKey tpk = new TerminationPointKey(new TpId(url));
final TerminationPointBuilder tpb = new TerminationPointBuilder();
tpb.withKey(tpk).setTpId(tpk.getTpId());
tpb.addAugmentation(new TerminationPoint1Builder()
.setIgpTerminationPointAttributes(new IgpTerminationPointAttributesBuilder()
.setTerminationPointType(new IpBuilder().setIpAddress(Lists.newArrayList(addr)).build())
.build())
.build());
final NodeKey nk = new NodeKey(new NodeId(url));
final NodeBuilder nb = new NodeBuilder();
nb.withKey(nk).setNodeId(nk.getNodeId());
nb.setTerminationPoint(Lists.newArrayList(tpb.build()));
if (sni != null) {
nb.setSupportingNode(Lists.newArrayList(createSupportingNode(InstanceIdentifier.keyOf(sni).getNodeId(),
inControl)));
}
final InstanceIdentifier<Node> nid = this.target.child(Node.class, nb.key());
trans.put(LogicalDatastoreType.OPERATIONAL, nid, nb.build());
return nid.child(TerminationPoint.class, tpb.key());
}
示例2
private static Node createNode(final NodeId nodeId, final TpId tpId, final String ipv4Address) {
final TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
tpBuilder.setTpId(tpId);
tpBuilder.withKey(new TerminationPointKey(tpId));
tpBuilder.addAugmentation(new TerminationPoint1Builder()
.setIgpTerminationPointAttributes(new IgpTerminationPointAttributesBuilder()
.setTerminationPointType(new IpBuilder()
.setIpAddress(Collections.singletonList(new IpAddress(new Ipv4Address(ipv4Address))))
.build()).build()).build());
final NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setNodeId(nodeId);
nodeBuilder.withKey(new NodeKey(nodeId));
nodeBuilder.setTerminationPoint(Lists.newArrayList(tpBuilder.build()));
final SupportingNode supportingNode = new SupportingNodeBuilder()
.withKey(new SupportingNodeKey(nodeId, new TopologyId("dummy")))
.addAugmentation(new SupportingNode1Builder()
.setPathComputationClient(new PathComputationClientBuilder()
.setControlling(true).build()).build()).build();
nodeBuilder.setSupportingNode(Lists.newArrayList(supportingNode));
return nodeBuilder.build();
}
示例3
private void removeTp(final WriteTransaction trans, final NodeId node, final TpId tp,
final LinkId link, final boolean isRemote) {
final NodeHolder nh = this.nodes.get(node);
if (nh != null) {
final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey(nh.getNodeId()));
trans.delete(LogicalDatastoreType.OPERATIONAL, nid.child(TerminationPoint.class,
new TerminationPointKey(tp)));
nh.removeTp(tp, link, isRemote);
if (!isRemote) {
nh.createSrHolderIfRequired().removeAdjacencySid(trans, link);
}
checkNodeForRemoval(trans, nh);
} else {
LOG.warn("Removed non-existent node {}", node.getValue());
}
}
示例4
private void removePrefix(final WriteTransaction trans, final UriBuilder base, final PrefixCase prefixCase) {
final NodeId node = buildNodeId(base, prefixCase.getAdvertisingNodeDescriptors());
final NodeHolder nh = this.nodes.get(node);
if (nh != null) {
LOG.debug("Removed prefix {}", prefixCase);
final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey(nh.getNodeId()));
final InstanceIdentifier<IgpNodeAttributes> inaId = nid.builder().augmentation(Node1.class)
.child(IgpNodeAttributes.class).build();
final IpPrefix ippfx = prefixCase.getPrefixDescriptors().getIpReachabilityInformation();
if (ippfx == null) {
LOG.warn("IP reachability not present in prefix {}, skipping it", prefixCase);
return;
}
final PrefixKey pk = new PrefixKey(ippfx);
trans.delete(LogicalDatastoreType.OPERATIONAL, inaId.child(Prefix.class, pk));
nh.removePrefix(prefixCase);
nh.createSrHolderIfRequired().removeSrPrefix(trans, ippfx);
checkNodeForRemoval(trans, nh);
} else {
LOG.warn("Removing prefix from non-existing node {}", node.getValue());
}
}
示例5
private InstanceIdentifier<IgpNodeAttributes> ensureNodePresent(final ReadWriteTransaction trans, final NodeId ni) {
final NodeUsage present = this.nodes.get(ni);
if (present != null) {
return present.attrId;
}
final KeyedInstanceIdentifier<Node, NodeKey> nii = nodeInstanceId(ni);
final InstanceIdentifier<IgpNodeAttributes> ret = nii.builder().augmentation(Node1.class)
.child(IgpNodeAttributes.class).build();
trans.merge(LogicalDatastoreType.OPERATIONAL, nii, new NodeBuilder().withKey(nii.getKey()).setNodeId(ni)
.addAugmentation(new Node1Builder().setIgpNodeAttributes(
new IgpNodeAttributesBuilder().setPrefix(Collections.emptyList()).build()).build()).build());
this.nodes.put(ni, new NodeUsage(ret));
return ret;
}
示例6
private static boolean matchesBridgeName(ManagedNodeEntry managedNode, String bridgeName) {
InstanceIdentifier<?> bridgeIid = managedNode.getBridgeRef().getValue();
for (PathArgument bridgeIidPathArg : bridgeIid.getPathArguments()) {
if (bridgeIidPathArg instanceof IdentifiableItem<?, ?>) {
IdentifiableItem<?, ?> identifiableItem = (IdentifiableItem<?, ?>) bridgeIidPathArg;
Identifier<?> key = identifiableItem.getKey();
if (key instanceof NodeKey) {
// Do not combine the above if with that below, we want to
// avoid the toString() call in the else if this is a NodeKey
NodeKey nodeKey = (NodeKey) key;
if (nodeKey.getNodeId().getValue().contains(bridgeName)) {
return true;
}
} else if (key.toString().contains(bridgeName)) {
return true;
}
} else if (bridgeIidPathArg instanceof Item<?>) {
if (((Item<?>) bridgeIidPathArg).getType().getName().contains(bridgeName)) {
return true;
}
} else {
throw new IllegalArgumentException("Unknown kind of PathArgument: " + bridgeIidPathArg);
}
}
return false;
}
示例7
public static InstanceIdentifier<Node> getInstanceIdentifier(final InstanceIdentifierCodec instanceIdentifierCodec,
final OpenVSwitch ovs) {
if (ovs.getExternalIdsColumn() != null
&& ovs.getExternalIdsColumn().getData() != null
&& ovs.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) {
String iidString = ovs.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY);
return (InstanceIdentifier<Node>) instanceIdentifierCodec.bindingDeserializerOrNull(iidString);
} else {
String nodeString = SouthboundConstants.OVSDB_URI_PREFIX + "://" + SouthboundConstants.UUID + "/"
+ ovs.getUuid().toString();
NodeId nodeId = new NodeId(new Uri(nodeString));
NodeKey nodeKey = new NodeKey(nodeId);
return InstanceIdentifier.builder(NetworkTopology.class)
.child(Topology.class,new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
.child(Node.class,nodeKey)
.build();
}
}
示例8
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "https://github.com/spotbugs/spotbugs/issues/811")
private Map<InstanceIdentifier<OvsdbTerminationPointAugmentation>, OvsdbTerminationPointAugmentation>
filterTerminationPointsForBridge(NodeKey nodeKey,
Map<InstanceIdentifier<OvsdbTerminationPointAugmentation>, OvsdbTerminationPointAugmentation>
terminationPoints) {
Map<InstanceIdentifier<OvsdbTerminationPointAugmentation>, OvsdbTerminationPointAugmentation>
filteredTerminationPoints = new HashMap<>();
for (Map.Entry<InstanceIdentifier<OvsdbTerminationPointAugmentation>, OvsdbTerminationPointAugmentation> entry :
terminationPoints.entrySet()) {
InstanceIdentifier<?> bridgeIid = entry.getKey();
NodeKey terminationPointNodeKey = bridgeIid.firstKeyOf(Node.class);
if (terminationPointNodeKey.getNodeId().equals(nodeKey.getNodeId())) {
LOG.trace("TP Match found: {} {} ", terminationPointNodeKey.getNodeId(), nodeKey.getNodeId());
filteredTerminationPoints.put(entry.getKey(), entry.getValue());
} else {
LOG.trace("TP No Match found : {} {} ", terminationPointNodeKey.getNodeId(), nodeKey.getNodeId());
}
}
return filteredTerminationPoints;
}
示例9
private static OvsdbBridgeAugmentation getBridge(final InstanceIdentifier<OvsdbNodeAugmentation> key,
final Uri bridgeUri) {
final InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid = InstanceIdentifier
.create(NetworkTopology.class)
.child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
.child(Node.class, new NodeKey(new NodeId(bridgeUri)))
.augmentation(OvsdbBridgeAugmentation.class);
OvsdbBridgeAugmentation bridge = null;
try (ReadTransaction transaction = SouthboundProvider.getDb().newReadOnlyTransaction()) {
final Optional<OvsdbBridgeAugmentation> bridgeOptional =
transaction.read(LogicalDatastoreType.OPERATIONAL, bridgeIid).get();
if (bridgeOptional.isPresent()) {
bridge = bridgeOptional.get();
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Error reading from datastore", e);
}
return bridge;
}
示例10
/**
* Create the {@link InstanceIdentifier} for the {@link ControllerEntry}.
*
* @param controllerEntry the {@link ControllerEntry}
* @param bridgeName the name of the bridge
* @return the {@link InstanceIdentifier}
*/
@VisibleForTesting
InstanceIdentifier<ControllerEntry> getControllerEntryIid(
final ControllerEntry controllerEntry, final String bridgeName) {
OvsdbConnectionInstance client = getOvsdbConnectionInstance();
String nodeString = client.getNodeKey().getNodeId().getValue()
+ "/bridge/" + bridgeName;
NodeId nodeId = new NodeId(new Uri(nodeString));
NodeKey nodeKey = new NodeKey(nodeId);
InstanceIdentifier<Node> bridgeIid = InstanceIdentifier.builder(NetworkTopology.class)
.child(Topology.class,new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
.child(Node.class,nodeKey)
.build();
return bridgeIid
.augmentation(OvsdbBridgeAugmentation.class)
.child(ControllerEntry.class, controllerEntry.key());
}
示例11
/**
* Create the {@link InstanceIdentifier} for the {@link ManagerEntry}.
*
* @param managerEntry the {@link ManagerEntry}
* @return the {@link InstanceIdentifier}
*/
private InstanceIdentifier<ManagerEntry> getManagerEntryIid(ManagerEntry managerEntry) {
OvsdbConnectionInstance client = getOvsdbConnectionInstance();
String nodeString = client.getNodeKey().getNodeId().getValue();
NodeId nodeId = new NodeId(new Uri(nodeString));
NodeKey nodeKey = new NodeKey(nodeId);
InstanceIdentifier<Node> ovsdbNodeIid = InstanceIdentifier.builder(NetworkTopology.class)
.child(Topology.class,new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
.child(Node.class,nodeKey)
.build();
return ovsdbNodeIid
.augmentation(OvsdbNodeAugmentation.class)
.child(ManagerEntry.class, managerEntry.key());
}
示例12
@Before
public void setUp() throws Exception {
NodeKey nodeKey = new NodeKey(new NodeId(new Uri(NODE_ID)));
iid = SouthboundMapper.createInstanceIdentifier(nodeKey.getNodeId());
SouthboundProvider.setBridgesReconciliationInclusionList(Arrays.asList(BR_INT));
Node brIntNode = createBridgeNode(NODE_ID + "/bridge/" + BR_INT);
Optional<Node> nodeOptional = Optional.of(brIntNode);
FluentFuture<Optional<Node>> readNodeFuture =
FluentFutures.immediateFluentFuture(nodeOptional);
when(reconciliationManager.getDb()).thenReturn(db);
ReadTransaction tx = mock(ReadTransaction.class);
Mockito.when(db.newReadOnlyTransaction()).thenReturn(tx);
Mockito.when(tx.read(any(LogicalDatastoreType.class),any(InstanceIdentifier.class)))
.thenReturn(readNodeFuture);
when(topology.getNode()).thenReturn(Map.of(brIntNode.key(), brIntNode));
configurationReconciliationTask =
new BridgeConfigReconciliationTask(reconciliationManager, ovsdbConnectionManager, iid,
ovsdbConnectionInstance, mock(InstanceIdentifierCodec.class));
}
示例13
@Test
public void testGetManagerEntryIid() throws Exception {
ManagerEntry managerEntry = mock(ManagerEntry.class);
OvsdbConnectionInstance client = mock(OvsdbConnectionInstance.class, Mockito.RETURNS_DEEP_STUBS);
when(ovsdbManagersUpdateCommand.getOvsdbConnectionInstance()).thenReturn(client);
when(client.getNodeKey().getNodeId().getValue()).thenReturn(NODE_ID);
PowerMockito.whenNew(Uri.class).withAnyArguments().thenReturn(mock(Uri.class));
NodeId nodeId = mock(NodeId.class);
PowerMockito.whenNew(NodeId.class).withAnyArguments().thenReturn(nodeId);
NodeKey nodeKey = mock(NodeKey.class);
PowerMockito.whenNew(NodeKey.class).withAnyArguments().thenReturn(nodeKey);
when(managerEntry.key()).thenReturn(mock(ManagerEntryKey.class));
assertEquals(KeyedInstanceIdentifier.class,
Whitebox.invokeMethod(ovsdbManagersUpdateCommand, "getManagerEntryIid", managerEntry).getClass());
}
示例14
@Test
public void testGetControllerEntryIid() throws Exception {
ControllerEntry controllerEntry = mock(ControllerEntry.class);
OvsdbConnectionInstance client = mock(OvsdbConnectionInstance.class);
when(ovsdbControllerUpdateCommand.getOvsdbConnectionInstance()).thenReturn(client);
NodeKey nodeKey = mock(NodeKey.class);
when(client.getNodeKey()).thenReturn(nodeKey);
NodeId nodeId = mock(NodeId.class);
when(nodeKey.getNodeId()).thenReturn(nodeId);
when(nodeId.getValue()).thenReturn(NODE_ID);
PowerMockito.whenNew(Uri.class).withAnyArguments().thenReturn(mock(Uri.class));
PowerMockito.whenNew(NodeId.class).withAnyArguments().thenReturn(nodeId);
PowerMockito.whenNew(NodeKey.class).withAnyArguments().thenReturn(nodeKey);
PowerMockito.whenNew(TopologyKey.class).withAnyArguments().thenReturn(mock(TopologyKey.class));
//PowerMockito.suppress(MemberMatcher.methodsDeclaredIn(InstanceIdentifier.class));
when(controllerEntry.key()).thenReturn(mock(ControllerEntryKey.class));
assertEquals(KeyedInstanceIdentifier.class, Whitebox
.invokeMethod(ovsdbControllerUpdateCommand, "getControllerEntryIid", controllerEntry, BRIDGE_NAME)
.getClass());
}
示例15
/**
* Creates a NodeBuilder based on the given HostNodeBuilder.
*
* @param hostNode
* The HostNodeBuilder where the AttachmentPoints and Id are.
* @return A NodeBuilder with the same Id of HostNodeBuilder and a list of
* TerminationPoint corresponding to each HostNodeBuilder's
* AttachmentPoints.
*/
private NodeBuilder createNodeBuilder(HostNodeBuilder hostNode, List<AttachmentPointsBuilder> apbs) {
List<TerminationPoint> tps = new ArrayList<>();
for (AttachmentPointsBuilder atb : apbs) {
TerminationPoint tp = createTerminationPoint(hostNode);
tps.add(tp);
atb.setCorrespondingTp(tp.getTpId());
}
NodeBuilder node = new NodeBuilder().setNodeId(createNodeId(hostNode)).setTerminationPoint(tps);
node.setKey(new NodeKey(node.getNodeId()));
return node;
}
示例16
private void createNode(final NodeId nodeId, final String ipv4Address, final String lspName, final Uint32 lspId,
final String dstIpv4Address) throws InterruptedException, ExecutionException {
final NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.withKey(new NodeKey(nodeId));
nodeBuilder.setNodeId(nodeId);
final PathBuilder pathBuilder = new PathBuilder();
pathBuilder.withKey(new PathKey(new LspId(lspId)));
pathBuilder.setBandwidth(new BandwidthBuilder().setBandwidth(
new Bandwidth(new byte[]{0x00, 0x00, (byte) 0xff, (byte) 0xff})).build());
pathBuilder.addAugmentation(new Path1Builder().setLsp(new LspBuilder().setTlvs(new TlvsBuilder()
.setLspIdentifiers(new LspIdentifiersBuilder().setAddressFamily(new Ipv4CaseBuilder().setIpv4(
new Ipv4Builder().setIpv4TunnelSenderAddress(new Ipv4AddressNoZone(ipv4Address))
.setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(ipv4Address))
.setIpv4TunnelEndpointAddress(new Ipv4AddressNoZone(dstIpv4Address))
.build()).build()).build()).build()).setAdministrative(true)
.setDelegate(true).build()).build());
final ReportedLsp reportedLps = new ReportedLspBuilder().withKey(new ReportedLspKey(lspName)).setPath(
Collections.singletonList(pathBuilder.build())).build();
final Node1Builder node1Builder = new Node1Builder();
node1Builder.setPathComputationClient(new PathComputationClientBuilder()
.setStateSync(PccSyncState.Synchronized)
.setReportedLsp(Lists.newArrayList(reportedLps))
.setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(ipv4Address)))
.build());
nodeBuilder.addAugmentation(node1Builder.build());
final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID.builder().child(Node.class,
new NodeKey(nodeId)).build(), nodeBuilder.build());
wTx.commit().get();
}
示例17
void setPeerProposal(final NodeId nodeId, final TlvsBuilder openTlvsBuilder, final byte[] speakerId) {
if (isSynOptimizationEnabled(openTlvsBuilder)) {
Optional<LspDbVersion> result = Optional.empty();
try (ReadTransaction rTx = this.dataBroker.newReadOnlyTransaction()) {
final ListenableFuture<Optional<LspDbVersion>> future = rTx.read(
LogicalDatastoreType.OPERATIONAL,
this.topologyId.child(Node.class, new NodeKey(nodeId)).augmentation(Node1.class)
.child(PathComputationClient.class).augmentation(PathComputationClient1.class)
.child(LspDbVersion.class));
try {
result = future.get();
} catch (final InterruptedException | ExecutionException e) {
LOG.warn("Failed to read toplogy {}.", InstanceIdentifier.keyOf(
PCEPStatefulPeerProposal.this.topologyId), e);
}
}
if (speakerId == null && !result.isPresent()) {
return;
}
final Tlvs3Builder syncBuilder = new Tlvs3Builder();
if (result.isPresent()) {
syncBuilder.setLspDbVersion(result.get());
}
if (speakerId != null) {
syncBuilder.setSpeakerEntityId(new SpeakerEntityIdBuilder().setSpeakerEntityIdValue(speakerId).build());
}
openTlvsBuilder.addAugmentation(syncBuilder.build()).build();
}
}
示例18
TopologyNodeState(final DataBroker broker, final InstanceIdentifier<Topology> topology, final NodeId id,
final long holdStateNanos) {
Preconditions.checkArgument(holdStateNanos >= 0);
this.nodeId = topology.child(Node.class, new NodeKey(id));
this.holdStateNanos = holdStateNanos;
this.chain = broker.createMergingTransactionChain(this);
}
示例19
@SuppressWarnings("checkstyle:IllegalCatch")
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "https://github.com/spotbugs/spotbugs/issues/811")
private synchronized void updatePcepStats() {
final WriteTransaction tx = TopologyStatsProviderImpl.this.transactionChain.newWriteOnlyTransaction();
try {
for (final Map.Entry<KeyedInstanceIdentifier<Node, NodeKey>, PcepSessionState> entry
: this.statsMap.entrySet()) {
final PcepTopologyNodeStatsAug nodeStatsAug = new PcepTopologyNodeStatsAugBuilder()
.setPcepSessionState(new PcepSessionStateBuilder(entry.getValue()).build()).build();
final InstanceIdentifier<PcepTopologyNodeStatsAug> statId =
entry.getKey().augmentation(PcepTopologyNodeStatsAug.class);
tx.put(LogicalDatastoreType.OPERATIONAL, statId, nodeStatsAug);
}
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.debug("Successfully committed Topology stats update");
}
@Override
public void onFailure(final Throwable ex) {
LOG.error("Failed to commit Topology stats update", ex);
}
}, MoreExecutors.directExecutor());
} catch (final Exception e) {
LOG.warn("Failed to prepare Tx for PCEP stats update", e);
tx.cancel();
}
}
示例20
@Override
public synchronized void close() throws Exception {
if (closed.compareAndSet(false, true)) {
LOG.info("Closing TopologyStatsProvider service.");
this.scheduleTask.cancel(true);
final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
for (final KeyedInstanceIdentifier<Node, NodeKey> statId : this.statsMap.keySet()) {
wTx.delete(LogicalDatastoreType.OPERATIONAL, statId);
}
wTx.commit().get();
this.statsMap.clear();
this.transactionChain.close();
this.scheduler.shutdown();
}
}
示例21
@Override
public synchronized void unbind(final KeyedInstanceIdentifier<Node, NodeKey> nodeId) {
this.statsMap.remove(nodeId);
final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
wTx.delete(LogicalDatastoreType.OPERATIONAL, nodeId);
try {
wTx.commit().get();
} catch (final InterruptedException | ExecutionException e) {
LOG.warn("Failed to remove Pcep Node stats {}.", nodeId.getKey().getNodeId(), e);
}
}
示例22
private static Node readNodeFromDataStore(final DataBroker dataBroker,
final String topologyId, final String nodeId) {
final InstanceIdentifier<Node> topology = InstanceIdentifier.builder(NetworkTopology.class)
.child(Topology.class, new TopologyKey(new TopologyId(topologyId)))
.child(Node.class, new NodeKey(new NodeId(nodeId))).build();
final ReadTransaction rot = dataBroker.newReadOnlyTransaction();
try {
return rot.read(LogicalDatastoreType.OPERATIONAL, topology).get().orElse(null);
} catch (final InterruptedException | ExecutionException e) {
LOG.warn("Failed to read node {}", nodeId, e);
}
return null;
}
示例23
private void createDefaultProtocol() throws ExecutionException, InterruptedException {
final WriteTransaction wt = getDataBroker().newWriteOnlyTransaction();
final Node node = new NodeBuilder()
.setNodeId(new NodeId(NODE_ID))
.addAugmentation(new PcepTopologyNodeStatsAugBuilder().setPcepSessionState(createPcepSessionState())
.build())
.build();
final InstanceIdentifier<Node> topology = InstanceIdentifier.builder(NetworkTopology.class)
.child(Topology.class, new TopologyKey(new TopologyId(PCEP_TOPOLOGY)))
.child(Node.class, new NodeKey(new NodeId(NODE_ID))).build();
wt.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, topology, node);
wt.commit().get();
}
示例24
void addSegment(final WriteTransaction trans, final boolean updateNode, final Segments segment) {
if (updateNode) {
final InstanceIdentifier<Node> nodeIId = getNodeInstanceIdentifier(new NodeKey(this.nodeId));
final InstanceIdentifier<Segments> segmentIId = nodeIId.builder()
.augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr
.rev130819.Node1.class)
.child(Segments.class, segment.key()).build();
trans.put(LogicalDatastoreType.OPERATIONAL, segmentIId, segment);
}
addSrAwareTopologyType(trans);
}
示例25
void removeSegment(final WriteTransaction trans, final boolean updateNode, final Segments segment) {
if (updateNode) {
final InstanceIdentifier<Node> nodeIId = getNodeInstanceIdentifier(new NodeKey(this.nodeId));
final InstanceIdentifier<Segments> segmentIId = nodeIId.builder()
.augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr
.rev130819.Node1.class)
.child(Segments.class, segment.key()).build();
trans.delete(LogicalDatastoreType.OPERATIONAL, segmentIId);
}
removeSrAwareTopologyTypeIfRequired(trans);
}
示例26
/**
* Read the list of <code>OvsdbTerminationPointAugmentation</code> for the particular <code>node</code>.
*/
public List<OvsdbTerminationPointAugmentation> readTerminationPointAugmentations(Node node) {
if (node == null) {
LOG.error("readTerminationPointAugmentations: Node value is null");
return Collections.emptyList();
}
Node operNode = provider.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier
.create(NetworkTopology.class)
.child(Topology.class, new TopologyKey(OVSDB_TOPOLOGY_ID))
.child(Node.class, new NodeKey(node.getNodeId())));
if (operNode != null) {
return extractTerminationPointAugmentations(operNode);
}
return new ArrayList<>();
}
示例27
/**
* Get all OVSDB nodes from topology.
* @return a list of nodes or null if the topology could not found
*/
public Map<NodeKey, Node> getOvsdbNodes() {
InstanceIdentifier<Topology> inst = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class,
new TopologyKey(OVSDB_TOPOLOGY_ID));
Topology topology = provider.read(LogicalDatastoreType.OPERATIONAL, inst);
return topology != null ? topology.getNode() : null;
}
示例28
public Node getNodeByTerminationPointExternalId(final String interfaceName) {
Map<NodeKey, Node> nodes = getOvsdbNodes();
if (nodes != null) {
for (Node node : nodes.values()) {
TerminationPoint tp = getTerminationPointByExternalId(node, interfaceName);
if (tp != null) {
return node;
}
}
}
return null;
}
示例29
private LoadingCache<NodeKey, NodeConnectionMetadata> buildBridgeNodeCache() {
return CacheBuilder.newBuilder()
.expireAfterWrite(BRIDGE_CACHE_TIMEOUT_IN_SECONDS, TimeUnit.SECONDS)
.build(new CacheLoader<NodeKey, NodeConnectionMetadata>() {
@Override
public NodeConnectionMetadata load(NodeKey nodeKey) throws Exception {
// the termination points are explicitly added to the cache, retrieving bridges that are not in
// the cache results in NoSuchElementException
throw new NoSuchElementException();
}
});
}
示例30
@VisibleForTesting
void removeOldConfigs(ReadWriteTransaction transaction, Map<String, String> oldOtherConfigs, OpenVSwitch ovs) {
InstanceIdentifier<OvsdbNodeAugmentation> nodeAugmentataionIid = InstanceIdentifier
.create(NetworkTopology.class)
.child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
.child(Node.class, new NodeKey(getNodeId(ovs)))
.augmentation(OvsdbNodeAugmentation.class);
Set<String> otherConfigKeys = oldOtherConfigs.keySet();
for (String otherConfigKey : otherConfigKeys) {
KeyedInstanceIdentifier<OpenvswitchOtherConfigs, OpenvswitchOtherConfigsKey> externalIid =
nodeAugmentataionIid
.child(OpenvswitchOtherConfigs.class, new OpenvswitchOtherConfigsKey(otherConfigKey));
transaction.delete(LogicalDatastoreType.OPERATIONAL, externalIid);
}
}