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.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.Manager;
19 import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersKey;
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 public class HwvtepManagerRemoveCommand extends AbstractTransactionCommand {
30 private static final Logger LOG = LoggerFactory.getLogger(HwvtepManagerRemoveCommand.class);
32 public HwvtepManagerRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates,
33 DatabaseSchema dbSchema) {
34 super(key, updates, dbSchema);
38 public void execute(ReadWriteTransaction transaction) {
39 Collection<Manager> deletedManagerRows =
40 TyperUtils.extractRowsRemoved(Manager.class, getUpdates(),getDbSchema()).values();
41 for (Manager manager : deletedManagerRows) {
42 InstanceIdentifier<Managers> managerIid = getOvsdbConnectionInstance().getInstanceIdentifier()
43 .augmentation(HwvtepGlobalAugmentation.class)
44 .child(Managers.class, new ManagersKey(new Uri(manager.getTargetColumn().getData())));
45 // TODO Delete any references
46 transaction.delete(LogicalDatastoreType.OPERATIONAL, managerIid);
47 addToDeviceUpdate(TransactionType.DELETE, manager);
48 LOG.info("DEVICE - {} {}", TransactionType.DELETE, manager);