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 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev150622.Evcs;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev150622.Unis;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev150622.evcs.Evc;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev150622.evcs.EvcKey;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev150622.unis.Uni;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev150622.unis.UniKey;
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.Node;
23 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
24 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
25 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 public class UnimgrMapper {
32 private static final Logger LOG = LoggerFactory.getLogger(UnimgrMapper.class);
34 public static InstanceIdentifier<Unis> getUnisIid() {
35 return InstanceIdentifier.builder(Unis.class)
39 public static InstanceIdentifier<Uni> getUniIid() {
40 return InstanceIdentifier.builder(Unis.class)
45 public static InstanceIdentifier<Uni> getUniIid(String id) {
46 return InstanceIdentifier.builder(Unis.class)
47 .child(Uni.class, new UniKey(new NodeId(id)))
51 public static InstanceIdentifier<Uni> getUniIid(UniKey uniKey) {
52 return InstanceIdentifier.builder(Unis.class)
53 .child(Uni.class, uniKey)
57 public static InstanceIdentifier<Uni> getUniIid(NodeId uniNodeId) {
58 return InstanceIdentifier.builder(Unis.class)
59 .child(Uni.class, new UniKey(uniNodeId))
63 public static InstanceIdentifier<Uni> getUniIid(Uni uni) {
64 return InstanceIdentifier.builder(Unis.class)
65 .child(Uni.class, uni.getKey())
69 public static InstanceIdentifier<Evcs> getEvcsIid() {
70 return InstanceIdentifier.builder(Evcs.class)
74 public static InstanceIdentifier<Evc> getEvcIid() {
75 return InstanceIdentifier.builder(Evcs.class)
80 public static InstanceIdentifier<Evc> getEvcIid(String id) {
81 return InstanceIdentifier.builder(Evcs.class)
82 .child(Evc.class, new EvcKey(new NodeId(id)))
86 public static InstanceIdentifier<Node> getOvsdbNodeIID(NodeId nodeId) {
87 InstanceIdentifier<Node> nodePath = InstanceIdentifier
88 .create(NetworkTopology.class)
89 .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
90 .child(Node.class,new NodeKey(nodeId));
94 public static InstanceIdentifier<Node> getOvsdbBridgeNodeIID(NodeId ovsdbNode, String bridgeName) {
95 NodeId bridgeNodeId = new NodeId(ovsdbNode + UnimgrConstants.DEFAULT_BRIDGE_NODE_ID_SUFFIX + bridgeName);
96 InstanceIdentifier<Node> nodePath = InstanceIdentifier
97 .create(NetworkTopology.class)
98 .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
99 .child(Node.class,new NodeKey(bridgeNodeId));
103 public static InstanceIdentifier<Node> getOvsdbNodeIID(IpAddress ipAddress) {
104 String nodeId = UnimgrConstants.OVSDB_PREFIX
105 + ipAddress.getIpv4Address().getValue().toString()
107 + UnimgrConstants.OVSDB_PORT;
108 InstanceIdentifier<Node> nodePath = InstanceIdentifier
109 .create(NetworkTopology.class)
110 .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
111 .child(Node.class,new NodeKey(new NodeId(nodeId)));
115 public static NodeId createNodeId(IpAddress ipAddress) {
116 String nodeId = UnimgrConstants.OVSDB_PREFIX
117 + ipAddress.getIpv4Address().getValue().toString()
119 + UnimgrConstants.OVSDB_PORT;
120 return new NodeId(nodeId);
123 public static InstanceIdentifier<Node> getOvsdbTopologyIdentifier() {
124 InstanceIdentifier<Node> path = InstanceIdentifier
125 .create(NetworkTopology.class)
126 .child(Topology.class,
127 new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
132 public static InstanceIdentifier<TerminationPoint> createTerminationPointInstanceIdentifier(
133 Node bridgeNode, String portName) {
134 InstanceIdentifier<TerminationPoint> terminationPointPath = InstanceIdentifier
135 .create(NetworkTopology.class)
136 .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
137 .child(Node.class,bridgeNode.getKey())
138 .child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
140 LOG.debug("Termination point InstanceIdentifier generated : {}",terminationPointPath);
141 return terminationPointPath;