2 * Copyright © 2017 Hewlett Packard Enterprise, Co. 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.mdsal.common.api.LogicalDatastoreType;
14 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
15 import org.opendaylight.ovsdb.lib.message.TableUpdates;
16 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
17 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
18 import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalRouter;
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.LogicalRouters;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalRoutersKey;
23 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 public class HwvtepLogicalRouterRemoveCommand extends AbstractTransactionCommand<LogicalRouters> {
28 private static final Logger LOG = LoggerFactory.getLogger(HwvtepLogicalRouterRemoveCommand.class);
30 public HwvtepLogicalRouterRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates,
31 DatabaseSchema dbSchema) {
32 super(key, updates, dbSchema);
36 public void execute(ReadWriteTransaction transaction) {
37 Collection<LogicalRouter> deletedLRRows =
38 TyperUtils.extractRowsRemoved(LogicalRouter.class, getUpdates(), getDbSchema()).values();
39 if (deletedLRRows != null) {
40 for (LogicalRouter router : deletedLRRows) {
41 HwvtepNodeName routerNode = new HwvtepNodeName(router.getName());
42 LOG.debug("Clearing device operational data for logical router {}", routerNode);
43 InstanceIdentifier<LogicalRouters> routerIid = getOvsdbConnectionInstance().getInstanceIdentifier()
44 .augmentation(HwvtepGlobalAugmentation.class)
45 .child(LogicalRouters.class, new LogicalRoutersKey(routerNode));
46 transaction.delete(LogicalDatastoreType.OPERATIONAL, routerIid);
47 getOvsdbConnectionInstance().getDeviceInfo().clearDeviceOperData(LogicalRouters.class, routerIid);