org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey Java Examples

The following examples show how to use org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey. 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: OvsdbControllerUpdateCommandTest.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@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 #2
Source File: ReconciliationManager.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@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;

}
 
Example #3
Source File: AutoAttachUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
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 #4
Source File: SouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
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 #5
Source File: OvsdbControllerUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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());
}
 
Example #6
Source File: OvsdbManagersUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 #7
Source File: BridgeConfigReconciliationTaskTest.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@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 #8
Source File: OvsdbManagersUpdateCommandTest.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@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 #9
Source File: TunnelProgrammingTest.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
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 #10
Source File: SouthboundUtils.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #11
Source File: LinkstateTopologyBuilder.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
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 #12
Source File: AbstractReachabilityTopologyBuilder.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
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 #13
Source File: NodeChangedListener.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
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 #14
Source File: LinkstateTopologyBuilder.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
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 #15
Source File: SouthboundUtils.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #16
Source File: TopologyStatsProviderImpl.java    From bgpcep with Eclipse Public License 1.0 5 votes vote down vote up
@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();
    }
}
 
Example #17
Source File: SouthboundUtils.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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<>();
}
 
Example #18
Source File: SouthboundUtils.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example #19
Source File: ReconciliationManager.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
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();
                }
            });
}
 
Example #20
Source File: TransactionInvokerImplTest.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
private InstanceIdentifier<Node> createInstanceIdentifier(final String nodeIdString) {
    NodeId nodeId = new NodeId(new Uri(nodeIdString));
    NodeKey nodeKey = new NodeKey(nodeId);
    TopologyKey topoKey = new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID);
    return InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, topoKey)
            .child(Node.class, nodeKey)
            .build();
}
 
Example #21
Source File: OpenVSwitchUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@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);
    }
}
 
Example #22
Source File: OpenVSwitchUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@VisibleForTesting
void removeExternalIds(ReadWriteTransaction transaction, Map<String, String> oldExternalIds, 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> externalIdKeys = oldExternalIds.keySet();
    for (String externalIdKey : externalIdKeys) {
        KeyedInstanceIdentifier<OpenvswitchExternalIds, OpenvswitchExternalIdsKey> externalIid =
                nodeAugmentataionIid
                .child(OpenvswitchExternalIds.class, new OpenvswitchExternalIdsKey(externalIdKey));
        transaction.delete(LogicalDatastoreType.OPERATIONAL, externalIid);
    }
}
 
Example #23
Source File: BridgeOperationalStateTest.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    iidNode = InstanceIdentifier.create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(new TopologyId("foo")))
            .child(Node.class, new NodeKey(nd.getNodeId()));
    protocolEntry = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class).child(Node.class)
            .augmentation(OvsdbBridgeAugmentation.class).child(ProtocolEntry.class);

    briOperationState = mock(BridgeOperationalState.class, Mockito.CALLS_REAL_METHODS);

    getField(BridgeOperationalState.class,"db").set(briOperationState, db);
    doReturn(mockReadTx).when(db).newReadOnlyTransaction();
    OvsdbOperGlobalListener.OPER_NODE_CACHE.put(nodeIid, brNode);
}
 
Example #24
Source File: HwvtepSouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
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 #25
Source File: HwvtepSouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
public static InstanceIdentifier<Node> createInstanceIdentifier(HwvtepConnectionInstance client,
                HwvtepNodeName psName) {
    NodeKey nodeKey = new NodeKey(createManagedNodeId(client, psName));
    return InstanceIdentifier.builder(NetworkTopology.class)
                    .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID))
                    .child(Node.class, nodeKey).build();
}
 
Example #26
Source File: HwvtepSouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
public static InstanceIdentifier<Node> getInstanceIdentifier(Global global) {
    String nodeString = HwvtepSouthboundConstants.HWVTEP_URI_PREFIX + "://"
            + HwvtepSouthboundConstants.UUID + "/" + global.getUuid().toString();
    NodeId nodeId = new NodeId(new Uri(nodeString));
    NodeKey nodeKey = new NodeKey(nodeId);
    TopologyKey topoKey = new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID);
    return InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, topoKey)
            .child(Node.class, nodeKey)
            .build();
}
 
Example #27
Source File: HwvtepCacheDisplayCmd.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
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();
}
 
Example #28
Source File: HwvtepSouthboundUtil.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
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 #29
Source File: DataChangeListenerTestBase.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
public InstanceIdentifier<Node> createInstanceIdentifier(final String nodeIdString) {
    NodeId nodeId = new NodeId(new Uri(nodeIdString));
    NodeKey nodeKey = new NodeKey(nodeId);
    TopologyKey topoKey = new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID);
    return InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, topoKey)
            .child(Node.class, nodeKey)
            .build();
}
 
Example #30
Source File: Host.java    From atrium-odl with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}