2 * Copyright (c) 2016, 2017 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
8 package org.opendaylight.netvirt.elan.l2gw.ha.commands;
10 import java.util.ArrayList;
11 import java.util.List;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitchesBuilder;
18 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
19 import org.opendaylight.yangtools.yang.binding.Identifier;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
22 public class LogicalSwitchesCmd extends MergeCommand<LogicalSwitches,
23 HwvtepGlobalAugmentationBuilder, HwvtepGlobalAugmentation> {
25 public LogicalSwitchesCmd() {
30 public List<LogicalSwitches> getData(HwvtepGlobalAugmentation node) {
31 if (node != null && node.getLogicalSwitches() != null) {
32 return new ArrayList<LogicalSwitches>(node.nonnullLogicalSwitches().values());
38 public void setData(HwvtepGlobalAugmentationBuilder builder, List<LogicalSwitches> data) {
39 builder.setLogicalSwitches(data);
43 public InstanceIdentifier<LogicalSwitches> generateId(InstanceIdentifier<Node> id, LogicalSwitches node) {
44 return id.augmentation(HwvtepGlobalAugmentation.class).child(LogicalSwitches.class, node.key());
48 public LogicalSwitches transform(InstanceIdentifier<Node> nodePath, LogicalSwitches src) {
49 LogicalSwitchesBuilder logicalSwitchesBuilder = new LogicalSwitchesBuilder(src);
50 logicalSwitchesBuilder.setLogicalSwitchUuid(HwvtepHAUtil.getUUid(src.getHwvtepNodeName().getValue()));
51 return logicalSwitchesBuilder.build();
55 public Identifier getKey(LogicalSwitches data) {
60 public String getDescription() {
61 return "LogicalSwitches";
65 public boolean areEqual(LogicalSwitches updated, LogicalSwitches orig) {
66 return updated.getHwvtepNodeName().getValue().equals(orig.getHwvtepNodeName().getValue());
70 public LogicalSwitches withoutUuid(LogicalSwitches data) {
71 return new LogicalSwitchesBuilder(data).setLogicalSwitchUuid(null).build();