Upgrade ietf-{inet,yang}-types to 2013-07-15
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / transactions / md / HwvtepManagerRemoveCommand.java
1 /*
2  * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
10
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.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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
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.hwvtep.global.attributes.Managers;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersKey;
23 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 public class HwvtepManagerRemoveCommand extends AbstractTransactionCommand {
28
29     private static final Logger LOG = LoggerFactory.getLogger(HwvtepManagerRemoveCommand.class);
30
31     public HwvtepManagerRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates,
32             DatabaseSchema dbSchema) {
33         super(key, updates, dbSchema);
34     }
35
36     @Override
37     public void execute(ReadWriteTransaction transaction) {
38         Collection<Manager> deletedManagerRows = TyperUtils.extractRowsRemoved(Manager.class, getUpdates(),getDbSchema()).values();
39         for (Manager manager : deletedManagerRows) {
40             InstanceIdentifier<Managers> managerIid = getOvsdbConnectionInstance().getInstanceIdentifier()
41                             .augmentation(HwvtepGlobalAugmentation.class)
42                             .child(Managers.class, new ManagersKey(new Uri(manager.getTargetColumn().getData())));
43                     // TODO Delete any references
44                     transaction.delete(LogicalDatastoreType.OPERATIONAL, managerIid);
45         }
46     }
47
48 }