Update MRI projects for Aluminium
[ovsdb.git] / southbound / southbound-impl / src / main / java / org / opendaylight / ovsdb / southbound / ovsdb / transact / TerminationPointUpdateCommand.java
index 9df44ab503babd3fb3407fbd49138ed8cbacef9c..ada83a02243db759926f25f395e298013fe266c6 100644 (file)
@@ -11,7 +11,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.opendaylight.ovsdb.lib.operations.Operations.op;
 import static org.opendaylight.ovsdb.southbound.SouthboundUtil.schemaMismatchLog;
 
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -40,13 +39,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbQosRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.QosEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.QosEntriesKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfd;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIdsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldpKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.PortExternalIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.PortOtherConfigs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.PortOtherConfigsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Trunks;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -160,13 +165,14 @@ public class TerminationPointUpdateCommand implements TransactCommand {
 
         // First check if QosEntry is present and use that
         if (terminationPoint.getQosEntry() != null && !terminationPoint.getQosEntry().isEmpty()) {
-            OvsdbQosRef qosRef = terminationPoint.getQosEntry().iterator().next().getQosRef();
+            OvsdbQosRef qosRef = terminationPoint.getQosEntry().values().iterator().next().getQosRef();
             Uri qosId = qosRef.getValue().firstKeyOf(QosEntries.class).getQosId();
             OvsdbNodeAugmentation operNode = getOperNode(operBridge);
-            if (operNode != null && operNode.getQosEntries() != null
-                    && !operNode.getQosEntries().isEmpty()) {
-                for (QosEntries qosEntry : operNode.getQosEntries()) {
-                    if (qosEntry.getQosId().equals(qosId)) {
+            if (operNode != null) {
+                Map<QosEntriesKey, QosEntries> entries = operNode.getQosEntries();
+                if (entries != null) {
+                    QosEntries qosEntry = entries.get(new QosEntriesKey(qosId));
+                    if (qosEntry != null) {
                         uuidSet.add(new UUID(qosEntry.getQosUuid().getValue()));
                     }
                 }
@@ -230,14 +236,14 @@ public class TerminationPointUpdateCommand implements TransactCommand {
     private static void updateInterfaceExternalIds(final OvsdbTerminationPointAugmentation terminationPoint,
             final Interface ovsInterface) {
 
-        List<InterfaceExternalIds> interfaceExternalIds =
+        Map<InterfaceExternalIdsKey, InterfaceExternalIds> interfaceExternalIds =
                 terminationPoint.getInterfaceExternalIds();
+        final InterfaceExternalIds odl = SouthboundUtil.interfaceCreatedByOpenDaylight();
+
         if (interfaceExternalIds != null && !interfaceExternalIds.isEmpty()) {
-            interfaceExternalIds.add(SouthboundUtil.createExternalIdsForInterface(
-                SouthboundConstants.CREATED_BY, SouthboundConstants.ODL));
+            interfaceExternalIds.put(odl.key(), odl);
         } else {
-            interfaceExternalIds = Arrays.asList(SouthboundUtil.createExternalIdsForInterface(
-                SouthboundConstants.CREATED_BY, SouthboundConstants.ODL));
+            interfaceExternalIds = Map.of(odl.key(), odl);
         }
         try {
             ovsInterface.setExternalIds(YangUtils.convertYangKeyValueListToMap(interfaceExternalIds,
@@ -250,7 +256,7 @@ public class TerminationPointUpdateCommand implements TransactCommand {
     private static void updateInterfaceLldp(final OvsdbTerminationPointAugmentation terminationPoint,
             final Interface ovsInterface) {
         try {
-            List<InterfaceLldp> interfaceLldpList =
+            Map<InterfaceLldpKey, InterfaceLldp> interfaceLldpList =
                     terminationPoint.getInterfaceLldp();
             if (interfaceLldpList != null && !interfaceLldpList.isEmpty()) {
                 try {
@@ -268,11 +274,11 @@ public class TerminationPointUpdateCommand implements TransactCommand {
     private static void updateInterfaceOtherConfig(final OvsdbTerminationPointAugmentation terminationPoint,
             final Interface ovsInterface) {
 
-        List<InterfaceOtherConfigs> interfaceOtherConfigs =
+        Map<InterfaceOtherConfigsKey, InterfaceOtherConfigs> interfaceOtherConfigs =
                 terminationPoint.getInterfaceOtherConfigs();
         if (interfaceOtherConfigs != null && !interfaceOtherConfigs.isEmpty()) {
             Map<String, String> otherConfigsMap = new HashMap<>();
-            for (InterfaceOtherConfigs interfaceOtherConfig : interfaceOtherConfigs) {
+            for (InterfaceOtherConfigs interfaceOtherConfig : interfaceOtherConfigs.values()) {
                 otherConfigsMap.put(interfaceOtherConfig.getOtherConfigKey(),
                         interfaceOtherConfig.getOtherConfigValue());
             }
@@ -288,8 +294,7 @@ public class TerminationPointUpdateCommand implements TransactCommand {
             final Interface ovsInterface) {
 
         try {
-            List<InterfaceBfd> interfaceBfdList =
-                    terminationPoint.getInterfaceBfd();
+            Map<InterfaceBfdKey, InterfaceBfd> interfaceBfdList = terminationPoint.getInterfaceBfd();
             if (interfaceBfdList != null && !interfaceBfdList.isEmpty()) {
                 try {
                     ovsInterface.setBfd(YangUtils.convertYangKeyValueListToMap(interfaceBfdList,
@@ -363,7 +368,7 @@ public class TerminationPointUpdateCommand implements TransactCommand {
 
     private static void updatePortOtherConfig(final OvsdbTerminationPointAugmentation terminationPoint,
             final Port ovsPort) {
-        List<PortOtherConfigs> portOtherConfigs =
+        Map<PortOtherConfigsKey, PortOtherConfigs> portOtherConfigs =
                 terminationPoint.getPortOtherConfigs();
         if (portOtherConfigs != null && !portOtherConfigs.isEmpty()) {
             try {