Fix Physical Switch Update Command 13/31413/5
authorPeng Zhang <pzhang@ctbri.com.cn>
Wed, 16 Dec 2015 09:42:16 +0000 (17:42 +0800)
committerPeng Zhang <pzhang@ctbri.com.cn>
Thu, 17 Dec 2015 12:08:32 +0000 (20:08 +0800)
Change-Id: Ibcb66f43bead8b381f8f6ad98050401c2e8b5de1
Signed-off-by: Peng Zhang <pzhang@ctbri.com.cn>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchUpdateCommand.java
resources/commons/Ovsdb-HwvtepSouthbound-Collection.json.postman_collection

index 08a617c6c51f21d3b247f3be4b7a90dafb7d50dc..ef6b09f575ceeb2729457bc37a2dde26b9bef372 100644 (file)
@@ -19,9 +19,12 @@ import java.util.Set;
 
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
+import org.opendaylight.ovsdb.lib.notation.Mutator;
 import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
+import org.opendaylight.ovsdb.schema.hardwarevtep.Global;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.ManagementIps;
@@ -33,6 +36,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Optional;
+import com.google.common.collect.Sets;
 
 public class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
     private static final Logger LOG = LoggerFactory.getLogger(PhysicalSwitchUpdateCommand.class);
@@ -74,8 +78,18 @@ public class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
         setTunnuleIps(physicalSwitch, physicalSwitchAugmentation);
         setTunnels(physicalSwitch, physicalSwitchAugmentation);
         if (!operationalPhysicalSwitchOptional.isPresent()) {
+            //create a physical switch
             setName(physicalSwitch, physicalSwitchAugmentation, operationalPhysicalSwitchOptional);
-            transaction.add(op.insert(physicalSwitch));
+            String pswitchUuid = "PhysicalSwitch_" + HwvtepSouthboundMapper.getRandomUUID();
+            transaction.add(op.insert(physicalSwitch).withId(pswitchUuid));
+            //update global table
+            Global global = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Global.class);
+            global.setSwitches(Sets.newHashSet(new UUID(pswitchUuid)));
+
+            LOG.debug("execute: physical switch: {}", physicalSwitch);
+            transaction.add(op.mutate(global)
+                    .addMutation(global.getSwitchesColumn().getSchema(), Mutator.INSERT,
+                            global.getSwitchesColumn().getData()));
         } else {
             PhysicalSwitchAugmentation updatedPhysicalSwitch = operationalPhysicalSwitchOptional.get();
             String existingPhysicalSwitchName = updatedPhysicalSwitch.getHwvtepNodeName().getValue();
index c523adc018a395c3980b547314ebf0b6b8268e27..29d00df9ce49116bd317df0924f9d734d01fb43b 100755 (executable)
             "time": 1449468092415,
             "name": "Create Specific Config McastMacRemote",
             "description": "",
-            "rawModeData": "{\n  \"remote-mcast-macs\": [\n        {\n            \"mac-entry-key\": \"33:33:33:33:33:55\",\n            \"logical-switch-ref\": \"ls0\",\n            \"ipaddr\": \"3.3.3.5\",\n            \"locator-set\": [\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:219.141.189.49']\"\n                },\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:219.141.189.48']\"\n                }\n            ]\n        }\n    ]\n}"
+            "rawModeData": "{\n  \"remote-mcast-macs\": [\n        {\n            \"mac-entry-key\": \"33:33:33:33:33:55\",\n            \"logical-switch-ref\": \"ls0\",\n            \"ipaddr\": \"3.3.3.5\",\n            \"locator-set\": [\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:{{locatorIp-1}}']\"\n                },\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:{{locatorIp-2}}']\"\n                }\n            ]\n        }\n    ]\n}"
         },
         {
             "collectionId": "19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
             "time": 1449468318065,
             "name": "Update Specific Config McastMacRemote ",
             "description": "",
-            "rawModeData": "{\n  \"remote-mcast-macs\": [\n        {\n            \"mac-entry-key\": \"33:33:33:33:33:33\",\n            \"logical-switch-ref\": \"ls1\",\n            \"ipaddr\": \"3.3.3.3\",\n            \"locator-set\": [\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:219.141.189.49']\"\n                },\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:219.141.189.48']\"\n                }\n            ]\n        }\n    ]\n}"
+            "rawModeData": "{\n  \"remote-mcast-macs\": [\n        {\n            \"mac-entry-key\": \"33:33:33:33:33:33\",\n            \"logical-switch-ref\": \"ls1\",\n            \"ipaddr\": \"3.3.3.3\",\n            \"locator-set\": [\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:{{locatorIp-1}}']\"\n                },\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:{{locatorIp-2}}']\"\n                }\n            ]\n        }\n    ]\n}"
         },
         {
             "collectionId": "19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
             "time": 1449468010690,
             "name": "Create Specific Config McastMacLocal",
             "description": "",
-            "rawModeData": "{\n  \"local-mcast-macs\": [\n        {\n            \"mac-entry-key\": \"44:44:44:44:44:66\",\n            \"logical-switch-ref\": \"ls0\",\n            \"ipaddr\": \"4.4.4.6\",\n            \"locator-set\": [\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:219.141.189.49']\"\n                },\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:219.141.189.48']\"\n                }\n            ]\n        }\n    ]\n}"
+            "rawModeData": "{\n  \"local-mcast-macs\": [\n        {\n            \"mac-entry-key\": \"44:44:44:44:44:66\",\n            \"logical-switch-ref\": \"ls0\",\n            \"ipaddr\": \"4.4.4.6\",\n            \"locator-set\": [\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:{{locatorIp-1}}']\"\n                },\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:{{locatorIp-2}}']\"\n                }\n            ]\n        }\n    ]\n}"
         },
         {
             "collectionId": "19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
             "time": 1449468504628,
             "name": "Update Specific Config McastMacLocal",
             "description": "",
-            "rawModeData": "{\n  \"local-mcast-macs\": [\n        {\n            \"mac-entry-key\": \"44:44:44:44:44:44\",\n            \"logical-switch-ref\": \"ls0\",\n            \"ipaddr\": \"4.4.4.4\",\n            \"locator-set\": [\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:219.141.189.49']\"\n                },\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:219.141.189.48']\"\n                }\n            ]\n        }\n    ]\n}"
+            "rawModeData": "{\n  \"local-mcast-macs\": [\n        {\n            \"mac-entry-key\": \"44:44:44:44:44:44\",\n            \"logical-switch-ref\": \"ls0\",\n            \"ipaddr\": \"4.4.4.4\",\n            \"locator-set\": [\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:{{locatorIp-1}}']\"\n                },\n                {\n                    \"locator-ref\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']/network-topology:termination-point[network-topology:tp-id='vxlan_over_ipv4:{{locatorIp-2}}']\"\n                }\n            ]\n        }\n    ]\n}"
         },
         {
             "collectionId": "19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",