Added code for PhysicalPort, LogicalSwitch 59/29659/2
authorVishal Thapar <vishal.thapar@ericsson.com>
Fri, 13 Nov 2015 13:11:45 +0000 (18:41 +0530)
committerVishal Thapar <vishal.thapar@ericsson.com>
Mon, 16 Nov 2015 10:12:41 +0000 (15:42 +0530)
1. Added PhysicalPortUpdate and PhysicalPortRemove
2. Added LogicalSwitchUpdate and LogicalSwitchRemove
With these changes physical-port and logical-switch changes on device are
reflected in OperationalDS.

Patchset2:
1. Rebase
2. Add VlanBindings to OperationalDataStore
3. Use env vars for IPs in postman collection
4. Fixed a bug in postman collection

Change-Id: Ic1b3d0e15088db6d81316ad88c2db5299a9c9be0
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundMapper.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepOperationalCommandAggregator.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/LogicalSwitchRemoveCommand.java [new file with mode: 0644]
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/LogicalSwitchUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/PhysicalPortRemoveCommand.java [new file with mode: 0644]
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/PhysicalPortUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/PhysicalSwitchUpdateCommand.java
resources/commons/Ovsdb-HwvtepSouthbound-Collection.json.postman_collection

index e487f25dc2eb5855280e2edde7c531f57946137b..1c87b838c623ae4e7d170da441d8182b3c924a85 100644 (file)
@@ -15,6 +15,7 @@ import java.net.UnknownHostException;
 
 import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.schema.hardwarevtep.Global;
+import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
@@ -144,4 +145,17 @@ public class HwvtepSouthboundMapper {
                         .child(Node.class, nodeKey).build();
         return iid;
     }
+
+    public static InstanceIdentifier<Node> createInstanceIdentifier(HwvtepConnectionInstance client,
+                    LogicalSwitch lSwitch) {
+        InstanceIdentifier<Node> iid = null;
+        String nodeString = client.getNodeKey().getNodeId().getValue() + "/logicalswitch/" + lSwitch.getName();
+        NodeId nodeId = new NodeId(new Uri(nodeString));
+        NodeKey nodeKey = new NodeKey(nodeId);
+        iid =InstanceIdentifier.builder(NetworkTopology.class)
+                        .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID))
+                        .child(Node.class, nodeKey).build();
+        return iid;
+    }
+
 }
