summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actn-interface-tools/pom.xml20
-rw-r--r--sample-apps/pom.xml44
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/converter/PncConverter.java1043
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/converter/PncUtils.java100
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/BandwidthMgmtService.java23
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrv.java30
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvAccessPoint.java41
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvEndPoint.java55
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvInstance.java63
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/LTPoint.java84
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/Link.java47
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/LtpId.java84
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/Network.java61
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OduResource.java309
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OduType.java68
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OtnNetwork.java106
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/PncOtnBandwidthProfile.java202
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TeNodeKey.java128
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsEthSrv.java37
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsLink.java179
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsLinkKey.java139
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsNodeInfo.java45
-rw-r--r--sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsTunnel.java113
23 files changed, 3021 insertions, 0 deletions
diff --git a/actn-interface-tools/pom.xml b/actn-interface-tools/pom.xml
index 740faea..baa2400 100644
--- a/actn-interface-tools/pom.xml
+++ b/actn-interface-tools/pom.xml
@@ -36,5 +36,25 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>22.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.0.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <scope>provided</scope>
+ <version>1.9.12</version>
+ </dependency>
+ </dependencies>
</project> \ No newline at end of file
diff --git a/sample-apps/pom.xml b/sample-apps/pom.xml
new file mode 100644
index 0000000..dab5311
--- /dev/null
+++ b/sample-apps/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ Actn Interface Tools
+ ~ ================================================================================
+ ~ Copyright (C) 2023 Huawei Canada Limited.
+ ~ ================================================================================
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~ ============LICENSE_END=========================================================
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.onap.integration.ietf-actn-tools</groupId>
+ <artifactId>sample-apps</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>sample-app</name>
+ <properties>
+ <maven.compiler.source>11</maven.compiler.source>
+ <maven.compiler.target>11</maven.compiler.target>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.integration.ietf-actn-tools</groupId>
+ <artifactId>actn-model</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.integration.ietf-actn-tools</groupId>
+ <artifactId>actn-client</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/converter/PncConverter.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/converter/PncConverter.java
new file mode 100644
index 0000000..7a8b4a7
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/converter/PncConverter.java
@@ -0,0 +1,1043 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.converter;
+
+import org.onap.integration.actninterfacetools.actnclient.api.ActnDataConverter;
+import org.onap.integration.actninterfacetools.actnclient.api.CustomerEthService;
+import org.onap.integration.actninterfacetools.actnclient.api.CustomerOtnTopology;
+import org.onap.integration.actninterfacetools.actnclient.api.CustomerOtnTunnel;
+import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.*;
+import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.OduType;
+import org.onosproject.yang.gen.v1.ietfyangtypes.rev20210414.ietfyangtypes.DottedQuad;
+import org.onosproject.yang.gen.v1.ietfyangtypes.rev20210414.ietfyangtypes.HexString;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.DefaultEthtSvc;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.bandwidthprofiles.Direction;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.bandwidthprofiles.direction.DefaultSymmetrical;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.bandwidthprofiles.direction.Symmetrical;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.bandwidthprofiles.direction.symmetrical.DefaultIngressEgressBandwidthProfile;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.bandwidthprofiles.direction.symmetrical.IngressEgressBandwidthProfile;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvc.DefaultEthtSvcInstances;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvc.EthtSvcInstances;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvcendpointgrouping.DefaultEthtSvcAccessPoints;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvcendpointgrouping.EthtSvcAccessPoints;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvcendpointgrouping.ServiceClassification;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvcendpointgrouping.serviceclassification.DefaultVlanClassification;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvcendpointgrouping.serviceclassification.vlanclassification.DefaultOuterTag;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvcendpointgrouping.serviceclassification.vlanclassification.OuterTag;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvcinstanceconfig.DefaultEthtSvcEndPoints;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvcinstanceconfig.DefaultUnderlay;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvcinstanceconfig.EthtSvcEndPoints;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvcinstanceconfig.Underlay;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvctunnelparameters.technology.DefaultFrameBase;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvctunnelparameters.technology.framebase.DefaultOtnTunnels;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvctunnelparameters.technology.framebase.OtnTunnels;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.namedorvaluebandwidthprofile.Style;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.namedorvaluebandwidthprofile.style.DefaultValue;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.resiliencegrouping.DefaultResilience;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.resiliencegrouping.Resilience;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.vlanclassification.individualbundlingvlan.DefaultIndividualVlan;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.vlanclassification.individualbundlingvlan.IndividualVlan;
+import org.onosproject.yang.gen.v11.ietfethtrantypes.rev20191103.ietfethtrantypes.*;
+import org.onosproject.yang.gen.v11.ietflayer1types.rev20210219.ietflayer1types.*;
+import org.onosproject.yang.gen.v11.ietflayer1types.rev20210219.ietflayer1types.otnlabelstep.RangeType;
+import org.onosproject.yang.gen.v11.ietflayer1types.rev20210219.ietflayer1types.otnlabelstep.rangetype.DefaultTribPort;
+import org.onosproject.yang.gen.v11.ietflayer1types.rev20210219.ietflayer1types.otnlinkbandwidth.Odulist;
+import org.onosproject.yang.gen.v11.ietflayer1types.rev20210219.ietflayer1types.otnpathbandwidth.otn.oduflextype.DefaultGfpNk;
+import org.onosproject.yang.gen.v11.ietflayer1types.rev20210219.ietflayer1types.otnpathbandwidth.otn.oduflextype.GfpNk;
+import org.onosproject.yang.gen.v11.ietfte.rev20210220.ietfte.pathconstraintscommon.DefaultPathOutSegment;
+import org.onosproject.yang.gen.v11.ietfte.rev20210220.ietfte.pathconstraintscommon.PathOutSegment;
+import org.onosproject.yang.gen.v11.ietfte.rev20210220.ietfte.protectionrestorationproperties.DefaultProtection;
+import org.onosproject.yang.gen.v11.ietfte.rev20210220.ietfte.protectionrestorationproperties.Protection;
+import org.onosproject.yang.gen.v11.ietfte.rev20210220.ietfte.tunnelproperties.DefaultPrimaryPaths;
+import org.onosproject.yang.gen.v11.ietfte.rev20210220.ietfte.tunnelproperties.PrimaryPaths;
+import org.onosproject.yang.gen.v11.ietfte.rev20210220.ietfte.tunnelproperties.primarypaths.DefaultPrimaryPath;
+import org.onosproject.yang.gen.v11.ietfte.rev20210220.ietfte.tunnelproperties.primarypaths.PrimaryPath;
+import org.onosproject.yang.gen.v11.ietfte.rev20210220.ietfte.tunnelsgrouping.tunnels.DefaultTunnel;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.*;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.labelrestrictioninfo.DefaultLabelStart;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.labelrestrictioninfo.LabelStart;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.labelsetinfo.DefaultLabelRestrictions;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.labelsetinfo.LabelRestrictions;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.labelsetinfo.labelrestrictions.DefaultLabelRestriction;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.labelsetinfo.labelrestrictions.LabelRestriction;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.tebandwidth.DefaultTeBandwidth;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.tebandwidth.TeBandwidth;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.tebandwidth.tebandwidth.Technology;
+import org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.Networks;
+import org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.NodeId;
+import org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.networks.DefaultNetwork;
+import org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.networks.Network;
+import org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.networks.network.DefaultNode;
+import org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.networks.network.Node;
+import org.onosproject.yang.gen.v11.ietfnetworktopology.rev20180226.ietfnetworktopology.LinkId;
+import org.onosproject.yang.gen.v11.ietfnetworktopology.rev20180226.ietfnetworktopology.TpId;
+import org.onosproject.yang.gen.v11.ietfnetworktopology.rev20180226.ietfnetworktopology.networks.network.DefaultAugmentedNwNetwork;
+import org.onosproject.yang.gen.v11.ietfnetworktopology.rev20180226.ietfnetworktopology.networks.network.augmentednwnetwork.DefaultLink;
+import org.onosproject.yang.gen.v11.ietfnetworktopology.rev20180226.ietfnetworktopology.networks.network.augmentednwnetwork.Link;
+import org.onosproject.yang.gen.v11.ietfnetworktopology.rev20180226.ietfnetworktopology.networks.network.augmentednwnetwork.link.DefaultDestination;
+import org.onosproject.yang.gen.v11.ietfnetworktopology.rev20180226.ietfnetworktopology.networks.network.augmentednwnetwork.link.DefaultSource;
+import org.onosproject.yang.gen.v11.ietfnetworktopology.rev20180226.ietfnetworktopology.networks.network.augmentednwnetwork.link.Destination;
+import org.onosproject.yang.gen.v11.ietfnetworktopology.rev20180226.ietfnetworktopology.networks.network.augmentednwnetwork.link.Source;
+import org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.link.te.telinkattributes.maxlinkbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn;
+import org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.networks.network.link.DefaultAugmentedNtLink;
+import org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.networks.network.link.augmentedntlink.DefaultTe;
+import org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.networks.network.node.augmentednwnode.Te;
+import org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.networks.network.node.te.tunnelterminationpoint.locallinkconnectivities.DefaultAugmentedLocalLinkConnectivities;
+import org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.telinkconfigattributes.TeLinkAttributes;
+import org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.telinkinfoattributes.UnreservedBandwidth;
+import org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.tenodeaugment.TunnelTerminationPoint;
+import org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.tenodetunnelterminationpointconfig.LocalLinkConnectivities;
+import org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.tenodetunnelterminationpointllclist.LocalLinkConnectivity;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.telabel.DefaultTeLabel;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.telabel.TeLabel;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.tetopologyid.TeTopologyIdUnion;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.tetopologyidentifier.DefaultTeTopologyIdentifier;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.tetopologyidentifier.TeTopologyIdentifier;
+import org.onosproject.yang.gen.v11.ietftetypes.rev20200610.ietftetypes.tetpid.TeTpIdUnion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigInteger;
+import java.util.*;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.Link.State.ACTIVE;
+
+public class PncConverter extends ActnDataConverter {
+
+ private static final Logger log = LoggerFactory.getLogger(PncConverter.class);
+
+ public CustomerOtnTopology convertActnOtnTopology(org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.networks.Network network) throws Exception {
+ checkNotNull(network, "convertActnOtnTopology: network is null");
+ String networkId = network.networkId().toString();
+ List<TeNodeKey> otnNodes = getOtnNodes(network);
+ Map<TeNodeKey, TsNodeInfo> tsNodeInfo = getTsNodeInfo(network);
+ List<TsLink> otnInnerLinks = getOtnInnerLinks(network);
+ Map<TeNodeKey, List<TsLink>> otnEdgeLinks = getOtnEdgeLinks(network);
+ PncOtnBandwidthProfile bandWidthProfile = getBandWidthProfile(network);
+ return new OtnNetwork(networkId, otnNodes, tsNodeInfo, otnInnerLinks, otnEdgeLinks, bandWidthProfile);
+ }
+
+ public CustomerOtnTunnel convertActnOtnTunnel(DefaultTunnel actnOtnTunnel) throws Exception {
+ checkNotNull(actnOtnTunnel, "convertActnOtnTunnel: actnOtnTunnel is null");
+ TeNodeKey srcNode = (actnOtnTunnel.srcTunnelTpId() != null && !(new String(actnOtnTunnel.srcTunnelTpId())).isEmpty()) ? TeNodeKey.of(actnOtnTunnel.source().toString()) : new TeNodeKey(-1, -1, -1, -1);
+ LtpId srcLtpId = (actnOtnTunnel.srcTunnelTpId() != null && !(new String(actnOtnTunnel.srcTunnelTpId())).isEmpty()) ? LtpId.ltpId(actnOtnTunnel.srcTunnelTpId().toString()) : LtpId.ltpId(-1);
+ LTPoint srcLtPoint = new LTPoint(srcNode, srcLtpId);
+ TsLink srcLink = new TsLink("defaultSrcId",srcLtPoint,srcLtPoint, ACTIVE, org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.Link.Type.REGULAR);
+ TeNodeKey dstNode = (actnOtnTunnel.dstTunnelTpId() != null && !(new String(actnOtnTunnel.dstTunnelTpId())).isEmpty()) ? TeNodeKey.of(actnOtnTunnel.destination().toString()) : new TeNodeKey(-1, -1, -1, -1);
+ LtpId dstLtpId = (actnOtnTunnel.dstTunnelTpId() != null && !(new String(actnOtnTunnel.dstTunnelTpId())).isEmpty()) ? LtpId.ltpId(actnOtnTunnel.dstTunnelTpId().toString()) : LtpId.ltpId(-1);
+ LTPoint dstLtPoint = new LTPoint(dstNode, dstLtpId);
+ TsLink dstLink = new TsLink("defaultDstId",dstLtPoint,dstLtPoint, ACTIVE, org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.Link.Type.REGULAR);
+ List<TsLink> linkList = new ArrayList<>();
+ linkList.add(srcLink);
+ linkList.add(dstLink);
+ TsTunnel tsTunnel = new TsTunnel(linkList, actnOtnTunnel.name());
+ if (actnOtnTunnel.teBandwidth() != null &&
+ actnOtnTunnel.teBandwidth().technology() instanceof org.onosproject.yang.gen.v11.ietfotntunnel.rev20210625.
+ ietfotntunnel.te.tunnels.tunnel.tebandwidth.technology.augmentedtetechnology.DefaultOtn) {
+ TeBandwidth teBandwidth = actnOtnTunnel.teBandwidth();
+ OduResource oduRsrce = teBandwidthToOduResource(teBandwidth);
+ tsTunnel.bw(oduRsrce);
+ } else {
+ log.warn("Missing valid tunnel bandwidth info inside Otn DefaultTunnel");
+ }
+ return tsTunnel;
+ }
+ public DefaultTunnel convertActnOtnTunnel(CustomerOtnTunnel customerOtnTunnel) throws Exception {
+ checkNotNull(customerOtnTunnel, "convertActnOtnTunnel: customerOtnTunnel is null");
+ DefaultTunnel defaultTunnel = new DefaultTunnel();
+ LTPoint src = ((TsTunnel)customerOtnTunnel).src();
+ LTPoint dst = ((TsTunnel)customerOtnTunnel).dst();
+ TeNodeKey srcTeNodeKey = src.tsDeviceId();
+ TeNodeKey dstTeNodeKey = dst.tsDeviceId();
+ String srcTeNodeId = srcTeNodeKey.toString();
+ String dstTeNodeId = dstTeNodeKey.toString();
+ defaultTunnel.source(TeNodeId.fromString(srcTeNodeId));
+ defaultTunnel.destination(TeNodeId.fromString(dstTeNodeId));
+ defaultTunnel.srcTunnelTpId(src.ltPointId().toString().getBytes());
+ defaultTunnel.name(((TsTunnel)customerOtnTunnel).name());
+
+ org.onosproject.yang.gen.v11.ietflayer1types.rev20210219.ietflayer1types.otnpathbandwidth.Otn layer1Otn = new org.onosproject.yang.gen.v11.ietflayer1types.rev20210219.ietflayer1types.otnpathbandwidth.DefaultOtn();
+ GfpNk oduflexType = new DefaultGfpNk();
+ oduflexType.gfpn((short) ((TsTunnel)customerOtnTunnel).bw().getNumberOfOdu(OduType.ODUFLEX));
+ layer1Otn.oduType(Oduflex.class);
+ layer1Otn.oduflexType(oduflexType);
+ Technology otn = new org.onosproject.yang.gen.v11.ietfotntunnel.rev20210625.ietfotntunnel.te.tunnels.tunnel.tebandwidth.technology.augmentedtetechnology.DefaultOtn();
+ ((org.onosproject.yang.gen.v11.ietfotntunnel.rev20210625.ietfotntunnel.te.tunnels.tunnel.tebandwidth.technology.augmentedtetechnology.DefaultOtn)otn).otn(layer1Otn);
+ TeBandwidth teBandwidth = new DefaultTeBandwidth();
+ teBandwidth.technology(otn);
+ defaultTunnel.teBandwidth(teBandwidth);
+
+ defaultTunnel.encoding(LspEncodingOduk.class);
+ defaultTunnel.switchingType(SwitchingOtn.class);
+ defaultTunnel.adminState(TunnelAdminStateUp.class);
+
+ Protection protection = new DefaultProtection();
+ protection.enable(true);
+ protection.holdOffTime(0);
+ protection.protectionReversionDisable(true);
+ protection.protectionType(LspProtectionUnprotected.class);
+ protection.waitToRevert(0);
+ defaultTunnel.protection(protection);
+
+ PrimaryPaths primaryPaths = new DefaultPrimaryPaths();
+ List<PrimaryPath> primaryPathList = new ArrayList<PrimaryPath>();
+ PrimaryPath primaryPath = new DefaultPrimaryPath();
+ primaryPath.name("primary");
+ PathOutSegment pathOutSegment = new DefaultPathOutSegment();
+ LabelRestrictions labelRestrictions = new DefaultLabelRestrictions();
+ List<LabelRestriction> labelRestrictionList = new ArrayList<LabelRestriction>();
+ LabelRestriction labelRestriction = new DefaultLabelRestriction();
+ labelRestriction.index(1);
+ LabelStart labelStart = new DefaultLabelStart();
+ TeLabel teLabel = new DefaultTeLabel();
+ org.onosproject.yang.gen.v11.ietfotntunnel.rev20210625.ietfotntunnel.te.tunnels.tunnel.primarypaths.primarypath.pathinsegment.labelrestrictions.labelrestriction.labelstart.telabel.technology.augmentedtetechnology.DefaultOtn otnTpnTech = new org.onosproject.yang.gen.v11.ietfotntunnel.rev20210625.ietfotntunnel.te.tunnels.tunnel.primarypaths.primarypath.pathinsegment.labelrestrictions.labelrestriction.labelstart.telabel.technology.augmentedtetechnology.DefaultOtn();
+ OtnTpn otnTpn = new OtnTpn(1);
+ RangeType rangeType = new DefaultTribPort();
+ ((DefaultTribPort)rangeType).otnTpn(otnTpn);
+ otnTpnTech.rangeType((org.onosproject.yang.gen.v11.ietflayer1types.rev20210219.ietflayer1types.otnlabelstartend.RangeType) rangeType);
+ teLabel.technology(otnTpnTech);
+ labelStart.teLabel(teLabel);
+ labelRestriction.labelStart(labelStart);
+ labelRestrictions.labelRestriction(labelRestrictionList);
+ pathOutSegment.labelRestrictions(labelRestrictions);
+ primaryPath.pathOutSegment(pathOutSegment);
+ primaryPathList.add(primaryPath);
+ primaryPaths.primaryPath(primaryPathList);
+ defaultTunnel.primaryPaths(primaryPaths);
+ return defaultTunnel;
+ }
+ public CustomerEthService convertActnEthService(DefaultEthtSvc actnEthService) throws Exception {
+ checkNotNull(actnEthService, "convertActnEthService: actnEthService is null");
+ List<EthtSvcInstances> ethtSvcInstances = actnEthService.ethtSvcInstances();
+ if(ethtSvcInstances!=null && !ethtSvcInstances.isEmpty()){
+ List<EthSrvInstance> ethSrvInstances = new ArrayList<>();
+ for(EthtSvcInstances ethtSvcInstance: ethtSvcInstances){
+ String ethtSvcName = ethtSvcInstance.ethtSvcName();
+ String ethtSvcDescr = ethtSvcInstance.ethtSvcDescr();
+ TeTopologyIdentifier teTopologyIdentifier = ethtSvcInstance.teTopologyIdentifier();
+ long providerId = teTopologyIdentifier.providerId().uint32();
+ long clientId = teTopologyIdentifier.clientId().uint32();
+ String topologyId = teTopologyIdentifier.topologyId().union().string();
+ List<TsTunnel> tsTunnels = new ArrayList<>();
+ List<OtnTunnels> otnTunnels = ((DefaultFrameBase) ethtSvcInstance.underlay().technology()).otnTunnels();
+ if(otnTunnels!=null && !otnTunnels.isEmpty()){
+ for(OtnTunnels otnTunnel : otnTunnels){
+ tsTunnels.add(new TsTunnel(null, otnTunnel.name().toString()));
+ }
+ }
+ List<EthSrvEndPoint> ethSrvEndPoints = new ArrayList<>();
+ List<EthtSvcEndPoints> ethtSvcEndPoints = ethtSvcInstance.ethtSvcEndPoints();
+ if(ethtSvcEndPoints!=null && !ethtSvcEndPoints.isEmpty()){
+ for (EthtSvcEndPoints ethtSvcEndPoint: ethtSvcEndPoints) {
+ String ethtSvcEndPointName = ethtSvcEndPoint.ethtSvcEndPointName();
+ List<EthSrvAccessPoint> ethSrvAccessPoints = new ArrayList<>();
+ List<EthtSvcAccessPoints> ethtSvcAccessPoints = ethtSvcEndPoint.ethtSvcAccessPoints();
+ if(ethtSvcAccessPoints!=null && !ethtSvcAccessPoints.isEmpty()){
+ for(EthtSvcAccessPoints ethtSvcAccessPoint : ethtSvcAccessPoints){
+ ethSrvAccessPoints.add(new EthSrvAccessPoint(ethtSvcAccessPoint.accessPointId(),ethtSvcAccessPoint.accessNodeId().dottedQuad().string(), ethtSvcAccessPoint.accessLtpId().union().uint32()));
+ }
+ }
+ int vlanValue = ((DefaultIndividualVlan) ((DefaultVlanClassification) ethtSvcEndPoint.serviceClassification()).outerTag().individualBundlingVlan()).vlanValue().uint16();
+ BigInteger cir = ((DefaultValue) ((Symmetrical) ethtSvcEndPoint.direction()).ingressEgressBandwidthProfile().style()).cir();
+ BigInteger eir = ((DefaultValue) ((Symmetrical) ethtSvcEndPoint.direction()).ingressEgressBandwidthProfile().style()).eir();
+ ethSrvEndPoints.add(new EthSrvEndPoint(ethtSvcEndPointName, ethSrvAccessPoints, vlanValue, cir, eir));
+ }
+ }
+ ethSrvInstances.add(new EthSrvInstance(ethtSvcName,ethtSvcDescr, providerId, clientId, topologyId, tsTunnels, ethSrvEndPoints));
+ }
+ return new TsEthSrv(ethSrvInstances);
+ }else{
+ return new TsEthSrv(null);
+ }
+ }
+
+ public DefaultEthtSvc convertActnEthService(CustomerEthService customerEthService) throws Exception {
+ checkNotNull(customerEthService, "convertActnEthService: customerEthService is null");
+ List<EthSrvInstance> ethSrvInstances = ((TsEthSrv) customerEthService).getEthSrvInstances();
+ if(ethSrvInstances!=null && !ethSrvInstances.isEmpty()){
+ DefaultEthtSvc defaultEthtSvc = new DefaultEthtSvc();
+ List<EthtSvcInstances> ethtSvcInstances = new ArrayList<>();
+ for(EthSrvInstance ethSrvInstance: ethSrvInstances){
+ EthtSvcInstances ethtSvcInstance = new DefaultEthtSvcInstances();
+ String ethSrvName = ethSrvInstance.getEthSrvName();
+ ethtSvcInstance.ethtSvcName(ethSrvName);
+ String ethSrvDescr = ethSrvInstance.getEthSrvDescr();
+ ethtSvcInstance.ethtSvcDescr(ethSrvDescr);
+ ServiceTypeTypedef serviceTypeTypedef = new ServiceTypeTypedef(RmpSvc.class);
+ ethtSvcInstance.ethtSvcType(serviceTypeTypedef);
+ ethtSvcInstance.adminStatus(TunnelAdminStateUp.class);
+ TeTopologyIdentifier teTopologyIdentifier = new DefaultTeTopologyIdentifier();
+ teTopologyIdentifier.clientId(new TeGlobalId(ethSrvInstance.getClientId()));
+ teTopologyIdentifier.providerId(new TeGlobalId(ethSrvInstance.getProviderId()));
+ teTopologyIdentifier.topologyId(new TeTopologyId(new TeTopologyIdUnion(ethSrvInstance.getTopologyId())));
+ ethtSvcInstance.teTopologyIdentifier(teTopologyIdentifier);
+ Underlay underlay = new DefaultUnderlay();
+ DefaultFrameBase defaultFrameBase = new DefaultFrameBase();
+ List<OtnTunnels> otnTunnels = new ArrayList<>();
+ if(ethSrvInstance.getOtnTunnels()!=null &&!ethSrvInstance.getOtnTunnels().isEmpty() ){
+ for(TsTunnel tsTunnel: ethSrvInstance.getOtnTunnels()){
+ DefaultOtnTunnels defaultOtnTunnels = new DefaultOtnTunnels();
+ defaultOtnTunnels.name(tsTunnel.name());
+ otnTunnels.add(defaultOtnTunnels);
+ }
+ }
+ defaultFrameBase.otnTunnels(otnTunnels);
+ underlay.technology(defaultFrameBase);
+ ethtSvcInstance.underlay(underlay);
+ Resilience resilience = new DefaultResilience();
+ Protection protection = new DefaultProtection();
+ protection.enable(true);
+ protection.holdOffTime(0);
+ protection.protectionReversionDisable(true);
+ protection.protectionType(LspProtectionUnprotected.class);
+ protection.waitToRevert(0);
+ resilience.protection(protection);
+ ethtSvcInstance.resilience(resilience);
+ List<EthtSvcEndPoints> ethtSvcEndPoints = new ArrayList<>();
+ if(ethSrvInstance.getEthSrvEndPoints()!=null &&!ethSrvInstance.getEthSrvEndPoints().isEmpty()){
+ for(EthSrvEndPoint ethSrvEndPoint: ethSrvInstance.getEthSrvEndPoints()){
+ EthtSvcEndPoints ethtSvcEndPoint = new DefaultEthtSvcEndPoints();
+ ethtSvcEndPoint.ethtSvcEndPointName(ethSrvEndPoint.getEthtSvcEndPointName());
+ List<EthtSvcAccessPoints> ethtSvcAccessPoints = new ArrayList<>();
+ if(ethSrvEndPoint.getEthSrvAccessPoints()!=null && !ethSrvEndPoint.getEthSrvAccessPoints().isEmpty()){
+ for(EthSrvAccessPoint ethSrvAccessPoint: ethSrvEndPoint.getEthSrvAccessPoints()){
+ EthtSvcAccessPoints ethtSvcAccessPoint = new DefaultEthtSvcAccessPoints();
+ ethtSvcAccessPoint.accessPointId(ethSrvAccessPoint.getAccessPointId());
+ ethtSvcAccessPoint.accessNodeId(new TeNodeId(new DottedQuad(ethSrvAccessPoint.getAccessNodeId())));
+ ethtSvcAccessPoint.accessLtpId(new TeTpId(new TeTpIdUnion(ethSrvAccessPoint.getAccessLtpId())));
+ ethtSvcAccessPoints.add(ethtSvcAccessPoint);
+ }
+ }
+ ethtSvcEndPoint.serviceClassificationType(VlanClassification.class);
+ ServiceClassification serviceClassification = new DefaultVlanClassification();
+ OuterTag outerTag = new DefaultOuterTag();
+ outerTag.tagType(new EthTagClassify(ClassifyCvlan.class));
+ IndividualVlan individualVlan = new DefaultIndividualVlan();
+ individualVlan.vlanValue(new Vlanid(ethSrvEndPoint.getVlanValue()));
+ outerTag.individualBundlingVlan();
+ ((DefaultVlanClassification)serviceClassification).outerTag(outerTag);
+ ethtSvcEndPoint.serviceClassification(serviceClassification);
+ Direction direction = new DefaultSymmetrical();
+ IngressEgressBandwidthProfile ingressEgressBandwidthProfile = new DefaultIngressEgressBandwidthProfile();
+ Style style = new DefaultValue();
+ ((DefaultValue)style).bandwidthProfileType(new BandwidthProfileTypeTypedef(Mef10Bwp.class));
+ ((DefaultValue)style).cir(ethSrvEndPoint.getCIR());
+ ((DefaultValue)style).eir(ethSrvEndPoint.getEIR());
+ ingressEgressBandwidthProfile.style(style);
+ ((DefaultSymmetrical)direction).ingressEgressBandwidthProfile(ingressEgressBandwidthProfile);
+ ethtSvcEndPoint.direction(direction);
+ ethtSvcEndPoints.add(ethtSvcEndPoint);
+ }
+ }
+ ethtSvcInstance.ethtSvcEndPoints(ethtSvcEndPoints);
+ ethtSvcInstances.add(ethtSvcInstance);
+ }
+ defaultEthtSvc.ethtSvcInstances(ethtSvcInstances);
+ return defaultEthtSvc;
+ }else{
+ return new DefaultEthtSvc();
+ }
+ }
+ private OduResource teBandwidthToOduResource(TeBandwidth teBandwidth) {
+ Technology otn = teBandwidth.technology();
+ short odu0s = 0, odu1s = 0, odu2s = 0, odu2es = 0, odu3s = 0, odu4s = 0, oduFlex = 0;
+ short numOfThisOdu = 1;
+ for (Odulist elemOdu : ((DefaultOtn) otn).odulist()) {
+ if (elemOdu.oduType().isAssignableFrom(Odu0.class)) {
+ odu0s = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Odu1.class)) {
+ odu1s = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Odu2.class)) {
+ odu2s = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Odu2e.class)) {
+ odu2es = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Odu3.class)) {
+ odu3s = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Odu4.class)) {
+ odu4s = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Oduflex.class)) {
+ oduFlex = (short) elemOdu.number();
+ }
+ }
+ return new OduResource(odu0s, odu1s, odu2s, odu2es, odu3s, odu4s, oduFlex,
+ null, null); //TODO: TribPorts and TribSlots
+ }
+
+ //Transfer tslink to yanglink for otn tunnel deletion
+ private static DefaultLink tsLink2YangLinkForTunnelDeletion(String sliceId, TsLink tslink, OduResource rezvdOdu,
+ Network yangNetwork, Networks yangNetworks, boolean isEdge, int tpn) {
+ checkNotNull(tslink, "tsLink2YangLinkForTunnelDeletion: tslink is null");
+ LinkId yangLinkId = LinkId.fromString(tslink.id());
+ DefaultLink yangLink = new DefaultLink();
+ yangLink.linkId(yangLinkId);
+
+ //Update link source
+ if (tslink.src() != null) {
+ DefaultSource yangLinkSource = new DefaultSource();
+ yangLinkSource.sourceNode(NodeId.fromString(tslink.src().tsDeviceId().toString()));
+ yangLinkSource.sourceTp(TpId.fromString(tslink.src().ltPointId().toString()));
+ yangLink.source(yangLinkSource);
+ }
+ //Update link destination
+ if (tslink.dst() != null) {
+ DefaultDestination yangLinkDest = new DefaultDestination();
+ yangLinkDest.destNode(NodeId.fromString(tslink.dst().tsDeviceId().toString()));
+ yangLinkDest.destTp(TpId.fromString(tslink.dst().ltPointId().toString()));
+ yangLink.destination(yangLinkDest);
+ }
+
+ //Update te link attributes
+ TeLinkAttributes yangLinkAttr = null;
+ Link yangLinkSource = getLinkTeByLinkId(tslink.id(), yangNetwork, yangNetworks);
+
+ if (((DefaultLink) yangLinkSource).augmentations() != null
+ && !((DefaultLink) yangLinkSource).augmentations().isEmpty()) {
+ DefaultAugmentedNtLink yangLinkAugment =
+ ((DefaultLink) yangLinkSource).augmentation(DefaultAugmentedNtLink.class);
+ if (yangLinkAugment != null && yangLinkAugment.te() != null) {
+ yangLinkAttr =
+ yangLinkAugment.te().teLinkAttributes();
+ if (yangLinkAttr == null) {
+ log.error("Yanglink {} doesn't have yangLinkAttributes", tslink.id());
+ return null;
+ }
+ }
+ }
+ yangLinkAttr = updateYangLinkAttrForTunnelDeletion(sliceId, yangLinkAttr, tslink.id(), rezvdOdu, isEdge, tpn);
+
+ DefaultTe yangLinkTe = new DefaultTe();
+ yangLinkTe.teLinkAttributes(yangLinkAttr);
+
+ DefaultAugmentedNtLink yangLinkAug = new DefaultAugmentedNtLink();
+ yangLinkAug.te(yangLinkTe);
+ yangLink.addAugmentation(yangLinkAug);
+ return yangLink;
+ }
+
+ //Transfer tslink to yanglink for otn tunnel creation
+ private static DefaultLink tsLink2YangLinkForTunnelCreation(String sliceId, TsLink tslink, OduResource rezvdOdu,
+ Network yangNetwork, Networks yangNetworks, boolean isEdgeLink,
+ int tpn) {
+ checkNotNull(tslink, "tsLink2YangLinkForTunnelCreation");
+ LinkId yangLinkId = LinkId.fromString(tslink.id());
+ DefaultLink yangLink = new DefaultLink();
+ yangLink.linkId(yangLinkId);
+
+ //Update link source
+ if (tslink.src() != null) {
+ DefaultSource yangLinkSource = new DefaultSource();
+ yangLinkSource.sourceNode(NodeId.fromString(tslink.src().tsDeviceId().toString()));
+ yangLinkSource.sourceTp(TpId.fromString(tslink.src().ltPointId().toString()));
+ yangLink.source(yangLinkSource);
+ }
+ //Update link destination
+ if (tslink.dst() != null) {
+ DefaultDestination yangLinkDest = new DefaultDestination();
+ yangLinkDest.destNode(NodeId.fromString(tslink.dst().tsDeviceId().toString()));
+ yangLinkDest.destTp(TpId.fromString(tslink.dst().ltPointId().toString()));
+ yangLink.destination(yangLinkDest);
+ }
+
+ //Update te link attributes
+ TeLinkAttributes yangLinkAttr = null;
+ Link yangLinkSource = getLinkTeByLinkId(tslink.id(), yangNetwork, yangNetworks);
+
+ if (((DefaultLink) yangLinkSource).augmentations() != null
+ && !((DefaultLink) yangLinkSource).augmentations().isEmpty()) {
+ DefaultAugmentedNtLink yangLinkAugment =
+ ((DefaultLink) yangLinkSource).augmentation(DefaultAugmentedNtLink.class);
+ if (yangLinkAugment != null && yangLinkAugment.te() != null) {
+ yangLinkAttr =
+ yangLinkAugment.te().teLinkAttributes();
+ if (yangLinkAttr == null) {
+ log.error("Yanglink {} doesn't have yangLinkAttributes", tslink.id());
+ return null;
+ }
+ }
+ }
+ yangLinkAttr = updateYangLinkAttrForTunnelPvsn(sliceId, yangLinkAttr, tslink.id(), rezvdOdu, isEdgeLink, tpn);
+
+ DefaultTe yangLinkTe = new DefaultTe();
+ yangLinkTe.teLinkAttributes(yangLinkAttr);
+
+ DefaultAugmentedNtLink yangLinkAug = new DefaultAugmentedNtLink();
+ yangLinkAug.te(yangLinkTe);
+ yangLink.addAugmentation(yangLinkAug);
+ return yangLink;
+ }
+
+ //Transfer tslink to yanglink for optical slice creation rpc
+ private static DefaultLink tsLink2YangLinkForSliceCreation(String sliceId, TsLink tslink, OduResource oduResource,
+ Network yangNetwork, Networks yangNetworks) {
+ checkNotNull(tslink, "tsLink2YangLinkForSliceCreation: tslink is null");
+ LinkId yangLinkId = LinkId.fromString(tslink.id());
+ DefaultLink yangLink = new DefaultLink();
+ yangLink.linkId(yangLinkId);
+
+ //Update link source
+ if (tslink.src() != null) {
+ DefaultSource yangLinkSource = new DefaultSource();
+ yangLinkSource.sourceNode(NodeId.fromString(tslink.src().tsDeviceId().toString()));
+ yangLinkSource.sourceTp(TpId.fromString(tslink.src().ltPointId().toString()));
+ yangLink.source(yangLinkSource);
+ }
+ //Update link destination
+ if (tslink.dst() != null) {
+ DefaultDestination yangLinkDest = new DefaultDestination();
+ yangLinkDest.destNode(NodeId.fromString(tslink.dst().tsDeviceId().toString()));
+ yangLinkDest.destTp(TpId.fromString(tslink.dst().ltPointId().toString()));
+ yangLink.destination(yangLinkDest);
+ }
+
+ //Update te link attributes
+ TeLinkAttributes yangLinkAttr = null;
+ Link yangLinkSource = getLinkTeByLinkId(tslink.id(), yangNetwork, yangNetworks);
+
+ if (((DefaultLink) yangLinkSource).augmentations() != null
+ && !((DefaultLink) yangLinkSource).augmentations().isEmpty()) {
+ DefaultAugmentedNtLink yangLinkAugment =
+ ((DefaultLink) yangLinkSource).augmentation(DefaultAugmentedNtLink.class);
+ if (yangLinkAugment != null && yangLinkAugment.te() != null) {
+ yangLinkAttr =
+ yangLinkAugment.te().teLinkAttributes();
+ if (yangLinkAttr == null) {
+ log.error("Yanglink {} doesn't have yangLinkAttributes", tslink.id());
+ return null;
+ }
+ }
+ }
+ yangLinkAttr = updateYangLinkAttrForSlicePvsn(sliceId, yangLinkAttr, tslink.id(), oduResource);
+
+ DefaultTe yangLinkTe = new DefaultTe();
+ yangLinkTe.teLinkAttributes(yangLinkAttr);
+
+ DefaultAugmentedNtLink yangLinkAug = new DefaultAugmentedNtLink();
+ yangLinkAug.te(yangLinkTe);
+ yangLink.addAugmentation(yangLinkAug);
+ return yangLink;
+ }
+
+ private static TeLinkAttributes updateYangLinkAttrForTunnelPvsn(String sliceId, TeLinkAttributes yangLinkAttr,
+ String id, OduResource rezvedOdu, boolean isEdge,
+ int tpn) {
+
+
+ //Update label-restriction
+ if (isEdge && !yangLinkAttr.labelRestrictions().labelRestriction().isEmpty()) {
+ //Note: Only support single unreservedBandwidth/tebandwidth
+ HexString bitmap = yangLinkAttr.labelRestrictions().labelRestriction().get(0).rangeBitmap();
+ byte[] bytemap = new byte[bitmap.toString().length() / 2];
+ for (int i = 0; i < bytemap.length; i++) {
+ int index = i * 2;
+ int j = Integer.parseInt(bitmap.toString().substring(index, index + 2), 16);
+ bytemap[i] = (byte) j;
+ }
+ PncUtils.setBitsZero(bytemap, tpn, rezvedOdu.equivalentToNumOfOdu0s());
+ yangLinkAttr.labelRestrictions().labelRestriction().get(0).rangeBitmap(bitmap);
+ }
+
+ //Write optical slice unreservedBandwidth info into te/te-link-attributes/unreservedBandwidth
+ //Note: Only support single unreservedBandwidth/tebandwidth
+ Technology otnAug = yangLinkAttr.unreservedBandwidth().get(0).teBandwidth().technology();
+ checkNotNull(otnAug, "yanglinkAttr/unreservedBandwidth/tebandwidth/technology is null");
+ short priority = yangLinkAttr.unreservedBandwidth().get(0).priority();
+ TeBandwidth teBandWidth = new DefaultTeBandwidth();
+ if (otnAug != null &&
+ (otnAug instanceof org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn)) {
+ org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn otnAugUpdated =
+ new org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn();
+
+ //Update unreservedbandwidth/te-bandwidth/technology/slicelist
+ org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.otnslicelinkbandwidth.DefaultSlicelist
+ newSliceElem = null;
+ for (org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.otnslicelinkbandwidth.Slicelist elemSlice :
+ ((org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn) otnAug).slicelist()) {
+ if (elemSlice.sliceId().equals(sliceId)) {
+
+ if (elemSlice.odu0Number() >= (int) rezvedOdu.equivalentToNumOfOdu0s()) {
+ newSliceElem =
+ new org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.otnslicelinkbandwidth.DefaultSlicelist();
+ newSliceElem.sliceId(sliceId);
+ newSliceElem.odu0Number(elemSlice.odu0Number() - (int) rezvedOdu.equivalentToNumOfOdu0s());
+ } else {
+ throw new RuntimeException("Target slice does't have enough bandwidth");
+ }
+ ;
+ }
+ }
+ if (newSliceElem != null) {
+ otnAugUpdated.slicelist(((org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn) otnAug).slicelist());
+ otnAugUpdated.addToSlicelist(newSliceElem);
+ } else {
+ throw new RuntimeException("Target slice doesn't exist");
+ }
+
+ //Update OduList
+ for (org.onosproject.yang.gen.v11.ietflayer1types.rev20210219.ietflayer1types.otnlinkbandwidth.Odulist elemOdu :
+ ((org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn) otnAug).odulist()) {
+ if (elemOdu.oduType().isAssignableFrom(Odu0.class)) {
+ elemOdu.number((short) elemOdu.number() - (short) rezvedOdu.equivalentToNumOfOdu0s());
+ }
+ ;
+ otnAugUpdated.addToOdulist(elemOdu);
+ }
+
+ teBandWidth.technology(otnAugUpdated);
+ org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.telinkinfoattributes.DefaultUnreservedBandwidth urLkBw =
+ new org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.telinkinfoattributes.DefaultUnreservedBandwidth();
+ urLkBw.teBandwidth(teBandWidth);
+ urLkBw.priority(priority);
+ List<UnreservedBandwidth> uRsBwList = yangLinkAttr.unreservedBandwidth();
+ uRsBwList.clear();
+ uRsBwList.add(urLkBw);
+ yangLinkAttr.unreservedBandwidth(uRsBwList);
+ }
+ return yangLinkAttr;
+ }
+
+ private static TeLinkAttributes updateYangLinkAttrForTunnelDeletion(String sliceId, TeLinkAttributes yangLinkAttr,
+ String id, OduResource rezvedOdu,
+ boolean isEdge,
+ int tpn) {
+ {
+ //Update label-restriction
+ if (isEdge && !yangLinkAttr.labelRestrictions().labelRestriction().isEmpty()) {
+ //Note: Only support single unreservedBandwidth/tebandwidth
+ HexString bitmap = yangLinkAttr.labelRestrictions().labelRestriction().get(0).rangeBitmap();
+ byte[] bytemap = new byte[bitmap.toString().length() / 2];
+ for (int i = 0; i < bytemap.length; i++) {
+ int index = i * 2;
+ int j = Integer.parseInt(bitmap.toString().substring(index, index + 2), 16);
+ bytemap[i] = (byte) j;
+ }
+ PncUtils.setBitsOne(bytemap, tpn, rezvedOdu.equivalentToNumOfOdu0s());
+ yangLinkAttr.labelRestrictions().labelRestriction().get(0).rangeBitmap(bitmap);
+ }
+
+
+ //Write optical slice unreservedBandwidth info into te/te-link-attributes/unreservedBandwidth
+ //Note: Only support single unreservedBandwidth/tebandwidth
+ Technology otnAug = yangLinkAttr.unreservedBandwidth().get(0).teBandwidth().technology();
+ checkNotNull(otnAug, "yanglinkAttr/unreservedBandwidth/tebandwidth/technology is null");
+ short priority = yangLinkAttr.unreservedBandwidth().get(0).priority();
+ TeBandwidth teBandWidth = new DefaultTeBandwidth();
+ if (otnAug != null &&
+ (otnAug instanceof org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn)) {
+ org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn otnAugUpdated =
+ new org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn();
+
+ //Update unreservedbandwidth/te-bandwidth/technology/slicelist
+ org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.otnslicelinkbandwidth.DefaultSlicelist
+ newSliceElem = null;
+ for (org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.otnslicelinkbandwidth.Slicelist elemSlice :
+ ((org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn) otnAug).slicelist()) {
+ if (elemSlice.sliceId().equals(sliceId)) {
+
+ newSliceElem =
+ new org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.otnslicelinkbandwidth.DefaultSlicelist();
+ newSliceElem.sliceId(sliceId);
+ newSliceElem.odu0Number(elemSlice.odu0Number() + (int) rezvedOdu.equivalentToNumOfOdu0s());
+ }
+ }
+ if (newSliceElem != null) {
+ otnAugUpdated.slicelist(((org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn) otnAug).slicelist());
+ otnAugUpdated.addToSlicelist(newSliceElem);
+ } else {
+ throw new RuntimeException("Target slice doesn't exist");
+ }
+
+// Update OduList
+ for (org.onosproject.yang.gen.v11.ietflayer1types.rev20210219.ietflayer1types.otnlinkbandwidth.Odulist elemOdu :
+ ((org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn) otnAug).odulist()) {
+ if (elemOdu.oduType().isAssignableFrom(Odu0.class)) {
+ elemOdu.number((short) elemOdu.number() + (short) rezvedOdu.equivalentToNumOfOdu0s());
+ }
+ ;
+ otnAugUpdated.addToOdulist(elemOdu);
+ }
+
+ teBandWidth.technology(otnAugUpdated);
+ org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.telinkinfoattributes.DefaultUnreservedBandwidth urLkBw =
+ new org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.telinkinfoattributes.DefaultUnreservedBandwidth();
+ urLkBw.teBandwidth(teBandWidth);
+ urLkBw.priority(priority);
+ List<UnreservedBandwidth> uRsBwList = yangLinkAttr.unreservedBandwidth();
+ uRsBwList.clear();
+ uRsBwList.add(urLkBw);
+ yangLinkAttr.unreservedBandwidth(uRsBwList);
+ }
+ return yangLinkAttr;
+ }
+ }
+
+ private static TeLinkAttributes updateYangLinkAttrForSlicePvsn(String sliceId, TeLinkAttributes yangLinkAttr, String id, OduResource oduResource) {
+
+ //Write optical slice maxLinkBandwidth info into te/te-link-attributes/maxLinkBandwidth
+ Technology otnAug = yangLinkAttr.maxLinkBandwidth().teBandwidth().technology();
+ TeBandwidth teBandWidth = new DefaultTeBandwidth();
+ if (otnAug != null &&
+ (otnAug instanceof DefaultOtn)) {
+
+ DefaultOtn otnAugUpdated = new DefaultOtn();
+
+ otnAugUpdated.odulist(((DefaultOtn) otnAug).odulist());
+ org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.otnslicelinkbandwidth.DefaultSlicelist
+ newSliceElem =
+ new org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.otnslicelinkbandwidth.DefaultSlicelist();
+ newSliceElem.sliceId(sliceId);
+ newSliceElem.odu0Number((int) oduResource.odu0s());
+
+ ((DefaultOtn) otnAugUpdated).addToSlicelist(newSliceElem);
+ teBandWidth.technology(otnAugUpdated);
+ org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.telinkinfoattributes.DefaultMaxLinkBandwidth mxLkBw =
+ new org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.telinkinfoattributes.DefaultMaxLinkBandwidth();
+ mxLkBw.teBandwidth(teBandWidth);
+ yangLinkAttr.maxLinkBandwidth(mxLkBw);
+ }
+
+ //Write optical slice unreservedBandwidth info into te/te-link-attributes/unreservedBandwidth
+ //Note: Only support single unreservedBandwidth/tebandwidth
+ otnAug = yangLinkAttr.unreservedBandwidth().get(0).teBandwidth().technology();
+ short priority = yangLinkAttr.unreservedBandwidth().get(0).priority();
+ teBandWidth = new DefaultTeBandwidth();
+ if (otnAug != null &&
+ (otnAug instanceof org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn)) {
+ org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn otnAugUpdated =
+ new org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn();
+
+ otnAugUpdated.odulist(((org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.
+ link.te.telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn) otnAug).odulist());
+
+ org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.otnslicelinkbandwidth.DefaultSlicelist
+ newSliceElem =
+ new org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.otnslicelinkbandwidth.DefaultSlicelist();
+ newSliceElem.sliceId(sliceId);
+ newSliceElem.odu0Number((int) oduResource.odu0s());
+
+ otnAugUpdated.addToSlicelist(newSliceElem);
+ teBandWidth.technology(otnAugUpdated);
+ org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.telinkinfoattributes.DefaultUnreservedBandwidth urLkBw =
+ new org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.telinkinfoattributes.DefaultUnreservedBandwidth();
+ urLkBw.teBandwidth(teBandWidth);
+ urLkBw.priority(priority);
+ List<UnreservedBandwidth> uRsBwList = yangLinkAttr.unreservedBandwidth();
+ uRsBwList.clear();
+ uRsBwList.add(urLkBw);
+ yangLinkAttr.unreservedBandwidth(uRsBwList);
+ }
+ return yangLinkAttr;
+ }
+
+ public static Link getLinkTeByLinkId(String id, Network yangNetwork, Networks yangNetworks) {
+
+ if (((DefaultNetwork) yangNetwork).augmentation(DefaultAugmentedNwNetwork.class) != null) { //check augmentations
+ DefaultAugmentedNwNetwork augmentLink =
+ ((DefaultNetwork) yangNetwork).augmentation(DefaultAugmentedNwNetwork.class);
+ for (Link yangLink : augmentLink.link()) {
+ if (yangLink.linkId().uri().string().equals(id)) {
+ return yangLink;
+ }
+ }
+
+ }
+ return null;
+ }
+
+ //Reading Info from datastore
+ //Get a list of TeNodeKey within this yang otn network
+ public static List<TeNodeKey> getOtnNodes(Network yangNetwork) {
+ List<Node> yangNodes;
+ List<TeNodeKey> tenodeKeys = null;
+ if ((yangNodes = yangNetwork.node()) != null) {
+ for (Node node : yangNodes) {
+ if (null == tenodeKeys) {
+ tenodeKeys = new ArrayList<>(yangNodes.size());
+ }
+ tenodeKeys.add(TeNodeKey.of(node.nodeId().uri().string()));
+ }
+ }
+ return tenodeKeys;
+ }
+
+ public static Map<TeNodeKey, TsNodeInfo> getTsNodeInfo(Network yangNetwork) {
+ Map<TeNodeKey, TsNodeInfo> ttpMap = new HashMap<>();
+ for (Node yangNode : yangNetwork.node()) {
+ TeNodeKey tenodeKey = TeNodeKey.of(yangNode.nodeId().uri().string());
+ TsNodeInfo tsNodeInfo = new TsNodeInfo();
+
+ org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.networks
+ .network.node.DefaultAugmentedNwNode yangNodeAugment = ((DefaultNode) yangNode)
+ .augmentation(org.onosproject.yang.gen.v11.ietftetopology.rev20200806.ietftetopology.networks
+ .network.node.DefaultAugmentedNwNode.class);
+ if (yangNodeAugment != null
+ && yangNodeAugment.te() != null) {
+ Te yangNodeAugTe = yangNodeAugment.te();
+ if (yangNodeAugTe.tunnelTerminationPoint() != null) {
+ for (TunnelTerminationPoint yangTtp : yangNodeAugTe.tunnelTerminationPoint()) {
+ String ttpId = new String(yangTtp.tunnelTpId());
+ LocalLinkConnectivities localLinkConnectivities = yangTtp.localLinkConnectivities();
+ if (localLinkConnectivities != null) {
+ DefaultAugmentedLocalLinkConnectivities augmentedLocalLinkConnectivities = localLinkConnectivities.augmentation(DefaultAugmentedLocalLinkConnectivities.class);
+ if (augmentedLocalLinkConnectivities != null) {
+ for (LocalLinkConnectivity localLinkConnectivity : augmentedLocalLinkConnectivities.localLinkConnectivity()) {
+ if (localLinkConnectivity.isAllowed()) {
+ String linkTpRef = localLinkConnectivity.linkTpRef().toString();
+ tsNodeInfo.addToTtpMap(ttpId, LtpId.ltpId(linkTpRef));
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+ ttpMap.put(tenodeKey, tsNodeInfo);
+ }
+ return ttpMap;
+ }
+
+ public static Map<TeNodeKey, List<TsLink>> getOtnEdgeLinks(Network yangNetwork) {
+ Map<TeNodeKey, List<TsLink>> edgeLinkMap = new HashMap<TeNodeKey, List<TsLink>>();
+ DefaultAugmentedNwNetwork augmentLink;
+ //check augmentations
+ if ((augmentLink = ((DefaultNetwork) yangNetwork).augmentation(DefaultAugmentedNwNetwork.class))
+ != null) {
+ for (Link link : augmentLink.link()) {
+ if (link.source() == null ^ link.destination() == null) {
+ TsLink lk = makeTsLink(link);
+ TeNodeKey nodeKey;
+ List<TsLink> egLinks;
+ if (lk != null) {
+ switch (lk.type()) {
+ case INGRESS:
+ nodeKey = lk.dst().tsDeviceId();
+ egLinks = edgeLinkMap.get(nodeKey);
+ if (egLinks == null) {
+ egLinks = new LinkedList<>();
+ }
+ egLinks.add(lk);
+ edgeLinkMap.put(nodeKey, egLinks);
+ break;
+ case EGRESS:
+ nodeKey = lk.src().tsDeviceId();
+ egLinks = edgeLinkMap.get(nodeKey);
+ if (egLinks == null) {
+ egLinks = new LinkedList<>();
+ }
+ egLinks.add(lk);
+ edgeLinkMap.put(nodeKey, egLinks);
+ break;
+ default:
+ break;
+ }
+
+ }
+ }
+ }
+ }
+ return edgeLinkMap;
+ }
+
+ //Get a list of TsLink within this yang
+ public static List<TsLink> getOtnInnerLinks(Network yangNetwork) {
+ List<TsLink> links = null;
+ DefaultAugmentedNwNetwork augmentLink;
+ //check augmentations
+ if ((augmentLink = ((DefaultNetwork) yangNetwork).augmentation(DefaultAugmentedNwNetwork.class))
+ != null) {
+ for (Link link : augmentLink.link()) {
+ // Convert the Yang Link to a link
+ if (links == null) {
+ links = new ArrayList<>();
+ }
+
+ if (link.source() != null && link.destination() != null) {
+ // This link contains both source and destination attributes
+ TsLink lk = makeTsLink(link);
+ links.add(lk);
+ }
+
+ }
+ }
+ return links;
+ }
+
+ ;
+
+ public static PncOtnBandwidthProfile getBandWidthProfile(Network yangNetwork) {
+ DefaultAugmentedNwNetwork augmentLink;
+ PncOtnBandwidthProfile bandwidthProfile = new PncOtnBandwidthProfile();
+ //check augmentations
+ if ((augmentLink = ((DefaultNetwork) yangNetwork).augmentation(DefaultAugmentedNwNetwork.class))
+ != null) {
+ for (Link yangLink : augmentLink.link()) {
+ // Convert the Yang Link to a link
+ Source yangsrc = yangLink.source();
+ Destination yangdst = yangLink.destination();
+ if (yangsrc == null || yangdst == null) {
+ //Skip ingress and egress link,
+ continue;
+ }
+ //checkNotNull(yangsrc, "yanglink source attribute is missing");
+ //checkNotNull(yangdst, "yanglink destination attribute is missing");
+ String linkId = yangLink.linkId().uri().toString();
+ TeNodeKey device1 = TeNodeKey.of(yangsrc.sourceNode().uri().toString());
+ TeNodeKey device2 = TeNodeKey.of(yangdst.destNode().uri().toString());
+ String ltp1 = yangsrc.sourceTp().uri().toString();
+ String ltp2 = yangdst.destTp().uri().toString();
+ LTPoint src = new LTPoint(device1, LtpId.ltpId(ltp1));
+ LTPoint dst = new LTPoint(device2, LtpId.ltpId(ltp2));
+ TsLinkKey linkKey = new TsLinkKey(src, dst, linkId);
+
+ //Add bandwidth info into bandwidthProfile
+ OduResource oduResource;
+ DefaultLink defaultYangLink = (DefaultLink) yangLink;
+ if (defaultYangLink.augmentations() != null
+ && !defaultYangLink.augmentations().isEmpty()) {
+ DefaultAugmentedNtLink yangLinkAugment =
+ defaultYangLink.augmentation(DefaultAugmentedNtLink.class);
+ if (yangLinkAugment != null && yangLinkAugment.te() != null) {
+ TeLinkAttributes yangLinkAttr =
+ yangLinkAugment.te().teLinkAttributes();
+ if (yangLinkAttr != null) {
+ oduResource = yangLinkAttr2TeOduResource(yangLinkAttr);
+ if (oduResource != null) {
+ bandwidthProfile.addUnreservedOdu(linkKey, oduResource);
+ }
+ }
+
+ }
+ }
+ }
+
+
+ }
+ return bandwidthProfile;
+ }
+
+ private static TsLink makeTsLink(Link yangLink) {
+ TsLink curLink;
+ Source yangsrc = yangLink.source();
+ Destination yangdst = yangLink.destination();
+ if (yangsrc != null && yangdst != null) {
+ //checkNotNull(yangsrc, "yanglink source attribute is missing");
+ //checkNotNull(yangdst, "yanglink destination attribute is missing");
+ String linkId = yangLink.linkId().uri().toString();
+ TeNodeKey device1 = TeNodeKey.of(yangsrc.sourceNode().uri().toString());
+ TeNodeKey device2 = TeNodeKey.of(yangdst.destNode().uri().toString());
+ String ltp1 = yangsrc.sourceTp().uri().toString();
+ String ltp2 = yangdst.destTp().uri().toString();
+ LTPoint src = new LTPoint(device1, LtpId.ltpId(ltp1));
+ LTPoint dst = new LTPoint(device2, LtpId.ltpId(ltp2));
+
+ //DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder();
+ //TODO:If cost not set cost : default value case
+ curLink = TsLink.builder().id(linkId).src(src).dst(dst).state(ACTIVE).build();
+ } else if (yangsrc != null && yangdst == null) {
+ // egress link
+ String linkId = yangLink.linkId().uri().toString();
+ TeNodeKey device1 = TeNodeKey.of(yangsrc.sourceNode().uri().toString());
+ String ltp1 = yangsrc.sourceTp().uri().toString();
+ LTPoint src = new LTPoint(device1, LtpId.ltpId(ltp1));
+ curLink = TsLink.builder().id(linkId).src(src).type(org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.Link.Type.EGRESS).build();
+ } else if (yangsrc == null && yangdst != null) {
+ // ingress link
+ String linkId = yangLink.linkId().uri().toString();
+ TeNodeKey device2 = TeNodeKey.of(yangdst.destNode().uri().toString());
+ String ltp2 = yangdst.destTp().uri().toString();
+ LTPoint dst = new LTPoint(device2, LtpId.ltpId(ltp2));
+ curLink = TsLink.builder().id(linkId).dst(dst).type(org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.Link.Type.INGRESS).build();
+
+ } else {
+ return null;
+ }
+ return curLink;
+ }
+
+ public static OduResource yangLinkAttr2TeOduResource(TeLinkAttributes yangTeLinkAttr) {
+ if (yangTeLinkAttr == null ||
+ yangTeLinkAttr.unreservedBandwidth() == null) {
+ log.error("ERROR: yangLinkAttr2TeOduResource: {} is null",
+ yangTeLinkAttr == null ? "yangTeLinkAttr" : "yangTeLinkAttr.unreservedBandwidth");
+ return null;
+ }
+
+ List<UnreservedBandwidth> urbwList = yangTeLinkAttr.unreservedBandwidth();
+ UnreservedBandwidth urbw = urbwList.get(0);
+ if (urbw == null || urbw.teBandwidth() == null || urbw.teBandwidth().technology() == null) {
+ return null;
+ }
+
+
+ Technology otnAug = urbw.teBandwidth().technology();
+
+ if (otnAug == null ||
+ !(otnAug instanceof org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.link.te
+ .telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn)) {
+ return null;
+ }
+
+ short odu0s = 0, odu1s = 0, odu2s = 0, odu2es = 0, odu3s = 0, odu4s = 0, oduFlex = 0;
+ org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.link.te
+ .telinkattributes.unreservedbandwidth.tebandwidth
+ .technology.augmentedtettechnology.DefaultOtn otn = (org.onosproject.yang.gen.v11.ietfotntopology.rev20210222.ietfotntopology.networks.network.link.te
+ .telinkattributes.unreservedbandwidth.tebandwidth.technology.augmentedtettechnology.DefaultOtn) otnAug;
+
+ for (Odulist elemOdu : otn.odulist()) {
+ if (elemOdu.oduType().isAssignableFrom(Odu0.class)) {
+ odu0s = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Odu1.class)) {
+ odu1s = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Odu2.class)) {
+ odu2s = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Odu2e.class)) {
+ odu2es = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Odu3.class)) {
+ odu3s = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Odu4.class)) {
+ odu4s = (short) elemOdu.number();
+ } else if (elemOdu.oduType().isAssignableFrom(Oduflex.class)) {
+ oduFlex = (short) elemOdu.number();
+ }
+ }
+
+ return new OduResource(odu0s, odu1s, odu2s, odu2es, odu3s, odu4s, oduFlex,
+ null, null); //TODO: TribPorts and TribSlots
+
+ }
+
+
+}
+
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/converter/PncUtils.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/converter/PncUtils.java
new file mode 100644
index 0000000..3d92d4c
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/converter/PncUtils.java
@@ -0,0 +1,100 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.converter;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PncUtils {
+
+ private static final Logger log = LoggerFactory.getLogger(PncUtils.class);
+ //startIdx is 1-indexing;
+ public static void setBitsZero(byte[] bytes, int startIdx, int length){
+ int currentByteIdx = (startIdx -1) / 8;
+
+ if (currentByteIdx < bytes.length){
+ byte currByte = bytes[currentByteIdx];
+ int offset = startIdx ;
+ while (offset - startIdx < length){
+ int currBitIdx = (offset - 1) % 8;
+ currByte = (byte) (currByte & ~(1 << (7 - currBitIdx)));
+ bytes[currentByteIdx] = currByte;
+ if (currBitIdx == 7){
+ currentByteIdx++;
+ if (currentByteIdx < bytes.length ){
+ currByte = bytes[currentByteIdx];
+ }
+ }
+ offset++;
+ }
+ return;
+ }
+ throw new IllegalArgumentException("PncUtils: setBits: Illegal Argument");
+ }
+
+ public static void setBitsOne(byte[] bytes, int startIdx, int length){
+ int currentByteIdx = (startIdx -1) / 8;
+
+ if (currentByteIdx < bytes.length){
+ byte currByte = bytes[currentByteIdx];
+ int offset = startIdx ;
+ while (offset - startIdx < length){
+ int currBitIdx = (offset - 1) % 8;
+ currByte = (byte) (currByte | (1 << (7 - currBitIdx)));
+ bytes[currentByteIdx] = currByte;
+ if (currBitIdx == 7){
+ currentByteIdx++;
+ if (currentByteIdx < bytes.length ){
+ currByte = bytes[currentByteIdx];
+ }
+ }
+ offset++;
+ }
+ return;
+ }
+ throw new IllegalArgumentException("PncUtils: setBits: Illegal Argument");
+ }
+
+ public static boolean isBitsOne(byte[] bytes, int startIdx, int length){
+ int currentByteIdx = (startIdx -1) / 8;
+
+ if (currentByteIdx < bytes.length){
+ byte currByte = bytes[currentByteIdx];
+ int offset = startIdx ;
+ while (offset - startIdx < length){
+ int currBitIdx = (offset - 1) % 8;
+ if ( ((0x01 << (7 - currBitIdx)) & currByte) == 0){
+ return false;
+ };
+ if (currBitIdx == 7){
+ bytes[currentByteIdx] = currByte;
+ currentByteIdx++;
+ if (currentByteIdx < bytes.length ){
+ currByte = bytes[currentByteIdx];
+ }
+ }
+ offset++;
+ }
+ return true;
+ }
+ throw new IllegalArgumentException("PncUtils: setBits: Illegal Argument");
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/BandwidthMgmtService.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/BandwidthMgmtService.java
new file mode 100644
index 0000000..3d9be27
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/BandwidthMgmtService.java
@@ -0,0 +1,23 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+public interface BandwidthMgmtService {
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrv.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrv.java
new file mode 100644
index 0000000..0af701f
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrv.java
@@ -0,0 +1,30 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import org.onap.integration.actninterfacetools.actnclient.api.CustomerEthService;
+
+import java.util.List;
+
+public interface EthSrv {
+
+ public List<EthSrvInstance> getEthSrvInstances();
+
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvAccessPoint.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvAccessPoint.java
new file mode 100644
index 0000000..c2649c7
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvAccessPoint.java
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+public class EthSrvAccessPoint {
+ private final String accessPointId;
+ private final String accessNodeId;
+ private final long accessLtpId;
+
+ public EthSrvAccessPoint(String accessPointId, String accessNodeId, long accessLtpId) {
+ this.accessPointId = accessPointId;
+ this.accessNodeId = accessNodeId;
+ this.accessLtpId = accessLtpId;
+ }
+ public String getAccessPointId(){
+ return this.accessPointId;
+ }
+ public String getAccessNodeId(){
+ return this.accessNodeId;
+ }
+ public long getAccessLtpId(){
+ return this.accessLtpId;
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvEndPoint.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvEndPoint.java
new file mode 100644
index 0000000..c671ae2
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvEndPoint.java
@@ -0,0 +1,55 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import java.math.BigInteger;
+import java.util.List;
+
+public class EthSrvEndPoint {
+ private final String ethtSvcEndPointName;
+ private final List<EthSrvAccessPoint> ethSrvAccessPoints;
+ private final int vlanValue;
+ private final BigInteger CIR;
+ private final BigInteger EIR;
+
+ public EthSrvEndPoint(String ethtSvcEndPointName, List<EthSrvAccessPoint> ethSrvAccessPoints, int vlanValue, BigInteger CIR, BigInteger EIR) {
+ this.ethtSvcEndPointName = ethtSvcEndPointName;
+ this.ethSrvAccessPoints = ethSrvAccessPoints;
+ this.vlanValue = vlanValue;
+ this.CIR = CIR;
+ this.EIR = EIR;
+ }
+ public String getEthtSvcEndPointName(){
+ return this.ethtSvcEndPointName;
+ }
+ public List<EthSrvAccessPoint> getEthSrvAccessPoints(){
+ return this.ethSrvAccessPoints;
+ }
+
+ public int getVlanValue(){
+ return this.vlanValue;
+ }
+ public BigInteger getCIR(){
+ return this.CIR;
+ }
+ public BigInteger getEIR(){
+ return this.EIR;
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvInstance.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvInstance.java
new file mode 100644
index 0000000..bf45af2
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/EthSrvInstance.java
@@ -0,0 +1,63 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import java.util.List;
+
+public class EthSrvInstance {
+ private final String ethSrvName;
+ private final String ethSrvDescr;
+ private final long providerId;
+ private final long clientId;
+ private final String topologyId;
+ private final List<TsTunnel> otnTunnels;
+ private final List<EthSrvEndPoint> ethSrvEndPoints;
+
+ public EthSrvInstance(String ethSrvName, String ethSrvDescr, long providerId, long clientId, String topologyId, List<TsTunnel> otnTunnels, List<EthSrvEndPoint> ethSrvEndPoints) {
+ this.ethSrvName = ethSrvName;
+ this.ethSrvDescr = ethSrvDescr;
+ this.providerId = providerId;
+ this.clientId = clientId;
+ this.topologyId = topologyId;
+ this.otnTunnels = otnTunnels;
+ this.ethSrvEndPoints = ethSrvEndPoints;
+ }
+ public String getEthSrvName(){
+ return this.ethSrvName;
+ }
+ public String getEthSrvDescr(){
+ return this.ethSrvDescr;
+ }
+ public long getProviderId(){
+ return this.providerId;
+ }
+ public long getClientId(){
+ return this.clientId;
+ }
+ public String getTopologyId(){
+ return this.topologyId;
+ }
+ public List<TsTunnel> getOtnTunnels(){
+ return this.otnTunnels;
+ }
+ public List<EthSrvEndPoint> getEthSrvEndPoints(){
+ return this.ethSrvEndPoints;
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/LTPoint.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/LTPoint.java
new file mode 100644
index 0000000..a9fcf0d
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/LTPoint.java
@@ -0,0 +1,84 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+
+import java.util.Objects;
+
+public class LTPoint implements Comparable<LTPoint> {
+
+
+ private final TeNodeKey tsDeviceId;
+ private final LtpId ltPointId;
+ public static final LTPoint DUMMY = new LTPoint(new TeNodeKey(-1L, -1L, -1L, -1l),
+ LtpId.ltpId(-1L));
+
+ public LTPoint(TeNodeKey tsDeviceId, LtpId ltPointId) {
+ this.tsDeviceId = tsDeviceId;
+ this.ltPointId = ltPointId;
+ }
+
+ public TeNodeKey tsDeviceId() {
+ return tsDeviceId;
+ }
+
+ public LtpId ltPointId() {
+ return ltPointId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tsDeviceId, ltPointId);
+ }
+
+ @Override
+ public String toString() {
+ return "[" +
+ tsDeviceId.providerId() + "." +
+ tsDeviceId.clientId() + "." +
+ tsDeviceId.topologyId() + "." +
+ tsDeviceId.teNodeId() +
+ "](Tpid-" +
+ ltPointId + ")";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof LTPoint){
+ final LTPoint other = (LTPoint) obj;
+ return Objects.equals(this.tsDeviceId, other.tsDeviceId) &&
+ Objects.equals(this.ltPointId, other.ltPointId);
+ }
+ return false;
+ }
+
+ @Override
+ public int compareTo(LTPoint o) {
+ int result = tsDeviceId().toString().compareTo(o.tsDeviceId().toString());
+ if (result == 0) {
+ int delta = ltPointId().toString().compareTo(o.ltPointId.toString());
+ result = delta == 0 ? 0 : (delta < 0 ? -1 : 1);
+ }
+ return result;
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/Link.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/Link.java
new file mode 100644
index 0000000..b9c7078
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/Link.java
@@ -0,0 +1,47 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+/**
+ * The interface for infrastructure-dependent link
+ */
+public interface Link {
+
+ enum State {
+ ACTIVE,
+ INACTIVE
+ }
+
+ enum Type {
+ INGRESS,
+ EGRESS,
+ REGULAR
+ }
+
+ String id();
+
+ LTPoint src();
+
+ LTPoint dst();
+
+ State state();
+
+ Type type();
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/LtpId.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/LtpId.java
new file mode 100644
index 0000000..b526198
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/LtpId.java
@@ -0,0 +1,84 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import com.google.common.primitives.UnsignedLongs;
+
+import java.util.Objects;
+
+public final class LtpId {
+
+
+ private final long number;
+ private final String name;
+ private final boolean hasName;
+
+ private LtpId(long number){
+ this.number = number;
+ this.name = String.valueOf(number);
+ this.hasName = false;
+ }
+
+ private LtpId(long number, String name) {
+ this.number = number;
+ this.name = name;
+ this.hasName = true;
+ }
+
+ public static LtpId ltpId(long number) {
+ return new LtpId(number);
+ }
+
+ public static LtpId ltpId(String string) {
+ return new LtpId(UnsignedLongs.decode(string));
+ }
+
+ public static LtpId ltpId(long number, String name) {
+ return new LtpId(number, name);
+ }
+ public boolean hasName() { return hasName; }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.number);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this){
+ return true;
+ }
+ if (o instanceof LtpId) {
+ LtpId other = (LtpId) o;
+ return Objects.equals(other.number, this.number);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ if (hasName()) {
+ //return String.format("[%s](%d)", name, number);
+ return name;
+ } else {
+ return name;
+ }
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/Network.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/Network.java
new file mode 100644
index 0000000..42f38f8
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/Network.java
@@ -0,0 +1,61 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+
+import java.util.List;
+
+public interface Network {
+
+ Type networkType();
+
+ List<TeNodeKey> nodes();
+
+ String networkId();
+
+ public enum Type {
+ OTN_NETWORK(0),
+ DWDM_NETWORK(1),
+ PHYSICAL_NETWORK(2);
+
+ private int value;
+
+ Type(int value) {
+ this.value = value;
+ }
+
+ public int value() {
+ return value;
+ }
+
+ public static Type of(int value) {
+ switch (value) {
+ case 0:
+ return Type.OTN_NETWORK;
+ case 1:
+ return Type.DWDM_NETWORK;
+ case 2:
+ return Type.PHYSICAL_NETWORK;
+ default:
+ return null;
+ }
+ }
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OduResource.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OduResource.java
new file mode 100644
index 0000000..8557bb2
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OduResource.java
@@ -0,0 +1,309 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+
+import java.util.Arrays;
+
+/**
+ * Representation of an ODU link resource.
+ */
+public class OduResource{
+ private final short odu0s;
+ private final short odu1s;
+ private final short odu2s;
+ private final short odu2es;
+ private final short odu3s;
+ private final short odu4s;
+ private final short oduFlex;
+ private final byte[] tribPortAvailabilityBitmap;
+ private final byte[] tribSlotAvailabilityBitmap;
+
+
+ public final static OduType[] SIMPLE_ODU = {
+ OduType.ODU0, OduType.ODU1, OduType.ODU2, OduType.ODU3, OduType.ODU4
+ };
+
+ public final static OduType[] ADVANCE_ODU = {
+ OduType.ODU0, OduType.ODU1, OduType.ODU2, OduType.ODU3, OduType.ODU4,
+ OduType.ODU2E, OduType.ODU3E2, OduType.ODUFLEX
+ };
+
+ /**
+ * Creates an instance of an ODU link resource.
+ *
+ * @param odu0s number of available ODU0 containers
+ * @param odu1s number of available ODU1 containers
+ * @param odu2s number of available ODU2 containers
+ * @param odu2es number of available ODU2e containers
+ * @param odu3s number of available ODU3 containers
+ * @param odu4s number of available ODU4 containers
+ * @param oduFlex available ODUflex bandwidth in terms of ODU0 containers
+ */
+ public OduResource(short odu0s, short odu1s, short odu2s,
+ short odu2es, short odu3s, short odu4s,
+ short oduFlex,
+ byte[] tpMap, byte[] tsMap) {
+ this.odu0s = odu0s;
+ this.odu1s = odu1s;
+ this.odu2s = odu2s;
+ this.odu2es = odu2es;
+ this.odu3s = odu3s;
+ this.odu4s = odu4s;
+ this.oduFlex = oduFlex;
+// this.oduFlexCbrs = oduFlexCbrs;
+ this.tribPortAvailabilityBitmap = tpMap == null ? null :
+ Arrays.copyOf(tpMap, tpMap.length);
+ this.tribSlotAvailabilityBitmap = tsMap == null ? null :
+ Arrays.copyOf(tsMap, tsMap.length);
+ }
+
+ public int[] getOduResourceArray(OduType[] odus){
+ int size = odus.length;
+ int [] ans = new int [size];
+ for(int i = 0, e = size; i < e; i++ ) {
+ ans[i] = getNumberOfOdu(odus[i]);
+ }
+ return ans;
+ }
+
+ public static OduResource getOduResourceFromArray(int [] oduArray) {
+ short odu0s = 0, odu1s = 0, odu2s = 0, odu2es = 0, odu3s = 0, odu4s = 0, oduFlex = 0;
+
+ for (int i=0, e= oduArray.length; i<e; i++) {
+ short val = (short) oduArray[i];
+ switch(ADVANCE_ODU[i]){
+ case ODU0: odu0s = val; break;
+ case ODU1: odu1s = val; break;
+ case ODU2: odu2s = val; break;
+ case ODU3: odu3s = val; break;
+ case ODU4: odu4s = val; break;
+ case ODU2E: odu2es = val; break;
+ case ODU3E2: break;
+ case ODUFLEX: oduFlex = val; break;
+// case ODUFLEX_GFP: oduFlexGfps = val; break;
+ default: break;
+ }
+ }
+ return new OduResource(odu0s, odu1s, odu2s, odu2es, odu3s, odu4s, oduFlex,
+ null, null);
+
+ }
+ public int getNumberOfOdu(OduType oduType){
+ switch(oduType) {
+ case ODU0: return this.odu0s();
+ case ODU1: return this.odu1s();
+ case ODU2: return this.odu2s();
+ case ODU3: return this.odu3s();
+ case ODU4: return this.odu4s();
+ case ODU2E: return this.odu2es();
+ case ODU3E2: return 0;
+ case ODUFLEX: return this.oduFlex();
+// case ODUFLEX_GFP: return this.oduFlexGfps();
+ default: throw new IllegalArgumentException("oduType has not been setup inside getNumberOfOdu method");
+ }
+ }
+
+ public static OduResource fromString(String val) {
+ short odu0s = 0, odu1s = 0, odu2s = 0, odu2es = 0, odu3s = 0, odu4s = 0, oduFlex = 0;
+ String [] sarr = val.split("\\,");
+ if (sarr.length % 2 == 0){
+ for(int i=0, e=sarr.length; i < e ; i=i+2){
+ try{
+ int odutype = Integer.parseInt(sarr[i].trim());
+ int num = Integer.parseInt(sarr[i+1].trim());
+ if (num <= 0) {
+ continue;
+ }
+ switch (odutype){
+ case 0: odu0s = (short) num; break;
+ case 1: odu1s = (short) num; break;
+ case 2: odu2s = (short) num; break;
+ case 3: odu3s = (short) num; break;
+ case 4: odu4s = (short) num; break;
+ case 5: odu2es = (short) num; break;
+ case 6: break;
+ case 7: oduFlex = (short) num; break;
+// case 8: oduFlexGfps = (short) num; break;
+ default: continue;
+ }
+
+ } catch (NumberFormatException exception){
+ return null;
+ }
+ }
+
+ return new OduResource(odu0s, odu1s, odu2s, odu2es, odu3s, odu4s, oduFlex,
+ null, null);
+ }
+ return null;
+ }
+ public static OduResource clone(OduResource o) {
+ return new OduResource(o.odu0s(), o.odu1s(), o.odu2s(), o.odu2es(),
+ o.odu3s(), o.odu4s(), o.oduFlex(),
+ o.getTribPortAvailabilityBitmap(), o.getTribSlotAvailabilityBitmap());
+ }
+
+
+ public short equivalentToNumOfOdu0s() {
+ short count = 0;
+ for(OduType otype : ADVANCE_ODU){
+ switch (otype){
+ case ODU0: count += this.odu0s();break;
+ case ODU1: count += 2 * this.odu1s();break;
+ case ODU2: count += 8 * this.odu2s();break;
+ case ODU3: count += 32 * this.odu3s();break;
+ case ODU4: count += 80 * this.odu4s();break;
+ case ODU2E: count += 8 * this.odu2es();break;
+ case ODU3E2: count += 0;break;
+ case ODUFLEX: break;
+// case ODUFLEX_GFP: break;
+ default: continue;
+ }
+ }
+ return count;
+ }
+ /**
+ * Returns the number of available ODU0s.
+ *
+ * @return the odu0s
+ */
+ public short odu0s() {
+ return odu0s;
+ }
+
+ /**
+ * Returns the number of available ODU1s.
+ *
+ * @return the odu1s
+ */
+ public short odu1s() {
+ return odu1s;
+ }
+
+ /**
+ * Returns the number of available ODU2s.
+ *
+ * @return the odu2s
+ */
+ public short odu2s() {
+ return odu2s;
+ }
+
+ /**
+ * Returns the number of available ODU2es.
+ *
+ * @return the odu2es
+ */
+ public short odu2es() {
+ return odu2es;
+ }
+
+ /**
+ * Returns the number of available ODU3s.
+ *
+ * @return the odu3s
+ */
+ public short odu3s() {
+ return odu3s;
+ }
+
+ /**
+ * Returns the number of available ODU4s.
+ *
+ * @return the odu4s
+ */
+ public short odu4s() {
+ return odu4s;
+ }
+
+ /**
+ * Returns available ODUflex bandwidth in terms of ODU0 containers.
+ *
+ * @return the oduFlexes
+ */
+ public short oduFlex() {
+ return oduFlex;
+ }
+
+// public short oduFlexCbrs() {
+// return oduFlexCbrs;
+// }
+
+ public byte[] getTribPortAvailabilityBitmap() {
+ return tribPortAvailabilityBitmap == null ? null :
+ Arrays.copyOf(tribPortAvailabilityBitmap,
+ tribPortAvailabilityBitmap.length);
+ }
+
+ public byte[] getTribSlotAvailabilityBitmap() {
+ return tribSlotAvailabilityBitmap == null ? null :
+ Arrays.copyOf(tribSlotAvailabilityBitmap,
+ tribSlotAvailabilityBitmap.length);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(odu0s, odu1s, odu2s, odu2es, odu3s,
+ odu4s, oduFlex,
+ Arrays.hashCode(tribPortAvailabilityBitmap),
+ Arrays.hashCode(tribSlotAvailabilityBitmap));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof OduResource) {
+ OduResource that = (OduResource) object;
+ return (this.odu0s == that.odu0s) &&
+ (this.odu1s == that.odu1s) &&
+ (this.odu2s == that.odu2s) &&
+ (this.odu2es == that.odu2es) &&
+ (this.odu3s == that.odu3s) &&
+ (this.odu4s == that.odu4s) &&
+ (this.oduFlex == that.oduFlex) &&
+ Arrays.equals(this.tribPortAvailabilityBitmap,
+ that.tribPortAvailabilityBitmap) &&
+ Arrays.equals(this.tribSlotAvailabilityBitmap,
+ that.tribSlotAvailabilityBitmap);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("odu0s", odu0s)
+ .add("odu1s", odu1s)
+ .add("odu2s", odu2s)
+ .add("odu2es", odu2es)
+ .add("odu3s", odu3s)
+ .add("odu4s", odu4s)
+ .add("oduFlexes", oduFlex)
+ .add("tribPortAvailabilityBitmap", tribPortAvailabilityBitmap)
+ .add("tribSlotAvailabilityBitmap", tribSlotAvailabilityBitmap)
+ .toString();
+ }
+
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OduType.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OduType.java
new file mode 100644
index 0000000..244a7f3
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OduType.java
@@ -0,0 +1,68 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+public enum OduType {
+ ODU0 (0, 1_244_160),
+ ODU1 (1, 2_498_770),
+ ODU2 (2, 10_037_270),
+ ODU3 (3, 40_319_210),
+ ODU4 (4, 104_794_440),
+ ODU2E (5, 10_399_520),
+ ODU3E2 (6, 41_785_960),
+ ODUFLEX (7, 3);
+// ODUFLEX_GFP (8, -1);
+
+ protected int type;
+
+ //Bandwidth in Mbit/s
+ protected int bandwidth;
+
+ OduType(int type, int bandwidth){
+ this.type = type;
+ this.bandwidth = bandwidth;
+ }
+
+ public int typeValue() {
+ return this.type;
+ }
+
+ public int getBandwidth() {
+ return this.bandwidth;
+ }
+
+ static public OduType of(int i) {
+ if (i >=0 && i <= 4) {
+ switch (i){
+ case 0: return OduType.ODU0;
+ case 1: return OduType.ODU1;
+ case 2: return OduType.ODU2;
+ case 3: return OduType.ODU3;
+ case 4: return OduType.ODU4;
+ case 5: return OduType.ODU2E;
+ case 6: return OduType.ODU3E2;
+ case 7: return OduType.ODUFLEX;
+// case 8: return OduType.ODUFLEX_GFP;
+ }
+ }
+ return null;
+
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OtnNetwork.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OtnNetwork.java
new file mode 100644
index 0000000..b6d1fb0
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/OtnNetwork.java
@@ -0,0 +1,106 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import org.onap.integration.actninterfacetools.actnclient.api.CustomerOtnTopology;
+import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.converter.PncConverter;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class OtnNetwork extends CustomerOtnTopology implements Network {
+
+ private final Type networkType = Type.of(0);
+ private final String networkId;
+ private final List<TeNodeKey> nodes;
+ private final Map<TeNodeKey, TsNodeInfo> tsNodeInfos;
+ private final List<TsLink> innerLinks;
+ private final Map<TeNodeKey,List<TsLink>> edgeLinks;
+ private final PncOtnBandwidthProfile bandwidthProfileSupplier;
+
+// public OtnNetwork(org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.networks.Network yangNetwork){
+//
+// this(yangNetwork,
+// ()-> PncConverter.getOtnNodes(yangNetwork),
+// ()-> PncConverter.getTsNodeInfo(yangNetwork),
+// ()-> PncConverter.getOtnInnerLinks(yangNetwork),
+// ()-> PncConverter.getOtnEdgeLinks(yangNetwork),
+// ()-> PncConverter.getBandWidthProfile(yangNetwork));
+// }
+
+
+// OtnNetwork(org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.networks.Network yangNetwork,
+// Supplier<List<TeNodeKey>> nodes,
+// Supplier<Map<TeNodeKey, TsNodeInfo>> tsNodeInfos,
+// Supplier<List<TsLink>> innerLinks,
+// Supplier<Map<TeNodeKey, List<TsLink>>> edgeLinks,
+// Supplier<PncOtnBandwidthProfile> bandwidthProfile){
+// checkNotNull(yangNetwork, "OtnNetwork: yangNetwork passed in is null");
+// this.networkId = yangNetwork.networkId().toString();
+// this.nodes = nodes;
+// this.innerLinks = innerLinks;
+// this.edgeLinks = edgeLinks;
+// this.tsNodeInfos = tsNodeInfos;
+// this.bandwidthProfileSupplier = bandwidthProfile;
+// }
+
+ public OtnNetwork(String networkId, List<TeNodeKey> otnNodes, Map<TeNodeKey, TsNodeInfo> tsNodeInfo, List<TsLink> otnInnerLinks, Map<TeNodeKey, List<TsLink>> otnEdgeLinks, PncOtnBandwidthProfile bandWidthProfile) {
+ this.networkId = networkId;
+ this.nodes = otnNodes;
+ this.innerLinks = otnInnerLinks;
+ this.edgeLinks = otnEdgeLinks;
+ this.tsNodeInfos = tsNodeInfo;
+ this.bandwidthProfileSupplier = bandWidthProfile;
+ }
+
+ @Override
+ public Type networkType() {
+ return networkType;
+ }
+
+ @Override
+ public List<TeNodeKey> nodes() {
+ return nodes;
+ }
+
+ public List<TsLink> innerlinks() {
+ return innerLinks;
+ }
+
+ public Map<TeNodeKey,List<TsLink>> edgeLinks(){
+ return edgeLinks;
+ }
+
+ public Map<TeNodeKey, TsNodeInfo> tsNodeInfos(){
+ return tsNodeInfos;
+ }
+
+ public PncOtnBandwidthProfile bandwidthProfile() {
+ return bandwidthProfileSupplier;
+ }
+
+ @Override
+ public String networkId(){
+ return this.networkId;
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/PncOtnBandwidthProfile.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/PncOtnBandwidthProfile.java
new file mode 100644
index 0000000..153efb7
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/PncOtnBandwidthProfile.java
@@ -0,0 +1,202 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class PncOtnBandwidthProfile implements Cloneable, BandwidthMgmtService {
+
+
+ public static final boolean CAN_ODU_MULTIPLEXING = true;
+
+ public static OduResource EMPTY_ODU_RESOURCE = new OduResource((short)0,(short)0,(short)0,(short)0,(short)0,
+ (short)0,(short)0, null, null);
+
+ private Map<TsLinkKey, int[]> unResvOdu = new HashMap<>();
+
+ private Map<TsLinkKey, int[]> localReservedOdu = new HashMap<>();
+
+ //private Map<TsLinkKey, Multiset<BwUsageRecord>> localReservedOdu = new HashMap<>();
+
+ //Default PncOtnBandwidthProfile constructor
+ public PncOtnBandwidthProfile(){
+
+ }
+
+ // Allocate new ODu bandwidth to link tunnel, the allocation will add new entry into localReservedOdu map
+ // and deduct one odu of specific type from unReserOdu map
+ // NOTE: always call this function before checking there are feasible odu(s) left.
+ public boolean allocLocalReserveOdu(TsLinkKey linkkey, OduResource request) {
+
+ //Multiset<BwUsageRecord> allocatedBw = localReservedOdu.get(linkkey);
+ int [] unreservedOdulist = unResvOdu.get(linkkey);
+ int [] reservedOdu = localReservedOdu.get(linkkey);
+ if (reservedOdu == null){
+ reservedOdu = new int[OduResource.ADVANCE_ODU.length];
+ }
+ int oduRequestArray[] = request.getOduResourceArray(OduResource.ADVANCE_ODU);
+ checkArgument(unreservedOdulist.length == oduRequestArray.length, "Target Odu is not available");
+ //Subtract certain share(s) of this ODU Type
+ if (unreservedOdulist[0] >= reservedOdu[0] + request.equivalentToNumOfOdu0s()){
+ reservedOdu[0] += request.equivalentToNumOfOdu0s();
+ } else {
+ for(int i=0,e=unreservedOdulist.length;i < e; i++) {
+ int leftover = unreservedOdulist[i] - (reservedOdu[i] + oduRequestArray[i]);
+ checkArgument(leftover >= 0, "Odu type is not sufficient for building slice tunnel");
+ reservedOdu[i] += oduRequestArray[i];
+ }
+ }
+ localReservedOdu.put(linkkey, reservedOdu);
+ return true;
+ }
+
+
+ public boolean addUnreservedOdu(TsLinkKey linkkey, OduResource oduResource) {
+ int oduInventory[] = oduResource.getOduResourceArray(OduResource.ADVANCE_ODU);
+ unResvOdu.put(linkkey, oduInventory);
+ return true;
+ }
+
+ public boolean addUnreservedOdu(TsLinkKey linkkey, int[] odulist) {
+ unResvOdu.put(linkkey, odulist);
+ return true;
+ }
+
+
+ public boolean removeUnreservedOdu(TsLinkKey linkkey) {
+ unResvOdu.remove(linkkey);
+ return true;
+ }
+
+
+ public int[] getUnreservedOdu(TsLinkKey linkkey) {
+ checkNotNull(linkkey);
+ int [] origin = unResvOdu.get(linkkey);
+ return origin;
+ }
+
+ public int[] getReservedOdu(TsLinkKey linkkey) {
+ checkNotNull(linkkey);
+ int [] origin = localReservedOdu.get(linkkey);
+ return origin;
+ }
+
+ public OduResource getUnreserveOduResource(TsLinkKey linkkey){
+ int [] oduArray = getUnreservedOdu(linkkey);
+ return (oduArray == null)? null: OduResource.getOduResourceFromArray(oduArray);
+ }
+
+ public OduResource getReservedOduResource(TsLinkKey linkkey) {
+ int [] oduArray = getReservedOdu(linkkey);
+ return (oduArray == null)? null: OduResource.getOduResourceFromArray(oduArray);
+ }
+
+ public boolean isOduTypeAvailable(TsLink link, OduResource request) {
+ boolean available = true;
+ OduResource unreserveOduResource = getUnreserveOduResource(TsLinkKey.tsLinkKey(link));
+ OduResource reservedOduResource = getReservedOduResource(TsLinkKey.tsLinkKey(link));
+ //int oduRequestArray[] = request.getOduResourceArray(ODU_TYPE_IN_IETF_TE_TYPE_SIMPLE);
+ if (null != unreserveOduResource) {
+ if (null != reservedOduResource &&
+ unreserveOduResource.equivalentToNumOfOdu0s() < request.equivalentToNumOfOdu0s() + reservedOduResource.equivalentToNumOfOdu0s()){
+ available = false;
+ } else if ( null == reservedOduResource &&
+ unreserveOduResource.equivalentToNumOfOdu0s() < request.equivalentToNumOfOdu0s()){
+ available = false;
+ }
+ if(available == false){
+ available = true;
+ for (OduType t : OduResource.ADVANCE_ODU) {
+ if (null != reservedOduResource &&
+ unreserveOduResource.getNumberOfOdu(t) < request.getNumberOfOdu(t) + reservedOduResource.getNumberOfOdu(t)){
+ available = false;
+ } else if ( null == reservedOduResource &&
+ unreserveOduResource.getNumberOfOdu(t) < request.getNumberOfOdu(t) ) {
+ available = false;
+ }
+ }
+ }
+ } else {
+ available = false;
+ }
+ return available;
+ }
+
+
+ private int feasibleOduByBandwidth(double[] bandwidthArr, int target) {
+ int start = 0, end = bandwidthArr.length - 1;
+ int ans = -1;
+ while (start <= end) {
+ int mid = (start + end) / 2;
+ if (bandwidthArr[mid] < target) {
+ start = mid + 1;
+ } else {
+ ans = mid;
+ end = mid - 1;
+ }
+ }
+ return ans;
+ }
+
+ private int feasibleOduByOduList(int[] numberODUArr, int idx, boolean multiplexing) {
+ int oduIdx = -1;
+ int len = numberODUArr.length;
+ if (idx >= len) {
+ return -1;
+ }
+ while (idx < len) {
+ if (numberODUArr[idx] > 0) {
+ oduIdx = idx;
+ break;
+ } else if (!multiplexing) {
+ break;
+ } else {
+ idx++;
+ }
+ }
+ return oduIdx;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ PncOtnBandwidthProfile t = (PncOtnBandwidthProfile) super.clone();
+ t.unResvOdu = new HashMap<TsLinkKey, int[]>();
+ t.localReservedOdu = new HashMap<TsLinkKey, int[]> ();
+ for (Map.Entry<TsLinkKey, int[]> entry : unResvOdu.entrySet()) {
+ t.unResvOdu.put(entry.getKey(),
+ Arrays.copyOf(entry.getValue(),
+ entry.getValue().length));
+ }
+
+ for (Map.Entry<TsLinkKey, int[]> entry : localReservedOdu.entrySet()) {
+ t.localReservedOdu.put(entry.getKey(),
+ Arrays.copyOf(entry.getValue(),
+ entry.getValue().length));
+ }
+ //t.localReservedOdu = new HashMap<TsLinkKey, Multiset<BwUsageRecord>>();
+ return t;
+ }
+
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TeNodeKey.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TeNodeKey.java
new file mode 100644
index 0000000..2955fe9
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TeNodeKey.java
@@ -0,0 +1,128 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import com.google.common.base.Objects;
+
+import java.util.Arrays;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Node Key.
+ */
+public class TeNodeKey {
+
+ private final long teNodeId;
+ private final long providerId;
+ private final long clientId;
+ private final long topologyId;
+
+ /**
+ * Creates a TE node key.
+ *
+ * @param teNodeKey TE node key
+ */
+ public TeNodeKey(TeNodeKey teNodeKey) {
+ this.providerId = teNodeKey.providerId();
+ this.clientId = teNodeKey.clientId();
+ this.topologyId = teNodeKey.topologyId();
+ this.teNodeId = teNodeKey.teNodeId();
+ }
+
+ /**
+ * Creates a TE node key.
+ *
+ * @param providerId provider identifier
+ * @param clientId client identifier
+ * @param topologyId topology identifier
+ * @param teNodeId TE node identifier
+ */
+ public TeNodeKey(long providerId, long clientId,
+ long topologyId, long teNodeId) {
+ this.providerId = providerId;
+ this.clientId = clientId;
+ this.topologyId = topologyId;
+ this.teNodeId = teNodeId;
+ }
+
+ /**
+ * Returns the TE Node identifier.
+ *
+ * @return the TE node id
+ */
+ public long teNodeId() {
+ return teNodeId;
+ }
+
+ public long providerId() {
+ return providerId;
+ }
+
+ public long clientId() {
+ return clientId;
+ }
+
+ public long topologyId() {
+ return topologyId;
+ }
+ /**
+ * Parse a tenodekey from a string
+ * @param string
+ * @return a TeNodeKey based on provided string
+ */
+ public static TeNodeKey of(String string) {
+ checkNotNull(string);
+ String [] pieces = string.split("\\.");
+ long [] ids = Arrays.stream(pieces).mapToLong(x -> Long.parseLong(x)).toArray();
+ checkArgument( pieces.length == 4,
+ "TeNodeKeyString must be in \"prviderId.clientid.topologyid.tenodeid\" format, but got %s", string);
+ return new TeNodeKey(ids[0], ids[1], ids[2], ids[3]);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(providerId, clientId, topologyId, teNodeId);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof TeNodeKey) {
+ TeNodeKey that = (TeNodeKey) object;
+ return Objects.equal(this.providerId, that.providerId) &&
+ Objects.equal(this.clientId, that.clientId) &&
+ Objects.equal(this.topologyId, that.topologyId) &&
+ Objects.equal(this.teNodeId, that.teNodeId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return this.providerId() + "." +
+ this.clientId() + "." +
+ this.topologyId() + "." +
+ this.teNodeId();
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsEthSrv.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsEthSrv.java
new file mode 100644
index 0000000..74ec498
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsEthSrv.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import org.onap.integration.actninterfacetools.actnclient.api.CustomerEthService;
+
+import java.util.List;
+
+public class TsEthSrv extends CustomerEthService implements EthSrv{
+ private List<EthSrvInstance> ethSrvInstances;
+
+ public TsEthSrv(List<EthSrvInstance> ethSrvInstances) {
+ this.ethSrvInstances = ethSrvInstances;
+ }
+
+ @Override
+ public List<EthSrvInstance> getEthSrvInstances(){
+ return this.ethSrvInstances;
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsLink.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsLink.java
new file mode 100644
index 0000000..8ae8209
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsLink.java
@@ -0,0 +1,179 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import org.onap.integration.actninterfacetools.actnclient.api.CustomerOtnTunnel;
+
+import java.util.List;
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class TsLink extends CustomerOtnTunnel implements Link {
+
+ private final String id;
+ private final LTPoint src;
+ private final LTPoint dst;
+ private final State state;
+ private final Type type;
+ private String transportSliceId;
+ private List<Integer> numberOfOdu;
+
+ protected TsLink(LTPoint src, LTPoint dst, State state){
+ this("Default", src, dst, state);
+ }
+
+ protected TsLink(String id, LTPoint src, LTPoint dst, State state){
+ this(id, src, dst, state, Type.REGULAR);
+ }
+
+ public TsLink(String id, LTPoint src, LTPoint dst, State state, Type type){
+ this.id = id;
+ this.src = src;
+ this.dst = dst;
+ this.state = state;
+ this.type = type;
+ }
+
+ public TsLink(LTPoint srcLtPoint, LTPoint dstLtPoint) {
+ this.id = "defaultId";
+ this.src = srcLtPoint;
+ this.dst = dstLtPoint;
+ this.state = State.ACTIVE;
+ this.type = Type.REGULAR;
+ }
+
+ public String sliceId() {
+ return transportSliceId;
+ }
+
+ public void sliceId(String id) {
+ this.transportSliceId = id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o instanceof TsLink){
+ final TsLink other = (TsLink) o;
+ return Objects.equals(this.id, other.id) &&
+ Objects.equals(this.type, other.type) &&
+ Objects.equals(this.state, other.state);
+ }
+ return false;
+ }
+
+ public String id() {
+ return this.id;
+ }
+
+ @Override
+ public String toString(){
+ return (src + "==>" + dst);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, type, src, dst, state);
+ }
+
+ @Override
+ public LTPoint src() {
+ return this.src;
+ }
+
+ @Override
+ public LTPoint dst() {
+ return this.dst;
+ }
+
+ @Override
+ public State state() {
+ return state;
+ }
+
+ @Override
+ public Type type() {
+ return type;
+ }
+
+ //===Builder========
+ public static Builder builder() { return new Builder(); }
+
+ public List<Integer> getNumberOfOdu() {
+ return numberOfOdu;
+ }
+
+ public void setNumberOfOdu(List<Integer> numberOfOdu) {
+ this.numberOfOdu = numberOfOdu;
+ }
+
+ public static class Builder {
+
+ private String id;
+ private LTPoint src;
+ private LTPoint dst;
+ private State state = State.ACTIVE;
+ private Type type = Type.REGULAR;
+
+
+ protected Builder() {
+
+ }
+
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+ public Builder src(LTPoint src) {
+ this.src = src;
+ return this;
+ }
+ public Builder dst(LTPoint dst) {
+ this.dst = dst;
+ return this;
+ }
+ public Builder state(State state) {
+ this.state = state;
+ return this;
+ }
+ public Builder type(Type type) {
+ this.type = type;
+ return this;
+ }
+ public TsLink build(){
+ if (type == Type.INGRESS){
+ checkNotNull(dst, "Destination connect point cannot be null");
+ } else if (type == Type.EGRESS) {
+ checkNotNull(src, "Source connect point cannot be null");
+ } else if (type == Type.REGULAR){
+ checkNotNull(dst, "Destination connect point cannot be null");
+ checkNotNull(src, "Source connect point cannot be null");
+ }
+ checkNotNull(state, "State cannot be null");
+ return new TsLink(id, src, dst, state, type);
+ }
+ }
+
+
+
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsLinkKey.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsLinkKey.java
new file mode 100644
index 0000000..b83b5f1
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsLinkKey.java
@@ -0,0 +1,139 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import com.google.common.base.MoreObjects;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public final class TsLinkKey {
+
+
+ private static final String DELIM = "-";
+
+ private final LTPoint src = null;
+ private final LTPoint dst = null;
+ private final String id;
+
+ /**
+ * Creates a link identifier with source and destination LTPoint point.
+ *
+ * @param src source LTPoint point
+ * @param dst destination LTPoint point
+ */
+ private TsLinkKey(LTPoint src, LTPoint dst) {
+ this(src, dst, src + DELIM + dst);
+ }
+
+ /**
+ * Creates a link identifier with source and destination LTPoint point.
+ *
+ * @param src source LTPoint point
+ * @param dst destination LTPoint point
+ */
+ public TsLinkKey(LTPoint src, LTPoint dst, String id) {
+ this.id = checkNotNull(id);
+ //this.src = checkNotNull(src);
+ //this.dst = checkNotNull(dst);
+ }
+
+ /**
+ * Returns source connection point.
+ *
+ * @return source connection point
+ */
+ public LTPoint src() {
+ return src;
+ }
+
+ /**
+ * Returns destination connection point.
+ *
+ * @return destination connection point
+ */
+ public LTPoint dst() {
+ return dst;
+ }
+
+ /**
+ * Returns a string suitable to be used as an identifier.
+ *
+ * @return string as identifier
+ */
+ public String asId() {
+ return src + DELIM + dst;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TsLinkKey) {
+ final TsLinkKey other = (TsLinkKey) obj;
+ return Objects.equals(this.id, other.id) &&
+ Objects.equals(this.src, other.src) &&
+ Objects.equals(this.dst, other.dst);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("src", src)
+ .add("dst", dst)
+ .toString();
+ }
+
+ /**
+ * Creates a link identifier with source and destination connection point.
+ *
+ * @param src source connection point
+ * @param dst destination connection point
+ * @return a link identifier
+ */
+ public static TsLinkKey tsLinkKey(LTPoint src, LTPoint dst) {
+ return new TsLinkKey(src, dst);
+ }
+
+ /**
+ * Creates a link identifier for the specified link.
+ *
+ * @param link link descriptor
+ * @return a link identifier
+ */
+ public static TsLinkKey tsLinkKey(Link link) {
+ if (link.src() == null || link.dst() == null) {
+ checkArgument(link.type() != Link.Type.REGULAR,
+ "TsLinkKey invalid; only ingress/egress link can have null src/dst");
+ }
+ return new TsLinkKey(link.src(), link.dst(), link.id() );
+ }
+
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsNodeInfo.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsNodeInfo.java
new file mode 100644
index 0000000..333387a
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsNodeInfo.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import java.util.*;
+
+public class TsNodeInfo {
+ Map<String, Set<LtpId>> tpIdbyTtpId;
+
+ public TsNodeInfo(){}
+
+ public void addToTtpMap(String ttpId, LtpId tpId){
+ if (tpIdbyTtpId == null) {
+ tpIdbyTtpId = new HashMap<>();
+ }
+ Set<LtpId> iLLIds = tpIdbyTtpId.get(ttpId);
+ if ( iLLIds == null) {
+ iLLIds = new HashSet<>();
+ }
+ iLLIds.add(tpId);
+ tpIdbyTtpId.put(ttpId, iLLIds);
+ }
+
+ public Set<LtpId> getTpRefsByTtpId(String ttpId){
+ return tpIdbyTtpId == null? null : tpIdbyTtpId.get(ttpId);
+ }
+}
diff --git a/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsTunnel.java b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsTunnel.java
new file mode 100644
index 0000000..f076a17
--- /dev/null
+++ b/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/model/TsTunnel.java
@@ -0,0 +1,113 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Actn Interface Tools
+ * ================================================================================
+ * Copyright (C) 2023 Huawei Canada Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model;
+
+import com.google.common.collect.ImmutableList;
+
+
+import java.util.List;
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class TsTunnel extends TsLink {
+
+ private final List<TsLink> links;
+// private final Weight cost;
+ private final String name;
+ private OduResource bw = null;
+
+
+ public TsTunnel(List<TsLink> links, String name) {
+ super(source(links), destination(links), State.ACTIVE);
+ this.links = ImmutableList.copyOf(links);
+// this.cost = cost;
+ this.name = name;
+
+ }
+// public TsTunnel(LTPoint srcLtPoint, LTPoint dstLtPoint){
+// super(srcLtPoint, dstLtPoint);
+// this.links = null;
+// this.cost = null;
+// }
+
+ public List<TsLink> links(){
+ return links;
+ }
+
+// public double cost() {
+// if (cost instanceof ScalarWeight) {
+// return ((ScalarWeight) cost).value();
+// }
+// return 0;
+// }
+
+// public Weight weight() {
+// return cost;
+// }
+ public String name() {
+ return this.name;
+ }
+ private static LTPoint source(List<TsLink> links) {
+ checkNotNull(links, "List of path links cannot be null");
+ checkArgument(!links.isEmpty(), "List of path links cannot be null");
+ return links.get(0).dst();
+ }
+
+ private static LTPoint destination(List<TsLink> links) {
+ checkNotNull(links, "List of path links cannot be null");
+ checkArgument(!links.isEmpty(), "List of path links cannot be null");
+ return links.get(links.size() - 1).dst();
+ }
+
+ public String toString(){
+ StringBuilder sb = new StringBuilder("TsTunnel: ");
+ for (TsLink li : this.links()) {
+ sb.append("\n");
+ sb.append(li.toString());
+ };
+ sb.append("\n");
+// sb.append("with total cost: " + this.cost.toString());
+ return sb.toString();
+ }
+ public int hashCode() {
+ return links.hashCode();
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TsTunnel) {
+ final TsTunnel other = (TsTunnel) obj;
+ return Objects.equals(this.links, other.links);
+ }
+ return false;
+ }
+
+ public OduResource bw() {
+ return bw;
+ }
+
+ public void bw(OduResource bw) {
+ this.bw = bw;
+ }
+}