78e28a113e498ef8600cbfaec8e5a8e0e0d10db7
[netvirt.git] / elanmanager / impl / src / main / java / org / opendaylight / netvirt / elan / l2gw / ha / handlers / ConfigNodeUpdatedHandler.java
1 /*
2  * Copyright (c) 2016 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 package org.opendaylight.netvirt.elan.l2gw.ha.handlers;
9
10 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
11 import org.opendaylight.genius.infra.Datastore.Configuration;
12 import org.opendaylight.genius.infra.TypedReadWriteTransaction;
13 import org.opendaylight.netvirt.elan.l2gw.ha.merge.GlobalAugmentationMerger;
14 import org.opendaylight.netvirt.elan.l2gw.ha.merge.GlobalNodeMerger;
15 import org.opendaylight.netvirt.elan.l2gw.ha.merge.PSAugmentationMerger;
16 import org.opendaylight.netvirt.elan.l2gw.ha.merge.PSNodeMerger;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
19 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
21
22 public class ConfigNodeUpdatedHandler {
23     GlobalAugmentationMerger globalAugmentationMerger = GlobalAugmentationMerger.getInstance();
24     PSAugmentationMerger psAugmentationMerger = PSAugmentationMerger.getInstance();
25     GlobalNodeMerger globalNodeMerger = GlobalNodeMerger.getInstance();
26     PSNodeMerger psNodeMerger = PSNodeMerger.getInstance();
27
28     /**
29      * Copy updated data from HA node to child node of config data tree.
30      *
31      * @param haChildNodeId HA child node which needs to be updated
32      * @param mod the data object modification
33      * @param tx Transaction
34      */
35     public void copyHAGlobalUpdateToChild(InstanceIdentifier<Node> haChildNodeId,
36                                           DataObjectModification<Node> mod,
37                                           TypedReadWriteTransaction<Configuration> tx) {
38         globalAugmentationMerger.mergeConfigUpdate(haChildNodeId,
39                 mod.getModifiedAugmentation(HwvtepGlobalAugmentation.class), tx);
40         globalNodeMerger.mergeConfigUpdate(haChildNodeId, mod, tx);
41     }
42
43     /**
44      * Copy HA ps node update to HA child ps node of config data tree.
45      *
46      * @param haChildNodeId HA child node which needs to be updated
47      * @param mod the data object modification
48      * @param tx Transaction
49      */
50     public void copyHAPSUpdateToChild(InstanceIdentifier<Node> haChildNodeId,
51                                       DataObjectModification<Node> mod,
52                                       TypedReadWriteTransaction<Configuration> tx) {
53
54         psAugmentationMerger.mergeConfigUpdate(haChildNodeId,
55                 mod.getModifiedAugmentation(PhysicalSwitchAugmentation.class), tx);
56         psNodeMerger.mergeConfigUpdate(haChildNodeId, mod, tx);
57     }
58
59 }