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 java.util.Objects;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacsBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacsKey;
23 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
24 import org.opendaylight.yangtools.yang.binding.Identifier;
25 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 public class RemoteUcastCmd extends MergeCommand<RemoteUcastMacs,
28 HwvtepGlobalAugmentationBuilder, HwvtepGlobalAugmentation> {
30 public RemoteUcastCmd() {
35 public List<RemoteUcastMacs> getData(HwvtepGlobalAugmentation node) {
36 if (node != null && node.nonnullRemoteUcastMacs() != null) {
37 return new ArrayList<RemoteUcastMacs>(node.nonnullRemoteUcastMacs().values());
43 public void setData(HwvtepGlobalAugmentationBuilder builder, List<RemoteUcastMacs> data) {
44 builder.setRemoteUcastMacs(data);
48 public InstanceIdentifier<RemoteUcastMacs> generateId(InstanceIdentifier<Node> id, RemoteUcastMacs node) {
49 HwvtepLogicalSwitchRef lsRef = HwvtepHAUtil.convertLogicalSwitchRef(node.key().getLogicalSwitchRef(), id);
50 RemoteUcastMacsKey key = new RemoteUcastMacsKey(lsRef, node.getMacEntryKey());
51 return id.augmentation(HwvtepGlobalAugmentation.class).child(RemoteUcastMacs.class, key);
55 public RemoteUcastMacs transform(InstanceIdentifier<Node> nodePath, RemoteUcastMacs src) {
56 RemoteUcastMacsBuilder ucmlBuilder = new RemoteUcastMacsBuilder(src);
57 ucmlBuilder.setLocatorRef(HwvtepHAUtil.convertLocatorRef(src.getLocatorRef(), nodePath));
58 ucmlBuilder.setLogicalSwitchRef(HwvtepHAUtil.convertLogicalSwitchRef(src.getLogicalSwitchRef(), nodePath));
59 ucmlBuilder.setMacEntryUuid(HwvtepHAUtil.getUUid(src.getMacEntryKey().getValue()));
61 RemoteUcastMacsKey key = new RemoteUcastMacsKey(ucmlBuilder.getLogicalSwitchRef(),
62 ucmlBuilder.getMacEntryKey());
63 ucmlBuilder.withKey(key);
65 return ucmlBuilder.build();
69 public Identifier getKey(RemoteUcastMacs data) {
74 public String getDescription() {
75 return "RemoteUcastMacs";
79 public boolean areEqual(RemoteUcastMacs updated, RemoteUcastMacs orig) {
80 InstanceIdentifier<?> updatedMacRefIdentifier = updated.getLogicalSwitchRef().getValue();
81 HwvtepNodeName updatedMacNodeName = updatedMacRefIdentifier.firstKeyOf(LogicalSwitches.class)
83 InstanceIdentifier<?> origMacRefIdentifier = orig.getLogicalSwitchRef().getValue();
84 HwvtepNodeName origMacNodeName = origMacRefIdentifier.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName();
85 return Objects.equals(updated.getMacEntryKey(), orig.getMacEntryKey())
86 && updatedMacNodeName.equals(origMacNodeName);
90 public RemoteUcastMacs withoutUuid(RemoteUcastMacs data) {
91 return new RemoteUcastMacsBuilder(data).setMacEntryUuid(null).build();