+
+ NodeId nodeId = node.getNodeId();
+ OvsdbNodeAugmentation ovsdbNode = node.getAugmentation(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(new Long(SouthboundConstants.PORT_QOS_LIST_KEY)));
+// new QosEntryKey(new OvsdbQosRef(oldQosIid)));
+ 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()
+ .setKey(new QosEntryKey(new Long(SouthboundConstants.PORT_QOS_LIST_KEY)))
+ .setQosRef(qosRef).build());
+ ovsdbTerminationPointBuilder.setQosEntry(qosList);
+ }
+ }
+ }
+
+ private InstanceIdentifier<QosEntries> getQosIid(NodeId nodeId, OvsdbNodeAugmentation ovsdbNode, UUID qosUuid) {
+ // Search for the QoS entry first in the operational datastore
+ for (QosEntries qosEntry : ovsdbNode.getQosEntries()) {
+ if (qosEntry.getQosUuid().equals(new Uuid(qosUuid.toString()))) {
+ return SouthboundMapper.createInstanceIdentifier(nodeId)
+ .augmentation(OvsdbNodeAugmentation.class)
+ .child(QosEntries.class, new QosEntriesKey(qosEntry.getQosId()));
+ }
+ }
+
+ // Search for the QoS entry in the current OVS updates
+ for (Entry<UUID, Qos> qosUpdate : qosUpdatedRows.entrySet()) {
+ Qos qos = qosUpdate.getValue();
+ if (qos.getUuid().equals(qosUuid)) {
+ if (qos.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) {
+ return (InstanceIdentifier<QosEntries>) SouthboundUtil.deserializeInstanceIdentifier(
+ qos.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY));
+ } else {
+ return SouthboundMapper.createInstanceIdentifier(nodeId)
+ .augmentation(OvsdbNodeAugmentation.class)
+ .child(QosEntries.class, new QosEntriesKey(
+ new Uri(SouthboundConstants.QOS_URI_PREFIX + "://" + qosUuid.toString())));
+ }
+ }