Java Code Examples for org.opendaylight.yangtools.yang.binding.InstanceIdentifier#firstKeyOf()

The following examples show how to use org.opendaylight.yangtools.yang.binding.InstanceIdentifier#firstKeyOf() . 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: 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 2
Source File: BridgeOperationalState.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
public Optional<TerminationPoint> getBridgeTerminationPoint(InstanceIdentifier<?> iid) {
    if (iid != null) {
        Optional<Node> nodeOptional = getBridgeNode(iid);
        if (nodeOptional.isPresent() && nodeOptional.get().getTerminationPoint() != null) {
            TerminationPointKey key = iid.firstKeyOf(TerminationPoint.class);
            if (key != null) {
                final TerminationPoint tp = nodeOptional.get().nonnullTerminationPoint().get(key);
                if (tp != null) {
                    return Optional.of(tp);
                }
            }
        } else {
            LOG.debug("TerminationPoints or Operational BridgeNode missing for {}", iid);
        }
    }
    return Optional.empty();
}
 
Example 3
Source File: BridgeOperationalState.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
public Optional<ControllerEntry> getControllerEntry(InstanceIdentifier<?> iid) {
    if (iid != null) {
        Optional<OvsdbBridgeAugmentation> ovsdbBridgeOptional = getOvsdbBridgeAugmentation(iid);
        if (ovsdbBridgeOptional.isPresent()) {
            Map<ControllerEntryKey, ControllerEntry> entries = ovsdbBridgeOptional.get().getControllerEntry();
            if (entries != null) {
                ControllerEntryKey key = iid.firstKeyOf(ControllerEntry.class);
                if (key != null) {
                    ControllerEntry entry = entries.get(key);
                    if (entry != null) {
                        return Optional.of(entry);
                    }
                }
            }
        }
    }
    return Optional.empty();
}
 
Example 4
Source File: BridgeOperationalState.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
public Optional<ProtocolEntry> getProtocolEntry(InstanceIdentifier<ProtocolEntry> iid) {
    if (iid != null) {
        Optional<OvsdbBridgeAugmentation> ovsdbBridgeOptional = getOvsdbBridgeAugmentation(iid);
        if (ovsdbBridgeOptional.isPresent()) {
            Map<ProtocolEntryKey, ProtocolEntry> entries = ovsdbBridgeOptional.get().getProtocolEntry();
            if (entries != null) {
                ProtocolEntryKey key = iid.firstKeyOf(ProtocolEntry.class);
                if (key != null) {
                    ProtocolEntry entry = entries.get(key);
                    if (entry != null) {
                        return Optional.of(entry);
                    }
                }
            }
        }
    }
    return Optional.empty();
}
 
Example 5
Source File: OvsdbQueueUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private String getQueueId(Queue queue) {
    if (queue.getExternalIdsColumn() != null
            && queue.getExternalIdsColumn().getData() != null) {
        if (queue.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) {
            InstanceIdentifier<Queues> queueIid =
                    (InstanceIdentifier<Queues>) instanceIdentifierCodec.bindingDeserializerOrNull(
                            queue.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY));
            if (queueIid != null) {
                QueuesKey queuesKey = queueIid.firstKeyOf(Queues.class);
                if (queuesKey != null) {
                    return queuesKey.getQueueId().getValue();
                }
            }
        } else if (queue.getExternalIdsColumn().getData()
                .containsKey(SouthboundConstants.QUEUE_ID_EXTERNAL_ID_KEY)) {
            return queue.getExternalIdsColumn().getData().get(SouthboundConstants.QUEUE_ID_EXTERNAL_ID_KEY);
        }
    }
    return SouthboundConstants.QUEUE_URI_PREFIX + "://" + queue.getUuid().toString();
}
 
Example 6
Source File: OvsdbQosUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private String getQosId(Qos qos) {
    if (qos.getExternalIdsColumn() != null
            && qos.getExternalIdsColumn().getData() != null) {
        if (qos.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) {
            InstanceIdentifier<QosEntries> qosIid =
                    (InstanceIdentifier<QosEntries>) instanceIdentifierCodec.bindingDeserializerOrNull(
                            qos.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY));
            if (qosIid != null) {
                QosEntriesKey qosEntriesKey = qosIid.firstKeyOf(QosEntries.class);
                if (qosEntriesKey != null) {
                    return qosEntriesKey.getQosId().getValue();
                }
            }
        } else if (qos.getExternalIdsColumn().getData().containsKey(SouthboundConstants.QOS_ID_EXTERNAL_ID_KEY)) {
            return qos.getExternalIdsColumn().getData().get(SouthboundConstants.QOS_ID_EXTERNAL_ID_KEY);
        }
    }
    return SouthboundConstants.QOS_URI_PREFIX + "://" + qos.getUuid().toString();
}
 
Example 7
Source File: HwvtepTableReader.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public List<Condition> apply(final InstanceIdentifier<RemoteUcastMacs> iid) {
    RemoteUcastMacsKey key = iid.firstKeyOf(RemoteUcastMacs.class);
    InstanceIdentifier<LogicalSwitches> lsIid = (InstanceIdentifier<LogicalSwitches>) key.getLogicalSwitchRef()
            .getValue();
    UUID lsUUID = connectionInstance.getDeviceInfo().getUUID(LogicalSwitches.class, lsIid);
    if (lsUUID == null) {
        LOG.error("Could not find uuid for ls key {}", lsIid);
        return null;
    }

    ArrayList<Condition> conditions = new ArrayList<>();
    conditions.add(macTable.getLogicalSwitchColumn().getSchema().opEqual(lsUUID));
    conditions.add(macTable.getMacColumn().getSchema().opEqual(key.getMacEntryKey().getValue()));
    return conditions;
}
 
Example 8
Source File: HwvtepTableReader.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public List<Condition> apply(final InstanceIdentifier<RemoteMcastMacs> iid) {
    RemoteMcastMacsKey key = iid.firstKeyOf(RemoteMcastMacs.class);
    InstanceIdentifier<LogicalSwitches> lsIid = (InstanceIdentifier<LogicalSwitches>) key.getLogicalSwitchRef()
            .getValue();
    UUID lsUUID = getLsUuid(lsIid);
    if (lsUUID == null) {
        LOG.warn("Could not find uuid for ls key {}", lsIid);
        return null;
    }

    ArrayList<Condition> conditions = new ArrayList<>();
    conditions.add(macTable.getLogicalSwitchColumn().getSchema().opEqual(lsUUID));
    return conditions;
}
 
Example 9
Source File: SouthboundUtils.java    From ovsdb with Eclipse Public License 1.0 4 votes vote down vote up
public static NodeId createManagedNodeId(InstanceIdentifier<Node> iid) {
    NodeKey nodeKey = iid.firstKeyOf(Node.class);
    return nodeKey.getNodeId();
}
 
Example 10
Source File: SouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 4 votes vote down vote up
public static NodeId createManagedNodeId(final InstanceIdentifier<Node> iid) {
    NodeKey nodeKey = iid.firstKeyOf(Node.class);
    return nodeKey.getNodeId();
}
 
Example 11
Source File: HwvtepSouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 4 votes vote down vote up
public static NodeId createManagedNodeId(InstanceIdentifier<Node> iid) {
    NodeKey nodeKey = iid.firstKeyOf(Node.class);
    return nodeKey.getNodeId();
}