index b0bcdf3c0ea9f24b6caa25460fc0ec177b6bdc70..2c0e9638a6a4398a6ffb1b332e3937c538706b99 100644 (file)
@@ -29,7 +29,9 @@ public class HwvtepOperationalCommandAggregator implements TransactionCommand {
         commands.add(new PhysicalSwitchRemoveCommand(key, updates, dbSchema));
         commands.add(new HwvtepManagerUpdateCommand(key, updates, dbSchema));
         commands.add(new LogicalSwitchUpdateCommand(key, updates, dbSchema));
+        commands.add(new LogicalSwitchRemoveCommand(key, updates, dbSchema));
         commands.add(new PhysicalPortUpdateCommand(key, updates, dbSchema));
+        commands.add(new PhysicalPortRemoveCommand(key, updates, dbSchema));
         commands.add(new HwvtepTunnelUpdateCommand(key, updates, dbSchema));
         commands.add(new PhysicalLocatorUpdateCommand(key, updates, dbSchema));
         commands.add(new PhysicalLocatorSetUpdateCommand(key, updates, dbSchema));
diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/LogicalSwitchRemoveCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/LogicalSwitchRemoveCommand.java
new file mode 100644 (file)
index 0000000..388d158
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
+
+import java.util.Collection;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
+import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
+import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalSwitchRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.SwitchesKey;
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LogicalSwitchRemoveCommand extends AbstractTransactionCommand {
+
+    private static final Logger LOG = LoggerFactory.getLogger(LogicalSwitchRemoveCommand.class);
+
+    public LogicalSwitchRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates,
+            DatabaseSchema dbSchema) {
+        super(key, updates, dbSchema);
+    }
+
+    @Override
+    public void execute(ReadWriteTransaction transaction) {
+        Collection<LogicalSwitch> deletedLSRows = TyperUtils.extractRowsRemoved(LogicalSwitch.class, getUpdates(),getDbSchema()).values();
+        if(deletedLSRows != null && !deletedLSRows.isEmpty()) {
+            for (LogicalSwitch lSwitch : deletedLSRows) {
+                InstanceIdentifier<Node> nodeIid = HwvtepSouthboundMapper.createInstanceIdentifier(
+                                getOvsdbConnectionInstance(), lSwitch);
+                /*
+                 * TODO:
+                 * Once hwvtep.yang is modified, replace HwvtepPhysicalSwitchRef with appropriate
+                 * class [HWvtepSwitchRef].
+                 */
+                InstanceIdentifier<Switches> switchIid = getOvsdbConnectionInstance().getInstanceIdentifier()
+                                .augmentation(HwvtepGlobalAugmentation.class)
+                                .child(Switches.class, new SwitchesKey(new HwvtepPhysicalSwitchRef(nodeIid)));
+                        // TODO handle removal of reference to managed switch from model
+                        transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid);
+                        transaction.delete(LogicalDatastoreType.OPERATIONAL, switchIid);
+            }
+        }
+    }
+
+}
index 87464cdbd4fa518c2eeb031298184a2dd0a68242..37256840530ca580f1b06a0c88d8fbd1ecf9dbf6 100644 (file)
@@ -8,18 +8,39 @@
 
 package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundUtil;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalSwitchRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.SwitchesBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+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.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Optional;
