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.List;
11 import java.util.Objects;
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.HwvtepLogicalSwitchRef;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacsBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacsKey;
22 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
23 import org.opendaylight.yangtools.yang.binding.Identifier;
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
26 public class RemoteUcastCmd extends MergeCommand<RemoteUcastMacs,
27 HwvtepGlobalAugmentationBuilder, HwvtepGlobalAugmentation> {
29 public RemoteUcastCmd() {
34 public List<RemoteUcastMacs> getData(HwvtepGlobalAugmentation node) {
36 return node.getRemoteUcastMacs();
42 public void setData(HwvtepGlobalAugmentationBuilder builder, List<RemoteUcastMacs> data) {
43 builder.setRemoteUcastMacs(data);
47 public InstanceIdentifier<RemoteUcastMacs> generateId(InstanceIdentifier<Node> id, RemoteUcastMacs node) {
48 HwvtepLogicalSwitchRef lsRef = HwvtepHAUtil.convertLogicalSwitchRef(node.key().getLogicalSwitchRef(), id);
49 RemoteUcastMacsKey key = new RemoteUcastMacsKey(lsRef, node.getMacEntryKey());
50 return id.augmentation(HwvtepGlobalAugmentation.class).child(RemoteUcastMacs.class, key);
54 public RemoteUcastMacs transform(InstanceIdentifier<Node> nodePath, RemoteUcastMacs src) {
55 RemoteUcastMacsBuilder ucmlBuilder = new RemoteUcastMacsBuilder(src);
56 ucmlBuilder.setLocatorRef(HwvtepHAUtil.convertLocatorRef(src.getLocatorRef(), nodePath));
57 ucmlBuilder.setLogicalSwitchRef(HwvtepHAUtil.convertLogicalSwitchRef(src.getLogicalSwitchRef(), nodePath));
58 ucmlBuilder.setMacEntryUuid(HwvtepHAUtil.getUUid(src.getMacEntryKey().getValue()));
60 RemoteUcastMacsKey key = new RemoteUcastMacsKey(ucmlBuilder.getLogicalSwitchRef(),
61 ucmlBuilder.getMacEntryKey());
62 ucmlBuilder.withKey(key);
64 return ucmlBuilder.build();
68 public Identifier getKey(RemoteUcastMacs data) {
73 public String getDescription() {
74 return "RemoteUcastMacs";
78 public boolean areEqual(RemoteUcastMacs updated, RemoteUcastMacs orig) {
79 InstanceIdentifier<?> updatedMacRefIdentifier = updated.getLogicalSwitchRef().getValue();
80 HwvtepNodeName updatedMacNodeName = updatedMacRefIdentifier.firstKeyOf(LogicalSwitches.class)
82 InstanceIdentifier<?> origMacRefIdentifier = orig.getLogicalSwitchRef().getValue();
83 HwvtepNodeName origMacNodeName = origMacRefIdentifier.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName();
84 return Objects.equals(updated.getMacEntryKey(), orig.getMacEntryKey())
85 && updatedMacNodeName.equals(origMacNodeName);
89 public RemoteUcastMacs withoutUuid(RemoteUcastMacs data) {
90 return new RemoteUcastMacsBuilder(data).setMacEntryUuid(null).build();