2 * Copyright (c) 2015 - 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
11 import java.util.Collection;
12 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
15 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
16 import org.opendaylight.ovsdb.lib.message.TableUpdates;
17 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
18 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
19 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocator;
20 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
21 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 public class HwvtepPhysicalLocatorRemoveCommand extends AbstractTransactionCommand {
26 public HwvtepPhysicalLocatorRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates,
27 DatabaseSchema dbSchema) {
28 super(key, updates, dbSchema);
32 public void execute(ReadWriteTransaction transaction) {
33 Collection<PhysicalLocator> deletedPLRows =
34 TyperUtils.extractRowsRemoved(PhysicalLocator.class, getUpdates(), getDbSchema()).values();
35 for (PhysicalLocator locator : deletedPLRows) {
36 final InstanceIdentifier<Node> connectionIId = getOvsdbConnectionInstance().getInstanceIdentifier();
37 final InstanceIdentifier<TerminationPoint> nodePath = HwvtepSouthboundMapper
38 .createInstanceIdentifier(connectionIId, locator);
39 transaction.delete(LogicalDatastoreType.OPERATIONAL, nodePath);
40 getOvsdbConnectionInstance().getDeviceInfo().clearDeviceOperData(TerminationPoint.class, nodePath);
42 //TODO: Check if any cleanup is required