Added Update and Remove commands code
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / transactions / md / LogicalSwitchRemoveCommand.java
index 388d158d736b4d455ab9237a4e1d03dc43ee6c8b..fde28381ff877da82e3995b2590f7dd0ae381ae3 100644 (file)
@@ -12,16 +12,14 @@ 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.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.hwvtep.global.attributes.LogicalSwitches;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitchesKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -40,18 +38,10 @@ public class LogicalSwitchRemoveCommand extends AbstractTransactionCommand {
         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()
+                InstanceIdentifier<LogicalSwitches> 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);
+                                .child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName(lSwitch.getName())));
+                        // TODO Delete any references
                         transaction.delete(LogicalDatastoreType.OPERATIONAL, switchIid);
             }
         }