2 * Copyright (c) 2015 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.LogicalSwitch;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalSwitchRef;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.SwitchesKey;
24 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
25 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
29 public class LogicalSwitchRemoveCommand extends AbstractTransactionCommand {
31 private static final Logger LOG = LoggerFactory.getLogger(LogicalSwitchRemoveCommand.class);
33 public LogicalSwitchRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates,
34 DatabaseSchema dbSchema) {
35 super(key, updates, dbSchema);
39 public void execute(ReadWriteTransaction transaction) {
40 Collection<LogicalSwitch> deletedLSRows = TyperUtils.extractRowsRemoved(LogicalSwitch.class, getUpdates(),getDbSchema()).values();
41 if(deletedLSRows != null && !deletedLSRows.isEmpty()) {
42 for (LogicalSwitch lSwitch : deletedLSRows) {
43 InstanceIdentifier<Node> nodeIid = HwvtepSouthboundMapper.createInstanceIdentifier(
44 getOvsdbConnectionInstance(), lSwitch);
47 * Once hwvtep.yang is modified, replace HwvtepPhysicalSwitchRef with appropriate
48 * class [HWvtepSwitchRef].
50 InstanceIdentifier<Switches> switchIid = getOvsdbConnectionInstance().getInstanceIdentifier()
51 .augmentation(HwvtepGlobalAugmentation.class)
52 .child(Switches.class, new SwitchesKey(new HwvtepPhysicalSwitchRef(nodeIid)));
53 // TODO handle removal of reference to managed switch from model
54 transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid);
55 transaction.delete(LogicalDatastoreType.OPERATIONAL, switchIid);