+
 public class LogicalSwitchUpdateCommand extends AbstractTransactionCommand {
 
     private static final Logger LOG = LoggerFactory.getLogger(LogicalSwitchUpdateCommand.class);
@@ -35,7 +56,87 @@ public class LogicalSwitchUpdateCommand extends AbstractTransactionCommand {
 
     @Override
     public void execute(ReadWriteTransaction transaction) {
-        // TODO Auto-generated method stub
+        if(updatedLSRows != null && !updatedLSRows.isEmpty()) {
+            for (Entry<UUID, LogicalSwitch> entry : updatedLSRows.entrySet()) {
+                updateLogicalSwitch(transaction, entry.getValue());
+            }
+        }
+    }
+
+    private void updateLogicalSwitch(ReadWriteTransaction transaction, LogicalSwitch lSwitch) {
+        final InstanceIdentifier<Node> connectionIId = getOvsdbConnectionInstance().getInstanceIdentifier();
+        Optional<Node> connection = HwvtepSouthboundUtil.readNode(transaction, connectionIId);
+        if (connection.isPresent()) {
+            LOG.debug("Connection {} is present",connection);
+            Node connectionNode = buildConnectionNode(lSwitch);
+            transaction.merge(LogicalDatastoreType.OPERATIONAL, connectionIId, connectionNode);
+            // Update the Logical Switch with whatever data we are getting
+            InstanceIdentifier<Node> lsIid = getInstanceIdentifier(lSwitch);
+            Node lsNode = buildLogicalSwitchNode(lSwitch);
+            transaction.merge(LogicalDatastoreType.OPERATIONAL, lsIid, lsNode);
+//            TODO: Delete entries that are no longer needed
+        }
+    }
+
+    private Node buildLogicalSwitchNode(LogicalSwitch lSwitch) {
+        NodeBuilder lsNodeBuilder = new NodeBuilder();
+        NodeId psNodeId = getNodeId(lSwitch);
+        lsNodeBuilder.setNodeId(psNodeId);
+        HwvtepLogicalSwitchAugmentationBuilder lsAugBuilder = new HwvtepLogicalSwitchAugmentationBuilder();
+        setManagedBy(lsAugBuilder, lSwitch);
+        setLogicalSwitchId(lsAugBuilder, lSwitch);
+
+        lsNodeBuilder.addAugmentation(HwvtepLogicalSwitchAugmentation.class, lsAugBuilder.build());
+
+        LOG.trace("Built with the intent to store PhysicalSwitch data {}",
+                lsAugBuilder.build());
+        return lsNodeBuilder.build();
+    }
+
+    private void setManagedBy(HwvtepLogicalSwitchAugmentationBuilder lsAugBuilder, LogicalSwitch lSwitch) {
+        // TODO This requires change to yang file
+    }
+
+
+    private void setLogicalSwitchId(HwvtepLogicalSwitchAugmentationBuilder lsAugBuilder, LogicalSwitch lSwitch) {
+        lsAugBuilder.setHwvtepNodeName(new HwvtepNodeName(lSwitch.getName()));
+        if(lSwitch.getDescription() != null) {
+            lsAugBuilder.setHwvtepNodeDescription(lSwitch.getDescription());
+        }
+    }
+
+    private Node buildConnectionNode(LogicalSwitch lSwitch) {
+        //Update node with PhysicalSwitch reference
+        NodeBuilder connectionNode = new NodeBuilder();
+        connectionNode.setNodeId(getOvsdbConnectionInstance().getNodeId());
+
+        HwvtepGlobalAugmentationBuilder hgAugmentationBuilder = new HwvtepGlobalAugmentationBuilder();
+        List<Switches> switches = new ArrayList<>();
+        InstanceIdentifier<Node> switchIid = HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(),
+                        lSwitch);
+        hgAugmentationBuilder.setSwitches(switches);
+        /* FIXME:
+         * TODO: This need to be revisited after fix in yang file.
+         * It should ideally be HwvtepSwitchRef
+         */
+        Switches logicalSwitch = new SwitchesBuilder().setSwitchRef(
+                        new HwvtepPhysicalSwitchRef(switchIid)).build(); 
+        switches.add(logicalSwitch);
+
+        connectionNode.addAugmentation(HwvtepGlobalAugmentation.class, hgAugmentationBuilder.build());
+
+        LOG.debug("Update node with logicalswitch ref {}",
+                hgAugmentationBuilder.getSwitches().iterator().next());
+        return connectionNode.build();
     }
 
+    private InstanceIdentifier<Node> getInstanceIdentifier(LogicalSwitch lSwitch) {
+        return HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(),
+                lSwitch);
+    }
+
+    private NodeId getNodeId(LogicalSwitch lSwitch) {
+        NodeKey nodeKey = getInstanceIdentifier(lSwitch).firstKeyOf(Node.class, NodeKey.class);
+        return nodeKey.getNodeId();
+    }
 }
diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/PhysicalPortRemoveCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/PhysicalPortRemoveCommand.java
new file mode 100644 (file)
index 0000000..c9f276d
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
+import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
+import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalPort;
+import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PhysicalPortRemoveCommand extends AbstractTransactionCommand {
+
+    private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+
+    public PhysicalPortRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates,
+            DatabaseSchema dbSchema) {
+        super(key, updates, dbSchema);
+    }
+
+    @Override
+    public void execute(ReadWriteTransaction transaction) {
+        String portName = null;
+        Collection<PhysicalPort> deletedPortRows = TyperUtils.extractRowsRemoved(PhysicalPort.class, getUpdates(),getDbSchema()).values();
+        Map<UUID, PhysicalSwitch> updatedPSRows = TyperUtils.extractRowsUpdated(PhysicalSwitch.class, getUpdates(),getDbSchema());
+        Map<UUID, PhysicalSwitch> oldPSRows = TyperUtils.extractRowsOld(PhysicalSwitch.class, getUpdates(),getDbSchema());
+        if(deletedPortRows != null && !deletedPortRows.isEmpty()) {
+            for (PhysicalPort pPort : deletedPortRows) {
+                PhysicalSwitch updatedPSwitchData = null;
+                for(UUID pSwitchUUID: updatedPSRows.keySet()) {
+                    PhysicalSwitch oldPSwitchData = oldPSRows.get(pSwitchUUID);
+                    if(oldPSwitchData.getPortsColumn() != null
+                            && oldPSwitchData.getPortsColumn().getData().contains(pPort.getUuidColumn().getData())
+                            && (!updatedPSRows.isEmpty())) {
+                        updatedPSwitchData = updatedPSRows.get(pSwitchUUID);
+                        break;
+                    }
+                }
+                if(updatedPSwitchData == null) {
+                    LOG.warn("PhysicalSwitch not found for port {}", pPort);
+                    continue;
+                }
+                portName = pPort.getName();
+                final InstanceIdentifier<TerminationPoint> nodePath = HwvtepSouthboundMapper
+                        .createInstanceIdentifier(getOvsdbConnectionInstance(), 
+                                updatedPSwitchData).child(
+                                TerminationPoint.class,
+                                new TerminationPointKey(new TpId(portName)));
+                transaction.delete(LogicalDatastoreType.OPERATIONAL, nodePath);
+            }
+        }
+    }
+
+}
index 3585894724c7dca494b65399712b16915a0414c3..780a49dbd37d510d0bae728ca3f55e7f3863e721 100644 (file)
 
 package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
 
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
+import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalPort;
+import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentationBuilder;
+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.global.attributes.Switches;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.PhysicalPortIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindingsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindingsKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
+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.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Optional;
+
 public class PhysicalPortUpdateCommand extends AbstractTransactionCommand {
 
     private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortUpdateCommand.class);
     private Map<UUID, PhysicalPort> updatedPPRows;
     private Map<UUID, PhysicalPort> oldPPRows;
