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 org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentationBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsKey;
18 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
19 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
20 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
21 import org.opendaylight.yangtools.yang.binding.Identifier;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 public class TunnelCmd extends MergeCommand<Tunnels, PhysicalSwitchAugmentationBuilder, PhysicalSwitchAugmentation> {
30 public List<Tunnels> getData(PhysicalSwitchAugmentation node) {
32 return node.getTunnels();
38 public void setData(PhysicalSwitchAugmentationBuilder builder, List<Tunnels> data) {
39 builder.setTunnels(data);
43 public InstanceIdentifier<Tunnels> generateId(InstanceIdentifier<Node> id, Tunnels src) {
44 HwvtepPhysicalLocatorRef hwvtepPhysicalLocatorRef =
45 HwvtepHAUtil.convertLocatorRef(src.getLocalLocatorRef(), id);
46 HwvtepPhysicalLocatorRef hwvtepPhysicalLocatorRef1 =
47 HwvtepHAUtil.convertLocatorRef(src.getRemoteLocatorRef(), id);
48 TunnelsKey key = new TunnelsKey(hwvtepPhysicalLocatorRef, hwvtepPhysicalLocatorRef1);
49 return id.augmentation(PhysicalSwitchAugmentation.class).child(Tunnels.class, key);
53 public Tunnels transform(InstanceIdentifier<Node> nodePath, Tunnels src) {
54 TunnelsBuilder tunnelsBuilder = new TunnelsBuilder(src);
55 tunnelsBuilder.setLocalLocatorRef(HwvtepHAUtil.convertLocatorRef(src.getLocalLocatorRef(), nodePath));
56 tunnelsBuilder.setRemoteLocatorRef(HwvtepHAUtil.convertLocatorRef(src.getRemoteLocatorRef(), nodePath));
57 tunnelsBuilder.setTunnelUuid(HwvtepHAUtil.getUUid(HwvtepHAUtil.getTepIpVal(src.getRemoteLocatorRef())));
58 HwvtepPhysicalLocatorRef hwvtepPhysicalLocatorRef =
59 HwvtepHAUtil.convertLocatorRef(src.getLocalLocatorRef(), nodePath);
60 HwvtepPhysicalLocatorRef hwvtepPhysicalLocatorRef1 =
61 HwvtepHAUtil.convertLocatorRef(src.getRemoteLocatorRef(), nodePath);
63 tunnelsBuilder.setKey(new TunnelsKey(hwvtepPhysicalLocatorRef,hwvtepPhysicalLocatorRef1));
64 return tunnelsBuilder.build();
68 public Identifier getKey(Tunnels data) {
73 public String getDescription() {
78 public boolean areEqual(Tunnels updated, Tunnels orig) {
79 InstanceIdentifier<TerminationPoint> remoteLocatorRefUpdated = (InstanceIdentifier<TerminationPoint>)
80 updated.getRemoteLocatorRef().getValue();
81 InstanceIdentifier<TerminationPoint> remoteLocatorRefOriginal = (InstanceIdentifier<TerminationPoint>)
82 orig.getRemoteLocatorRef().getValue();
83 TpId tpId1 = remoteLocatorRefUpdated.firstKeyOf(TerminationPoint.class).getTpId();
84 TpId tpId2 = remoteLocatorRefOriginal.firstKeyOf(TerminationPoint.class).getTpId();
85 return tpId1.equals(tpId2);
89 public Tunnels withoutUuid(Tunnels data) {
90 return new TunnelsBuilder(data).setTunnelUuid(null).build();