Java Code Examples for org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node#augmentation()
The following examples show how to use
org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node#augmentation() .
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: SouthboundMapper.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
/** * Create the {@link ControllerEntry} list given an MDSAL {@link Node} bridge * and {@link Controller} rows. * * @param bridgeNode the {@link Node} to update * @param updatedControllerRows the list of {@link Controller} controllers with updates * @return list of {@link ControllerEntry} entries */ public static List<ControllerEntry> createControllerEntries(final Node bridgeNode, final Map<UUID, Controller> updatedControllerRows) { LOG.debug("createControllerEntries Bridge 2: {}\n, updatedControllerRows: {}", bridgeNode, updatedControllerRows); final List<ControllerEntry> controllerEntriesCreated = new ArrayList<>(); final OvsdbBridgeAugmentation ovsdbBridgeAugmentation = bridgeNode.augmentation(OvsdbBridgeAugmentation.class); if (ovsdbBridgeAugmentation == null) { return controllerEntriesCreated; } final Map<ControllerEntryKey, ControllerEntry> controllerEntries = ovsdbBridgeAugmentation.getControllerEntry(); if (controllerEntries != null) { for (ControllerEntry controllerEntry : controllerEntries.values()) { final Controller controller = updatedControllerRows.get( new UUID(controllerEntry.getControllerUuid().getValue())); addControllerEntries(controllerEntriesCreated, controller); } } LOG.debug("controllerEntries: {}", controllerEntriesCreated); return controllerEntriesCreated; }
Example 2
Source File: OvsdbPortUpdateCommand.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("unchecked") // FIXME: non-static for implementation internals mocking private Optional<InstanceIdentifier<Node>> getTerminationPointBridge( final ReadWriteTransaction transaction, Node node, String tpName) { OvsdbNodeAugmentation ovsdbNode = node.augmentation(OvsdbNodeAugmentation.class); Map<ManagedNodeEntryKey, ManagedNodeEntry> managedNodes = ovsdbNode.nonnullManagedNodeEntry(); TpId tpId = new TpId(tpName); for (ManagedNodeEntry managedNodeEntry : managedNodes.values()) { Optional<Node> optManagedNode = SouthboundUtil.readNode(transaction, (InstanceIdentifier<Node>)managedNodeEntry.getBridgeRef().getValue()); if (optManagedNode.isPresent()) { Node managedNode = optManagedNode.get(); Map<TerminationPointKey, TerminationPoint> tpEntrys = managedNode.getTerminationPoint(); if (tpEntrys != null) { TerminationPoint tpEntry = tpEntrys.get(new TerminationPointKey(tpId)); if (tpEntry != null) { return Optional.of((InstanceIdentifier<Node>) managedNodeEntry.getBridgeRef().getValue()); } } } } return Optional.empty(); }
Example 3
Source File: DataChangesManagedByOvsdbNodeEvent.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
private InstanceIdentifier<?> getManagedByIid(Map<InstanceIdentifier<?>, DataObject> map, InstanceIdentifier<?> iidToCheck) { // Get the InstanceIdentifier of the containing node InstanceIdentifier<Node> nodeEntryIid = iidToCheck.firstIdentifierOf(Node.class); // Look for the Node in the created/updated data DataObject dataObject = null; if (map != null && map.get(nodeEntryIid) != null) { dataObject = map.get(nodeEntryIid); } // If we are contained in a bridge managed by this iid if (dataObject != null && dataObject instanceof Node) { Node node = (Node)dataObject; OvsdbBridgeAugmentation bridge = node.augmentation(OvsdbBridgeAugmentation.class); if (bridge != null && bridge.getManagedBy() != null && bridge.getManagedBy().getValue().equals(this.iid)) { return bridge.getManagedBy().getValue(); } } return null; }
Example 4
Source File: PhysicalSwitchUpdateCommand.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
private static Map<InstanceIdentifier<Node>, PhysicalSwitchAugmentation> extractUpdatedSwitches( final Collection<DataTreeModification<Node>> changes, final Class<PhysicalSwitchAugmentation> class1) { Map<InstanceIdentifier<Node>, PhysicalSwitchAugmentation> result = new HashMap<>(); if (changes != null && !changes.isEmpty()) { for (DataTreeModification<Node> change : changes) { final InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier(); final DataObjectModification<Node> mod = change.getRootNode(); Node updated = TransactUtils.getUpdated(mod); if (updated != null) { PhysicalSwitchAugmentation physicalSwitch = updated.augmentation(PhysicalSwitchAugmentation.class); if (physicalSwitch != null) { result.put(key, physicalSwitch); } } } } return result; }
Example 5
Source File: PcepStateUtils.java From bgpcep with Eclipse Public License 1.0 | 6 votes |
/** * Display to stream operational state, rib Id is mandatory. * * @param dataBroker data broker * @param stream where to print * @param topologyId mandatory, Topology where Node pertains * @param nodeId mandatory, State per given Node Id will be printed */ public static void displayNodeState(@NonNull final DataBroker dataBroker, @NonNull final PrintStream stream, @NonNull final String topologyId, @NonNull final String nodeId) { final Node node = readNodeFromDataStore(dataBroker, topologyId, nodeId); if (node == null) { stream.println(String.format("Node [%s] not found", nodeId)); return; } final PcepTopologyNodeStatsAug state = node.augmentation(PcepTopologyNodeStatsAug.class); if (state == null) { stream.println(String.format("State not found for [%s]", nodeId)); return; } final PcepSessionState nodeState = state.getPcepSessionState(); displayNodeState(topologyId, nodeId, nodeState, stream); }
Example 6
Source File: HwvtepDataChangeListener.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
private void updateConnections(Collection<DataTreeModification<Node>> changes) { for (DataTreeModification<Node> change : changes) { final InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier(); final DataObjectModification<Node> mod = change.getRootNode(); Node updated = getUpdated(mod); if (updated != null) { Node original = getOriginal(mod); HwvtepGlobalAugmentation hgUpdated = updated.augmentation(HwvtepGlobalAugmentation.class); HwvtepGlobalAugmentation hgOriginal = original.augmentation(HwvtepGlobalAugmentation.class); // Check if user has updated connection information if (hgUpdated != null && hgOriginal != null && hgUpdated.getConnectionInfo() != null && !hgUpdated.getConnectionInfo().equals(hgOriginal.getConnectionInfo())) { OvsdbClient client = hcm.getClient(hgUpdated.getConnectionInfo()); if (client == null) { try { hcm.disconnect(hgOriginal); hcm.stopConnectionReconciliationIfActive(key, hgOriginal); OvsdbClient newClient = hcm.connect(key, hgUpdated); if (newClient == null) { hcm.reconcileConnection(key, hgUpdated); } } catch (UnknownHostException | ConnectException e) { LOG.warn("Failed to update connection on HWVTEP Node", e); } } } } } }
Example 7
Source File: SouthboundUtils.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
public OvsdbBridgeAugmentation getBridgeFromConfig(Node node, String bridge) { OvsdbBridgeAugmentation ovsdbBridgeAugmentation = null; InstanceIdentifier<Node> bridgeIid = createInstanceIdentifier(node.key(), bridge); Node bridgeNode = provider.read(LogicalDatastoreType.CONFIGURATION, bridgeIid); if (bridgeNode != null) { ovsdbBridgeAugmentation = bridgeNode.augmentation(OvsdbBridgeAugmentation.class); } return ovsdbBridgeAugmentation; }
Example 8
Source File: SouthboundUtils.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
public OvsdbTerminationPointAugmentation extractTerminationPointAugmentation(Node bridgeNode, String portName) { if (bridgeNode.augmentation(OvsdbBridgeAugmentation.class) != null) { List<OvsdbTerminationPointAugmentation> tpAugmentations = extractTerminationPointAugmentations(bridgeNode); for (OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation : tpAugmentations) { if (ovsdbTerminationPointAugmentation.getName().equals(portName)) { return ovsdbTerminationPointAugmentation; } } } return null; }
Example 9
Source File: HwvtepGlobalRemoveCommand.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
@Override public void execute(ReadWriteTransaction transaction) { FluentFuture<Optional<Node>> hwvtepGlobalFuture = transaction.read( LogicalDatastoreType.OPERATIONAL, nodeInstanceIdentifier); try { Optional<Node> hwvtepGlobalOptional = hwvtepGlobalFuture.get(); if (hwvtepGlobalOptional.isPresent()) { Node hwvtepNode = hwvtepGlobalOptional.get(); HwvtepGlobalAugmentation hgAugmentation = hwvtepNode.augmentation(HwvtepGlobalAugmentation.class); if (checkIfOnlyConnectedManager(hgAugmentation)) { if (hgAugmentation != null) { Map<SwitchesKey, Switches> switches = hgAugmentation.getSwitches(); if (switches != null) { for (Switches hwSwitch : switches.values()) { LOG.debug("Deleting hwvtep switch {}", hwSwitch); transaction.delete( LogicalDatastoreType.OPERATIONAL, hwSwitch.getSwitchRef().getValue()); } } else { LOG.debug("{} had no switches", hwvtepNode.getNodeId().getValue()); } } else { LOG.warn("{} had no HwvtepGlobalAugmentation", hwvtepNode.getNodeId().getValue()); } transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeInstanceIdentifier); } else { LOG.debug("Other southbound plugin instances in cluster are connected to the device," + " not deleting OvsdbNode form data store."); } } } catch (InterruptedException | ExecutionException e) { LOG.warn("Failure to delete ovsdbNode", e); } }
Example 10
Source File: GlobalConfigOperationalChangeGetter.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
static HwvtepGlobalAugmentationBuilder augmentationFromNode(final Node node) { if (node == null) { return new HwvtepGlobalAugmentationBuilder(); } HwvtepGlobalAugmentation src = node.augmentation(HwvtepGlobalAugmentation.class); HwvtepGlobalAugmentationBuilder builder = new HwvtepGlobalAugmentationBuilder(); if (src != null) { builder.setLogicalSwitches(src.getLogicalSwitches()); builder.setRemoteMcastMacs(src.getRemoteMcastMacs()); builder.setRemoteUcastMacs(src.getRemoteUcastMacs()); } return builder; }
Example 11
Source File: GlobalConfigOperationalChangeGetter.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
static List<LocalUcastMacs> getLocalUcastMacsToBeRemoved(final Node opNode, final Set<String> removedSwitchNames) { if (opNode == null || opNode.augmentation(HwvtepGlobalAugmentation.class) == null) { return null; } Map<LocalUcastMacsKey, LocalUcastMacs> localUcastMacs = opNode.augmentation(HwvtepGlobalAugmentation.class) .getLocalUcastMacs(); if (localUcastMacs == null) { return null; } return localUcastMacs.values().stream() .filter(mac -> removedSwitchNames.contains( mac.getLogicalSwitchRef().getValue().firstKeyOf( LogicalSwitches.class).getHwvtepNodeName().getValue())) .collect(Collectors.toList()); }
Example 12
Source File: OvsdbConnectionManager.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
public OvsdbConnectionInstance getConnectionInstance(final Node node) { Preconditions.checkNotNull(node); OvsdbNodeAugmentation ovsdbNode = node.augmentation(OvsdbNodeAugmentation.class); OvsdbBridgeAugmentation ovsdbManagedNode = node.augmentation(OvsdbBridgeAugmentation.class); if (ovsdbNode != null) { return getConnectionInstance(ovsdbNode.getConnectionInfo()); } else if (ovsdbManagedNode != null) { return getConnectionInstance(ovsdbManagedNode); } else { LOG.warn("This is not a node that gives any hint how to find its OVSDB Manager: {}",node); return null; } }
Example 13
Source File: DataChangesManagedByOvsdbNodeEvent.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
private InstanceIdentifier<?> getManagedByIidFromOperDS(InstanceIdentifier<?> bridgeIid) { // Get the InstanceIdentifier of the containing node InstanceIdentifier<Node> nodeEntryIid = bridgeIid.firstIdentifierOf(Node.class); Optional<?> bridgeNode = SouthboundUtil.readNode(db.newReadWriteTransaction(),nodeEntryIid); if (bridgeNode.isPresent() && bridgeNode.get() instanceof Node) { Node node = (Node)bridgeNode.get(); OvsdbBridgeAugmentation bridge = node.augmentation(OvsdbBridgeAugmentation.class); if (bridge != null && bridge.getManagedBy() != null) { return bridge.getManagedBy().getValue(); } } return null; }
Example 14
Source File: GlobalConfigOperationalChangeGetter.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
static List<LocalMcastMacs> getLocalMcastMacsToBeRemoved(final Node opNode, final Set<String> removedSwitchNames) { if (opNode == null || opNode.augmentation(HwvtepGlobalAugmentation.class) == null) { return null; } Map<LocalMcastMacsKey, LocalMcastMacs> localMcastMacs = opNode.augmentation(HwvtepGlobalAugmentation.class) .getLocalMcastMacs(); if (localMcastMacs == null) { return null; } return localMcastMacs.values().stream() .filter(mac -> removedSwitchNames.contains( mac.getLogicalSwitchRef().getValue().firstKeyOf( LogicalSwitches.class).getHwvtepNodeName().getValue())) .collect(Collectors.toList()); }
Example 15
Source File: HwvtepOperationalState.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
public HwvtepOperationalState(final DataBroker db, final HwvtepConnectionInstance connectionInstance, final Collection<DataTreeModification<Node>> changes, final Node globalOperNode, final Node psNode) { this(db, connectionInstance, changes); operationalNodes.put(connectionInstance.getInstanceIdentifier(), globalOperNode); HwvtepGlobalAugmentation globalAugmentation = globalOperNode.augmentation(HwvtepGlobalAugmentation.class); if (globalAugmentation != null) { if (!HwvtepSouthboundUtil.isEmptyMap(globalAugmentation.getSwitches())) { operationalNodes.put((InstanceIdentifier<Node>) globalAugmentation.getSwitches().values().iterator().next().getSwitchRef().getValue(), psNode); } } }
Example 16
Source File: OvsdbQosUpdateCommand.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("unchecked") private InstanceIdentifier<Queues> getQueueIid(UUID queueUuid, Node ovsdbNode) { Queue queue = getQueue(queueUuid); if (queue != null && queue.getExternalIdsColumn() != null && queue.getExternalIdsColumn().getData() != null && queue.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) { return (InstanceIdentifier<Queues>) instanceIdentifierCodec.bindingDeserializerOrNull( queue.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY)); } else { OvsdbNodeAugmentation node = ovsdbNode.augmentation(OvsdbNodeAugmentation.class); Map<QueuesKey, Queues> queues = node.getQueues(); if (queues != null) { final Uuid uuid = new Uuid(queueUuid.toString()); for (Queues q : queues.values()) { if (uuid.equals(q.getQueueUuid())) { return SouthboundMapper.createInstanceIdentifier(ovsdbNode.getNodeId()) .augmentation(OvsdbNodeAugmentation.class) .child(Queues.class, q.key()); } } } LOG.debug("A Queue with UUID {} was not found in Ovsdb Node {}", queueUuid, node); return SouthboundMapper.createInstanceIdentifier(ovsdbNode.getNodeId()) .augmentation(OvsdbNodeAugmentation.class) .child(Queues.class, new QueuesKey( new Uri(SouthboundConstants.QUEUE_URI_PREFIX + "://" + queueUuid.toString()))); } }
Example 17
Source File: HwvtepSouthboundUtil.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("checkstyle:IllegalCatch") public static Optional<HwvtepGlobalAugmentation> getManagingNode(DataBroker db, HwvtepGlobalRef ref) { try { @SuppressWarnings("unchecked") // Note: erasure makes this safe in combination with the typecheck // below InstanceIdentifier<Node> path = (InstanceIdentifier<Node>) ref.getValue(); Optional<Node> optional = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, path); if (optional != null && optional.isPresent()) { HwvtepGlobalAugmentation hwvtepNode = null; Node node = optional.get(); if (node instanceof HwvtepGlobalAugmentation) { hwvtepNode = (HwvtepGlobalAugmentation) node; } else if (node != null) { hwvtepNode = node.augmentation(HwvtepGlobalAugmentation.class); } if (hwvtepNode != null) { return Optional.of(hwvtepNode); } else { LOG.warn("Hwvtep switch claims to be managed by {} but " + "that HwvtepNode does not exist", ref.getValue()); return Optional.empty(); } } else { LOG.warn("Mysteriously got back a thing which is *not* a topology Node: {}", optional); return Optional.empty(); } } catch (RuntimeException e) { LOG.warn("Failed to get HwvtepNode {}", ref, e); return Optional.empty(); } }
Example 18
Source File: OvsdbDataTreeChangeListener.java From ovsdb with Eclipse Public License 1.0 | 4 votes |
private Map<OvsdbConnectionInstance, Collection<DataTreeModification<Node>>> changesPerConnectionInstance( @NonNull Collection<DataTreeModification<Node>> changes) { Map<OvsdbConnectionInstance, Collection<DataTreeModification<Node>>> result = new HashMap<>(); for (DataTreeModification<Node> change : changes) { OvsdbConnectionInstance client = null; Node dataAfter = change.getRootNode().getDataAfter(); Node node = dataAfter != null ? dataAfter : change.getRootNode().getDataBefore(); if (node != null) { OvsdbNodeAugmentation ovsdbNode = node.augmentation(OvsdbNodeAugmentation.class); if (ovsdbNode != null) { if (ovsdbNode.getConnectionInfo() != null) { client = cm.getConnectionInstance(ovsdbNode.getConnectionInfo()); } else { client = cm.getConnectionInstance(SouthboundMapper.createInstanceIdentifier(node.getNodeId())); } } else { OvsdbBridgeAugmentation bridgeAugmentation = node.augmentation(OvsdbBridgeAugmentation.class); if (bridgeAugmentation != null) { OvsdbNodeRef managedBy = bridgeAugmentation.getManagedBy(); if (managedBy != null) { client = cm.getConnectionInstance((InstanceIdentifier<Node>) managedBy.getValue()); } } } if (client == null) { //Try getting from change root identifier client = cm.getConnectionInstance(change.getRootPath().getRootIdentifier()); } } else { LOG.warn("Following change don't have after/before data {}", change); } if (client != null) { LOG.debug("Found client for {}", node); /* * As of now data change sets are processed by single thread, so we can assume that device will * be connected and ownership will be decided before sending any instructions down to the device. * Note:Processing order in onDataChange() method should not change. If processing is changed to * use multiple thread, we might need to take care of corner cases, where ownership is not decided * but transaction are ready to go to switch. In that scenario, either we need to queue those task * till ownership is decided for that specific device. * Given that each DataChangeNotification is notified through separate thread, so we are already * multi threaded and i don't see any need to further parallelism per DataChange * notifications processing. */ if (cm.getHasDeviceOwnership(client.getMDConnectionInfo())) { LOG.debug("*This* instance of southbound plugin is an owner of the device {}", node); result.computeIfAbsent(client, key -> new ArrayList<>()).add(change); } else { LOG.debug("*This* instance of southbound plugin is *not* an owner of the device {}", node); } } else { LOG.debug("Did not find client for {}", node); } } return result; }
Example 19
Source File: SouthboundUtils.java From ovsdb with Eclipse Public License 1.0 | 4 votes |
public OvsdbBridgeAugmentation extractBridgeAugmentation(Node node) { if (node == null) { return null; } return node.augmentation(OvsdbBridgeAugmentation.class); }
Example 20
Source File: OvsdbPortUpdateCommand.java From ovsdb with Eclipse Public License 1.0 | 4 votes |
private void updateQos(final ReadWriteTransaction transaction, final Node node, InstanceIdentifier<TerminationPoint> tpPath, final Entry<UUID, Port> port, final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) { if (port.getValue() == null) { return; } Collection<UUID> qosUuidCol = port.getValue().getQosColumn().getData(); if (!qosUuidCol.isEmpty()) { UUID qosUuid = qosUuidCol.iterator().next(); NodeId nodeId = node.getNodeId(); OvsdbNodeAugmentation ovsdbNode = node.augmentation(OvsdbNodeAugmentation.class); // Delete an older QoS entry if (portOldRows.containsKey(port.getKey()) && portOldRows.get(port.getKey()).getQosColumn() != null) { Collection<UUID> oldQos = portOldRows.get(port.getKey()).getQosColumn().getData(); if (!oldQos.isEmpty()) { UUID oldQosUuid = oldQos.iterator().next(); if (!oldQosUuid.equals(qosUuid)) { InstanceIdentifier<QosEntries> oldQosIid = getQosIid(nodeId, ovsdbNode, oldQosUuid); if (oldQosIid != null) { InstanceIdentifier<QosEntry> oldPortQosIid = tpPath .augmentation(OvsdbTerminationPointAugmentation.class) .child(QosEntry.class, new QosEntryKey(Long.valueOf(SouthboundConstants.PORT_QOS_LIST_KEY))); transaction.delete(LogicalDatastoreType.OPERATIONAL, oldPortQosIid); } } } } InstanceIdentifier<QosEntries> qosIid = getQosIid(nodeId, ovsdbNode, qosUuid); if (qosIid != null) { List<QosEntry> qosList = new ArrayList<>(); OvsdbQosRef qosRef = new OvsdbQosRef(qosIid); qosList.add(new QosEntryBuilder() .withKey(new QosEntryKey(Long.valueOf(SouthboundConstants.PORT_QOS_LIST_KEY))) .setQosRef(qosRef).build()); ovsdbTerminationPointBuilder.setQosEntry(qosList); } } }