+    private Map<UUID, PhysicalSwitch> switchUpdatedRows;
+    private Map<UUID, LogicalSwitch> lSwitchUpdatedRows;
 
     public PhysicalPortUpdateCommand(HwvtepConnectionInstance key, TableUpdates updates,
             DatabaseSchema dbSchema) {
         super(key, updates, dbSchema);
         updatedPPRows = TyperUtils.extractRowsUpdated(PhysicalPort.class, getUpdates(),getDbSchema());
         oldPPRows = TyperUtils.extractRowsOld(PhysicalPort.class, getUpdates(),getDbSchema());
+        switchUpdatedRows = TyperUtils.extractRowsUpdated(PhysicalSwitch.class, getUpdates(),getDbSchema());
+        lSwitchUpdatedRows = TyperUtils.extractRowsUpdated(LogicalSwitch.class, getUpdates(),getDbSchema());
     }
 
     @Override
     public void execute(ReadWriteTransaction transaction) {
-        // TODO Auto-generated method stub
+        final InstanceIdentifier<Node> connectionIId = getOvsdbConnectionInstance().getInstanceIdentifier();
+        if ( updatedPPRows == null
+                || updatedPPRows.isEmpty()) {
+            return;
+        }
+        LOG.trace("PhysicalPortTable updated: {}", updatedPPRows);
+        Optional<Node> node = readNode(transaction, connectionIId);
+        if (node.isPresent()) {
+            updateTerminationPoints(transaction, node.get());
+            //TODO: Handle Deletion of VLAN Bindings
+        }
+    }
+
+    private void updateTerminationPoints(ReadWriteTransaction transaction, Node node) {
+        for (Entry<UUID, PhysicalPort> pPortUpdate : updatedPPRows.entrySet()) {
+            String portName = null;
+            portName = pPortUpdate.getValue().getNameColumn().getData();
+            Optional<InstanceIdentifier<Node>> switchIid = getTerminationPointSwitch(pPortUpdate.getKey());
+            if (!switchIid.isPresent()) {
+                switchIid = getTerminationPointSwitch( transaction, node, portName);
+            }
+            if (switchIid.isPresent()) {
+                NodeId switchId = HwvtepSouthboundMapper.createManagedNodeId(switchIid.get());
+                TerminationPointKey tpKey = new TerminationPointKey(new TpId(portName));
+                TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
+                tpBuilder.setKey(tpKey);
+                tpBuilder.setTpId(tpKey.getTpId());
+                InstanceIdentifier<TerminationPoint> tpPath =
+                        getInstanceIdentifier(switchIid.get(), pPortUpdate.getValue());
+                HwvtepPhysicalPortAugmentationBuilder tpAugmentationBuilder =
+                        new HwvtepPhysicalPortAugmentationBuilder();
+                buildTerminationPoint(tpAugmentationBuilder,pPortUpdate.getValue());
+                tpBuilder.addAugmentation(HwvtepPhysicalPortAugmentation.class, tpAugmentationBuilder.build());
+                if (oldPPRows.containsKey(pPortUpdate.getKey())) {
+                    transaction.merge(LogicalDatastoreType.OPERATIONAL,
+                            tpPath, tpBuilder.build());
+                } else {
+                    transaction.put(LogicalDatastoreType.OPERATIONAL,
+                            tpPath, tpBuilder.build());
+                }
+            }
+        }
+    }
+
+    private void buildTerminationPoint(HwvtepPhysicalPortAugmentationBuilder tpAugmentationBuilder,
+                    PhysicalPort portUpdate) {
+        updatePhysicalPortId(portUpdate, tpAugmentationBuilder);
+        updatePort(portUpdate, tpAugmentationBuilder);
+    }
+
+    private void updatePort(PhysicalPort portUpdate,
+                    HwvtepPhysicalPortAugmentationBuilder tpAugmentationBuilder) {
+        updateVlanBindings(portUpdate, tpAugmentationBuilder);
+    }
+
+    private void updatePhysicalPortId(PhysicalPort portUpdate,
+                    HwvtepPhysicalPortAugmentationBuilder tpAugmentationBuilder) {
+        PhysicalPortIdBuilder portIdBuilder = new PhysicalPortIdBuilder();
+        portIdBuilder.setHwvtepNodeName(new HwvtepNodeName(portUpdate.getName()));
+        if(portUpdate.getDescription() != null) {
+            portIdBuilder.setHwvtepNodeDescription(portUpdate.getDescription());
+        }
+
+        tpAugmentationBuilder.setPhysicalPortId(portIdBuilder.build());
+    }
+
+    private void updateVlanBindings(PhysicalPort portUpdate,
+                    HwvtepPhysicalPortAugmentationBuilder tpAugmentationBuilder) {
+        Map<Long, UUID> vlanBindings = portUpdate.getVlanBindingsColumn().getData();
+        if(vlanBindings != null && !vlanBindings.isEmpty()) {
+            Set<Long> vlanBindingsKeys = vlanBindings.keySet();
+            List<VlanBindings> vlanBindingsList = new ArrayList<>();
+            UUID vlanBindingValue = null;
+            for(Long vlanBindingKey: vlanBindingsKeys) {
+                vlanBindingValue = vlanBindings.get(vlanBindingKey);
+                if(vlanBindingValue != null && vlanBindingKey != null) {
+                    vlanBindingsList.add(createVlanBinding(portUpdate, vlanBindingKey, vlanBindingValue));
+                }
+            }
+            tpAugmentationBuilder.setVlanBindings(vlanBindingsList);
+        }
+    }
+
+    private VlanBindings createVlanBinding(PhysicalPort portUpdate, Long key, UUID value) {
+        VlanBindingsBuilder vbBuilder = new VlanBindingsBuilder();
+        VlanBindingsKey vbKey = new VlanBindingsKey(new VlanId(key.intValue()));
+        vbBuilder.setKey(vbKey);
+        vbBuilder.setVlanIdKey(vbKey.getVlanIdKey());
+        HwvtepLogicalSwitchRef lSwitchRef = this.getLogicalSwitchRef(value, portUpdate.getUuid());
+        vbBuilder.setLogicalSwitch(lSwitchRef);
+        return vbBuilder.build();
+    }
+
+    private HwvtepLogicalSwitchRef getLogicalSwitchRef( UUID switchUUID, UUID portUUID) {
+            if (lSwitchUpdatedRows.get(switchUUID) != null) {
+                Optional<InstanceIdentifier<Node>> optSwitchIid = Optional.of(HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(),
+                        this.lSwitchUpdatedRows.get(switchUUID)));
+                if(optSwitchIid.isPresent()) {
+                    return new HwvtepLogicalSwitchRef(optSwitchIid.get());
+                }
+            }
+        return null;
+    }
+
+    private Optional<InstanceIdentifier<Node>> getTerminationPointSwitch( UUID portUUID) {
+        for (UUID switchUUID : this.switchUpdatedRows.keySet()) {
+            if (this.switchUpdatedRows.get(switchUUID).getPortsColumn().getData().contains(portUUID)) {
+                return Optional.of(HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(),
+                        this.switchUpdatedRows.get(switchUUID)));
+            }
+        }
+        return Optional.absent();
+    }
+
+    private Optional<InstanceIdentifier<Node>> getTerminationPointSwitch(
+                    final ReadWriteTransaction transaction, Node node, String tpName) {
+                HwvtepGlobalAugmentation hwvtepNode = node.getAugmentation(HwvtepGlobalAugmentation.class);
+                List<Switches> switchNodes = hwvtepNode.getSwitches();
+                for ( Switches managedNodeEntry : switchNodes ) {
+                    @SuppressWarnings("unchecked")
+                    Node switchNode = readNode(transaction,
+                            (InstanceIdentifier<Node>)managedNodeEntry.getSwitchRef().getValue()).get();
+                    TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
+                    TerminationPointKey tpKey = new TerminationPointKey(new TpId(tpName));
+                    tpBuilder.setKey(tpKey);
+                    if (switchNode.getTerminationPoint() != null
+                            && switchNode.getTerminationPoint().contains(tpBuilder.build())) {
+                        PhysicalSwitchAugmentation pSwitchAugment
+                            = switchNode.getAugmentation(PhysicalSwitchAugmentation.class);
+                        return Optional.of((InstanceIdentifier<Node>)managedNodeEntry.getSwitchRef().getValue());
+                    }
+                }
+                return Optional.absent();
+            }
+
+    private Optional<Node> readNode(final ReadWriteTransaction transaction, final InstanceIdentifier<Node> nodePath) {
+        Optional<Node> node = Optional.absent();
+        try {
+            node = transaction.read(
+                    LogicalDatastoreType.OPERATIONAL, nodePath)
+                    .checkedGet();
+        } catch (final ReadFailedException e) {
+            LOG.warn("Read Operational/DS for Node fail! {}",
+                    nodePath, e);
+        }
+        return node;
+    }
+
+    private InstanceIdentifier<TerminationPoint> getInstanceIdentifier(InstanceIdentifier<Node> switchIid,
+                    PhysicalPort pPort) {
+        return switchIid.child(TerminationPoint.class, new TerminationPointKey(new TpId(pPort.getName())));
     }
 
 }
