Bug 6336 using single tx for logical switch, macs 83/43683/1
authorAkash <a.k.sahu@ericsson.com>
Thu, 11 Aug 2016 06:54:01 +0000 (12:24 +0530)
committerAkash <a.k.sahu@ericsson.com>
Thu, 11 Aug 2016 06:54:01 +0000 (12:24 +0530)
To handle the issue if logical switch is not present in OP tree then
logical siwtch name will be fetch from instanceIdentifier sub node as part
of the function getLogicalSwitchUUID in TransactUtils.java class.

Change-Id: Id3addade78464f967019c9c87053856bb111aed4
Signed-off-by: Akash <a.k.sahu@ericsson.com>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundConstants.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/TransactUtils.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteUpdateCommand.java

index 9cf587904f2e5c2a29bb5fcfc064409287b04f87..c9cb33525feca81acb4f88149746ddbd434dbd76 100644 (file)
@@ -19,8 +19,6 @@ import com.google.common.collect.ImmutableBiMap;
 public class HwvtepSouthboundConstants {
 
     public static final TopologyId HWVTEP_TOPOLOGY_ID = new TopologyId(new Uri("hwvtep:1"));
-    public static final String HWVTEP_URI_PREFIX = "hwvtep";
-    public static final String PSWITCH_URI_PREFIX = "physicalswitch";
     public static final Integer DEFAULT_OVSDB_PORT = 6640;
     public static final String IID_OTHER_CONFIG_KEY = "opendaylight-iid";
     public static final String UUID = "uuid";
@@ -30,4 +28,7 @@ public class HwvtepSouthboundConstants {
         .build();
     public static final MacAddress UNKNOWN_DST_MAC = new MacAddress("00:00:00:00:00:00");
     public static final String UNKNOWN_DST_STRING = "unknown-dst";
+    public static final String HWVTEP_URI_PREFIX = "hwvtep";
+    public static final String PSWITCH_URI_PREFIX = "physicalswitch";
+    public static final String LOGICALSWITCH_UUID_PREFIX = "LogicalSwitch_";
 }
index 905a788dcf3a8147ed40fe7d220ecaf2dab60dc9..bbde50e671ea8840f8779e72a957c13f1c2876e8 100644 (file)
@@ -72,7 +72,7 @@ public class LogicalSwitchUpdateCommand extends AbstractTransactCommand {
             if (!operationalSwitchOptional.isPresent()) {
                 setName(logicalSwitch, lswitch, operationalSwitchOptional);
                 LOG.trace("execute: creating LogicalSwitch entry: {}", logicalSwitch);
-                transaction.add(op.insert(logicalSwitch));
+                transaction.add(op.insert(logicalSwitch).withId(TransactUtils.getLogicalSwitchId(lswitch)));
                 transaction.add(op.comment("Logical Switch: Creating " + lswitch.getHwvtepNodeName().getValue()));
             } else {
                 LogicalSwitches updatedLSwitch = operationalSwitchOptional.get();
index 0404c94017d7b3650cd41ad60dbde0047c9f6c2c..d53171df24f3b66852a580af720c9e550bbfae68 100644 (file)
@@ -105,8 +105,7 @@ public class McastMacsRemoteUpdateCommand extends AbstractTransactCommand {
                 UUID logicalSwitchUUID = new UUID(logicalSwitchUuid.getValue());
                 mcastMacsRemote.setLogicalSwitch(logicalSwitchUUID);
             } else {
-                LOG.warn("Create or update remoteMcastMac: NO logical switch with iid {} found in operational datastore!",
-                        lswitchIid);
+                mcastMacsRemote.setLogicalSwitch(TransactUtils.getLogicalSwitchUUID(lswitchIid));
             }
         }
     }
index 053c5cfc588142d44815a22a892e9bb0b8647460..3ecdd600764ef8d6ee73ca44a5cc9efec61bc259 100644 (file)
@@ -163,6 +163,8 @@ public class PhysicalPortUpdateCommand extends AbstractTransactCommand {
                 if (operationalSwitchOptional.isPresent()) {
                     Uuid logicalSwitchUuid = operationalSwitchOptional.get().getLogicalSwitchUuid();
                     bindingMap.put(vlanBinding.getVlanIdKey().getValue().longValue(), new UUID(logicalSwitchUuid.getValue()));
+                }else{
+                    bindingMap.put(vlanBinding.getVlanIdKey().getValue().longValue(), TransactUtils.getLogicalSwitchUUID(lswitchIid));
                 }
             }
             physicalPort.setVlanBindings(bindingMap);
index bdeb8843bdb6e04ecca8de406c5112ae181b99a0..271b28c0bf42e3cfc705b2171f8021c10a1999b0 100644 (file)
@@ -31,6 +31,7 @@ import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocator;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocatorSet;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -190,4 +191,12 @@ public class TransactUtils {
             physicalLocator.setDstIp(inputLocator.getDstIp().getIpv4Address().getValue());
         }
     }
+
+    public static String getLogicalSwitchId(LogicalSwitches lswitch){
+        return HwvtepSouthboundConstants.LOGICALSWITCH_UUID_PREFIX+lswitch.getHwvtepNodeName().getValue();
+    }
+
+    public static UUID getLogicalSwitchUUID(InstanceIdentifier<LogicalSwitches> lswitchIid){
+        return new UUID(HwvtepSouthboundConstants.LOGICALSWITCH_UUID_PREFIX+lswitchIid.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue());
+    }
 }
index 4ae8575ae625a9b68225be64c1e8b9a9ac1cf8af..509354e78491ef26dc23d73afbc37bca12bf2bca 100644 (file)
@@ -106,8 +106,7 @@ public class UcastMacsRemoteUpdateCommand extends AbstractTransactCommand {
                 UUID logicalSwitchUUID = new UUID(logicalSwitchUuid.getValue());
                 ucastMacsRemote.setLogicalSwitch(logicalSwitchUUID);
             } else {
-                LOG.warn("Create or update remoteUcastMac: No logical switch with iid {} found in operational datastore!",
-                        lswitchIid);
+                ucastMacsRemote.setLogicalSwitch(TransactUtils.getLogicalSwitchUUID(lswitchIid));
             }
         }
     }