org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId Java Examples
The following examples show how to use
org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HwvtepPhysicalSwitchUpdateCommand.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
private Node buildPhysicalSwitchNode(Node node, PhysicalSwitch phySwitch) { NodeBuilder psNodeBuilder = new NodeBuilder(); NodeId psNodeId = getNodeId(phySwitch); psNodeBuilder.setNodeId(psNodeId); PhysicalSwitchAugmentationBuilder psAugmentationBuilder = new PhysicalSwitchAugmentationBuilder(); psAugmentationBuilder.setPhysicalSwitchUuid(new Uuid(phySwitch.getUuid().toString())); setManagedBy(psAugmentationBuilder); setPhysicalSwitchId(psAugmentationBuilder, phySwitch); setManagementIps(psAugmentationBuilder, phySwitch); setTunnels(psAugmentationBuilder, phySwitch); setSwitchFaultStatus(psAugmentationBuilder, phySwitch); psNodeBuilder.addAugmentation(PhysicalSwitchAugmentation.class, psAugmentationBuilder.build()); LOG.trace("Built with the intent to store PhysicalSwitch data {}", psAugmentationBuilder.build()); return psNodeBuilder.build(); }
Example #2
Source File: BridgeConfigReconciliationTaskTest.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
@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)); }
Example #3
Source File: LinkstateTopologyBuilder.java From bgpcep with Eclipse Public License 1.0 | 6 votes |
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()); } }
Example #4
Source File: TopologyStatsRpcServiceImplTest.java From bgpcep with Eclipse Public License 1.0 | 6 votes |
@Before public void setUp() throws Exception { rpcService = new TopologyStatsRpcServiceImpl(getDataBroker()); rpcService.init(); // PCEP topology with one PCC node final Topology t1 = createTopology(TOPOLOGY_ID1, Collections.singletonList(createPcepNode(NODE_ID1))); // PCEP topology with two PCC node final Topology t2 = createTopology(TOPOLOGY_ID2, Arrays.asList(createPcepNode(NODE_ID2), createPcepNode(NODE_ID3))); // Non-PCEP topology with one non-PCC node final Topology t3 = createTopology(NONPCEP_TOPOLOGY, Collections.singletonList(new NodeBuilder().setNodeId(new NodeId(NONPCEP_NODE)).build())); final WriteTransaction wtx = getDataBroker().newWriteOnlyTransaction(); final NetworkTopologyBuilder ntb = new NetworkTopologyBuilder(); ntb.setTopology(Arrays.asList(t1, t2, t3)); wtx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(NetworkTopology.class).build(), ntb.build()); wtx.commit().get(); }
Example #5
Source File: OvsdbInitialPortUpdateCommand.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("checkstyle:IllegalCatch") protected void updateToDataStore(ReadWriteTransaction transaction, TerminationPointBuilder tpBuilder, InstanceIdentifier<TerminationPoint> tpPath, boolean merge) { try { NodeId bridgeNodeId = tpPath.firstKeyOf(Node.class).getNodeId(); TerminationPoint terminationPoint = tpBuilder.build(); if (updatedBridgeNodes.containsKey(bridgeNodeId)) { if (brigeToTerminationPointList.containsKey(bridgeNodeId)) { brigeToTerminationPointList.get(bridgeNodeId).add(terminationPoint); } else { List<TerminationPoint> terminationPointList = new ArrayList<>(); terminationPointList.add(terminationPoint); brigeToTerminationPointList.put(bridgeNodeId, terminationPointList); } LOG.debug("DEVICE - {} Initial TerminationPoint : {} to Bridge : {}", TransactionType.ADD, terminationPoint.key().getTpId().getValue(), bridgeNodeId.getValue()); } } catch (RuntimeException exp) { LOG.error("Exception in adding the terminationPoint {} to bridge ", tpPath); } }
Example #6
Source File: SouthboundMapper.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
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(); } }
Example #7
Source File: LinkstateTopologyBuilder.java From bgpcep with Eclipse Public License 1.0 | 6 votes |
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()); } }
Example #8
Source File: AutoAttachUpdateCommand.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
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; }
Example #9
Source File: SouthboundIT.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
private boolean addTerminationPoint(final NodeId bridgeNodeId, final String portName, final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointAugmentationBuilder) throws InterruptedException { InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(bridgeNodeId); NodeBuilder portNodeBuilder = new NodeBuilder(); NodeId portNodeId = SouthboundMapper.createManagedNodeId(portIid); portNodeBuilder.setNodeId(portNodeId); TerminationPointBuilder entry = new TerminationPointBuilder(); entry.withKey(new TerminationPointKey(new TpId(portName))); entry.addAugmentation( OvsdbTerminationPointAugmentation.class, ovsdbTerminationPointAugmentationBuilder.build()); portNodeBuilder.setTerminationPoint(Collections.singletonList(entry.build())); boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, portIid, portNodeBuilder.build()); Thread.sleep(OVSDB_UPDATE_TIMEOUT); return result; }
Example #10
Source File: AbstractReachabilityTopologyBuilder.java From bgpcep with Eclipse Public License 1.0 | 6 votes |
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; }
Example #11
Source File: OvsdbManagersUpdateCommand.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
/** * 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()); }
Example #12
Source File: OvsdbManagersRemovedCommandTest.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testExecute() throws Exception { updatedOpenVSwitchRows = new HashMap<>(); UUID uuid = mock(UUID.class); OpenVSwitch openVSwitch = mock(OpenVSwitch.class); updatedOpenVSwitchRows.put(uuid, openVSwitch); MemberModifier.field(OvsdbManagersRemovedCommand.class, "updatedOpenVSwitchRows") .set(ovsdbManagersRemovedCommand, updatedOpenVSwitchRows); PowerMockito.mockStatic(SouthboundMapper.class); OvsdbConnectionInstance ovsdbConnectionInstance = mock(OvsdbConnectionInstance.class); when(ovsdbManagersRemovedCommand.getOvsdbConnectionInstance()).thenReturn(ovsdbConnectionInstance); when(ovsdbConnectionInstance.getNodeId()).thenReturn(mock(NodeId.class)); when(SouthboundMapper.createInstanceIdentifier(any(NodeId.class))).thenReturn(mock(InstanceIdentifier.class)); doNothing().when(ovsdbManagersRemovedCommand).deleteManagers(any(ReadWriteTransaction.class), any(List.class)); doReturn(mock(List.class)).when(ovsdbManagersRemovedCommand).managerEntriesToRemove( any(InstanceIdentifier.class), any(OpenVSwitch.class)); ReadWriteTransaction transaction = mock(ReadWriteTransaction.class); ovsdbManagersRemovedCommand.execute(transaction); verify(ovsdbManagersRemovedCommand).deleteManagers(any(ReadWriteTransaction.class), any(List.class)); verify(ovsdbManagersRemovedCommand).managerEntriesToRemove(any(InstanceIdentifier.class), any(OpenVSwitch.class)); }
Example #13
Source File: OvsdbManagersUpdateCommandTest.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
@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()); }
Example #14
Source File: NodeChangedListener.java From bgpcep with Eclipse Public License 1.0 | 6 votes |
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()); }
Example #15
Source File: OvsdbBridgeUpdateCommand.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
private Node buildBridgeNode(Bridge bridge) { NodeBuilder bridgeNodeBuilder = new NodeBuilder(); NodeId bridgeNodeId = getNodeId(bridge); bridgeNodeBuilder.setNodeId(bridgeNodeId); OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder(); ovsdbBridgeAugmentationBuilder.setBridgeName(new OvsdbBridgeName(bridge.getName())); ovsdbBridgeAugmentationBuilder.setBridgeUuid(new Uuid(bridge.getUuid().toString())); setDataPath(ovsdbBridgeAugmentationBuilder, bridge); setDataPathType(ovsdbBridgeAugmentationBuilder, bridge); setProtocol(ovsdbBridgeAugmentationBuilder, bridge); setExternalIds(ovsdbBridgeAugmentationBuilder, bridge); setOtherConfig(ovsdbBridgeAugmentationBuilder, bridge); setFailMode(ovsdbBridgeAugmentationBuilder, bridge); setOpenFlowNodeRef(ovsdbBridgeAugmentationBuilder, bridge); setManagedBy(ovsdbBridgeAugmentationBuilder); setAutoAttach(ovsdbBridgeAugmentationBuilder, bridge); setStpEnalbe(ovsdbBridgeAugmentationBuilder,bridge); bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, ovsdbBridgeAugmentationBuilder.build()); LOG.debug("Built with the intent to store bridge data {}", ovsdbBridgeAugmentationBuilder.build()); return bridgeNodeBuilder.build(); }
Example #16
Source File: OvsdbControllerUpdateCommandTest.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
@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()); }
Example #17
Source File: TunnelProgrammingTest.java From bgpcep with Eclipse Public License 1.0 | 6 votes |
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(); }
Example #18
Source File: SouthboundMapper.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
public static InstanceIdentifier<Node> createInstanceIdentifier( final OvsdbConnectionInstance client, final String bridgeName) { String nodeString = client.getNodeKey().getNodeId().getValue() + "/bridge/" + bridgeName; NodeId nodeId = new NodeId(new Uri(nodeString)); return createInstanceIdentifier(nodeId); }
Example #19
Source File: PcepStateUtilsTest.java From bgpcep with Eclipse Public License 1.0 | 5 votes |
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(); }
Example #20
Source File: HwvtepSouthboundUtil.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
public static InstanceIdentifier<Node> getGlobalNodeIid(final InstanceIdentifier<Node> physicalNodeIid) { String nodeId = physicalNodeIid.firstKeyOf(Node.class).getNodeId().getValue(); int physicalSwitchIndex = nodeId.indexOf(HwvtepSouthboundConstants.PSWITCH_URI_PREFIX); if (physicalSwitchIndex > 0) { nodeId = nodeId.substring(0, physicalSwitchIndex - 1); } else { return null; } return physicalNodeIid.firstIdentifierOf(Topology.class).child(Node.class , new NodeKey(new NodeId(nodeId))); }
Example #21
Source File: OpenVSwitchUpdateCommandTest.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
@Test public void testRemoveExternalIds() throws Exception { ReadWriteTransaction transaction = mock(ReadWriteTransaction.class); doNothing().when(transaction).delete(any(LogicalDatastoreType.class), any(KeyedInstanceIdentifier.class)); //suppress getNodeId() OpenVSwitch ovs = mock(OpenVSwitch.class); doReturn(mock(NodeId.class)).when(openVSwitchUpdateCommand).getNodeId(any()); Whitebox.invokeMethod(openVSwitchUpdateCommand, "removeExternalIds", transaction, ImmutableMap.of("OpenvswitchExternalIdKey", "OpenvswitchExternalIdValue"), ovs); verify(transaction).delete(any(LogicalDatastoreType.class), any(KeyedInstanceIdentifier.class)); }
Example #22
Source File: PCEPStatefulPeerProposal.java From bgpcep with Eclipse Public License 1.0 | 5 votes |
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(); } }
Example #23
Source File: TopologyNodeState.java From bgpcep with Eclipse Public License 1.0 | 5 votes |
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); }
Example #24
Source File: MdsalUtilsAsyncTest.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
@Test public void testMerge() { final String operationDesc = "testMerge"; final SupportingNode supportingNodeBuilder1 = new SupportingNodeBuilder().withKey( new SupportingNodeKey(new NodeId("id1"), TOPOLOGY_TEST)).build(); final SupportingNode supportingNodeBuilder2 = new SupportingNodeBuilder().withKey( new SupportingNodeKey(new NodeId("id2"), TOPOLOGY_TEST)).build(); final Node data1 = new NodeBuilder(DATA).setSupportingNode( Collections.singletonList(supportingNodeBuilder1)).build(); final Node data2 = new NodeBuilder(DATA).setSupportingNode( Collections.singletonList(supportingNodeBuilder2)).build(); mdsalUtilsAsync.merge(LogicalDatastoreType.CONFIGURATION, TEST_IID, data1, operationDesc, true); assertEquals(data1, readDS()); final FluentFuture<? extends CommitInfo> future = mdsalUtilsAsync.merge(LogicalDatastoreType.CONFIGURATION, TEST_IID, data2, true); future.addCallback(new FutureCallback<CommitInfo>() { @Override public void onSuccess(final CommitInfo result) { assertEquals(2, readDS().getSupportingNode().size()); } @Override public void onFailure(final Throwable ex) { fail(ex.getMessage()); } }, MoreExecutors.directExecutor()); }
Example #25
Source File: HwvtepSouthboundMapper.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
private static InstanceIdentifier<Node> createInstanceIdentifier(IpAddress ip, PortNumber port) { String uriString = HwvtepSouthboundConstants.HWVTEP_URI_PREFIX + "://" + ip.stringValue() + ":" + port.getValue(); Uri uri = new Uri(uriString); NodeId nodeId = new NodeId(uri); InstanceIdentifier<Node> path = InstanceIdentifier.create(NetworkTopology.class) .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID)) .child(Node.class,new NodeKey(nodeId)); LOG.debug("Created ovsdb path: {}",path); return path; }
Example #26
Source File: OvsdbBridgeUpdateCommand.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
public OvsdbBridgeUpdateCommand(InstanceIdentifierCodec instanceIdentifierCodec, OvsdbConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema, Map<NodeId, Node> updatedBridgeNodes) { super(key,updates,dbSchema); this.instanceIdentifierCodec = instanceIdentifierCodec; updatedBridgeRows = TyperUtils.extractRowsUpdated(Bridge.class, getUpdates(), getDbSchema()); oldBridgeRows = TyperUtils.extractRowsOld(Bridge.class, getUpdates(), getDbSchema()); this.updatedBridgeNodes = updatedBridgeNodes; }
Example #27
Source File: SouthboundMapperTest.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void testCreateInstanceIdentifier1() throws Exception { Bridge bridge = mock(Bridge.class); // When bridge is not empty, we expect a deserialized identifier Column<GenericTableSchema, Map<String, String>> column = mock(Column.class); when(bridge.getExternalIdsColumn()).thenReturn(column); Map<String, String> map = new HashMap<>(); map.put(SouthboundConstants.IID_EXTERNAL_ID_KEY, "IID_EXTERNAL_ID_KEY"); when(column.getData()).thenReturn(map); InstanceIdentifierCodec iidc = mock(InstanceIdentifierCodec.class); InstanceIdentifier deserializedIid = InstanceIdentifier.create(Node.class); when(iidc.bindingDeserializerOrNull("IID_EXTERNAL_ID_KEY")).thenReturn(deserializedIid); OvsdbConnectionInstance client = mock(OvsdbConnectionInstance.class, Mockito.RETURNS_DEEP_STUBS); assertEquals("Incorrect Instance Identifier received", deserializedIid, SouthboundMapper.createInstanceIdentifier(iidc, client, bridge)); // When bridge is empty, we expect a new identifier pointing to the bridge when(bridge.getExternalIdsColumn()).thenReturn(null); when(client.getNodeKey().getNodeId().getValue()).thenReturn("uri"); when(bridge.getName()).thenReturn("bridgeName"); InstanceIdentifier<Node> returnedIid = SouthboundMapper.createInstanceIdentifier(iidc, client, bridge); assertEquals("Incorrect identifier type", Node.class, returnedIid.getTargetType()); assertEquals("Incorrect node key", new NodeId(new Uri("uri/bridge/bridgeName")), returnedIid.firstKeyOf(Node.class).getNodeId()); }
Example #28
Source File: LinkstateTopologyBuilder.java From bgpcep with Eclipse Public License 1.0 | 5 votes |
private void removeNode(final WriteTransaction trans, final UriBuilder base, final NodeCase nodeCase) { final NodeId id = buildNodeId(base, nodeCase.getNodeDescriptors()); final NodeHolder nh = this.nodes.get(id); if (nh != null) { nh.unadvertized(); nh.createSrHolderIfRequired().removeSrgb(trans); putNode(trans, nh); } else { LOG.warn("Node {} does not have a holder", id.getValue()); } }
Example #29
Source File: HwvtepSouthboundIT.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
TestPhysicalSwitch(final ConnectionInfo connectionInfo, final String name, @Nullable InstanceIdentifier<Node> psIid, @Nullable NodeId psNodeId, @Nullable final String description, final boolean setManagedBy, @Nullable final List<ManagementIps> managementIps, @Nullable final List<TunnelIps> tunnelIps, @Nullable final List<Tunnels> tunnels) { this.connectionInfo = connectionInfo; this.psName = name; NodeBuilder psNodeBuilder = new NodeBuilder(); if (psIid == null) { psIid = HwvtepSouthboundUtils.createInstanceIdentifier(connectionInfo, new HwvtepNodeName(psName)); } if (psNodeId == null) { psNodeId = HwvtepSouthboundMapper.createManagedNodeId(psIid); } psNodeBuilder.setNodeId(psNodeId); PhysicalSwitchAugmentationBuilder psAugBuilder = new PhysicalSwitchAugmentationBuilder(); psAugBuilder.setHwvtepNodeName(new HwvtepNodeName(psName)); if (description != null) { psAugBuilder.setHwvtepNodeDescription(description); } if (setManagedBy) { InstanceIdentifier<Node> nodePath = HwvtepSouthboundUtils.createInstanceIdentifier(connectionInfo); psAugBuilder.setManagedBy(new HwvtepGlobalRef(nodePath)); } psAugBuilder.setManagementIps(managementIps); psAugBuilder.setTunnelIps(tunnelIps); psAugBuilder.setTunnels(tunnels); psNodeBuilder.addAugmentation(PhysicalSwitchAugmentation.class, psAugBuilder.build()); LOG.debug("Built with intent to store PhysicalSwitch data {}", psAugBuilder); Assert.assertTrue( mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, psIid, psNodeBuilder.build())); try { Thread.sleep(OVSDB_UPDATE_TIMEOUT); } catch (InterruptedException e) { LOG.warn("Sleep interrupted while waiting for bridge creation (bridge {})", psName, e); } }
Example #30
Source File: HwvtepCacheDisplayCmd.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
private InstanceIdentifier<Node> getIid() { NodeId nodeId = new NodeId(new Uri(nodeid)); NodeKey nodeKey = new NodeKey(nodeId); TopologyKey topoKey = new TopologyKey(HWVTEP_TOPOLOGY_ID); return InstanceIdentifier.builder(NetworkTopology.class) .child(Topology.class, topoKey) .child(Node.class, nodeKey) .build(); }