index aef9a9763fd078f7f2c4304265546b2bf9901122..54212d84c8cf148a008ff6675ebbce1d5072b722 100644 (file)
@@ -108,7 +108,7 @@ public class PhysicalSwitchUpdateCommand extends AbstractTransactionCommand {
 
         psNodeBuilder.addAugmentation(PhysicalSwitchAugmentation.class, psAugmentationBuilder.build());
 
-        LOG.trace("Built with the intent to store bridge data {}",
+        LOG.trace("Built with the intent to store PhysicalSwitch data {}",
                 psAugmentationBuilder.build());
         return psNodeBuilder.build();
     }
index d629dbd455780f6a5e72b7042dc5d9042dc938a8..7c98745706c4ecfe68e6aa76d9a51258f7b4e7ae 100755 (executable)
@@ -29,7 +29,7 @@
             "id":"18032e93-3bc5-9976-4525-fe1e77e98207",
             "name":"Delete Specific Config Logical Switch",
             "description":"This restconf request delete specific logical switch from the config data store.",
-            "url":"http://odl:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F192.168.1.115:6640%2Flogicalswitch%2Fls0",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Flogicalswitch%2Fls0",
             "method":"DELETE",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
             "data":[],
@@ -43,7 +43,7 @@
             "id":"22354294-1d01-cebf-180c-d609747be9bc",
             "name":"Get All Operational Topology",
             "description":"This restconf request will fetch the operational topology. Operational topology details are fetch by hwvtepsouthbound plugin from all the connected hwvtep node.",
-            "url":"http://odl:8181/restconf/operational/network-topology:network-topology/",
+            "url":"http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
             "data":[],
             "id":"538c71b3-e3e6-f01b-cc4c-d2b686686aa8",
             "name":"Get Specific Operational Logical Switch",
             "description":"This restconf request fetch the operational for specific Logical Switch",
-            "url":"http://odl:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F192.168.1.115:6640%2logicalswitch%2ls0",
+            "url":"http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2logicalswitch%2ls0",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://192.168.1.115:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\"\n        }\n    ]\n}",
+            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\"\n        }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"6de1ede7-817c-ccbb-3df9-ef510bdaf583",
             "name":"Create Specific Config HwvtepNode",
             "description":"Fire this Restconf request if you want to initiate the connection to hwvtep node from controller. It assumes that hwvtep node is listening for tcp connection in passive mode.",
-            "url":"http://odl:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/",
             "method":"POST",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://192.168.1.115:6640\",\n            \"connection-info\": {\n              \"ovsdb:remote-port\": 6640,\n              \"ovsdb:remote-ip\": \"192.168.1.115\"\n            }\n        }\n    ]\n}",
+            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n            \"connection-info\": {\n              \"hwvtep:remote-port\": 6640,\n              \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n            }\n        }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"6e7c88e4-485d-ab9f-4c3a-cc235e022905",
             "name":"Update Specific Config HwvtepNode",
             "description":"Fire this Restconf request if you want to update the connection to Hwvtep node from controller.",
-            "url":"http://odl:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F192.168.1.115:6640",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640",
             "method":"PUT",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://192.168.1.115:6640\",\n            \"connection-info\": {\n              \"ovsdb:remote-port\": 6640,\n              \"ovsdb:remote-ip\": \"192.168.1.115\"\n            }\n        }\n    ]\n}",
+            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n            \"connection-info\": {\n              \"hwvtep:remote-port\": 6640,\n              \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n            }\n        }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"92ee7422-5b08-6d63-2b95-961ec0e18ffa",
             "name":"Get Specific Config HwvtepNode",
             "description":"This restconf request fetch the configration for specific hwvtep node.",
-            "url":"http://odl:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F192.168.1.115:6640",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://192.168.1.115:6640\",\n            \"connection-info\": {\n              \"ovsdb:remote-port\": 6640,\n              \"ovsdb:remote-ip\": \"192.168.1.115\"\n            }\n        }\n    ]\n}",
+            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n            \"connection-info\": {\n              \"hwvtep:remote-port\": 6640,\n              \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n            }\n        }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"9bc22ca7-049c-af51-7c12-6bf71044b2ec",
             "name":"Create Specific Config Logical Switch",
             "description":"Fire this Restconf request if you want to create a logical switch.",
-            "url":"http://odl:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/",
             "method":"POST",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://192.168.1.115:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\",\n            \"managed-by\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://192.168.1.115:6640']\"             \n        }\n    ]\n}",
+            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\",\n            \"managed-by\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']\"             \n        }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"c8e8f3fd-3bfb-aafa-e3ec-a671a942f426",
             "name":"Get Operational Hwvtep Topology",
             "description":"",
-            "url":"http://odl:8181/restconf/operational/network-topology:network-topology/hwvtep:1/",
+            "url":"http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://192.168.1.115:6640\",\n            \"connection-info\": {\n              \"ovsdb:remote-port\": 6640,\n              \"ovsdb:remote-ip\": \"192.168.1.115\"\n            }\n        }\n    ]\n}",
+            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n            \"connection-info\": {\n              \"hwvtep:remote-port\": 6640,\n              \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n            }\n        }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"d362ddc4-1c5f-67d5-e354-c2a8d2ba9d79",
             "name":"Get Specific Operational HwvtepNode",
             "description":"This restconf request fetch the operational for specific HwvtepNode",
-            "url":"http://odl:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F192.168.1.115:6640",
+            "url":"http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://192.168.1.115:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\"\n        }\n    ]\n}",
+            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\"\n        }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"e92ac963-daaf-0899-c3e8-a00d897be0e2",
             "name":"Delete Specific Config HwvtepNode",
             "description":"This restconf request delete any node (ovsdb node or bridge node) from the config data store. You can use the same request to delete the ovsdb node by using the following URI: http://localhost:8080/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F10.10.10.10:22222",
-            "url":"http://odl:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F219.141.189.115:6640",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640",
             "method":"DELETE",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
             "data":[],
             "id":"e9ff6957-4dc2-9257-c0c6-21560bfd5de2",
             "name":"Get All Config Topology",
             "description":"Fetch all the config topology from configuration data store.",
-            "url":"http://odl:8181/restconf/config/network-topology:network-topology/",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://219.141.189.115:6640\",\n            \"connection-info\": {\n              \"ovsdb:remote-port\": 6640,\n              \"ovsdb:remote-ip\": \"219.141.189.115\"\n            }\n        }\n    ]\n}",
+            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n            \"connection-info\": {\n              \"hwvtep:remote-port\": 6640,\n              \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n            }\n        }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"ee151670-85a0-30ec-b22b-5defe7b66e0b",
             "name":"Get Config  Hwvtep Topology",
             "description":"Fetch the config hwvtep topology from configuration data store.",
-            "url":"http://odl:8181/restconf/config/network-topology:network-topology/hwvtep:1/",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/hwvtep:1/",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://192.168.1.115:6640\",\n            \"connection-info\": {\n              \"ovsdb:remote-port\": 6640,\n              \"ovsdb:remote-ip\": \"192.168.1.115\"\n            }\n        }\n    ]\n}",
+            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n            \"connection-info\": {\n              \"hwvtep:remote-port\": 6640,\n              \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n            }\n        }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"f6d300f7-380a-d090-0d4a-2b2ddefe5104",
             "name":"Create Specific Config Logical Switch",
             "description":"Fire this request if you want to update specific logical switch.",
-            "url":"http://odl:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F192.168.1.115:6640%2Flogicalswitch%2Fls0",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Flogicalswitch%2Fls0",
             "method":"PUT",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://192.168.1.115:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\",\n            \"managed-by\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://192.168.1.115:6640']\"             \n        }\n    ]\n}",
+            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\",\n            \"managed-by\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']\"             \n        }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"f9f71d74-a49d-b190-d929-b6772ce0ba73",
             "name":"Get Specific Config Logical Switch",
             "description":"This restconf request fetch configuration for specific logical switch.",
-            "url":"http://odl:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F192.168.1.115:6640%2Flogicalswitch%2Fls0",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Flogicalswitch%2Fls0",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://192.168.1.115:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\"\n        }\n    ]\n}",
+            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\"\n        }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,