+ 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);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ 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>) instanceIdentifierCodec.bindingDeserializerOrNull(
+ 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())));
+ }
+ }
+ }
+ LOG.debug("QoS UUID {} assigned to port not found in operational node {} or QoS updates", qosUuid, ovsdbNode);
+ return SouthboundMapper.createInstanceIdentifier(nodeId)
+ .augmentation(OvsdbNodeAugmentation.class)
+ .child(QosEntries.class, new QosEntriesKey(
+ new Uri(SouthboundConstants.QOS_URI_PREFIX + "://" + qosUuid.toString())));
+ }
+
+ private void updateIfIndex(final Interface interf,
+ final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
+ Set<Long> ifIndexSet = null;
+ try {
+ if (interf.getIfIndexColumn() != null) {
+ ifIndexSet = interf.getIfIndexColumn().getData();
+ }
+ if (ifIndexSet != null && !ifIndexSet.isEmpty()) {
+ for (Long ifIndex : ifIndexSet) {
+ ovsdbTerminationPointBuilder.setIfindex(ifIndex);
+ }
+ }
+ } catch (SchemaVersionMismatchException e) {
+ schemaMismatchLog("ifindex", "Interface", e);
+ }
+ }
+
+ private void updateMac(final Interface interf,
+ final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
+ Set<String> macSet = null;
+ try {
+ if (interf.getMacColumn() != null) {
+ macSet = interf.getMacColumn().getData();
+ }
+ if (macSet != null && !macSet.isEmpty()) {
+ /*
+ * It is a set due to way JSON decoder converts [] objects. OVS
+ * only supports ONE mac, so we're fine.
+ */
+ for (String mac: macSet) {
+ ovsdbTerminationPointBuilder.setMac(new MacAddress(mac));
+ }
+ }
+ } catch (SchemaVersionMismatchException e) {
+ schemaMismatchLog("mac", "Interface", e);
+ }
+ }
+
+ private void updateMacInUse(final Interface interf,
+ final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
+ Set<String> macInUseSet = null;
+ try {
+ if (interf.getMacInUseColumn() != null) {
+ macInUseSet = interf.getMacInUseColumn().getData();
+ }
+ if (macInUseSet != null && !macInUseSet.isEmpty()) {
+ /*
+ * It is a set due to way JSON decoder converts [] objects. OVS
+ * only supports ONE mac, so we're fine.
+ */
+ for (String macInUse: macInUseSet) {
+ ovsdbTerminationPointBuilder.setMacInUse(new MacAddress(macInUse));
+ }
+ }
+ } catch (SchemaVersionMismatchException e) {
+ schemaMismatchLog("mac_in_use", "Interface", e);
+ }
+ }
+
+ @VisibleForTesting
+ void updateOfPort(final Interface interf,