2 * Copyright © 2017 AT&T, Inc. 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.transportpce.pce;
10 import java.util.ArrayList;
11 import java.util.List;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.span.attributes.LinkConcatenation;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.Link1;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.networks.network.link.oms.attributes.Span;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 public final class MapUtils {
24 private static final Logger LOG = LoggerFactory.getLogger(MapUtils.class);
29 public static String getCLLI(Node node) {
30 // TODO STUB retrieve CLLI from node. for now it is supporting node ID of the first supp node
31 return node.getSupportingNode().get(0).getNodeRef().getValue();
34 public static List<Long> getSRLG(Link link) {
35 List<Long> srlgList = new ArrayList<Long>();
36 Span span = getOmsAttributesSpan(link);
38 List<LinkConcatenation> linkList = span.getLinkConcatenation();
39 for (LinkConcatenation lc : linkList) {
40 srlgList.add(lc.getSRLGId());
43 LOG.error("MapUtils: No LinkConcatenation for link : {}", link);
48 public static String getSupNode(Node node) {
49 // TODO: supporting IDs exist as a List. this code takes just the first element
50 return node.getSupportingNode().get(0).getNodeRef().getValue();
53 public static OpenroadmLinkType calcType(Link link) {
55 OpenroadmLinkType tmplType = null;
57 link1 = link.augmentation(Link1.class);
59 LOG.error("MapUtils: No Link augmentation available. {}", link.getLinkId().getValue());
63 tmplType = link1.getLinkType();
64 if (tmplType == null) {
65 LOG.error("MapUtils: No Link type available. {}", link.getLinkId().getValue());
71 public static Span getOmsAttributesSpan(Link link) {
74 link1 = link.augmentation(Link1.class);
76 LOG.error("MapUtils: No Link augmentation available. {}", link.getLinkId().getValue());
80 tempSpan = link1.getOMSAttributes().getSpan();
81 if (tempSpan == null) {
82 LOG.error("MapUtils: No Link getOMSAttributes available. {}", link.getLinkId().getValue());
85 } catch (NullPointerException e) {
86 LOG.error("MapUtils: No Link getOMSAttributes available. {}", link.getLinkId().getValue());