2 * Copyright (c) 2015 CableLabs 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.unimgr.impl;
10 import java.util.List;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
16 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.LinkId;
17 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
18 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
19 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
20 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
21 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
22 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
23 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey;
24 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
25 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
26 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
27 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
28 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
30 public class UnimgrMapper {
32 public static InstanceIdentifier<Link> getEvcLinkIID(LinkId id) {
33 InstanceIdentifier<Link> linkPath = InstanceIdentifier
34 .create(NetworkTopology.class)
35 .child(Topology.class,
36 new TopologyKey(UnimgrConstants.EVC_TOPOLOGY_ID))
42 public static InstanceIdentifier<Topology> getEvcTopologyIid() {
43 InstanceIdentifier<Topology> topoPath = InstanceIdentifier
44 .create(NetworkTopology.class)
45 .child(Topology.class,
46 new TopologyKey(UnimgrConstants.EVC_TOPOLOGY_ID));
50 public static InstanceIdentifier<Node> getEvcTopologyNodeIid() {
51 InstanceIdentifier<Node> nodePath = InstanceIdentifier
52 .create(NetworkTopology.class)
53 .child(Topology.class,
54 new TopologyKey(UnimgrConstants.EVC_TOPOLOGY_ID))
59 public static InstanceIdentifier<Node> getOvsdbBridgeNodeIid(NodeId ovsdbNode,
61 String ovsdbNodeId = ovsdbNode.getValue();
62 NodeId bridgeNodeId = new NodeId(ovsdbNodeId
63 + UnimgrConstants.DEFAULT_BRIDGE_NODE_ID_SUFFIX
65 InstanceIdentifier<Node> nodePath = InstanceIdentifier
66 .create(NetworkTopology.class)
67 .child(Topology.class,
68 new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
70 new NodeKey(bridgeNodeId));
74 public static InstanceIdentifier<Node> getOvsdbNodeIid(IpAddress ipAddress) {
75 String nodeId = UnimgrConstants.OVSDB_PREFIX
76 + ipAddress.getIpv4Address().getValue().toString()
78 + UnimgrConstants.OVSDB_PORT;
79 InstanceIdentifier<Node> nodePath = InstanceIdentifier
80 .create(NetworkTopology.class)
81 .child(Topology.class,
82 new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
84 new NodeKey(new NodeId(nodeId)));
88 public static InstanceIdentifier<Node> getOvsdbNodeIid(NodeId nodeId) {
89 InstanceIdentifier<Node> nodePath = InstanceIdentifier
90 .create(NetworkTopology.class)
91 .child(Topology.class,
92 new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
98 public static InstanceIdentifier<Topology> getOvsdbTopologyIid() {
99 InstanceIdentifier<Topology> topoPath = InstanceIdentifier
100 .create(NetworkTopology.class)
101 .child(Topology.class,
102 new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID));
106 public static InstanceIdentifier<TerminationPoint> getTerminationPointIid(
109 InstanceIdentifier<TerminationPoint> terminationPointPath =
111 .create(NetworkTopology.class)
112 .child(Topology.class,
113 new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
114 .child(Node.class, bridgeNode.getKey())
115 .child(TerminationPoint.class,
116 new TerminationPointKey(new TpId(portName)));
117 return terminationPointPath;
120 public static InstanceIdentifier<Node> getUniIid(DataBroker dataBroker,
122 List<Node> uniNodes = UnimgrUtils.getUniNodes(dataBroker,
123 LogicalDatastoreType.OPERATIONAL);
124 for (Node node : uniNodes) {
125 UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
126 if (uniAugmentation.getIpAddress().equals(ip)) {
127 InstanceIdentifier<Node> uniNode = InstanceIdentifier
128 .create(NetworkTopology.class)
129 .child(Topology.class,
130 new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID))
132 new NodeKey(node.getKey()));
139 public static InstanceIdentifier<Node> getUniIid(DataBroker dataBroker,
141 LogicalDatastoreType store) {
142 List<Node> uniNodes = UnimgrUtils.getUniNodes(dataBroker,
144 for (Node node : uniNodes) {
145 UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
146 if (uniAugmentation.getIpAddress().equals(ip)) {
147 InstanceIdentifier<Node> uniNode = InstanceIdentifier
148 .create(NetworkTopology.class)
149 .child(Topology.class,
150 new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID))
152 new NodeKey(node.getKey()));
159 public static InstanceIdentifier<Topology> getUniTopologyIid() {
160 InstanceIdentifier<Topology> topoPath = InstanceIdentifier
161 .create(NetworkTopology.class)
162 .child(Topology.class,
163 new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID));
167 public static InstanceIdentifier<Node> getUniTopologyNodeIid() {
168 InstanceIdentifier<Node> nodePath = InstanceIdentifier
169 .create(NetworkTopology.class)
170 .child(Topology.class,
171 new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID))