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.mdsal.binding.api.ReadWriteTransaction;
13 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
14 import org.opendaylight.ovsdb.lib.message.TableUpdates;
15 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
16 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
17 import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
18 import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitchesKey;
23 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
25 public class HwvtepLogicalSwitchRemoveCommand extends AbstractTransactionCommand<LogicalSwitches> {
27 public HwvtepLogicalSwitchRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates,
28 DatabaseSchema dbSchema) {
29 super(key, updates, dbSchema);
33 public void execute(ReadWriteTransaction transaction) {
34 Collection<LogicalSwitch> deletedLSRows =
35 TyperUtils.extractRowsRemoved(LogicalSwitch.class, getUpdates(), getDbSchema()).values();
36 for (LogicalSwitch logicalSwitch : deletedLSRows) {
37 InstanceIdentifier<LogicalSwitches> switchIid = getOvsdbConnectionInstance().getInstanceIdentifier()
38 .augmentation(HwvtepGlobalAugmentation.class)
39 .child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName(logicalSwitch.getName())));
40 // TODO Delete any references
41 addToDeleteTx(transaction, LogicalSwitches.class, switchIid, logicalSwitch.getUuid());
42 addToDeviceUpdate(TransactionType.DELETE, logicalSwitch);