Yixiao Chen
Committed by Gerrit Code Review

[ONOS-4879][ONOS-5024][ONOS-5025]TE Topology NBI

The APP introduces IETF TE Topology YANG models as RESTCONF NBI,
and it works as an adapter for data conversion between
YMS(YANG generated JAVA classes) and TE Topology Core subsystem.

The APP implements the following interfaces:
IetfNetworkService Interface
IetfTopologyService Interface
IetfNetworkTopologyService Interface

Change-Id: I761ff684bde4b64ca42bb1b0d5b1ddfb8a2377fd
Showing 29 changed files with 7762 additions and 0 deletions
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
79 <module>tetopology</module> 79 <module>tetopology</module>
80 <module>rabbitmq</module> 80 <module>rabbitmq</module>
81 <module>learning-switch</module> 81 <module>learning-switch</module>
82 + <module>tenbi</module>
82 </modules> 83 </modules>
83 84
84 85
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016-present Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<project xmlns="http://maven.apache.org/POM/4.0.0"
18 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20 + <modelVersion>4.0.0</modelVersion>
21 +
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos-apps</artifactId>
25 + <version>1.8.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-app-tenbi</artifactId>
30 + <packaging>pom</packaging>
31 +
32 + <modules>
33 + <module>topology</module>
34 + <module>yangmodel</module>
35 + <module>utils</module>
36 + </modules>
37 +
38 + <description>TE YANG NBI Application</description>
39 +</project>
40 +
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2015 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<app name="org.onosproject.tenbi.topology" origin="HUAWEI" version="${project.version}"
18 + featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
19 + features="${project.artifactId}">
20 + <description>${project.description}</description>
21 + <artifact>mvn:${project.groupId}/${project.artifactId}/${project.version}</artifact>
22 + <artifact>mvn:${project.groupId}/onos-app-tenbi-yangmodel/${project.version}</artifact>
23 +</app>
24 +
1 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 +<!--
3 + ~ Copyright 2015 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
18 + <repository>mvn:${project.groupId}/onos-app-tenbi-yangmodel/${project.version}/xml/features</repository>
19 + <feature name="${project.artifactId}" version="${project.version}" description="${project.description}">
20 + <feature>onos-api</feature>
21 + <feature>onos-app-tenbi-yangmodel</feature>
22 + <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
23 + <bundle>mvn:${project.groupId}/onos-app-tetopology/${project.version}</bundle>
24 + <bundle>mvn:${project.groupId}/onos-app-yms-api/${project.version}</bundle>
25 + <bundle>mvn:${project.groupId}/onos-app-tenbi-utils/${project.version}</bundle>
26 + </feature>
27 +</features>
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<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/xsd/maven-4.0.0.xsd">
18 + <modelVersion>4.0.0</modelVersion>
19 +
20 + <parent>
21 + <groupId>org.onosproject</groupId>
22 + <artifactId>onos-app-tenbi</artifactId>
23 + <version>1.8.0-SNAPSHOT</version>
24 + <relativePath>../pom.xml</relativePath>
25 + </parent>
26 +
27 + <artifactId>onos-app-tenbi-topology</artifactId>
28 + <packaging>bundle</packaging>
29 +
30 + <description>IETF TE Topology NBI</description>
31 +
32 + <properties>
33 + <onos.app.name>tenbi.topology</onos.app.name>
34 + <onos.app.origin>HUAWEI</onos.app.origin>
35 + </properties>
36 +
37 + <dependencies>
38 + <dependency>
39 + <groupId>org.onosproject</groupId>
40 + <artifactId>onos-app-tenbi-yangmodel</artifactId>
41 + <version>${project.version}</version>
42 + </dependency>
43 + <dependency>
44 + <groupId>org.onosproject</groupId>
45 + <artifactId>onos-app-tenbi-utils</artifactId>
46 + <version>${project.version}</version>
47 + </dependency>
48 + <dependency>
49 + <groupId>org.onosproject</groupId>
50 + <artifactId>onlab-junit</artifactId>
51 + <scope>test</scope>
52 + </dependency>
53 + <dependency>
54 + <groupId>org.onosproject</groupId>
55 + <artifactId>onos-app-tetopology</artifactId>
56 + <version>${project.version}</version>
57 + </dependency>
58 + <dependency>
59 + <groupId>org.onosproject</groupId>
60 + <artifactId>onos-app-yms-api</artifactId>
61 + <version>${project.version}</version>
62 + </dependency>
63 + </dependencies>
64 +
65 +</project>
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.tenbi.topology.impl;
17 +
18 +import static com.google.common.base.Preconditions.checkNotNull;
19 +
20 +import org.apache.felix.scr.annotations.Activate;
21 +import org.apache.felix.scr.annotations.Component;
22 +import org.apache.felix.scr.annotations.Deactivate;
23 +import org.apache.felix.scr.annotations.Reference;
24 +import org.apache.felix.scr.annotations.ReferenceCardinality;
25 +import org.apache.felix.scr.annotations.Service;
26 +import org.onosproject.event.AbstractListenerManager;
27 +import org.onosproject.tetopology.management.api.TeTopologyService;
28 +import org.onosproject.teyang.api.OperationType;
29 +import org.onosproject.teyang.utils.topology.NetworkConverter;
30 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetwork;
31 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetworkOpParam;
32 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetworkService;
33 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.Networks;
34 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NetworksState;
35 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.IetfNetworkTopology;
36 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
37 + .IetfNetworkTopologyOpParam;
38 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
39 + .IetfNetworkTopologyService;
40 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.IetfTeTopology;
41 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.IetfTeTopologyOpParam;
42 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
43 + .IetfTeTopologyService;
44 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
45 + .ietftetopology.IetfTeTopologyEvent;
46 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
47 + .ietftetopology.IetfTeTopologyEventListener;
48 +import org.onosproject.yms.ymsm.YmsService;
49 +import org.slf4j.Logger;
50 +import org.slf4j.LoggerFactory;
51 +
52 +/**
53 + * The IETF TE Topology NBI Manager implementation.
54 + */
55 +@Component(immediate = true)
56 +@Service
57 +public class TeTopologyNbiManager
58 + extends AbstractListenerManager<IetfTeTopologyEvent, IetfTeTopologyEventListener>
59 + implements IetfNetworkService, IetfNetworkTopologyService, IetfTeTopologyService {
60 +
61 + private final Logger log = LoggerFactory.getLogger(getClass());
62 +
63 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
64 + protected TeTopologyService teTopologyService;
65 +
66 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
67 + protected YmsService ymsService;
68 +
69 + @Activate
70 + protected void activate() {
71 + // Register 3 services with YMS.
72 + ymsService.registerService(this, IetfNetworkService.class, null);
73 + ymsService.registerService(this, IetfNetworkTopologyService.class, null);
74 + ymsService.registerService(this, IetfTeTopologyService.class, null);
75 +
76 + log.info("Started");
77 + }
78 +
79 + @Deactivate
80 + protected void deactivate() {
81 + // Unregister 3 services.
82 + ymsService.unRegisterService(this, IetfNetworkService.class);
83 + ymsService.unRegisterService(this, IetfNetworkTopologyService.class);
84 + ymsService.unRegisterService(this, IetfTeTopologyService.class);
85 +
86 + log.info("Stopped");
87 + }
88 +
89 + @Override
90 + public IetfNetwork getIetfNetwork(IetfNetworkOpParam ietfNetwork) {
91 + log.info("getIetfNetwork: input {}", ietfNetwork);
92 +
93 + checkNotNull(ietfNetwork, "getIetfNetwork: ietfNetwork cannot be null");
94 +
95 + // Get the entire data tree from TE Subsystem core.
96 + org.onosproject.tetopology.management.api.Networks teNetworks = teTopologyService.getNetworks();
97 +
98 + // Convert the TE Subsystem core data into YANG Objects.
99 + Networks networks = NetworkConverter.teSubsystem2YangNetworks(teNetworks, OperationType.QUERY);
100 + NetworksState networkStates = NetworkConverter.teSubsystem2YangNetworkStates(teNetworks, OperationType.QUERY);
101 +
102 + IetfNetworkOpParam.IetfNetworkBuilder builder = new IetfNetworkOpParam.IetfNetworkBuilder();
103 + IetfNetwork newNetwork = builder.networks(networks)
104 + .networksState(networkStates)
105 + .onosYangNodeOperationType(IetfNetworkOpParam.OnosYangNodeOperationType.NONE)
106 + .build();
107 +
108 + // processSubtreeFiltering() filters the entire data tree based on the
109 + // user's query and returns the filtered data.
110 + return ietfNetwork.processSubtreeFiltering(newNetwork, false);
111 + }
112 +
113 + @Override
114 + public void setIetfNetwork(IetfNetworkOpParam ietfNetwork) {
115 + // In H release, topology is discovered from south, no NBI Set is supported.
116 + }
117 +
118 + @Override
119 + public IetfTeTopology getIetfTeTopology(IetfTeTopologyOpParam ietfTeTopology) {
120 + // unused method.
121 + return ietfTeTopology;
122 + }
123 +
124 + @Override
125 + public void setIetfTeTopology(IetfTeTopologyOpParam ietfTeTopology) {
126 + // unused methods.
127 + }
128 +
129 + @Override
130 + public IetfTeTopology getAugmentedIetfTeTopologyTeLinkEvent(IetfTeTopologyOpParam ietfTeTopology) {
131 + // unused methods.
132 + return ietfTeTopology;
133 + }
134 +
135 + @Override
136 + public void setAugmentedIetfTeTopologyTeLinkEvent(IetfTeTopologyOpParam augmentedIetfTeTopologyTeLinkEvent) {
137 + // unused methods.
138 + }
139 +
140 + @Override
141 + public IetfNetworkTopology getIetfNetworkTopology(IetfNetworkTopologyOpParam ietfNetworkTopology) {
142 + // unused methods.
143 + return ietfNetworkTopology;
144 + }
145 +
146 + @Override
147 + public void setIetfNetworkTopology(IetfNetworkTopologyOpParam ietfNetworkTopology) {
148 + // unused methods.
149 + }
150 +
151 + @Override
152 + public IetfNetwork getAugmentedIetfNetworkNetworks(IetfNetworkOpParam ietfNetwork) {
153 + // unused methods.
154 + return ietfNetwork;
155 + }
156 +
157 + @Override
158 + public void setAugmentedIetfNetworkNetworks(IetfNetworkOpParam augmentedIetfNetworkNetworks) {
159 + // unused methods.
160 + }
161 +
162 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +/**
17 + * The implementations of IETF TE Topology YANG NBI.
18 + */
19 +package org.onosproject.tenbi.topology.impl;
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<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/xsd/maven-4.0.0.xsd">
18 + <modelVersion>4.0.0</modelVersion>
19 +
20 + <parent>
21 + <groupId>org.onosproject</groupId>
22 + <artifactId>onos-app-tenbi</artifactId>
23 + <version>1.8.0-SNAPSHOT</version>
24 + <relativePath>../pom.xml</relativePath>
25 + </parent>
26 +
27 + <artifactId>onos-app-tenbi-utils</artifactId>
28 + <packaging>bundle</packaging>
29 +
30 + <description>IETF TE NBI Utilities</description>
31 +
32 + <dependencies>
33 + <dependency>
34 + <groupId>org.onosproject</groupId>
35 + <artifactId>onos-app-tenbi-yangmodel</artifactId>
36 + <version>${project.version}</version>
37 + </dependency>
38 + <dependency>
39 + <groupId>org.onosproject</groupId>
40 + <artifactId>onlab-junit</artifactId>
41 + <scope>test</scope>
42 + </dependency>
43 + <dependency>
44 + <groupId>org.onosproject</groupId>
45 + <artifactId>onos-app-tetopology</artifactId>
46 + <version>${project.version}</version>
47 + </dependency>
48 + </dependencies>
49 +
50 +</project>
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.teyang.api;
17 +
18 +/**
19 + * The operation type.
20 + */
21 +public enum OperationType {
22 +
23 + /**
24 + * The configuration data identified by the element
25 + * containing this attribute is merged with the configuration
26 + * at the corresponding level in the configuration datastore.
27 + */
28 + MERGE,
29 +
30 + /**
31 + * The configuration data identified by the element
32 + * containing this attribute replaces any related configuration
33 + * in the configuration datastore. If no such configuration
34 + * data exists in the configuration datastore, it is created.
35 + */
36 + REPLACE,
37 +
38 + /**
39 + * The configuration data identified by the element
40 + * containing this attribute is added to the configuration if
41 + * and only if the configuration data does not already exist in
42 + * the configuration datastore. If the configuration data
43 + * exists, an error is returned.
44 + */
45 + CREATE,
46 +
47 + /**
48 + * The configuration data identified by the element
49 + * containing this attribute is deleted from the configuration
50 + * if and only if the configuration data currently exists in
51 + * the configuration datastore. If the configuration data does
52 + * not exist, an error is returned".
53 + */
54 + DELETE,
55 +
56 + /**
57 + * The configuration data identified by the element
58 + * containing this attribute is deleted from the configuration
59 + * if the configuration data currently exists in the
60 + * configuration datastore. If the configuration data does not
61 + * exist, the "remove" operation is silently ignored by the
62 + * server.
63 + */
64 + REMOVE,
65 +
66 + /**
67 + * The node is used as a containment node to reach the child node,
68 + * There is no change in the data store for the values of this node in the
69 + * edit request.
70 + */
71 + NONE,
72 +
73 +// /**
74 +// * The YANG based request is to edit a config node / subtree in the data
75 +// * store.
76 +// */
77 +// EDIT_CONFIG,
78 +//
79 +// /**
80 +// * The YANG based request is to query a config node / subtree in the data
81 +// * store.
82 +// */
83 +// QUERY_CONFIG,
84 +//
85 + /**
86 + * The YANG based request is to query a node / subtree in the data store.
87 + */
88 + QUERY,
89 +
90 +// /**
91 +// * The YANG based request is to execute an RPC defined in YANG.
92 +// */
93 +// RPC,
94 +//
95 +// /**
96 +// * The YANG based request is to execute an RPC defined in YANG.
97 +// */
98 +// NOTIFICATION
99 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +/**
17 + * The utility APIs.
18 + */
19 +package org.onosproject.teyang.api;
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.teyang.utils.topology;
17 +
18 +import org.onosproject.tetopology.management.api.node.TeStatus;
19 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeAdminStatus;
20 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeOperStatus;
21 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.teadminstatus.TeAdminStatusEnum;
22 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.teoperstatus.TeOperStatusEnum;
23 +
24 +/**
25 + * The Enum conversion functions.
26 + */
27 +public final class EnumConverter {
28 +
29 + // no instantiation
30 + private EnumConverter() {
31 + }
32 +
33 + /**
34 + * Converts YANG Operation Status Enum to TE Topology TeStatus Enum.
35 + *
36 + * @param opStatus YANG Operation Status
37 + * @return the equivalent Enum from TE Topology TeStatus or null if not
38 + * found
39 + */
40 + public static TeStatus yang2TeSubsystemOpStatus(TeOperStatus opStatus) {
41 + switch (opStatus.enumeration()) {
42 + case DOWN:
43 + return TeStatus.DOWN;
44 + case UP:
45 + return TeStatus.UP;
46 + case MAINTENANCE:
47 + return TeStatus.MAINTENANCE;
48 + case PREPARING_MAINTENANCE:
49 + return TeStatus.PREPARING_MAINTENANCE;
50 + case TESTING:
51 + return TeStatus.TESTING;
52 + case UNKNOWN:
53 + return TeStatus.UNKNOWN;
54 + default:
55 + return null;
56 + }
57 + }
58 +
59 + /**
60 + * Converts YANG TeAdminStatus Enum to TE Topology TeStatus Enum.
61 + *
62 + * @param adminStatus YANG Admin Status
63 + * @return the equivalent Enum from TE Topology TeStatus or null if not
64 + * found
65 + */
66 + public static TeStatus yang2TeSubsystemAdminStatus(TeAdminStatus adminStatus) {
67 + switch (adminStatus.enumeration()) {
68 + case DOWN:
69 + return TeStatus.DOWN;
70 + case UP:
71 + return TeStatus.UP;
72 + case TESTING:
73 + return TeStatus.TESTING;
74 + case MAINTENANCE:
75 + return TeStatus.MAINTENANCE;
76 + case PREPARING_MAINTENANCE:
77 + return TeStatus.PREPARING_MAINTENANCE;
78 + default:
79 + return TeStatus.UNKNOWN;
80 + }
81 + }
82 +
83 + /**
84 + * Converts TE Topology TeStatus Enum to YANG TeAdminStatus Enum.
85 + *
86 + * @param adminStatus TE Topology admin status
87 + * @return the equivalent Enum from YANG TeAdminStatus or null if not found
88 + */
89 + public static TeAdminStatus teSubsystem2YangAdminStatus(TeStatus adminStatus) {
90 + switch (adminStatus) {
91 + case DOWN:
92 + return TeAdminStatus.of(TeAdminStatusEnum.DOWN);
93 + case UP:
94 + return TeAdminStatus.of(TeAdminStatusEnum.UP);
95 + case TESTING:
96 + return TeAdminStatus.of(TeAdminStatusEnum.TESTING);
97 + case MAINTENANCE:
98 + return TeAdminStatus.of(TeAdminStatusEnum.MAINTENANCE);
99 + case PREPARING_MAINTENANCE:
100 + return TeAdminStatus.of(TeAdminStatusEnum.PREPARING_MAINTENANCE);
101 + case UNKNOWN:
102 + return null;
103 + default:
104 + return null;
105 + }
106 + }
107 +
108 + /**
109 + * Converts TE Topology TeStatus Enum to YANG TeOperStatus Enum.
110 + *
111 + * @param opStatus TE Topology operation status
112 + * @return the equivalent Enum from YANG TeOperStatus or null if not found
113 + */
114 + public static TeOperStatus teSubsystem2YangOperStatus(TeStatus opStatus) {
115 + switch (opStatus) {
116 + case DOWN:
117 + return TeOperStatus.of(TeOperStatusEnum.DOWN);
118 + case UP:
119 + return TeOperStatus.of(TeOperStatusEnum.UP);
120 + case TESTING:
121 + return TeOperStatus.of(TeOperStatusEnum.TESTING);
122 + case MAINTENANCE:
123 + return TeOperStatus.of(TeOperStatusEnum.MAINTENANCE);
124 + case PREPARING_MAINTENANCE:
125 + return TeOperStatus.of(TeOperStatusEnum.PREPARING_MAINTENANCE);
126 + case UNKNOWN:
127 + return TeOperStatus.of(TeOperStatusEnum.UNKNOWN);
128 + default:
129 + return null;
130 + }
131 + }
132 +
133 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.teyang.utils.topology;
17 +
18 +import static com.google.common.base.Preconditions.checkNotNull;
19 +
20 +import java.util.List;
21 +
22 +import org.onosproject.tetopology.management.api.KeyId;
23 +import org.onosproject.tetopology.management.api.link.ExternalDomain;
24 +import org.onosproject.tetopology.management.api.link.LinkProtectionType;
25 +import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
26 +import org.onosproject.tetopology.management.api.link.PathElement;
27 +import org.onosproject.tetopology.management.api.link.TeLink;
28 +import org.onosproject.tetopology.management.api.link.UnderlayBackupPath;
29 +import org.onosproject.tetopology.management.api.link.UnderlayPath;
30 +import org.onosproject.tetopology.management.api.node.TeNetworkTopologyId;
31 +import org.onosproject.tetopology.management.api.node.TerminationPointKey;
32 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NetworkId;
33 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NodeId;
34 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
35 + .ietfnetworktopology.LinkId;
36 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
37 + .ietfnetworktopology.TpId;
38 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
39 + .ietfnetworktopology.networks.network.augmentedndnetwork.DefaultLink;
40 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
41 + .ietfnetworktopology.networks.network.augmentedndnetwork.DefaultLink.LinkBuilder;
42 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
43 + .ietfnetworktopology.networks.network.augmentedndnetwork.Link;
44 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
45 + .ietfnetworktopology.networks.network.augmentedndnetwork.link.DefaultDestination;
46 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
47 + .ietfnetworktopology.networks.network.augmentedndnetwork.link.DefaultSource;
48 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
49 + .ietfnetworktopology.networks.network.augmentedndnetwork.link.DefaultSupportingLink;
50 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
51 + .ietfnetworktopology.networks.network.augmentedndnetwork.link.Destination
52 + .DestinationBuilder;
53 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
54 + .ietfnetworktopology.networks.network.augmentedndnetwork.link.Source.SourceBuilder;
55 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
56 + .ietfnetworktopology.networks.network.augmentedndnetwork.link.SupportingLink;
57 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
58 + .ietfnetworktopology.networks.network.augmentedndnetwork.link.SupportingLink
59 + .SupportingLinkBuilder;
60 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
61 + .ietftetopology.networks.augmentednwnetworks.te.templates.linktemplate
62 + .telinkattributes.LinkProtectionTypeEnum;
63 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
64 + .ietftetopology.networks.network.link.AugmentedNtLink;
65 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
66 + .ietftetopology.networks.network.link.DefaultAugmentedNtLink;
67 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
68 + .ietftetopology.networks.network.link.DefaultAugmentedNtLink.AugmentedNtLinkBuilder;
69 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
70 + .ietftetopology.networks.network.link.augmentedntlink.DefaultTe;
71 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
72 + .ietftetopology.networks.network.link.augmentedntlink.DefaultTe.TeBuilder;
73 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
74 + .ietftetopology.networks.network.link.augmentedntlink.te.Config;
75 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
76 +.ietftetopology.networks.network.link.augmentedntlink.te.Config.ConfigBuilder;
77 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
78 + .ietftetopology.networks.network.link.augmentedntlink.te.DefaultConfig;
79 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
80 + .ietftetopology.networks.network.link.augmentedntlink.te.DefaultState;
81 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
82 + .ietftetopology.networks.network.link.augmentedntlink.te.State;
83 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
84 +.ietftetopology.networks.network.link.augmentedntlink.te.State.StateBuilder;
85 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
86 + .ietftetopology.networks.network.link.augmentedntlink.te.config.DefaultTeLinkAttributes;
87 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
88 + .ietftetopology.networks.network.link.augmentedntlink.te.config.TeLinkAttributes;
89 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
90 + .ietftetopology.networks.network.link.augmentedntlink.te.config.TeLinkAttributes
91 + .TeLinkAttributesBuilder;
92 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
93 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
94 + .DefaultExternalDomain;
95 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
96 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
97 + .DefaultExternalDomain.ExternalDomainBuilder;
98 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
99 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes.DefaultTeSrlgs;
100 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
101 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes.DefaultUnderlay;
102 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
103 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
104 + .DefaultUnreservedBandwidth;
105 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
106 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes.TeSrlgs
107 + .TeSrlgsBuilder;
108 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
109 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes.Underlay;
110 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
111 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes.Underlay
112 + .UnderlayBuilder;
113 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
114 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
115 + .UnreservedBandwidth;
116 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
117 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
118 + .UnreservedBandwidth.UnreservedBandwidthBuilder;
119 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
120 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
121 + .underlay.DefaultUnderlayBackupPath;
122 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
123 + .networks.network.link.augmentedntlink.te.config.telinkattributes.underlay
124 + .DefaultUnderlayBackupPath.UnderlayBackupPathBuilder;
125 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
126 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
127 + .underlay.DefaultUnderlayPrimaryPath;
128 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
129 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
130 + .underlay.DefaultUnderlayTrailDes.UnderlayTrailDesBuilder;
131 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
132 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
133 + .underlay.DefaultUnderlayTrailSrc.UnderlayTrailSrcBuilder;
134 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
135 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
136 + .underlay.UnderlayPrimaryPath;
137 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
138 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
139 + .underlay.UnderlayPrimaryPath.UnderlayPrimaryPathBuilder;
140 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
141 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
142 + .underlay.underlayprimarypath.DefaultPathElement;
143 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.Srlg;
144 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeLinkAccessType;
145 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeNodeId;
146 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeTopologyId;
147 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeTpId;
148 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705
149 + .ietftetypes.telinkaccesstype.TeLinkAccessTypeEnum;
150 +
151 +import com.google.common.collect.Lists;
152 +
153 +/**
154 + * The conversion functions.
155 + */
156 +public final class LinkConverter {
157 + private static final String
158 + E_NULL_TELINK_UNDERLAY_PATH = "TeSubsystem link underlayPath object cannot be null";
159 + private static final String
160 + E_NULL_TELINK_DATA = "TeSubsystem teLink data cannot be null";
161 + private static final String
162 + E_NULL_TELINK = "TeSubsystem teLink object cannot be null";
163 + private static final String
164 + E_NULL_YANG_TELINK_CONFIG = "YANG telink config object cannot be null";
165 + private static final String
166 + E_NULL_YANG_TELINK = "YANG Link object cannot be null";
167 +
168 + // no instantiation
169 + private LinkConverter() {
170 + }
171 +
172 + private static UnderlayBuilder te2YangConfigUnderlayPrimaryPath(
173 + UnderlayBuilder yangBuilder,
174 + org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath tePath) {
175 + UnderlayPrimaryPathBuilder pathBuilder =
176 + DefaultUnderlayPrimaryPath.builder();
177 + if (tePath.pathElements() != null) {
178 + for (PathElement pathElementTe : tePath.pathElements()) {
179 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
180 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
181 + .config.telinkattributes.underlay.underlayprimarypath.PathElement
182 + .PathElementBuilder pathElementYangBuilder = DefaultPathElement.builder();
183 + // FIXME: pathElementTe does not have any getter or
184 + // setter at the moment --> pathElementYangBuilder =
185 + // pathElementYangBuilder.pathElementId(pathElementTe.getPathElementId());
186 + pathBuilder = pathBuilder.addToPathElement(pathElementYangBuilder.build());
187 + }
188 + }
189 + pathBuilder = pathBuilder.networkIdRef(NetworkId.fromString(
190 + tePath.ref().getNetworkId().toString()))
191 + .teTopologyIdRef(TeTopologyId.fromString(
192 + tePath.ref().getTopologyId().topologyId()));
193 + return yangBuilder.underlayPrimaryPath(pathBuilder.build());
194 + }
195 +
196 + private static UnderlayBuilder te2YangConfigUnderlayBackupPaths(
197 + UnderlayBuilder yangBuilder,
198 + List<org.onosproject.tetopology.management.api.link.UnderlayBackupPath> tePaths) {
199 +
200 + for (UnderlayBackupPath tePath : tePaths) {
201 + UnderlayBackupPathBuilder pathBuilder = DefaultUnderlayBackupPath.builder();
202 + pathBuilder = pathBuilder.index(tePath.index());
203 + pathBuilder = pathBuilder.networkIdRef(NetworkId.fromString(
204 + tePath.ref().getNetworkId().toString()))
205 + .teTopologyIdRef(TeTopologyId.fromString(
206 + tePath.ref().getTopologyId().topologyId()));
207 + for (PathElement backupPathElementTe : tePath.pathElements()) {
208 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
209 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
210 + .config.telinkattributes.underlay.underlaybackuppath.PathElement
211 + .PathElementBuilder elementBuilder =
212 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
213 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
214 + .config.telinkattributes.underlay.underlaybackuppath.DefaultPathElement.builder();
215 + // FIXME: backupPathElementTe does not have any
216 + // getter or setter at the moment -->
217 + // elementBuilder =
218 + // elementBuilder.pathElementId(backupPathElementTe.getPathElementId());
219 + pathBuilder = pathBuilder.addToPathElement(elementBuilder.build());
220 + }
221 + yangBuilder = yangBuilder.addToUnderlayBackupPath(pathBuilder.build());
222 + }
223 +
224 + return yangBuilder;
225 + }
226 +
227 + /**
228 + * TE Link underlay path Config object conversion from TE Topology subsystem to YANG.
229 + *
230 + * @param tePath TE underlay path object
231 + * @return Link underlay path Config YANG object
232 + */
233 + private static Underlay teSubsystem2YangConfigUnderlayPath(UnderlayPath tePath) {
234 + checkNotNull(tePath, E_NULL_TELINK_UNDERLAY_PATH);
235 + UnderlayBuilder builder =
236 + DefaultUnderlay.builder().underlayProtectionType(tePath.protectionType());
237 +
238 + if (tePath.primaryPath() != null) {
239 + builder = te2YangConfigUnderlayPrimaryPath(builder, tePath.primaryPath());
240 + }
241 + if (tePath.trailSrc() != null) {
242 + builder = builder.underlayTrailSrc(
243 + new UnderlayTrailSrcBuilder()
244 + .networkRef(NetworkId.fromString(
245 + tePath.trailSrc().networkId().toString()))
246 + .nodeRef(NodeId.fromString(
247 + tePath.trailSrc().nodeId().toString()))
248 + .tpRef(TpId.fromString(
249 + tePath.trailSrc().tpId().toString()))
250 + .build());
251 + }
252 + if (tePath.trailDes() != null) {
253 + builder = builder.underlayTrailDes(
254 + new UnderlayTrailDesBuilder()
255 + .networkRef(NetworkId.fromString(
256 + tePath.trailDes().networkId().toString()))
257 + .nodeRef(NodeId.fromString(
258 + tePath.trailDes().nodeId().toString()))
259 + .tpRef(TpId.fromString(
260 + tePath.trailDes().tpId().toString()))
261 + .build());
262 + }
263 + if (tePath.backupPaths() != null) {
264 + builder = te2YangConfigUnderlayBackupPaths(builder, tePath.backupPaths());
265 + }
266 +
267 + return builder.build();
268 + }
269 +
270 + private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
271 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
272 + .state.telinkattributes.Underlay.UnderlayBuilder
273 + te2YangStateUnderlayPrimaryPath(
274 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
275 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
276 + .state.telinkattributes.Underlay.UnderlayBuilder yangBuilder,
277 + org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath tePath) {
278 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
279 + .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
280 + .underlay.UnderlayPrimaryPath.UnderlayPrimaryPathBuilder pathBuilder =
281 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
282 + .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
283 + .underlay.DefaultUnderlayPrimaryPath.builder();
284 + if (tePath.pathElements() != null) {
285 + for (PathElement pathElementTe : tePath.pathElements()) {
286 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
287 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
288 + .state.telinkattributes.underlay.underlayprimarypath.PathElement
289 + .PathElementBuilder pathElementYangBuilder =
290 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
291 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
292 + .state.telinkattributes.underlay.underlayprimarypath.DefaultPathElement
293 + .builder();
294 + // FIXME: pathElementTe does not have any getter or
295 + // setter at the moment --> pathElementYangBuilder =
296 + // pathElementYangBuilder.pathElementId(pathElementTe.getPathElementId());
297 + pathBuilder = pathBuilder.addToPathElement(pathElementYangBuilder.build());
298 + }
299 + }
300 + pathBuilder = pathBuilder.networkIdRef(NetworkId.fromString(
301 + tePath.ref().getNetworkId().toString()))
302 + .teTopologyIdRef(TeTopologyId.fromString(
303 + tePath.ref().getTopologyId().topologyId()));
304 + return yangBuilder.underlayPrimaryPath(pathBuilder.build());
305 + }
306 +
307 + private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
308 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
309 + .state.telinkattributes.Underlay.UnderlayBuilder
310 + te2YangStateUnderlayBackupPaths(
311 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
312 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
313 + .state.telinkattributes.Underlay.UnderlayBuilder yangBuilder,
314 + List<org.onosproject.tetopology.management.api.link.UnderlayBackupPath> tePaths) {
315 +
316 + for (UnderlayBackupPath tePath : tePaths) {
317 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
318 + .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
319 + .underlay.UnderlayBackupPath.UnderlayBackupPathBuilder
320 + pathBuilder = org.onosproject.yang.gen.v1.urn.ietf.params.xml
321 + .ns.yang.ietf.te.topology.rev20160708.ietftetopology.networks.network.link.augmentedntlink
322 + .te.state.telinkattributes.underlay.DefaultUnderlayBackupPath
323 + .builder();
324 +
325 + pathBuilder = pathBuilder.index(tePath.index());
326 + pathBuilder = pathBuilder.networkIdRef(NetworkId.fromString(
327 + tePath.ref().getNetworkId().toString()))
328 + .teTopologyIdRef(TeTopologyId.fromString(
329 + tePath.ref().getTopologyId().topologyId()));
330 + for (PathElement backupPathElementTe : tePath.pathElements()) {
331 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
332 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
333 + .state.telinkattributes.underlay.underlaybackuppath.PathElement
334 + .PathElementBuilder elementBuilder =
335 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
336 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
337 + .state.telinkattributes.underlay.underlaybackuppath.DefaultPathElement.builder();
338 + // FIXME: backupPathElementTe does not have any
339 + // getter or setter at the moment -->
340 + // elementBuilder =
341 + // elementBuilder.pathElementId(backupPathElementTe.getPathElementId());
342 + pathBuilder = pathBuilder.addToPathElement(elementBuilder.build());
343 + }
344 + yangBuilder = yangBuilder.addToUnderlayBackupPath(pathBuilder.build());
345 + }
346 +
347 + return yangBuilder;
348 + }
349 +
350 + /**
351 + * TE Link underlay path State object conversion from TE Topology subsystem to YANG.
352 + *
353 + * @param tePath TE underlay object
354 + * @return Link underlay path State YANG object
355 + */
356 + private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
357 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
358 + .state.telinkattributes.Underlay
359 + teSubsystem2YangStateUnderlayPath(UnderlayPath tePath) {
360 + checkNotNull(tePath, E_NULL_TELINK_UNDERLAY_PATH);
361 +
362 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
363 + .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
364 + .Underlay.UnderlayBuilder builder =
365 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
366 + .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
367 + .DefaultUnderlay.builder().underlayProtectionType(tePath.protectionType());
368 +
369 + if (tePath.primaryPath() != null) {
370 + builder = te2YangStateUnderlayPrimaryPath(builder, tePath.primaryPath());
371 +
372 + }
373 + if (tePath.trailSrc() != null) {
374 + builder = builder.underlayTrailSrc(
375 + new org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te
376 + .topology.rev20160708.ietftetopology.networks.network.link
377 + .augmentedntlink.te.state.telinkattributes.underlay
378 + .DefaultUnderlayTrailSrc.UnderlayTrailSrcBuilder()
379 + .networkRef(NetworkId.fromString(
380 + tePath.trailSrc().networkId().toString()))
381 + .nodeRef(NodeId.fromString(
382 + tePath.trailSrc().nodeId().toString()))
383 + .tpRef(TpId.fromString(
384 + tePath.trailSrc().tpId().toString()))
385 + .build());
386 + }
387 + if (tePath.trailDes() != null) {
388 + builder = builder.underlayTrailDes(
389 + new org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te
390 + .topology.rev20160708.ietftetopology.networks.network.link
391 + .augmentedntlink.te.state.telinkattributes.underlay
392 + .DefaultUnderlayTrailDes.UnderlayTrailDesBuilder()
393 + .networkRef(NetworkId.fromString(
394 + tePath.trailDes().networkId().toString()))
395 + .nodeRef(NodeId.fromString(
396 + tePath.trailDes().nodeId().toString()))
397 + .tpRef(TpId.fromString(
398 + tePath.trailDes().tpId().toString()))
399 + .build());
400 + }
401 + if (tePath.backupPaths() != null) {
402 + builder = te2YangStateUnderlayBackupPaths(builder, tePath.backupPaths());
403 + }
404 +
405 + return builder.build();
406 + }
407 +
408 + /**
409 + * TE Link Config object conversion from TE Topology subsystem to YANG.
410 + *
411 + * @param teLink TE link object
412 + * @return TE Link Config YANG object
413 + */
414 + private static Config teLink2YangConfig(TeLink teLink) {
415 + checkNotNull(teLink, E_NULL_TELINK_DATA);
416 +
417 + TeLinkAttributesBuilder attrBuilder = DefaultTeLinkAttributes.builder();
418 + if (teLink.linkIndex() != null) {
419 + attrBuilder = attrBuilder.linkIndex(teLink.linkIndex());
420 + }
421 + if (teLink.name() != null) {
422 + attrBuilder = attrBuilder.name(teLink.name());
423 + }
424 + if (teLink.adminStatus() != null) {
425 + attrBuilder = attrBuilder
426 + .adminStatus(EnumConverter
427 + .teSubsystem2YangAdminStatus(teLink
428 + .adminStatus()));
429 + }
430 + if (teLink.accessType() != null) {
431 + attrBuilder = attrBuilder
432 + .accessType(teSubsystem2YangTeLinkAccess(teLink
433 + .accessType()));
434 + }
435 + if (teLink.linkProtectionType() != null) {
436 + attrBuilder = attrBuilder
437 + .linkProtectionType(teSubsystem2YangLinkProtectionType(teLink
438 + .linkProtectionType()));
439 + }
440 + if (teLink.maxLinkBandwidth() != null) {
441 + attrBuilder = attrBuilder.maxLinkBandwidth(teLink.maxLinkBandwidth());
442 + }
443 + if (teLink.maxResvLinkBandwidth() != null) {
444 + attrBuilder = attrBuilder.maxResvLinkBandwidth(teLink.maxResvLinkBandwidth());
445 + }
446 + attrBuilder = attrBuilder.teDefaultMetric(teLink.teDefaultMetric());
447 + if (teLink.teSrlgs() != null) {
448 + TeSrlgsBuilder teSrlgsBuilder = DefaultTeSrlgs.builder();
449 + for (Long srlgLongVal : teLink.teSrlgs()) {
450 + teSrlgsBuilder = teSrlgsBuilder.addToValue(new Srlg(srlgLongVal));
451 + }
452 + attrBuilder = attrBuilder.teSrlgs(teSrlgsBuilder.build());
453 + }
454 + attrBuilder = attrBuilder.isAbstract(teLink.isAbstract());
455 + if (teLink.underlayPath() != null) {
456 + attrBuilder = attrBuilder.underlay(
457 + teSubsystem2YangConfigUnderlayPath(teLink.underlayPath()));
458 + }
459 + if (teLink.externalDomain() != null) {
460 + ExternalDomainBuilder edBuilder =
461 + DefaultExternalDomain.builder()
462 + .plugId(teLink.externalDomain().plugId())
463 + .remoteTeLinkTpId(TeTpId.fromString(
464 + teLink.externalDomain().remoteTeLinkTpId().toString()))
465 + .remoteTeNodeId(TeNodeId.fromString(
466 + teLink.externalDomain().remoteTeNodeId().toString()));
467 + attrBuilder = attrBuilder.externalDomain(edBuilder.build());
468 + }
469 +
470 + if (teLink.unreservedBandwidths() != null) {
471 + for (org.onosproject.tetopology.management.api.link.UnreservedBandwidth unResBwTe :
472 + teLink.unreservedBandwidths()) {
473 + UnreservedBandwidthBuilder urBuilder =
474 + DefaultUnreservedBandwidth.builder()
475 + .bandwidth(unResBwTe.bandwidth())
476 + .priority(unResBwTe.priority());
477 + attrBuilder = attrBuilder.addToUnreservedBandwidth(urBuilder.build());
478 + }
479 + }
480 +
481 + ConfigBuilder yangConfigBuilder = DefaultConfig.builder()
482 + .teLinkAttributes(attrBuilder.build());
483 + return yangConfigBuilder.build();
484 + }
485 +
486 + private static LinkProtectionTypeEnum
487 + teSubsystem2YangLinkProtectionType(LinkProtectionType linkProtectionType) {
488 + switch (linkProtectionType) {
489 + case ENHANCED:
490 + return LinkProtectionTypeEnum.ENHANCED;
491 + case EXTRA_TRAFFIC:
492 + return LinkProtectionTypeEnum.EXTRA_TRAFFIC;
493 + case SHARED:
494 + return LinkProtectionTypeEnum.SHARED;
495 + case UNPROTECTED:
496 + return LinkProtectionTypeEnum.UNPROTECTED;
497 + case YANGAUTOPREFIX1_FOR_1:
498 + return LinkProtectionTypeEnum.YANGAUTOPREFIX1_FOR_1;
499 + case YANGAUTOPREFIX1_PLUS_1:
500 + return LinkProtectionTypeEnum.YANGAUTOPREFIX1_PLUS_1;
501 + default:
502 + return null;
503 + }
504 + }
505 +
506 + private static TeLinkAccessType teSubsystem2YangTeLinkAccess(
507 + org.onosproject.tetopology.management.api.link.TeLinkAccessType accessType) {
508 + switch (accessType) {
509 + case MULTI_ACCESS:
510 + return TeLinkAccessType.of(TeLinkAccessTypeEnum.MULTI_ACCESS);
511 + case POINT_TO_POINT:
512 + return TeLinkAccessType.of(TeLinkAccessTypeEnum.POINT_TO_POINT);
513 + default:
514 + return null;
515 + }
516 + }
517 +
518 + /**
519 + * TE Link State object conversion from TE Topology subsystem to YANG.
520 + *
521 + * @param teLink TE link object
522 + * @return TE Link State YANG object
523 + */
524 + private static State teLink2YangState(TeLink teLink) {
525 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
526 + .ietftetopology.networks.network.link.augmentedntlink.te.state.TeLinkAttributes
527 + .TeLinkAttributesBuilder attrBuilder =
528 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
529 + .ietftetopology.networks.network.link.augmentedntlink.te.state.DefaultTeLinkAttributes
530 + .builder()
531 + .teDefaultMetric(teLink.teDefaultMetric())
532 + .isAbstract(teLink.isAbstract());
533 + if (teLink.linkIndex() != null) {
534 + attrBuilder = attrBuilder.linkIndex(teLink.linkIndex());
535 + }
536 + if (teLink.name() != null) {
537 + attrBuilder = attrBuilder.name(teLink.name());
538 + }
539 + if (teLink.adminStatus() != null) {
540 + attrBuilder = attrBuilder
541 + .adminStatus(EnumConverter
542 + .teSubsystem2YangAdminStatus(teLink
543 + .adminStatus()));
544 + }
545 + if (teLink.accessType() != null) {
546 + attrBuilder = attrBuilder
547 + .accessType(teSubsystem2YangTeLinkAccess(teLink
548 + .accessType()));
549 + }
550 + if (teLink.linkProtectionType() != null) {
551 + attrBuilder = attrBuilder
552 + .linkProtectionType(teSubsystem2YangStateLinkProtectionType(teLink
553 + .linkProtectionType()));
554 + }
555 + if (teLink.maxLinkBandwidth() != null) {
556 + attrBuilder = attrBuilder.maxLinkBandwidth(teLink.maxLinkBandwidth());
557 + }
558 + if (teLink.maxResvLinkBandwidth() != null) {
559 + attrBuilder = attrBuilder.maxResvLinkBandwidth(teLink.maxResvLinkBandwidth());
560 + }
561 + if (teLink.teSrlgs() != null) {
562 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
563 + .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
564 + .TeSrlgs.TeSrlgsBuilder srlgsBuilder =
565 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
566 + .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
567 + .DefaultTeSrlgs.builder();
568 + for (Long srlgLongVal : teLink.teSrlgs()) {
569 + srlgsBuilder = srlgsBuilder.addToValue(new Srlg(srlgLongVal));
570 + }
571 + attrBuilder = attrBuilder.teSrlgs(srlgsBuilder.build());
572 + }
573 + if (teLink.underlayPath() != null) {
574 + attrBuilder = attrBuilder.underlay(teSubsystem2YangStateUnderlayPath(teLink.underlayPath()));
575 + }
576 + if (teLink.externalDomain() != null) {
577 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
578 + .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
579 + .ExternalDomain.ExternalDomainBuilder edBuilder =
580 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
581 + .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
582 + .DefaultExternalDomain.builder()
583 + .plugId(teLink.externalDomain().plugId())
584 + .remoteTeLinkTpId(TeTpId.fromString(
585 + teLink.externalDomain().remoteTeLinkTpId().toString()))
586 + .remoteTeNodeId(TeNodeId.fromString(
587 + teLink.externalDomain().remoteTeNodeId().toString()));
588 + attrBuilder = attrBuilder.externalDomain(edBuilder.build());
589 + }
590 + if (teLink.unreservedBandwidths() != null) {
591 + for (org.onosproject.tetopology.management.api.link.UnreservedBandwidth unResBwTe :
592 + teLink.unreservedBandwidths()) {
593 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
594 + .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
595 + .UnreservedBandwidth.UnreservedBandwidthBuilder urBuilder =
596 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
597 + .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
598 + .DefaultUnreservedBandwidth.builder()
599 + .bandwidth(unResBwTe.bandwidth())
600 + .priority(unResBwTe.priority());
601 + attrBuilder = attrBuilder.addToUnreservedBandwidth(urBuilder.build());
602 + }
603 + }
604 +
605 + StateBuilder yangStateBuilder = DefaultState.builder()
606 + .teLinkAttributes(attrBuilder.build());
607 + if (teLink.opStatus() != null) {
608 + yangStateBuilder = yangStateBuilder
609 + .operStatus(EnumConverter
610 + .teSubsystem2YangOperStatus(teLink
611 + .opStatus()));
612 + }
613 +
614 + return yangStateBuilder.build();
615 + }
616 +
617 + private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
618 + rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
619 + LinkProtectionTypeEnum teSubsystem2YangStateLinkProtectionType(LinkProtectionType linkProtectionType) {
620 + switch (linkProtectionType) {
621 + case ENHANCED:
622 + return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
623 + rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
624 + LinkProtectionTypeEnum.ENHANCED;
625 + case EXTRA_TRAFFIC:
626 + return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
627 + rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
628 + LinkProtectionTypeEnum.EXTRA_TRAFFIC;
629 + case SHARED:
630 + return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
631 + rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
632 + LinkProtectionTypeEnum.SHARED;
633 + case UNPROTECTED:
634 + return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
635 + rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
636 + LinkProtectionTypeEnum.UNPROTECTED;
637 + case YANGAUTOPREFIX1_FOR_1:
638 + return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
639 + rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
640 + LinkProtectionTypeEnum.YANGAUTOPREFIX1_FOR_1;
641 + case YANGAUTOPREFIX1_PLUS_1:
642 + return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
643 + rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
644 + LinkProtectionTypeEnum.YANGAUTOPREFIX1_PLUS_1;
645 + default:
646 + return null;
647 + }
648 + }
649 +
650 + /**
651 + * Link object conversion from TE Topology subsystem to YANG.
652 + *
653 + * @param teLink TE subsystem link object
654 + * @return YANG link object
655 + */
656 + public static Link teSubsystem2YangLink(
657 + org.onosproject.tetopology.management.api.link.NetworkLink teLink) {
658 + checkNotNull(teLink, E_NULL_TELINK);
659 +
660 + LinkId linkId = LinkId.fromString(teLink.linkId().toString());
661 + LinkBuilder builder = DefaultLink.builder().linkId(linkId);
662 + if (teLink.getSupportingLinkIds() != null) {
663 + List<SupportingLink> slinks = Lists.newArrayList();
664 + SupportingLinkBuilder spLinkBuilder = DefaultSupportingLink.builder();
665 + for (NetworkLinkKey linkKey : teLink.getSupportingLinkIds()) {
666 + slinks.add(spLinkBuilder.networkRef(NetworkId.fromString(
667 + linkKey.networkId().toString()))
668 + .linkRef(LinkId.fromString(
669 + linkKey.linkId().toString()))
670 + .build());
671 + }
672 + builder = builder.supportingLink(slinks);
673 + }
674 + if (teLink.getSource() != null) {
675 + SourceBuilder sourceBuilder = DefaultSource
676 + .builder()
677 + .sourceNode(NodeId.fromString(
678 + teLink.getSource().nodeId().toString()))
679 + .sourceTp(TpId.fromString(
680 + teLink.getSource().tpId().toString()));
681 + builder = builder.source(sourceBuilder.build());
682 + }
683 + if (teLink.getDestination() != null) {
684 + DestinationBuilder destBuilder = DefaultDestination
685 + .builder()
686 + .destNode(NodeId.fromString(
687 + teLink.getDestination().nodeId().toString()))
688 + .destTp(TpId.fromString(
689 + teLink.getDestination().tpId().toString()));
690 + builder = builder.destination(destBuilder.build());
691 + }
692 +
693 + if (teLink.getTe() != null) {
694 + TeLink teData = teLink.getTe();
695 + TeBuilder yangTeBuilder = DefaultTe.builder()
696 + .config(teLink2YangConfig(teData))
697 + .state(teLink2YangState(teData));
698 + AugmentedNtLinkBuilder linkAugmentBuilder =
699 + DefaultAugmentedNtLink.builder()
700 + .te(yangTeBuilder.build());
701 + builder.addYangAugmentedInfo(linkAugmentBuilder.build(), AugmentedNtLink.class);
702 + }
703 +
704 + return builder.build();
705 + }
706 +
707 + private static org.onosproject.tetopology.management.api.link.UnderlayPath
708 + yang2TeSubsystemUnderlayPrimaryPath(
709 + org.onosproject.tetopology.management.api.link.UnderlayPath teUnderlay,
710 + UnderlayPrimaryPath yangpath) {
711 + org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath teUnderlayPrimaryPath =
712 + new org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath();
713 + teUnderlayPrimaryPath.setRef(new TeNetworkTopologyId(KeyId.keyId(
714 + yangpath.networkIdRef().toString()),
715 + new org.onosproject.tetopology.management.api.TeTopologyId(
716 + yangpath.providerIdRef().uint32(),
717 + yangpath.clientIdRef().uint32(),
718 + yangpath.teTopologyIdRef().toString())));
719 +
720 + List<PathElement> pathElementList = Lists.newArrayList();
721 + for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
722 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
723 + .underlay.underlayprimarypath.PathElement pathElementConfigYang :
724 + yangpath.pathElement()) {
725 + //PathElement tePathElement = new PathElement();
726 + // FIXME: tePathElement does not have any getter
727 + // or setter at the moment -->
728 + // tePathElement.set...
729 + // TODO: construct the tePathElement object
730 + // properly using pathElementConfigYang
731 + //pathElementList.add(tePathElement);
732 + }
733 + teUnderlayPrimaryPath.setPathElement(pathElementList);
734 + teUnderlay.setPrimaryPath(teUnderlayPrimaryPath);
735 +
736 + return teUnderlay;
737 + }
738 +
739 + private static org.onosproject.tetopology.management.api.link.UnderlayPath
740 + yang2TeSubsystemUnderlayBackupPaths(
741 + org.onosproject.tetopology.management.api.link.UnderlayPath teUnderlay,
742 + List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te
743 + .topology.rev20160708.ietftetopology.networks.network.link
744 + .augmentedntlink.te.config.telinkattributes.underlay
745 + .UnderlayBackupPath> yangpaths) {
746 + List<UnderlayBackupPath> underlayBackupPathsList = Lists.newArrayList();
747 + for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
748 + .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
749 + .underlay.UnderlayBackupPath yangConfig : yangpaths) {
750 + UnderlayBackupPath ubp = new UnderlayBackupPath();
751 + ubp.setIndex(yangConfig.index());
752 + ubp.setRef(new TeNetworkTopologyId(KeyId.keyId(yangConfig.networkIdRef().toString()),
753 + new org.onosproject.tetopology.management.api.TeTopologyId(
754 + yangConfig.providerIdRef().uint32(),
755 + yangConfig.clientIdRef().uint32(),
756 + yangConfig.teTopologyIdRef().toString()
757 + )));
758 + List<PathElement> backupPathElementList = Lists.newArrayList();
759 + for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
760 + .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.config
761 + .telinkattributes.underlay.underlaybackuppath.PathElement
762 + pathElementBackupYang : yangConfig.pathElement()) {
763 + //PathElement tePathElementBackup = new PathElement();
764 + // FIXME: tePathElement does not have any
765 + // getter or setter at the moment -->
766 + // tePathElement.set...
767 + // TODO: construct the tePathElement object
768 + // properly using pathElementBackupYang
769 + //backupPathElementList.add(tePathElementBackup);
770 + }
771 + ubp.setPathElement(backupPathElementList);
772 + }
773 + teUnderlay.setBackupPath(underlayBackupPathsList);
774 +
775 + return teUnderlay;
776 + }
777 +
778 + /**
779 + * TE Link underlay path Config object conversion from YANG to TE Topology subsystem.
780 + *
781 + * @param yangLinkAtrr YANG link Config YANG object
782 + * @return teSubsystem TE underlay path object
783 + */
784 + private static org.onosproject.tetopology.management.api.link.UnderlayPath
785 + yang2TeSubsystemUnderlayPath(TeLinkAttributes yangLinkAtrr) {
786 + checkNotNull(yangLinkAtrr, E_NULL_YANG_TELINK_CONFIG);
787 +
788 + org.onosproject.tetopology.management.api.link.UnderlayPath teUnderlay =
789 + new org.onosproject.tetopology.management.api.link.UnderlayPath();
790 +
791 + teUnderlay.setProtectionType(yangLinkAtrr.underlay().underlayProtectionType());
792 +
793 + if (yangLinkAtrr.underlay().underlayPrimaryPath() != null) {
794 + teUnderlay = yang2TeSubsystemUnderlayPrimaryPath(teUnderlay,
795 + yangLinkAtrr.underlay().underlayPrimaryPath());
796 + }
797 +
798 + if (yangLinkAtrr.underlay().underlayBackupPath() != null) {
799 + teUnderlay = yang2TeSubsystemUnderlayBackupPaths(teUnderlay,
800 + yangLinkAtrr.underlay().underlayBackupPath());
801 + }
802 +
803 + if (yangLinkAtrr.underlay().underlayTrailSrc() != null) {
804 + teUnderlay.setTrailSrc(new TerminationPointKey(
805 + KeyId.keyId(yangLinkAtrr.underlay().underlayTrailSrc()
806 + .networkRef().uri().toString()),
807 + KeyId.keyId(yangLinkAtrr.underlay().underlayTrailSrc()
808 + .nodeRef().uri().toString()),
809 + KeyId.keyId(yangLinkAtrr.underlay().underlayTrailSrc()
810 + .tpRef().uri().toString())));
811 + }
812 +
813 + if (yangLinkAtrr.underlay().underlayTrailDes() != null) {
814 + teUnderlay.setTrailDes(new TerminationPointKey(
815 + KeyId.keyId(yangLinkAtrr.underlay().underlayTrailDes()
816 + .networkRef().uri().toString()),
817 + KeyId.keyId(yangLinkAtrr.underlay().underlayTrailDes()
818 + .nodeRef().uri().toString()),
819 + KeyId.keyId(yangLinkAtrr.underlay().underlayTrailDes()
820 + .tpRef().uri().toString())));
821 + }
822 +
823 + return teUnderlay;
824 + }
825 +
826 + private static TeLink yang2TeLinkAttributes(TeLinkAttributes yangLinkAtrr,
827 + State opState) {
828 + TeLink te = new TeLink(yangLinkAtrr.linkIndex());
829 + if (yangLinkAtrr.name() != null) {
830 + te.setName(yangLinkAtrr.name());
831 + }
832 + if (yangLinkAtrr.adminStatus() != null) {
833 + te.setAdminStatus(EnumConverter.yang2TeSubsystemAdminStatus(
834 + yangLinkAtrr.adminStatus()));
835 + }
836 + if (opState != null && opState.operStatus() != null) {
837 + te.setOpStatus(EnumConverter.yang2TeSubsystemOpStatus(
838 + opState.operStatus()));
839 + }
840 + if (yangLinkAtrr.accessType() != null) {
841 + te.setAccessType(yang2TeSubsystemAccessType(
842 + yangLinkAtrr.accessType()));
843 + }
844 + if (yangLinkAtrr.linkProtectionType() != null) {
845 + te.setLinkProtectionType(yang2TeSubsystemLinkProtectionType(
846 + yangLinkAtrr.linkProtectionType()));
847 + }
848 + if (yangLinkAtrr.maxLinkBandwidth() != null) {
849 + te.setMaxLinkBandwidth(yangLinkAtrr.maxLinkBandwidth());
850 + }
851 + if (yangLinkAtrr.maxResvLinkBandwidth() != null) {
852 + te.setMaxResvLinkBandwidth(yangLinkAtrr.maxResvLinkBandwidth());
853 + }
854 + te.setTeDefaultMetric(yangLinkAtrr.teDefaultMetric());
855 + te.setIsAbstract(yangLinkAtrr.isAbstract());
856 + if (yangLinkAtrr.teSrlgs() != null) {
857 + List<Long> srlgs = Lists.newArrayList();
858 + for (Srlg srlgConfigYang : yangLinkAtrr.teSrlgs().value()) {
859 + srlgs.add(srlgConfigYang.uint32());
860 + }
861 + te.setTeSrlgs(srlgs);
862 + }
863 + if (yangLinkAtrr.externalDomain() != null) {
864 + te.setExternalDomain(new ExternalDomain(
865 + KeyId.keyId(yangLinkAtrr.externalDomain()
866 + .remoteTeNodeId().toString()),
867 + KeyId.keyId(yangLinkAtrr.externalDomain()
868 + .remoteTeLinkTpId().toString()),
869 + yangLinkAtrr.externalDomain().plugId()));
870 + }
871 + if (yangLinkAtrr.underlay() != null) {
872 + te.setUnderlayPath(yang2TeSubsystemUnderlayPath(yangLinkAtrr));
873 + }
874 + if (yangLinkAtrr.unreservedBandwidth() != null) {
875 + List<org.onosproject.tetopology.management.api.link.UnreservedBandwidth>
876 + unreservedBandwidths = Lists.newArrayList();
877 + for (UnreservedBandwidth urBwYang : yangLinkAtrr.unreservedBandwidth()) {
878 + org.onosproject.tetopology.management.api.link.UnreservedBandwidth unResBw =
879 + new org.onosproject.tetopology.management.api.link.UnreservedBandwidth(
880 + urBwYang.priority(),
881 + urBwYang.bandwidth());
882 + unreservedBandwidths.add(unResBw);
883 + }
884 + te.setUnreservedBandwidths(unreservedBandwidths);
885 + }
886 + return te;
887 + }
888 +
889 + private static LinkProtectionType
890 + yang2TeSubsystemLinkProtectionType(LinkProtectionTypeEnum linkProtectionType) {
891 + switch (linkProtectionType) {
892 + case ENHANCED:
893 + return LinkProtectionType.ENHANCED;
894 + case EXTRA_TRAFFIC:
895 + return LinkProtectionType.EXTRA_TRAFFIC;
896 + case SHARED:
897 + return LinkProtectionType.SHARED;
898 + case UNPROTECTED:
899 + return LinkProtectionType.UNPROTECTED;
900 + case YANGAUTOPREFIX1_FOR_1:
901 + return LinkProtectionType.YANGAUTOPREFIX1_FOR_1;
902 + case YANGAUTOPREFIX1_PLUS_1:
903 + return LinkProtectionType.YANGAUTOPREFIX1_PLUS_1;
904 + default:
905 + return null;
906 + }
907 + }
908 +
909 + private static org.onosproject.tetopology.management.api.link.TeLinkAccessType
910 + yang2TeSubsystemAccessType(TeLinkAccessType accessType) {
911 + switch (accessType.enumeration()) {
912 + case MULTI_ACCESS:
913 + return org.onosproject.tetopology.management.api.link.TeLinkAccessType.MULTI_ACCESS;
914 + case POINT_TO_POINT:
915 + return org.onosproject.tetopology.management.api.link.TeLinkAccessType.POINT_TO_POINT;
916 + default:
917 + return null;
918 + }
919 + }
920 +
921 + /**
922 + * Link object conversion from YANG to TE Topology subsystem.
923 + *
924 + * @param yangLink YANG link object
925 + * @param networkId YANG networkId object
926 + * @return TE subsystem link object
927 + */
928 + public static org.onosproject.tetopology.management.api.link.NetworkLink
929 + yang2TeSubsystemLink(Link yangLink, NetworkId networkId) {
930 + checkNotNull(yangLink, E_NULL_YANG_TELINK);
931 +
932 + org.onosproject.tetopology.management.api.link.DefaultNetworkLink link =
933 + new org.onosproject.tetopology.management.api.link.DefaultNetworkLink(
934 + KeyId.keyId(yangLink.linkId().uri().toString()));
935 +
936 + if (yangLink.supportingLink() != null) {
937 + List<NetworkLinkKey> spLinkIds = Lists.newArrayList();
938 + for (SupportingLink yangSpLink : yangLink.supportingLink()) {
939 + NetworkLinkKey linkKey = new NetworkLinkKey(KeyId.keyId(yangSpLink.networkRef().uri().toString()),
940 + KeyId.keyId(yangSpLink.linkRef().uri().toString()));
941 + spLinkIds.add(linkKey);
942 + }
943 + link.setSupportingLinkIds(spLinkIds);
944 + }
945 +
946 + if (yangLink.source() != null) {
947 + TerminationPointKey source = new TerminationPointKey(
948 + KeyId.keyId(networkId.uri().toString()),
949 + KeyId.keyId(yangLink.source().sourceNode().uri().toString()),
950 + KeyId.keyId(yangLink.source().sourceTp().uri().toString()));
951 + link.setSource(source);
952 + }
953 +
954 + if (yangLink.destination() != null) {
955 + TerminationPointKey destination = new TerminationPointKey(
956 + KeyId.keyId(networkId.uri().toString()),
957 + KeyId.keyId(yangLink.destination().destNode().uri().toString()),
958 + KeyId.keyId(yangLink.destination().destTp().uri().toString()));
959 + link.setDestination(destination);
960 + }
961 +
962 + if (yangLink.yangAugmentedInfoMap() != null && !yangLink.yangAugmentedInfoMap().isEmpty()) {
963 +
964 + AugmentedNtLink yangLinkAugment =
965 + (AugmentedNtLink) yangLink.yangAugmentedInfo(AugmentedNtLink.class);
966 + if (yangLinkAugment != null &&
967 + yangLinkAugment.te() != null &&
968 + yangLinkAugment.te().config() != null) {
969 + TeLinkAttributes yangLinkAtrr =
970 + yangLinkAugment.te().config().teLinkAttributes();
971 + if (yangLinkAtrr != null && yangLinkAtrr.linkIndex() != null) {
972 + TeLink te = yang2TeLinkAttributes(yangLinkAtrr, yangLinkAugment.te().state());
973 + link.setTe(te);
974 + }
975 + }
976 + }
977 + return link;
978 + }
979 +
980 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.teyang.utils.topology;
17 +
18 +import static com.google.common.base.Preconditions.checkNotNull;
19 +import static com.google.common.base.Preconditions.checkState;
20 +
21 +import java.util.List;
22 +
23 +import org.onosproject.tetopology.management.api.KeyId;
24 +import org.onosproject.tetopology.management.api.link.NetworkLink;
25 +import org.onosproject.tetopology.management.api.node.NetworkNode;
26 +import org.onosproject.teyang.api.OperationType;
27 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
28 + .ietfnetwork.DefaultNetworks;
29 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
30 + .ietfnetwork.DefaultNetworks.OnosYangNodeOperationType;
31 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
32 + .ietfnetwork.DefaultNetworksState;
33 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
34 + .ietfnetwork.NetworkId;
35 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
36 + .ietfnetwork.Networks;
37 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
38 + .ietfnetwork.NetworksState;
39 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
40 + .ietfnetwork.networks.DefaultNetwork;
41 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
42 + .ietfnetwork.networks.Network;
43 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
44 + .ietfnetwork.networks.Network.NetworkBuilder;
45 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
46 + .ietfnetwork.networks.network.DefaultNetworkTypes;
47 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
48 + .ietfnetwork.networks.network.DefaultSupportingNetwork;
49 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.network.DefaultSupportingNetwork.SupportingNetworkBuilder;
50 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
51 + .ietfnetwork.networks.network.NetworkTypes;
52 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
53 + .ietfnetwork.networks.network.Node;
54 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
55 + .ietfnetwork.networks.network.SupportingNetwork;
56 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
57 + .ietfnetworktopology.networks.network.AugmentedNdNetwork;
58 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
59 + .ietfnetworktopology.networks.network.DefaultAugmentedNdNetwork;
60 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.ietfnetworktopology.networks.network.DefaultAugmentedNdNetwork.AugmentedNdNetworkBuilder;
61 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
62 + .ietfnetworktopology.networks.network.augmentedndnetwork.Link;
63 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
64 + .ietftetopology.networks.network.AugmentedNwNetwork;
65 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
66 + .ietftetopology.networks.network.DefaultAugmentedNwNetwork;
67 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
68 + .ietftetopology.networks.network.augmentednwnetwork.DefaultTe;
69 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
70 + .ietftetopology.networks.network.augmentednwnetwork.Te;
71 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
72 + .ietftetopology.networks.network.networktypes.AugmentedNwNetworkTypes;
73 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
74 + .ietftetopology.networks.network.networktypes.DefaultAugmentedNwNetworkTypes;
75 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
76 + .ietftetopology.networks.network.networktypes.augmentednwnetworktypes.DefaultTeTopology;
77 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
78 + .ietftetopology.networks.network.networktypes.augmentednwnetworktypes.TeTopology;
79 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705
80 + .ietftetypes.TeGlobalId;
81 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705
82 + .ietftetypes.TeTopologyId;
83 +import org.slf4j.Logger;
84 +import org.slf4j.LoggerFactory;
85 +
86 +import com.google.common.collect.Lists;
87 +
88 +
89 +/**
90 + * Networks, Networks State conversion functions.
91 + */
92 +public final class NetworkConverter {
93 + private static final String
94 + E_NULL_TE_NETWORKS = "TeSubsystem networks cannot be null";
95 + private static final String
96 + E_NULL_TE_NETWORK_LIST = "TeSubsystem network list cannot be null";
97 + private static final String
98 + E_NULL_TE_NETWORK = "TeSubsystem network cannot be null";
99 + private static final String
100 + E_NULL_TE_NETWORKID = "TeSubsystem networkId cannot be null";
101 + private static final String
102 + E_NULL_YANG_NETWORKS = "YANG networks cannot be null";
103 + private static final String
104 + E_NULL_YANG_NETWORK_LIST = "YANG network list cannot be null";
105 + private static final String
106 + E_NULL_YANG_NETWORK = "YANG network cannot be null";
107 + private static final String
108 + E_NULL_YANG_NETWORKID = "YANG networkId cannot be null";
109 + private static final String
110 + E_NULL_YANG_NETWORKSSTATE = "YANG networksState cannot be null";
111 + private static final String
112 + E_DIFF_YANG_NETWORKID = "YANG networkId must be same in Network and NetworkState";
113 + private static final String
114 + E_NULL_YANG_NETWORKSSTATE_NETWORK = "YANG networksState network cannot be null";
115 + private static final String
116 + E_NULL_YANG_NETWORKSSTATE_NETWORKREF = "YANG networksState networkRef cannot be null";
117 +
118 + private static final Logger log = LoggerFactory.getLogger(NetworkConverter.class);
119 +
120 + // no instantiation
121 + private NetworkConverter() {
122 + }
123 +
124 + private static OnosYangNodeOperationType toNetworksOperationType(OperationType operation) {
125 + switch (operation) {
126 + case CREATE:
127 + return OnosYangNodeOperationType.CREATE;
128 +
129 + case DELETE:
130 + return OnosYangNodeOperationType.DELETE;
131 +
132 + case REMOVE:
133 + return OnosYangNodeOperationType.REMOVE;
134 +
135 + case MERGE:
136 + return OnosYangNodeOperationType.MERGE;
137 +
138 + case REPLACE:
139 + return OnosYangNodeOperationType.REPLACE;
140 +
141 + default:
142 + return OnosYangNodeOperationType.NONE;
143 + }
144 + }
145 +
146 + /**
147 + * Networks object conversion from TE Topology subsystem to YANG.
148 + *
149 + * @param teSubsystem TE Topology subsystem networks object
150 + * @param operation operation type
151 + * @return Networks YANG object
152 + */
153 + public static Networks teSubsystem2YangNetworks(
154 + org.onosproject.tetopology.management.api.Networks teSubsystem,
155 + OperationType operation) {
156 + checkNotNull(teSubsystem, E_NULL_TE_NETWORKS);
157 + checkNotNull(teSubsystem.networks(), E_NULL_TE_NETWORK_LIST);
158 + Networks.NetworksBuilder builder =
159 + DefaultNetworks.builder().onosYangNodeOperationType(toNetworksOperationType(operation));
160 + List<Network> networks = Lists.newArrayList();
161 + for (org.onosproject.tetopology.management.api.Network teNetwork : teSubsystem.networks()) {
162 + networks.add(teSubsystem2YangNetwork(teNetwork, operation));
163 + }
164 + builder.network(networks);
165 + return builder.build();
166 + }
167 +
168 + private static DefaultNetworksState.OnosYangNodeOperationType
169 + toNetworksStateOperationType(OperationType operation) {
170 + switch (operation) {
171 + case CREATE:
172 + return DefaultNetworksState.OnosYangNodeOperationType.CREATE;
173 +
174 + case DELETE:
175 + return DefaultNetworksState.OnosYangNodeOperationType.DELETE;
176 +
177 + case REMOVE:
178 + return DefaultNetworksState.OnosYangNodeOperationType.REMOVE;
179 +
180 + case MERGE:
181 + return DefaultNetworksState.OnosYangNodeOperationType.MERGE;
182 +
183 + case REPLACE:
184 + return DefaultNetworksState.OnosYangNodeOperationType.REPLACE;
185 +
186 + default:
187 + return DefaultNetworksState.OnosYangNodeOperationType.NONE;
188 + }
189 + }
190 +
191 + /**
192 + * Network States object conversion from TE Topology subsystem to YANG.
193 + *
194 + * @param teSubsystem TE Topology subsystem networks object
195 + * @param operation operation type
196 + * @return NetworkStates YANG object
197 + */
198 + public static NetworksState teSubsystem2YangNetworkStates(
199 + org.onosproject.tetopology.management.api.Networks teSubsystem,
200 + OperationType operation) {
201 + checkNotNull(teSubsystem, "teSubsystem object cannot be null");
202 + checkNotNull(teSubsystem.networks(), "TeSubsystem Networks object cannot be null");
203 + NetworksState.NetworksStateBuilder builder =
204 + DefaultNetworksState.builder().onosYangNodeOperationType(toNetworksStateOperationType(operation));
205 + List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
206 + .ietfnetwork.networksstate.Network> networks = Lists.newArrayList();
207 + for (org.onosproject.tetopology.management.api.Network teNetwork : teSubsystem.networks()) {
208 + networks.add(teSubsystem2YangNetworkState(teNetwork, operation));
209 + }
210 + builder.network(networks);
211 + return builder.build();
212 + }
213 +
214 + private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
215 + .ietfnetwork.networksstate.Network networkStateNetwork(Network network,
216 + NetworksState yangNetworkStates) {
217 + checkNotNull(network, "YANG Network object cannot be null");
218 + checkNotNull(yangNetworkStates, "YANG NetworksState object cannot be null");
219 + if (yangNetworkStates.network() == null) {
220 + return null;
221 + }
222 +
223 + for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
224 + .ietfnetwork.networksstate.Network stateNetwork : yangNetworkStates.network()) {
225 + if (stateNetwork.networkRef().equals(network.networkId())) {
226 + return stateNetwork;
227 + }
228 + }
229 + return null;
230 + }
231 +
232 + /**
233 + * Networks object conversion from YANG to TE Topology subsystem.
234 + *
235 + * @param yangNetworks Networks YANG object
236 + * @param yangNetworkStates NetworkStates YANG object
237 + * @return teSubsystem TE Topology subsystem networks object
238 + */
239 + public static org.onosproject.tetopology.management.api.Networks yang2TeSubsystemNetworks(
240 + Networks yangNetworks, NetworksState yangNetworkStates) {
241 + checkNotNull(yangNetworks, E_NULL_YANG_NETWORKS);
242 + checkNotNull(yangNetworks.network(), E_NULL_YANG_NETWORK_LIST);
243 + checkNotNull(yangNetworkStates, E_NULL_YANG_NETWORKSSTATE);
244 +
245 + org.onosproject.tetopology.management.api.DefaultNetworks defaultNetworks =
246 + new org.onosproject.tetopology.management.api.DefaultNetworks();
247 + List<org.onosproject.tetopology.management.api.Network> networks = Lists.newArrayList();
248 + for (Network network : yangNetworks.network()) {
249 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
250 + .ietfnetwork.networksstate.Network stateNetwork =
251 + networkStateNetwork(network, yangNetworkStates);
252 + org.onosproject.tetopology.management.api.Network teNetwork;
253 + if (stateNetwork == null) {
254 + log.info("networkId {} can't be found in yangNetworkStates",
255 + network.networkId());
256 + teNetwork = yang2TeSubsystemNetwork(network);
257 + } else {
258 + teNetwork = yang2TeSubsystemNetwork(network, stateNetwork);
259 + }
260 + networks.add(teNetwork);
261 + }
262 +
263 + defaultNetworks.setNetworks(networks);
264 + return defaultNetworks;
265 + }
266 +
267 + private static DefaultNetwork.OnosYangNodeOperationType toNetworkOperationType(OperationType operation) {
268 + switch (operation) {
269 + case CREATE:
270 + return DefaultNetwork.OnosYangNodeOperationType.CREATE;
271 +
272 + case DELETE:
273 + return DefaultNetwork.OnosYangNodeOperationType.DELETE;
274 +
275 + case REMOVE:
276 + return DefaultNetwork.OnosYangNodeOperationType.REMOVE;
277 +
278 + case MERGE:
279 + return DefaultNetwork.OnosYangNodeOperationType.MERGE;
280 +
281 + case REPLACE:
282 + return DefaultNetwork.OnosYangNodeOperationType.REPLACE;
283 +
284 + default:
285 + return DefaultNetwork.OnosYangNodeOperationType.NONE;
286 + }
287 + }
288 +
289 + private static NetworkBuilder te2YangSupportingNetwork(NetworkBuilder builder,
290 + List<KeyId> teSpptNetworkIds) {
291 + List<SupportingNetwork> snws = Lists.newArrayList();
292 + SupportingNetworkBuilder spNetworkBuilder = DefaultSupportingNetwork.builder();
293 + for (KeyId teSpNwKey : teSpptNetworkIds) {
294 + snws.add(spNetworkBuilder
295 + .networkRef(NetworkId.fromString(teSpNwKey.toString()))
296 + .build());
297 + }
298 + return builder.supportingNetwork(snws);
299 + }
300 +
301 + private static NetworkBuilder te2YangNodes(NetworkBuilder builder,
302 + List<NetworkNode> teNodes) {
303 + List<Node> nodeList = Lists.newArrayList();
304 + // Add each node
305 + for (org.onosproject.tetopology.management.api.node.NetworkNode node : teNodes) {
306 + // Convert the te node to a YO.
307 + nodeList.add(NodeConverter.teSubsystem2YangNode(node));
308 + }
309 + return builder.node(nodeList);
310 + }
311 +
312 + private static NetworkBuilder te2YangLinks(NetworkBuilder builder,
313 + List<NetworkLink> teLinks) {
314 + List<Link> linkList = Lists.newArrayList();
315 + // Add each link
316 + for (org.onosproject.tetopology.management.api.link.NetworkLink link : teLinks) {
317 + // Convert the te link to a YO
318 + linkList.add(LinkConverter.teSubsystem2YangLink(link));
319 + }
320 + AugmentedNdNetworkBuilder ndAugment = DefaultAugmentedNdNetwork.builder();
321 + ndAugment.link(linkList);
322 + builder.addYangAugmentedInfo(ndAugment.build(), AugmentedNdNetwork.class);
323 + return builder;
324 + }
325 +
326 + private static NetworkBuilder te2YangNetworkType(NetworkBuilder builder,
327 + org.onosproject.tetopology.management.api.TeTopologyId teTopologyId) {
328 + NetworkTypes.NetworkTypesBuilder nwType = DefaultNetworkTypes.builder();
329 + if (teTopologyId != null) {
330 + // Set "te-topology" network type.
331 + TeTopology.TeTopologyBuilder teTopology = DefaultTeTopology.builder();
332 + AugmentedNwNetworkTypes.AugmentedNwNetworkTypesBuilder teNwType =
333 + DefaultAugmentedNwNetworkTypes.builder();
334 + teNwType.teTopology(teTopology.build());
335 + nwType.addYangAugmentedInfo(teNwType.build(), AugmentedNwNetworkTypes.class);
336 + }
337 + return builder.networkTypes(nwType.build());
338 + }
339 +
340 + private static NetworkBuilder te2YangTopologyIds(NetworkBuilder builder,
341 + org.onosproject.tetopology.management.api.TeTopologyId teTopologyId) {
342 + Te.TeBuilder teBuilder = DefaultTe.builder();
343 + teBuilder.clientId(new TeGlobalId(teTopologyId.clientId()));
344 + teBuilder.providerId(new TeGlobalId(teTopologyId.providerId()));
345 + if (teTopologyId.topologyId() != null) {
346 + teBuilder.teTopologyId(new TeTopologyId(teTopologyId.topologyId()));
347 + }
348 +
349 + AugmentedNwNetwork.AugmentedNwNetworkBuilder nwAugment = DefaultAugmentedNwNetwork
350 + .builder();
351 + nwAugment.te(teBuilder.build());
352 + builder.addYangAugmentedInfo(nwAugment.build(),
353 + AugmentedNwNetwork.class);
354 + return builder;
355 + }
356 +
357 + /**
358 + * Network object conversion from TE Topology subsystem to YANG.
359 + *
360 + * @param teSubsystem TE Topology subsystem network object
361 + * @param operation operation type
362 + * @return Network YANG object
363 + */
364 + public static Network teSubsystem2YangNetwork(
365 + org.onosproject.tetopology.management.api.Network teSubsystem,
366 + OperationType operation) {
367 + checkNotNull(teSubsystem, E_NULL_TE_NETWORK);
368 + checkNotNull(teSubsystem.networkId(), E_NULL_TE_NETWORKID);
369 +
370 + // Generate a network builder with the specific networkId.
371 + NetworkId networkId = NetworkId.fromString(teSubsystem.networkId().toString());
372 + NetworkBuilder builder = DefaultNetwork.builder()
373 + .onosYangNodeOperationType(
374 + toNetworkOperationType(operation))
375 + .networkId(networkId);
376 +
377 + // Supporting networks
378 + if (teSubsystem.getSupportingNetworkIds() != null) {
379 + builder = te2YangSupportingNetwork(builder, teSubsystem.getSupportingNetworkIds());
380 + }
381 +
382 + // Nodes
383 + if (teSubsystem.getNodes() != null) {
384 + builder = te2YangNodes(builder, teSubsystem.getNodes());
385 + }
386 +
387 + // Network types
388 + builder = te2YangNetworkType(builder, teSubsystem.getTeTopologyId());
389 +
390 + // Add links - link is the augmentation
391 + if (teSubsystem.getLinks() != null) {
392 + builder = te2YangLinks(builder, teSubsystem.getLinks());
393 + }
394 +
395 + // TE Topology IDs
396 + if (teSubsystem.getTeTopologyId() != null) {
397 + builder = te2YangTopologyIds(builder, teSubsystem.getTeTopologyId());
398 + }
399 +
400 + return builder.build();
401 + }
402 +
403 + /**
404 + * Network State object conversion from TE Topology subsystem to YANG.
405 + *
406 + * @param teSubsystem TE Topology subsystem network object
407 + * @param operation operation type
408 + * @return Network YANG object
409 + */
410 + public static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network
411 + .rev20151208.ietfnetwork.networksstate.Network
412 + teSubsystem2YangNetworkState(
413 + org.onosproject.tetopology.management.api.Network teSubsystem,
414 + OperationType operation) {
415 + checkNotNull(teSubsystem, E_NULL_TE_NETWORK);
416 + checkNotNull(teSubsystem.networkId(), E_NULL_TE_NETWORKID);
417 +
418 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
419 + .ietfnetwork.networksstate.Network.NetworkBuilder stateBuilder =
420 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
421 + .ietfnetwork.networksstate.DefaultNetwork.builder();
422 +
423 + if (teSubsystem.networkId() != null) {
424 + stateBuilder.networkRef(NetworkId.fromString(teSubsystem.networkId().toString()));
425 + }
426 + stateBuilder.serverProvided(teSubsystem.isServerProvided());
427 +
428 + // Operation type may be required.
429 + return stateBuilder.build();
430 + }
431 +
432 +
433 + /**
434 + * Network conversion from YANG to TE Topology subsystem.
435 + *
436 + * @param yangNetwork Network YANG object
437 + * @return TE Topology subsystem defaultNetwork object
438 + */
439 + private static org.onosproject.tetopology.management.api.DefaultNetwork yang2TeDefaultNetwork(
440 + Network yangNetwork) {
441 + checkNotNull(yangNetwork, E_NULL_YANG_NETWORK);
442 + checkNotNull(yangNetwork.networkId(), E_NULL_YANG_NETWORKID);
443 + String networkId = yangNetwork.networkId().uri().string();
444 + org.onosproject.tetopology.management.api.DefaultNetwork teNetwork =
445 + new org.onosproject.tetopology.management.api.DefaultNetwork(KeyId.keyId(networkId));
446 +
447 + // Supporting networks
448 + if (yangNetwork.supportingNetwork() != null) {
449 + List<KeyId> supportingNetworkIds = Lists.newArrayList();
450 + for (SupportingNetwork supportNw : yangNetwork.supportingNetwork()) {
451 + supportingNetworkIds.add(
452 + KeyId.keyId(supportNw.networkRef().uri().string()));
453 + }
454 + teNetwork.setSupportingNetworkIds(supportingNetworkIds);
455 + }
456 +
457 + // Nodes
458 + if (yangNetwork.node() != null) {
459 + List<org.onosproject.tetopology.management.api.node.NetworkNode>
460 + teNodes = Lists.newArrayList();
461 + for (Node node : yangNetwork.node()) {
462 + // Convert the Yang Node to a TE node.
463 + teNodes.add(NodeConverter.yang2TeSubsystemNode(node, yangNetwork.networkId()));
464 + }
465 + teNetwork.setNodes(teNodes);
466 + }
467 +
468 + // Links
469 + if (yangNetwork.yangAugmentedInfo(AugmentedNdNetwork.class) != null) {
470 + AugmentedNdNetwork augmentLink =
471 + (AugmentedNdNetwork) yangNetwork.yangAugmentedInfo(AugmentedNdNetwork.class);
472 + List<org.onosproject.tetopology.management.api.link.NetworkLink>
473 + teLinks = Lists.newArrayList();
474 + for (Link link : augmentLink.link()) {
475 + // Convert the Yang Link to a TE link.
476 + teLinks.add(LinkConverter.yang2TeSubsystemLink(link, yangNetwork.networkId()));
477 + }
478 + teNetwork.setLinks(teLinks);
479 + }
480 +
481 + // TE Topology Ids
482 + if (yangNetwork.yangAugmentedInfo(AugmentedNwNetwork.class) != null) {
483 + AugmentedNwNetwork augmentTeIds =
484 + (AugmentedNwNetwork) yangNetwork.yangAugmentedInfo(AugmentedNwNetwork.class);
485 + org.onosproject.tetopology.management.api.TeTopologyId teTopologyId =
486 + new org.onosproject.tetopology.management.api.TeTopologyId(
487 + augmentTeIds.te().clientId().uint32(),
488 + augmentTeIds.te().providerId().uint32(),
489 + augmentTeIds.te().teTopologyId().string());
490 +
491 + teNetwork.setTeTopologyId(teTopologyId);
492 + }
493 +
494 + return teNetwork;
495 + }
496 +
497 + /**
498 + * Network object conversion from YANG to TE Topology subsystem.
499 + *
500 + * @param yangNetwork Network YANG object
501 + * @return network TE Topology subsystem networks object
502 + */
503 + public static org.onosproject.tetopology.management.api.Network yang2TeSubsystemNetwork(Network yangNetwork) {
504 + return yang2TeDefaultNetwork(yangNetwork);
505 + }
506 +
507 + /**
508 + * Network and State object conversion from YANG to TE Topology subsystem.
509 + *
510 + * @param yangNetwork Network YANG object
511 + * @param yangNetworkState NetworkState YANG object
512 + * @return teSubsystem TE Topology subsystem networks object
513 + */
514 + public static org.onosproject.tetopology.management.api.Network yang2TeSubsystemNetwork(Network yangNetwork,
515 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork
516 + .networksstate.Network yangNetworkState) {
517 + org.onosproject.tetopology.management.api.DefaultNetwork teNetwork =
518 + yang2TeDefaultNetwork(yangNetwork);
519 +
520 + checkNotNull(yangNetworkState, E_NULL_YANG_NETWORKSSTATE_NETWORK);
521 + checkNotNull(yangNetworkState.networkRef(), E_NULL_YANG_NETWORKSSTATE_NETWORKREF);
522 + String networkref = yangNetworkState.networkRef().uri().string();
523 + checkState(teNetwork.networkId().toString().equals(networkref),
524 + E_DIFF_YANG_NETWORKID);
525 +
526 + teNetwork.setServerProvided(yangNetworkState.serverProvided());
527 +
528 + return teNetwork;
529 + }
530 +}
531 +
532 +
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.teyang.utils.topology;
17 +
18 +import static com.google.common.base.Preconditions.checkNotNull;
19 +
20 +import java.util.List;
21 +
22 +import org.onosproject.tetopology.management.api.KeyId;
23 +import org.onosproject.tetopology.management.api.node.InterfaceSwitchingCapability;
24 +import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
25 +import org.onosproject.tetopology.management.api.node.TeNetworkTopologyId;
26 +import org.onosproject.tetopology.management.api.node.TeNode;
27 +import org.onosproject.tetopology.management.api.node.TerminationCapability;
28 +import org.onosproject.tetopology.management.api.node.TerminationPoint;
29 +import org.onosproject.tetopology.management.api.node.TerminationPointKey;
30 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev20130715.ietfinettypes.DomainName;
31 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NetworkId;
32 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NodeId;
33 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
34 + .ietfnetwork.networks.network.DefaultNode;
35 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
36 + .ietfnetwork.networks.network.Node;
37 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
38 + .ietfnetwork.networks.network.node.DefaultSupportingNode;
39 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
40 + .ietfnetwork.networks.network.node.SupportingNode;
41 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
42 + .ietfnetworktopology.TpId;
43 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
44 + .ietfnetworktopology.networks.network.node.AugmentedNdNode;
45 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
46 + .ietfnetworktopology.networks.network.node.DefaultAugmentedNdNode;
47 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
48 + .ietftetopology.networks.network.node.AugmentedNwNode;
49 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
50 + .ietftetopology.networks.network.node.DefaultAugmentedNwNode;
51 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
52 + .ietftetopology.networks.network.node.augmentednwnode.DefaultTe;
53 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
54 + .ietftetopology.networks.network.node.augmentednwnode.DefaultTe.TeBuilder;
55 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
56 + .ietftetopology.networks.network.node.augmentednwnode.Te;
57 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
58 + .ietftetopology.networks.network.node.augmentednwnode.te.Config;
59 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
60 + .ietftetopology.networks.network.node.augmentednwnode.te.DefaultConfig;
61 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
62 + .ietftetopology.networks.network.node.augmentednwnode.te.DefaultState;
63 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
64 + .ietftetopology.networks.network.node.augmentednwnode.te.DefaultTunnelTerminationPoint;
65 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
66 + .ietftetopology.networks.network.node.augmentednwnode.te.State;
67 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
68 + .ietftetopology.networks.network.node.augmentednwnode.te.TunnelTerminationPoint;
69 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
70 + .ietftetopology.networks.network.node.augmentednwnode.te.config.DefaultTeNodeAttributes;
71 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
72 + .ietftetopology.networks.network.node.augmentednwnode.te.config.TeNodeAttributes;
73 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
74 + .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes.ConnectivityMatrix;
75 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
76 + .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes
77 + .DefaultConnectivityMatrix;
78 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
79 + .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes.DefaultUnderlayTopology;
80 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
81 + .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes.UnderlayTopology;
82 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
83 + .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes
84 + .connectivitymatrix.DefaultFrom;
85 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
86 + .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes
87 + .connectivitymatrix.DefaultTo;
88 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
89 + .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint
90 + .config.DefaultTerminationCapability;
91 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeNodeId;
92 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeTopologyId;
93 +
94 +import com.google.common.collect.Lists;
95 +
96 +/**
97 + * Node conversion functions.
98 + */
99 +public final class NodeConverter {
100 +
101 + private static final String E_NULL_TE_SUBSYSTEM_TE_NODE = "TeSubsystem teNode object cannot be null";
102 + private static final String E_NULL_TE_SUBSYSTEM_TE_TUNNEL_TP = "TeSubsystem teTunnelTp object cannot be null";
103 + private static final String E_NULL_TE_SUBSYSTEM_NODE = "TeSubsystem ndoe object cannot be null";
104 + private static final String E_NULL_YANG_NODE = "Yang node object cannot be null";
105 +
106 + // no instantiation
107 + private NodeConverter() {
108 + }
109 +
110 + /**
111 + * TE Node Config object conversion from TE Topology subsystem to YANG.
112 + *
113 + * @param teSubsystemTeNode TE node object
114 + * @return TE Node Config YANG object
115 + */
116 + private static Config teNode2YangConfig(TeNode teSubsystemTeNode) {
117 + checkNotNull(teSubsystemTeNode, E_NULL_TE_SUBSYSTEM_TE_NODE);
118 +
119 + TeNodeAttributes.TeNodeAttributesBuilder teNodeAttributesConfigBuilder =
120 + DefaultTeNodeAttributes.builder()
121 + .isAbstract(teSubsystemTeNode.isAbstract());
122 + if (teSubsystemTeNode.adminStatus() != null) {
123 + teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
124 + .adminStatus(EnumConverter
125 + .teSubsystem2YangAdminStatus(teSubsystemTeNode
126 + .adminStatus()));
127 + }
128 +
129 + if (teSubsystemTeNode.name() != null) {
130 + teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
131 + .name(DomainName.fromString(teSubsystemTeNode.name()));
132 + }
133 +
134 + if (teSubsystemTeNode.underlayTopology() != null) {
135 + teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
136 + .underlayTopology(teNode2YangUnderlayConfig(teSubsystemTeNode.underlayTopology()));
137 + }
138 +
139 + if (teSubsystemTeNode.connectivityMatrices() != null) {
140 + ConnectivityMatrix.ConnectivityMatrixBuilder connectivityMatrixConfigBuilder =
141 + DefaultConnectivityMatrix.builder();
142 + for (org.onosproject.tetopology.management.api.node.ConnectivityMatrix teCm : teSubsystemTeNode.
143 + connectivityMatrices()) {
144 + connectivityMatrixConfigBuilder = connectivityMatrixConfigBuilder
145 + .id(teCm.id())
146 + .isAllowed(teCm.isAllowed())
147 + .from(new DefaultFrom.FromBuilder()
148 + .tpRef(TpId.fromString(teCm.from().tpId()
149 + .toString()))
150 + .build())
151 + .to(new DefaultTo.ToBuilder()
152 + .tpRef(TpId.fromString(teCm.to().tpId()
153 + .toString()))
154 + .build());
155 + teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
156 + .addToConnectivityMatrix(connectivityMatrixConfigBuilder
157 + .build());
158 + }
159 + }
160 +
161 +
162 + Config.ConfigBuilder yangConfigBuilder = DefaultConfig.builder();
163 + yangConfigBuilder = yangConfigBuilder.teNodeAttributes(teNodeAttributesConfigBuilder.build());
164 +
165 + return yangConfigBuilder.build();
166 + }
167 +
168 + private static UnderlayTopology teNode2YangUnderlayConfig(TeNetworkTopologyId underlayTopology) {
169 + UnderlayTopology.UnderlayTopologyBuilder underlayConfigBuilder = DefaultUnderlayTopology
170 + .builder()
171 + .networkIdRef(NetworkId.fromString(underlayTopology.getNetworkId().toString()))
172 + .teTopologyIdRef(TeTopologyId
173 + .fromString(underlayTopology
174 + .getTopologyId().topologyId()));
175 + return underlayConfigBuilder.build();
176 + }
177 +
178 + /**
179 + * TE Node State object conversion from TE Topology subsystem to YANG.
180 + *
181 + * @param teSubsystemTeNode TE node object
182 + * @return TE Node State YANG object
183 + */
184 + private static State teNode2YangState(TeNode teSubsystemTeNode) {
185 + checkNotNull(teSubsystemTeNode, E_NULL_TE_SUBSYSTEM_TE_NODE);
186 +
187 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
188 + .networks.network.node.augmentednwnode.te.state.TeNodeAttributes
189 + .TeNodeAttributesBuilder teNodeAttributesStateBuilder =
190 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
191 + .networks.network.node.augmentednwnode.te.state.DefaultTeNodeAttributes.builder()
192 + .isAbstract(teSubsystemTeNode.isAbstract());
193 +
194 + if (teSubsystemTeNode.adminStatus() != null) {
195 + teNodeAttributesStateBuilder = teNodeAttributesStateBuilder
196 + .adminStatus(EnumConverter
197 + .teSubsystem2YangAdminStatus(teSubsystemTeNode
198 + .adminStatus()));
199 + }
200 +
201 + if (teSubsystemTeNode.name() != null) {
202 + teNodeAttributesStateBuilder = teNodeAttributesStateBuilder
203 + .name(DomainName.fromString(teSubsystemTeNode.name()));
204 + }
205 +
206 + if (teSubsystemTeNode.underlayTopology() != null) {
207 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
208 + .networks.network.node.augmentednwnode.te.state.tenodeattributes.UnderlayTopology.
209 + UnderlayTopologyBuilder underlayStateBuilder =
210 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
211 + .networks.network.node.augmentednwnode.te.state.tenodeattributes.DefaultUnderlayTopology
212 + .builder();
213 + underlayStateBuilder = underlayStateBuilder
214 + .networkIdRef(NetworkId.fromString(teSubsystemTeNode
215 + .underlayTopology().getNetworkId().toString()))
216 + .teTopologyIdRef(TeTopologyId.fromString(teSubsystemTeNode
217 + .underlayTopology().getTopologyId().topologyId()));
218 + teNodeAttributesStateBuilder = teNodeAttributesStateBuilder
219 + .underlayTopology(underlayStateBuilder.build());
220 + }
221 +
222 + if (teSubsystemTeNode.connectivityMatrices() != null) {
223 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
224 + .networks.network.node.augmentednwnode.te.state.tenodeattributes.ConnectivityMatrix
225 + .ConnectivityMatrixBuilder
226 + connectivityMatrixStateBuilder = org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
227 + .te.topology.rev20160708.ietftetopology.networks.network.node.augmentednwnode
228 + .te.state.tenodeattributes.DefaultConnectivityMatrix
229 + .builder();
230 + for (org.onosproject.tetopology.management.api.node.ConnectivityMatrix teCm : teSubsystemTeNode
231 + .connectivityMatrices()) {
232 + connectivityMatrixStateBuilder = connectivityMatrixStateBuilder
233 + .id(teCm.id())
234 + .isAllowed(teCm.isAllowed())
235 + .from(new org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
236 + .rev20160708.ietftetopology.networks.network.node.augmentednwnode.te.state
237 + .tenodeattributes.connectivitymatrix.DefaultFrom.FromBuilder()
238 + .tpRef(TpId.fromString(teCm.from().tpId()
239 + .toString()))
240 + .build())
241 + .to(new org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
242 + .rev20160708.ietftetopology.networks.network.node.augmentednwnode.te.state
243 + .tenodeattributes.connectivitymatrix.DefaultTo.ToBuilder()
244 + .tpRef(TpId.fromString(teCm.to().tpId()
245 + .toString()))
246 + .build());
247 + teNodeAttributesStateBuilder = teNodeAttributesStateBuilder
248 + .addToConnectivityMatrix(connectivityMatrixStateBuilder
249 + .build());
250 + }
251 + }
252 +
253 + State.StateBuilder yangStateBuilder = DefaultState.builder();
254 + yangStateBuilder = yangStateBuilder.teNodeAttributes(teNodeAttributesStateBuilder.build());
255 +
256 + if (teSubsystemTeNode.opStatus() != null) {
257 + yangStateBuilder = yangStateBuilder.operStatus(EnumConverter
258 + .teSubsystem2YangOperStatus(teSubsystemTeNode
259 + .opStatus()));
260 + }
261 +
262 + return yangStateBuilder.build();
263 + }
264 +
265 + /**
266 + * TE Node TunnelTerminationPoint object conversion from TE Topology subsystem to YANG.
267 + *
268 + * @param teTunnelTp TE TunnelTerminationPoint object
269 + * @return TunnelTerminationPoint YANG object
270 + */
271 + private static TunnelTerminationPoint teSubsystem2YangTtp(
272 + org.onosproject.tetopology.management.api.node.TunnelTerminationPoint teTunnelTp) {
273 + checkNotNull(teTunnelTp, E_NULL_TE_SUBSYSTEM_TE_TUNNEL_TP);
274 +
275 + TunnelTerminationPoint.TunnelTerminationPointBuilder tunnelTpBuilder =
276 + DefaultTunnelTerminationPoint.builder().tunnelTpId(teTunnelTp.getTunnelTpId());
277 +
278 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
279 + .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint
280 + .Config.ConfigBuilder ttpConfigBuilder =
281 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
282 + .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint
283 + .DefaultConfig.builder();
284 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
285 + .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint
286 + .State.StateBuilder ttpStateBuilder =
287 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
288 + .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint
289 + .DefaultState.builder();
290 +
291 + if (Long.valueOf(teTunnelTp.getInterLayerLockId()) != null) {
292 + ttpConfigBuilder = ttpConfigBuilder.interLayerLockId(teTunnelTp.getInterLayerLockId());
293 + ttpStateBuilder = ttpStateBuilder.interLayerLockId(teTunnelTp.getInterLayerLockId());
294 + }
295 +
296 + if (teTunnelTp.getSwitchingCapabilities() != null) {
297 + // FIXME: switchingCapabilities is a list in
298 + // teSubsystem, but is not a list in yang. how to handle
299 + // this?
300 + for (InterfaceSwitchingCapability iscTe : teTunnelTp.getSwitchingCapabilities()) {
301 + // ttpConfigBuilder =
302 + // ttpConfigBuilder.switchingCapability(switchingCapability)
303 + // ttpStateBuilder =
304 + // ttpStateBuilder.switchingCapability(switchingCapability)
305 + }
306 + }
307 +
308 + if (teTunnelTp.getTerminationCapabilities() != null) {
309 + for (TerminationCapability tcap : teTunnelTp.getTerminationCapabilities()) {
310 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
311 + .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint.config
312 + .TerminationCapability.TerminationCapabilityBuilder
313 + tcapConfigBuilder = DefaultTerminationCapability.builder();
314 + // FIXME: at this moment, tcap does not have any getter or setter.
315 + // add the following getLinkTpId possibly other attributes to Core data structure
316 + // tcapConfigBuilder =
317 + // tcapConfigBuilder.linkTp(TpId.fromString(tcap.getLinkTpId.toString()));
318 + ttpConfigBuilder = ttpConfigBuilder.addToTerminationCapability(tcapConfigBuilder.build());
319 +
320 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
321 + .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint.state
322 + .TerminationCapability.TerminationCapabilityBuilder tcapStateBuilder =
323 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
324 + .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint.state
325 + .DefaultTerminationCapability.builder();
326 + // FIXME: at this moment, tcap does not have any getter or setter.
327 + // add the following getLinkTpId possibly other attributes to Core data structure
328 + // tcapConfigBuilder =
329 + // tcapConfigBuilder.linkTp(TpId.fromString(tcap.getLinkTpId.toString()));
330 + ttpStateBuilder = ttpStateBuilder.addToTerminationCapability(tcapStateBuilder.build());
331 + }
332 + }
333 +
334 + tunnelTpBuilder = tunnelTpBuilder.config(ttpConfigBuilder.build())
335 + .state(ttpStateBuilder.build());
336 +
337 + return tunnelTpBuilder.build();
338 + }
339 +
340 + /**
341 + * Node object conversion from TE Topology subsystem to YANG.
342 + *
343 + * @param teSubsystem TE subsystem node object
344 + * @return YANG node object
345 + */
346 + public static Node teSubsystem2YangNode(org.onosproject.tetopology.management.api.node.NetworkNode teSubsystem) {
347 + checkNotNull(teSubsystem, E_NULL_TE_SUBSYSTEM_NODE);
348 +
349 + NodeId nodeId = NodeId.fromString(teSubsystem.nodeId().toString());
350 + Node.NodeBuilder builder = DefaultNode.builder().nodeId(nodeId);
351 +
352 + if (teSubsystem.getSupportingNodeIds() != null) {
353 + List<SupportingNode> sNodes = Lists.newArrayList();
354 + SupportingNode.SupportingNodeBuilder spNodeBuilder = DefaultSupportingNode
355 + .builder();
356 + for (NetworkNodeKey nodeKey : teSubsystem.getSupportingNodeIds()) {
357 + sNodes.add(spNodeBuilder
358 + .networkRef(NetworkId
359 + .fromString(nodeKey.networkId().toString()))
360 + .nodeRef(NodeId.fromString(nodeKey.nodeId().toString()))
361 + .build());
362 + }
363 + builder = builder.supportingNode(sNodes);
364 + }
365 +
366 + if (teSubsystem.getTerminationPoints() != null) {
367 + AugmentedNdNode.AugmentedNdNodeBuilder tpAugmentBuilder = DefaultAugmentedNdNode
368 + .builder();
369 + List<TerminationPoint> teSubsystemTeTp = teSubsystem
370 + .getTerminationPoints();
371 + for (TerminationPoint teTp : teSubsystemTeTp) {
372 + tpAugmentBuilder.addToTerminationPoint(TerminationPointConverter
373 + .teSubsystem2YangTerminationPoint(teTp));
374 + }
375 + builder.addYangAugmentedInfo(tpAugmentBuilder.build(),
376 + AugmentedNdNode.class);
377 + }
378 +
379 + if (teSubsystem.getTe() != null) {
380 + AugmentedNwNode.AugmentedNwNodeBuilder nodeAugmentBuilder = DefaultAugmentedNwNode
381 + .builder();
382 +
383 + TeNode teSubsystemTeNode = teSubsystem.getTe();
384 +
385 + TeBuilder yangTeBuilder = DefaultTe.builder();
386 +
387 + if (teSubsystemTeNode.teNodeId() != null) {
388 + yangTeBuilder = yangTeBuilder.teNodeId(TeNodeId
389 + .fromString(teSubsystemTeNode.teNodeId().toString()));
390 + }
391 +
392 + // Set configuration data
393 + // Set state data
394 + yangTeBuilder = yangTeBuilder.config(teNode2YangConfig(teSubsystemTeNode))
395 + .state(teNode2YangState(teSubsystemTeNode));
396 +
397 + if (teSubsystemTeNode.tunnelTerminationPoints() != null) {
398 + for (org.onosproject.tetopology.management.api.node.TunnelTerminationPoint
399 + teTunnelTp : teSubsystemTeNode.tunnelTerminationPoints()) {
400 + yangTeBuilder = yangTeBuilder.addToTunnelTerminationPoint(teSubsystem2YangTtp(teTunnelTp));
401 + }
402 + }
403 +
404 + nodeAugmentBuilder = nodeAugmentBuilder.te(yangTeBuilder.build());
405 + builder.addYangAugmentedInfo(nodeAugmentBuilder.build(),
406 + AugmentedNwNode.class);
407 + }
408 + return builder.build();
409 + }
410 +
411 + /**
412 + * Node object conversion from YANG to TE Topology subsystem.
413 + *
414 + * @param yangNode YANG node object
415 + * @param yangNetworkId YANG networkId object
416 + * @return TE subsystem node object
417 + */
418 + public static org.onosproject.tetopology.management.api.node.NetworkNode
419 + yang2TeSubsystemNode(Node yangNode, NetworkId yangNetworkId) {
420 + checkNotNull(yangNode, E_NULL_YANG_NODE);
421 +
422 + org.onosproject.tetopology.management.api.node.DefaultNetworkNode node =
423 + new org.onosproject.tetopology.management.api.node.DefaultNetworkNode(
424 + KeyId.keyId(yangNode.nodeId().uri().string()));
425 +
426 + if (yangNode.supportingNode() != null) {
427 + List<NetworkNodeKey> spNodes = Lists.newArrayList();
428 + for (SupportingNode yangSpNode : yangNode.supportingNode()) {
429 + NetworkNodeKey nodeKey = new NetworkNodeKey(KeyId.keyId(yangSpNode.nodeRef().uri().toString()),
430 + KeyId.keyId(yangSpNode.networkRef().uri().toString()));
431 + spNodes.add(nodeKey);
432 + }
433 + node.setSupportingNodeIds(spNodes);
434 + }
435 +
436 + if (yangNode.yangAugmentedInfoMap() != null
437 + && !yangNode.yangAugmentedInfoMap().isEmpty()) {
438 +
439 + AugmentedNdNode yangTpNodeAugment = (AugmentedNdNode) yangNode
440 + .yangAugmentedInfo(AugmentedNdNode.class);
441 + if (yang2TeSubsystemTpNodeAugment(yangTpNodeAugment) != null) {
442 + node.setTerminationPoints(yang2TeSubsystemTpNodeAugment(yangTpNodeAugment));
443 + }
444 +
445 + AugmentedNwNode yangNodeAugment = (AugmentedNwNode) yangNode
446 + .yangAugmentedInfo(AugmentedNwNode.class);
447 + if (yangNodeAugment != null && yangNodeAugment.te() != null && yangNodeAugment.te().teNodeId() != null) {
448 + Te yangNodeAugTe = yangNodeAugment.te();
449 + TeNode teNode = yang2TeSubsystemNodeAugment(yangNodeAugTe, yangNetworkId, yangNode.nodeId());
450 + node.setTe(teNode);
451 + }
452 + }
453 +
454 + return node;
455 + }
456 +
457 + private static TeNode yang2TeSubsystemNodeConnectivityMatrix(TeNode teNode,
458 + String networkId, String nodeId, List<ConnectivityMatrix> yangMatrix) {
459 + List<org.onosproject.tetopology.management.api.node.ConnectivityMatrix> teCmList =
460 + Lists.newArrayList();
461 + for (ConnectivityMatrix cmYang : yangMatrix) {
462 + Long id = cmYang.id();
463 + TerminationPointKey from = new TerminationPointKey(
464 + KeyId.keyId(networkId),
465 + KeyId.keyId(nodeId),
466 + KeyId.keyId(cmYang.from().tpRef().uri().toString()));
467 + TerminationPointKey to = new TerminationPointKey(
468 + KeyId.keyId(networkId),
469 + KeyId.keyId(nodeId),
470 + KeyId.keyId(cmYang.to().tpRef().uri().toString()));
471 + boolean isAllowed = cmYang.isAllowed();
472 + org.onosproject.tetopology.management.api.node.ConnectivityMatrix cmTe =
473 + new org.onosproject.tetopology.management.api.node.ConnectivityMatrix(
474 + id, from, to, isAllowed);
475 + teCmList.add(cmTe);
476 + }
477 + teNode.setConnectivityMatrices(teCmList);
478 + return teNode;
479 + }
480 +
481 + private static TeNode yang2TeSubsystemNodeUnderlayTopology(TeNode teNode,
482 + UnderlayTopology ut) {
483 + TeNetworkTopologyId underlayTopology =
484 + new TeNetworkTopologyId(KeyId.keyId(ut.networkIdRef().uri().toString()),
485 + new org.onosproject.tetopology.management.api.TeTopologyId(
486 + ut.providerIdRef().uint32(),
487 + ut.clientIdRef().uint32(),
488 + ut.teTopologyIdRef().toString()));
489 + teNode.setUnderlayTopology(underlayTopology);
490 + return teNode;
491 + }
492 +
493 + private static TeNode yang2TeSubsystemTtp(TeNode teNode,
494 + List<TunnelTerminationPoint> ttps) {
495 + List<org.onosproject.tetopology.management.api.node.TunnelTerminationPoint> ttpTeList =
496 + Lists.newArrayList();
497 + for (TunnelTerminationPoint ttpYang : ttps) {
498 + org.onosproject.tetopology.management.api.node.TunnelTerminationPoint ttpTe =
499 + new org.onosproject.tetopology.management.api.node.TunnelTerminationPoint(
500 + ttpYang.tunnelTpId());
501 + ttpTe.setInterLayerLockId(ttpYang.config().interLayerLockId());
502 + // FIXME: go through
503 + // ttpYang.config().switchingCapability() and populate
504 + // ttpTe.setSwitchingCapabilities(switchingCapabilities);
505 + // FIXME: go through
506 + // ttpYang.config().terminationCapability() and populate
507 + // ttpTe.setTerminationCapability(terminationCapability);
508 + ttpTeList.add(ttpTe);
509 + }
510 + teNode.setTunnelTerminationPoints(ttpTeList);
511 +
512 + return teNode;
513 + }
514 +
515 + private static TeNode yang2TeSubsystemNodeAugment(Te yangNodeAugTe,
516 + NetworkId yangNetworkId, NodeId yangNodeId) {
517 + TeNode teNode = new TeNode(yangNodeAugTe.teNodeId().toString());
518 + Config ynodeAugCfg = yangNodeAugTe.config();
519 + if (ynodeAugCfg != null) {
520 + TeNodeAttributes teNodeAttr = ynodeAugCfg.teNodeAttributes();
521 + if (teNodeAttr != null) {
522 + teNode.setAbstract(teNodeAttr.isAbstract());
523 +
524 + if (teNodeAttr.adminStatus() != null) {
525 + teNode.setAdminStatus(EnumConverter.yang2TeSubsystemAdminStatus(
526 + ynodeAugCfg.teNodeAttributes().adminStatus()));
527 + }
528 +
529 + if (yangNodeAugTe.state() != null &&
530 + yangNodeAugTe.state().operStatus() != null) {
531 + teNode.setOpStatus(EnumConverter.yang2TeSubsystemOpStatus(
532 + yangNodeAugTe.state().operStatus()));
533 + }
534 +
535 + if (teNodeAttr.connectivityMatrix() != null) {
536 + teNode = yang2TeSubsystemNodeConnectivityMatrix(teNode,
537 + yangNetworkId.uri().toString(),
538 + yangNodeId.uri().toString(),
539 + teNodeAttr.connectivityMatrix());
540 + }
541 +
542 + if (teNodeAttr.underlayTopology() != null) {
543 + teNode = yang2TeSubsystemNodeUnderlayTopology(teNode,
544 + teNodeAttr.underlayTopology());
545 + }
546 + }
547 + }
548 +
549 + if (yangNodeAugTe.tunnelTerminationPoint() != null) {
550 + teNode = yang2TeSubsystemTtp(teNode, yangNodeAugTe.tunnelTerminationPoint());
551 + }
552 + return teNode;
553 + }
554 +
555 + private static List<TerminationPoint> yang2TeSubsystemTpNodeAugment(AugmentedNdNode yangTpNodeAugment) {
556 + if (yangTpNodeAugment.terminationPoint() != null) {
557 + List<TerminationPoint> teTpList = Lists.newArrayList();
558 + for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology
559 + .rev20151208.ietfnetworktopology.networks.network.node.augmentedndnode.TerminationPoint
560 + yangTpnode : yangTpNodeAugment.terminationPoint()) {
561 + teTpList.add(TerminationPointConverter.yang2teSubsystemTerminationPoint(yangTpnode));
562 + }
563 + return teTpList;
564 + }
565 + return null;
566 + }
567 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.teyang.utils.topology;
17 +
18 +import static com.google.common.base.Preconditions.checkNotNull;
19 +
20 +import java.util.List;
21 +
22 +import org.onosproject.tetopology.management.api.KeyId;
23 +import org.onosproject.tetopology.management.api.node.TeTerminationPoint;
24 +import org.onosproject.tetopology.management.api.node.TerminationPointKey;
25 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NetworkId;
26 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NodeId;
27 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
28 + .ietfnetworktopology.TpId;
29 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
30 + .ietfnetworktopology.networks.network.node.augmentedndnode.DefaultTerminationPoint;
31 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
32 + .ietfnetworktopology.networks.network.node.augmentedndnode.TerminationPoint;
33 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
34 + .ietfnetworktopology.networks.network.node.augmentedndnode.terminationpoint
35 + .DefaultSupportingTerminationPoint;
36 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
37 + .ietfnetworktopology.networks.network.node.augmentedndnode.terminationpoint
38 + .SupportingTerminationPoint;
39 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
40 + .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.DefaultTe;
41 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
42 + .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.Te.TeBuilder;
43 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
44 + .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.te.Config;
45 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
46 + .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.te.DefaultConfig;
47 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
48 + .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.te.DefaultState;
49 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
50 + .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.te.State;
51 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
52 + .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint
53 + .te.config.DefaultInterfaceSwitchingCapability;
54 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
55 + .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint
56 + .te.config.InterfaceSwitchingCapability;
57 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeTpId;
58 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
59 + .ietftetopology.networks.network.node.terminationpoint.AugmentedNtTerminationPoint;
60 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
61 + .ietftetopology.networks.network.node.terminationpoint.DefaultAugmentedNtTerminationPoint;
62 +
63 +import com.google.common.collect.Lists;
64 +
65 +/**
66 + * The termination point translations.
67 + */
68 +public final class TerminationPointConverter {
69 +
70 + private static final String E_NULL_TE_SUBSYSTEM_TP = "TeSubsystem terminationPoint object cannot be null";
71 + private static final String E_NULL_YANG_TP = "YANG terminationPoint object cannot be null";
72 +
73 + // no instantiation
74 + private TerminationPointConverter() {
75 + }
76 +
77 + /**
78 + * TerminationPoint object translation from TE Topology subsystem to YANG.
79 + *
80 + * @param teSubsystem TE Topology subsystem termination point object
81 + * @return TerminationPoint YANG object
82 + */
83 + public static TerminationPoint teSubsystem2YangTerminationPoint(
84 + org.onosproject.tetopology.management.api.node.TerminationPoint teSubsystem) {
85 + checkNotNull(teSubsystem, E_NULL_TE_SUBSYSTEM_TP);
86 +
87 + TpId tpId = TpId.fromString(teSubsystem.id().toString());
88 + TerminationPoint.TerminationPointBuilder builder =
89 + new DefaultTerminationPoint.TerminationPointBuilder().tpId(tpId);
90 +
91 + if (teSubsystem.getSupportingTpIds() != null) {
92 + List<SupportingTerminationPoint> tps = Lists.newArrayList();
93 + SupportingTerminationPoint.SupportingTerminationPointBuilder
94 + spTpBuilder = DefaultSupportingTerminationPoint.builder();
95 + for (TerminationPointKey tpKey : teSubsystem.getSupportingTpIds()) {
96 + tps.add(spTpBuilder.networkRef(NetworkId.fromString(tpKey.networkId().toString()))
97 + .nodeRef(NodeId.fromString(tpKey.nodeId().toString()))
98 + .tpRef(TpId.fromString(tpKey.tpId().toString()))
99 + .build());
100 + }
101 + builder = builder.supportingTerminationPoint(tps);
102 + }
103 +
104 + if (teSubsystem.getTe() != null) {
105 + AugmentedNtTerminationPoint.AugmentedNtTerminationPointBuilder
106 + tpAugmentBuilder = DefaultAugmentedNtTerminationPoint.builder();
107 +
108 + TeTerminationPoint teSubsystemTe = teSubsystem.getTe();
109 + TeBuilder yangTeBuilder = DefaultTe.builder();
110 +
111 + if (teSubsystemTe.teTpId() != null) {
112 + yangTeBuilder = yangTeBuilder.teTpId(TeTpId.fromString(teSubsystemTe.teTpId().toString()));
113 + }
114 +
115 + Config yConfig = teSubsystem2YangTeAugConfig(teSubsystemTe);
116 + yangTeBuilder = yangTeBuilder.config(yConfig);
117 +
118 + State yState = teSubsystem2YangTeAugState(teSubsystemTe);
119 + yangTeBuilder = yangTeBuilder.state(yState);
120 +
121 + tpAugmentBuilder = tpAugmentBuilder.te(yangTeBuilder.build());
122 + builder.addYangAugmentedInfo(tpAugmentBuilder.build(), AugmentedNtTerminationPoint.class);
123 + }
124 +
125 + return builder.build();
126 + }
127 +
128 + private static State teSubsystem2YangTeAugState(TeTerminationPoint teSubsystemTe) {
129 + State.StateBuilder yangStateBuilder = DefaultState.builder();
130 + yangStateBuilder.interLayerLockId(teSubsystemTe.getInterLayerLockId());
131 +
132 + if (teSubsystemTe.interfaceSwitchingCapabilities() != null) {
133 + for (org.onosproject.tetopology.management.api.node.InterfaceSwitchingCapability teIsc :
134 + teSubsystemTe.interfaceSwitchingCapabilities()) {
135 + org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
136 + .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint
137 + .te.state.InterfaceSwitchingCapability.InterfaceSwitchingCapabilityBuilder
138 + isc = org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
139 + .rev20160708.ietftetopology.networks.network.node.terminationpoint
140 + .augmentedntterminationpoint.te.state.DefaultInterfaceSwitchingCapability.builder();
141 + // FIXME: teIsc at this moment is empty, therefore we cannot
142 + // really add its attributes to isc
143 + yangStateBuilder.addToInterfaceSwitchingCapability(isc.build());
144 + }
145 + }
146 + return yangStateBuilder.build();
147 + }
148 +
149 + private static Config teSubsystem2YangTeAugConfig(TeTerminationPoint teSubsystemTe) {
150 + Config.ConfigBuilder yangConfigBuilder = DefaultConfig.builder();
151 + yangConfigBuilder = yangConfigBuilder.interLayerLockId(teSubsystemTe.getInterLayerLockId());
152 + if (teSubsystemTe.interfaceSwitchingCapabilities() != null) {
153 + for (org.onosproject.tetopology.management.api.node.InterfaceSwitchingCapability teIsc :
154 + teSubsystemTe.interfaceSwitchingCapabilities()) {
155 + InterfaceSwitchingCapability.InterfaceSwitchingCapabilityBuilder
156 + isc = DefaultInterfaceSwitchingCapability.builder();
157 + // FIXME: teIsc at this moment is empty, therefore we cannot
158 + // really add its attributes to isc
159 + yangConfigBuilder = yangConfigBuilder.addToInterfaceSwitchingCapability(isc.build());
160 + }
161 + }
162 + return yangConfigBuilder.build();
163 + }
164 +
165 + /**
166 + * TerminationPoint object translation from YANG to TE Topology subsystem.
167 + *
168 + * @param yangTp TerminationPoint YANG object
169 + * @return TerminationPoint TE Topology subsystem termination point object
170 + */
171 + public static org.onosproject.tetopology.management.api.node.TerminationPoint
172 + yang2teSubsystemTerminationPoint(TerminationPoint yangTp) {
173 + checkNotNull(yangTp, E_NULL_YANG_TP);
174 +
175 + org.onosproject.tetopology.management.api.node.DefaultTerminationPoint tp = new org.onosproject.tetopology
176 + .management.api.node.DefaultTerminationPoint(KeyId.keyId(yangTp.tpId().uri().string()));
177 +
178 + if (yangTp.supportingTerminationPoint() != null) {
179 + List<org.onosproject.tetopology.management.api.node.TerminationPointKey> spTps = Lists.newArrayList();
180 + for (SupportingTerminationPoint yangSptp : yangTp.supportingTerminationPoint()) {
181 + org.onosproject.tetopology.management.api.node.TerminationPointKey tpKey =
182 + new org.onosproject.tetopology.management.api.node.TerminationPointKey(
183 + KeyId.keyId(yangSptp.networkRef().uri().string()),
184 + KeyId.keyId(yangSptp.nodeRef().uri().string()),
185 + KeyId.keyId(yangSptp.tpRef().uri().string()));
186 + spTps.add(tpKey);
187 + }
188 + tp.setSupportingTpIds(spTps);
189 + }
190 +
191 + if (yangTp.yangAugmentedInfoMap() != null && !yangTp.yangAugmentedInfoMap().isEmpty()) {
192 + AugmentedNtTerminationPoint yangTpAugment =
193 + (AugmentedNtTerminationPoint) yangTp.yangAugmentedInfo(AugmentedNtTerminationPoint.class);
194 + if (yangTpAugment.te() != null && yangTpAugment.te().teTpId() != null) {
195 + KeyId teTpId = KeyId.keyId(yangTpAugment.te().teTpId().toString());
196 + if (yangTpAugment.te().config() != null) {
197 + long interLayerLockId = yangTpAugment.te().config().interLayerLockId();
198 + List<org.onosproject.tetopology.management.api.node.InterfaceSwitchingCapability>
199 + teIscList = Lists.newArrayList();
200 + // FIXME: the following line is for config. State also has
201 + // similar stuff, but Te Subsystem does not diffrentiate
202 + // between the two
203 + if (yangTpAugment.te().config().interfaceSwitchingCapability() != null) {
204 + for (InterfaceSwitchingCapability iscConfigYang :
205 + yangTpAugment.te().config().interfaceSwitchingCapability()) {
206 + org.onosproject.tetopology.management.api.node.InterfaceSwitchingCapability iscTe =
207 + new org.onosproject.tetopology.management.api.node.InterfaceSwitchingCapability();
208 + // FIXME: at this moment, iscTe does not have any
209 + // attributes. Therefore, I cannot feed it with
210 + // attributes of iscConfigYang
211 + teIscList.add(iscTe);
212 + }
213 + }
214 +
215 + TeTerminationPoint teSubsystemTp = new TeTerminationPoint(teTpId,
216 + teIscList,
217 + interLayerLockId);
218 + tp.setTe(teSubsystemTp);
219 + }
220 + }
221 + }
222 + return tp;
223 + }
224 +
225 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +/**
17 + * The utilities for conversions between TE Topology core subsystem and
18 + * IETF TE Topology Yang generated Java code.
19 + */
20 +package org.onosproject.teyang.utils.topology;
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.teyang.utils.topology;
17 +
18 +import static org.junit.Assert.assertEquals;
19 +
20 +import org.junit.Before;
21 +import org.junit.Test;
22 +import org.onosproject.teyang.api.OperationType;
23 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network
24 + .rev20151208.ietfnetwork.networks.Network;
25 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology.networks.network.node.AugmentedNwNode;
26 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeAdminStatus;
27 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.teadminstatus.TeAdminStatusEnum;
28 +
29 +
30 +/**
31 + * Unit tests for converter functions.
32 + */
33 +public class ConverterTest {
34 +
35 + Network output;
36 +
37 + @Before
38 + public void setUp() {
39 + output = NetworkConverter.teSubsystem2YangNetwork(
40 + DefaultBuilder.sampleTeSubsystemNetworkBuilder(),
41 + OperationType.NONE);
42 + }
43 +
44 + @Test
45 + public void basics() {
46 + assertEquals("Wrong networkId",
47 + output.networkId().uri().string(),
48 + "HUAWEI_NETWORK_NEW");
49 + assertEquals("Wrong 1st nodeId",
50 + output.node().get(0).nodeId().uri().string(),
51 + "HUAWEI_ROADM_1");
52 + assertEquals("Wrong 2dn nodeId",
53 + output.node().get(1).nodeId().uri().string(),
54 + "HUAWEI_ROADM_2");
55 + AugmentedNwNode augmentedNode = (AugmentedNwNode) output.node().get(0)
56 + .yangAugmentedInfo(AugmentedNwNode.class);
57 +
58 + assertEquals("Wrong adminStatus",
59 + augmentedNode.te().config().teNodeAttributes().adminStatus(),
60 + TeAdminStatus.of(TeAdminStatusEnum.UP));
61 + }
62 +
63 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.teyang.utils.topology;
17 +
18 +import java.math.BigInteger;
19 +import java.util.List;
20 +
21 +import org.onosproject.tetopology.management.api.DefaultNetwork;
22 +import org.onosproject.tetopology.management.api.DefaultNetworks;
23 +import org.onosproject.tetopology.management.api.KeyId;
24 +import org.onosproject.tetopology.management.api.Network;
25 +import org.onosproject.tetopology.management.api.Networks;
26 +import org.onosproject.tetopology.management.api.TeTopologyId;
27 +import org.onosproject.tetopology.management.api.link.DefaultNetworkLink;
28 +import org.onosproject.tetopology.management.api.link.LinkProtectionType;
29 +import org.onosproject.tetopology.management.api.link.NetworkLink;
30 +import org.onosproject.tetopology.management.api.link.TeLink;
31 +import org.onosproject.tetopology.management.api.link.TeLinkAccessType;
32 +import org.onosproject.tetopology.management.api.node.ConnectivityMatrix;
33 +import org.onosproject.tetopology.management.api.node.DefaultNetworkNode;
34 +import org.onosproject.tetopology.management.api.node.DefaultTerminationPoint;
35 +import org.onosproject.tetopology.management.api.node.NetworkNode;
36 +import org.onosproject.tetopology.management.api.node.TeNetworkTopologyId;
37 +import org.onosproject.tetopology.management.api.node.TeNode;
38 +import org.onosproject.tetopology.management.api.node.TeStatus;
39 +import org.onosproject.tetopology.management.api.node.TerminationPoint;
40 +import org.onosproject.tetopology.management.api.node.TerminationPointKey;
41 +
42 +import com.google.common.collect.Lists;
43 +
44 +/**
45 + * Builds a sample Topology, which consists of two Nodes, one link,
46 + * and each node has two termination points.
47 + */
48 +public final class DefaultBuilder {
49 +
50 + private static final String HUAWEI_NETWORK_NEW = "HUAWEI_NETWORK_NEW";
51 + private static final String HUAWEI_ROADM_1 = "HUAWEI_ROADM_1";
52 + private static final String CLIENT1_NODE1 = "CLIENT1_NODE1";
53 + private static final String LINE1_NODE1 = "LINE1_NODE1";
54 + private static final String NODE1_IP = "10.11.12.33";
55 + private static final String HUAWEI_ROADM_2 = "HUAWEI_ROADM_2";
56 + private static final String CLIENT1_NODE2 = "CLIENT1_NODE2";
57 + private static final String LINE1_NODE2 = "LINE1_NODE2";
58 + private static final String NODE2_IP = "10.11.12.34";
59 + private static final String LINK1FORNETWORK1 = "LINK1FORNETWORK1";
60 + private static final String HUAWEI_TE_TOPOLOGY_NEW = "HUAWEI_TE_TOPOLOGY_NEW";
61 +
62 + // no instantiation
63 + private DefaultBuilder() {
64 + }
65 +
66 + /**
67 + * Returns a sample TeSubsystem Networks object.
68 + *
69 + * @return the Networks object
70 + */
71 + public static Networks sampleTeSubsystemNetworksBuilder() {
72 + DefaultNetworks defaultNetworks = new DefaultNetworks();
73 + List<Network> networks = Lists.newArrayList();
74 + networks.add(sampleTeSubsystemNetworkBuilder());
75 + defaultNetworks.setNetworks(networks);
76 + return defaultNetworks;
77 + }
78 +
79 + /**
80 + * Returns a sample TeSubsystem Network object.
81 + *
82 + * @return the Network object
83 + */
84 + public static Network sampleTeSubsystemNetworkBuilder() {
85 + DefaultNetwork huaweiNetworkNew = new DefaultNetwork(KeyId.keyId(HUAWEI_NETWORK_NEW));
86 + huaweiNetworkNew.setServerProvided(true);
87 + List<NetworkNode> nodes = Lists.newArrayList();
88 +
89 +
90 + DefaultNetworkNode node1 = new DefaultNetworkNode(KeyId.keyId(HUAWEI_ROADM_1));
91 +
92 + DefaultTerminationPoint tp11 = new DefaultTerminationPoint(KeyId.keyId(CLIENT1_NODE1));
93 + DefaultTerminationPoint tp12 = new DefaultTerminationPoint(KeyId.keyId(LINE1_NODE1));
94 +
95 + List<TerminationPoint> tps1 = Lists.newArrayList();
96 + tps1.add(tp11);
97 + tps1.add(tp12);
98 + node1.setTerminationPoints(tps1);
99 +
100 + TeNode teNode1 = new TeNode(NODE1_IP);
101 + teNode1.setAdminStatus(TeStatus.UP);
102 + teNode1.setAbstract(false);
103 + ConnectivityMatrix cMatrix1 =
104 + new ConnectivityMatrix(1,
105 + new TerminationPointKey(huaweiNetworkNew.networkId(),
106 + node1.nodeId(), tp11.id()),
107 + new TerminationPointKey(huaweiNetworkNew.networkId(),
108 + node1.nodeId(), tp12.id()),
109 + true);
110 + List<ConnectivityMatrix> connMatrices = Lists.newArrayList();
111 + connMatrices.add(cMatrix1);
112 + teNode1.setConnectivityMatrices(connMatrices);
113 + node1.setTe(teNode1);
114 +
115 + DefaultNetworkNode node2 = new DefaultNetworkNode(KeyId.keyId(HUAWEI_ROADM_2));
116 +
117 + DefaultTerminationPoint tp21 = new DefaultTerminationPoint(KeyId.keyId(CLIENT1_NODE2));
118 + DefaultTerminationPoint tp22 = new DefaultTerminationPoint(KeyId.keyId(LINE1_NODE2));
119 +
120 + List<TerminationPoint> tps2 = Lists.newArrayList();
121 + tps2.add(tp21);
122 + tps2.add(tp22);
123 + node2.setTerminationPoints(tps2);
124 +
125 + TeNode teNode2 = new TeNode(NODE2_IP);
126 + teNode1.setAdminStatus(TeStatus.UP);
127 + teNode1.setAbstract(false);
128 + ConnectivityMatrix cMatrix2 =
129 + new ConnectivityMatrix(1,
130 + new TerminationPointKey(huaweiNetworkNew.networkId(),
131 + node2.nodeId(), tp21.id()),
132 + new TerminationPointKey(huaweiNetworkNew.networkId(),
133 + node2.nodeId(), tp22.id()),
134 + true);
135 + List<ConnectivityMatrix> connMatrices2 = Lists.newArrayList();
136 + connMatrices.add(cMatrix2);
137 + teNode1.setConnectivityMatrices(connMatrices2);
138 + node2.setTe(teNode2);
139 +
140 + nodes.add(node1);
141 + nodes.add(node2);
142 + huaweiNetworkNew.setNodes(nodes);
143 +
144 + List<NetworkLink> links = Lists.newArrayList();
145 +
146 + DefaultNetworkLink link1 = new DefaultNetworkLink(KeyId.keyId(LINK1FORNETWORK1));
147 + link1.setSource(new TerminationPointKey(huaweiNetworkNew.networkId(),
148 + node1.nodeId(),
149 + tp11.id()));
150 + link1.setDestination(new TerminationPointKey(huaweiNetworkNew.networkId(),
151 + node2.nodeId(),
152 + tp21.id()));
153 + TeLink teLink1 = new TeLink(BigInteger.valueOf(1));
154 + teLink1.setIsAbstract(false);
155 + teLink1.setAdminStatus(TeStatus.UP);
156 + teLink1.setAccessType(TeLinkAccessType.POINT_TO_POINT);
157 + teLink1.setLinkProtectionType(LinkProtectionType.UNPROTECTED);
158 + List<Long> teSrlgs = Lists.newArrayList();
159 + teSrlgs.add(1000L);
160 + teSrlgs.add(2000L);
161 + teLink1.setTeSrlgs(teSrlgs);
162 + link1.setTe(teLink1);
163 + links.add(link1);
164 + huaweiNetworkNew.setLinks(links);
165 +
166 + TeNetworkTopologyId teNetwork =
167 + new TeNetworkTopologyId(new TeTopologyId(22222L, 44444L, HUAWEI_TE_TOPOLOGY_NEW));
168 + huaweiNetworkNew.setTeTopologyId(teNetwork.getTopologyId());
169 +
170 + return huaweiNetworkNew;
171 + }
172 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +/**
17 + * The topology utilities test functions.
18 + *
19 + */
20 +package org.onosproject.teyang.utils.topology;
1 +COMPILE = [
2 + '//lib:guava',
3 +]
4 +
5 +#yang_library(
6 +# deps = COMPILE,
7 +# name = 'onos-app-tenbi-yangmodel',
8 +# srcs = glob(['src/main/**/*.yang']),
9 +#)
1 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 +<!--
3 + ~ Copyright 2015 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="@PROJECT-ARTIFACTID-@ONOS-VERSION" >
18 + <feature name="@PROJECT-ARTIFACTID" version="@ONOS-VERSION"
19 + description="@PROJECT-DESCRIPTION" >
20 + <bundle>mvn:@PROJECT-GROUPID/@PROJECT-ARTIFACTID/@ONOS-VERSION</bundle>
21 + </feature>
22 +</features>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<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/xsd/maven-4.0.0.xsd">
18 + <modelVersion>4.0.0</modelVersion>
19 +
20 + <parent>
21 + <groupId>org.onosproject</groupId>
22 + <artifactId>onos-app-tenbi</artifactId>
23 + <version>1.8.0-SNAPSHOT</version>
24 + <relativePath>../pom.xml</relativePath>
25 + </parent>
26 +
27 + <artifactId>onos-app-tenbi-yangmodel</artifactId>
28 + <packaging>bundle</packaging>
29 +
30 + <description>IETF TE YANG models</description>
31 +
32 + <dependencies>
33 + <dependency>
34 + <groupId>org.onosproject</groupId>
35 + <artifactId>onos-yang-maven-plugin</artifactId>
36 + <version>1.8</version>
37 + </dependency>
38 + <dependency>
39 + <groupId>org.onosproject</groupId>
40 + <artifactId>onos-yang-datamodel</artifactId>
41 + <version>1.8</version>
42 + </dependency>
43 + </dependencies>
44 +
45 + <build>
46 + <plugins>
47 + <plugin>
48 + <groupId>org.onosproject</groupId>
49 + <artifactId>onos-yang-maven-plugin</artifactId>
50 + <version>1.8</version>
51 + <executions>
52 + <execution>
53 + <goals>
54 + <goal>yang2java</goal>
55 + </goals>
56 + </execution>
57 + </executions>
58 + </plugin>
59 + <plugin>
60 + <groupId>com.google.code.maven-replacer-plugin</groupId>
61 + <artifactId>replacer</artifactId>
62 + <version>1.5.3</version>
63 + <executions>
64 + <execution>
65 + <phase>prepare-package</phase>
66 + <goals>
67 + <goal>replace</goal>
68 + </goals>
69 + </execution>
70 + </executions>
71 + <configuration>
72 + <file>${pom.basedir}/features.xml</file>
73 + <outputFile>${pom.basedir}/target/features.xml</outputFile>
74 + <replacements>
75 + <replacement>
76 + <token>@ONOS-VERSION</token>
77 + <value>${project.version}</value>
78 + </replacement>
79 + <replacement>
80 + <token>@PROJECT-GROUPID</token>
81 + <value>${project.groupId}</value>
82 + </replacement>
83 + <replacement>
84 + <token>@PROJECT-ARTIFACTID</token>
85 + <value>${project.artifactId}</value>
86 + </replacement>
87 + <replacement>
88 + <token>@PROJECT-DESCRIPTION</token>
89 + <value>${project.description}</value>
90 + </replacement>
91 + <replacement>
92 + <token>@FEATURE-VERSION</token>
93 + <value>${project.version}</value>
94 + </replacement>
95 + </replacements>
96 + </configuration>
97 + </plugin>
98 + <plugin>
99 + <groupId>org.codehaus.mojo</groupId>
100 + <artifactId>build-helper-maven-plugin</artifactId>
101 + <version>1.9</version>
102 + <executions>
103 + <execution>
104 + <id>attach-artifacts</id>
105 + <phase>package</phase>
106 + <goals>
107 + <goal>attach-artifact</goal>
108 + </goals>
109 + <configuration>
110 + <artifacts>
111 + <artifact>
112 + <file>target/features.xml</file>
113 + <type>xml</type>
114 + <classifier>features</classifier>
115 + </artifact>
116 + </artifacts>
117 + </configuration>
118 + </execution>
119 + </executions>
120 + </plugin>
121 + </plugins>
122 + </build>
123 +
124 +</project>
1 +module ietf-inet-types {
2 +
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types";
4 + prefix "inet";
5 +
6 + organization
7 + "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/netmod/>
11 + WG List: <mailto:netmod@ietf.org>
12 +
13 + WG Chair: David Kessens
14 + <mailto:david.kessens@nsn.com>
15 +
16 + WG Chair: Juergen Schoenwaelder
17 + <mailto:j.schoenwaelder@jacobs-university.de>
18 +
19 + Editor: Juergen Schoenwaelder
20 + <mailto:j.schoenwaelder@jacobs-university.de>";
21 +
22 + description
23 + "This module contains a collection of generally useful derived
24 + YANG data types for Internet addresses and related things.
25 +
26 + Copyright (c) 2013 IETF Trust and the persons identified as
27 + authors of the code. All rights reserved.
28 +
29 + Redistribution and use in source and binary forms, with or
30 + without modification, is permitted pursuant to, and subject
31 + to the license terms contained in, the Simplified BSD License
32 + set forth in Section 4.c of the IETF Trust's Legal Provisions
33 + Relating to IETF Documents
34 + (http://trustee.ietf.org/license-info).
35 +
36 + This version of this YANG module is part of RFC 6991; see
37 + the RFC itself for full legal notices.";
38 +
39 + revision 2013-07-15 {
40 + description
41 + "This revision adds the following new data types:
42 + - ip-address-no-zone
43 + - ipv4-address-no-zone
44 + - ipv6-address-no-zone";
45 + reference
46 + "RFC 6991: Common YANG Data Types";
47 + }
48 +
49 + revision 2010-09-24 {
50 + description
51 + "Initial revision.";
52 + reference
53 + "RFC 6021: Common YANG Data Types";
54 + }
55 +
56 + /*** collection of types related to protocol fields ***/
57 +
58 + typedef ip-version {
59 + type enumeration {
60 + enum unknown {
61 + value "0";
62 + description
63 + "An unknown or unspecified version of the Internet
64 + protocol.";
65 + }
66 + enum ipv4 {
67 + value "1";
68 + description
69 + "The IPv4 protocol as defined in RFC 791.";
70 + }
71 + enum ipv6 {
72 + value "2";
73 + description
74 + "The IPv6 protocol as defined in RFC 2460.";
75 + }
76 + }
77 + description
78 + "This value represents the version of the IP protocol.
79 +
80 + In the value set and its semantics, this type is equivalent
81 + to the InetVersion textual convention of the SMIv2.";
82 + reference
83 + "RFC 791: Internet Protocol
84 + RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
85 + RFC 4001: Textual Conventions for Internet Network Addresses";
86 + }
87 +
88 + typedef dscp {
89 + type uint8 {
90 + range "0..63";
91 + }
92 + description
93 + "The dscp type represents a Differentiated Services Code Point
94 + that may be used for marking packets in a traffic stream.
95 + In the value set and its semantics, this type is equivalent
96 + to the Dscp textual convention of the SMIv2.";
97 + reference
98 + "RFC 3289: Management Information Base for the Differentiated
99 + Services Architecture
100 + RFC 2474: Definition of the Differentiated Services Field
101 + (DS Field) in the IPv4 and IPv6 Headers
102 + RFC 2780: IANA Allocation Guidelines For Values In
103 + the Internet Protocol and Related Headers";
104 + }
105 +
106 + typedef ipv6-flow-label {
107 + type uint32 {
108 + range "0..1048575";
109 + }
110 + description
111 + "The ipv6-flow-label type represents the flow identifier or Flow
112 + Label in an IPv6 packet header that may be used to
113 + discriminate traffic flows.
114 +
115 + In the value set and its semantics, this type is equivalent
116 + to the IPv6FlowLabel textual convention of the SMIv2.";
117 + reference
118 + "RFC 3595: Textual Conventions for IPv6 Flow Label
119 + RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
120 + }
121 +
122 + typedef port-number {
123 + type uint16 {
124 + range "0..65535";
125 + }
126 + description
127 + "The port-number type represents a 16-bit port number of an
128 + Internet transport-layer protocol such as UDP, TCP, DCCP, or
129 + SCTP. Port numbers are assigned by IANA. A current list of
130 + all assignments is available from <http://www.iana.org/>.
131 +
132 + Note that the port number value zero is reserved by IANA. In
133 + situations where the value zero does not make sense, it can
134 + be excluded by subtyping the port-number type.
135 + In the value set and its semantics, this type is equivalent
136 + to the InetPortNumber textual convention of the SMIv2.";
137 + reference
138 + "RFC 768: User Datagram Protocol
139 + RFC 793: Transmission Control Protocol
140 + RFC 4960: Stream Control Transmission Protocol
141 + RFC 4340: Datagram Congestion Control Protocol (DCCP)
142 + RFC 4001: Textual Conventions for Internet Network Addresses";
143 + }
144 +
145 + /*** collection of types related to autonomous systems ***/
146 +
147 + typedef as-number {
148 + type uint32;
149 + description
150 + "The as-number type represents autonomous system numbers
151 + which identify an Autonomous System (AS). An AS is a set
152 + of routers under a single technical administration, using
153 + an interior gateway protocol and common metrics to route
154 + packets within the AS, and using an exterior gateway
155 + protocol to route packets to other ASes. IANA maintains
156 + the AS number space and has delegated large parts to the
157 + regional registries.
158 +
159 + Autonomous system numbers were originally limited to 16
160 + bits. BGP extensions have enlarged the autonomous system
161 + number space to 32 bits. This type therefore uses an uint32
162 + base type without a range restriction in order to support
163 + a larger autonomous system number space.
164 +
165 + In the value set and its semantics, this type is equivalent
166 + to the InetAutonomousSystemNumber textual convention of
167 + the SMIv2.";
168 + reference
169 + "RFC 1930: Guidelines for creation, selection, and registration
170 + of an Autonomous System (AS)
171 + RFC 4271: A Border Gateway Protocol 4 (BGP-4)
172 + RFC 4001: Textual Conventions for Internet Network Addresses
173 + RFC 6793: BGP Support for Four-Octet Autonomous System (AS)
174 + Number Space";
175 + }
176 +
177 + /*** collection of types related to IP addresses and hostnames ***/
178 +
179 + typedef ip-address {
180 + type union {
181 + type inet:ipv4-address;
182 + type inet:ipv6-address;
183 + }
184 + description
185 + "The ip-address type represents an IP address and is IP
186 + version neutral. The format of the textual representation
187 + implies the IP version. This type supports scoped addresses
188 + by allowing zone identifiers in the address format.";
189 + reference
190 + "RFC 4007: IPv6 Scoped Address Architecture";
191 + }
192 +
193 + typedef ipv4-address {
194 + type string {
195 + pattern
196 + '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
197 + + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
198 + + '(%[\p{N}\p{L}]+)?';
199 + }
200 + description
201 + "The ipv4-address type represents an IPv4 address in
202 + dotted-quad notation. The IPv4 address may include a zone
203 + index, separated by a % sign.
204 +
205 + The zone index is used to disambiguate identical address
206 + values. For link-local addresses, the zone index will
207 + typically be the interface index number or the name of an
208 + interface. If the zone index is not present, the default
209 + zone of the device will be used.
210 +
211 + The canonical format for the zone index is the numerical
212 + format";
213 + }
214 +
215 + typedef ipv6-address {
216 + type string {
217 + pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
218 + + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
219 + + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
220 + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
221 + + '(%[\p{N}\p{L}]+)?';
222 + pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
223 + + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
224 + + '(%.+)?';
225 + }
226 + description
227 + "The ipv6-address type represents an IPv6 address in full,
228 + mixed, shortened, and shortened-mixed notation. The IPv6
229 + address may include a zone index, separated by a % sign.
230 +
231 + The zone index is used to disambiguate identical address
232 + values. For link-local addresses, the zone index will
233 + typically be the interface index number or the name of an
234 + interface. If the zone index is not present, the default
235 + zone of the device will be used.
236 +
237 +
238 +
239 + The canonical format of IPv6 addresses uses the textual
240 + representation defined in Section 4 of RFC 5952. The
241 + canonical format for the zone index is the numerical
242 + format as described in Section 11.2 of RFC 4007.";
243 + reference
244 + "RFC 4291: IP Version 6 Addressing Architecture
245 + RFC 4007: IPv6 Scoped Address Architecture
246 + RFC 5952: A Recommendation for IPv6 Address Text
247 + Representation";
248 + }
249 +
250 + typedef ip-address-no-zone {
251 + type union {
252 + type inet:ipv4-address-no-zone;
253 + type inet:ipv6-address-no-zone;
254 + }
255 + description
256 + "The ip-address-no-zone type represents an IP address and is
257 + IP version neutral. The format of the textual representation
258 + implies the IP version. This type does not support scoped
259 + addresses since it does not allow zone identifiers in the
260 + address format.";
261 + reference
262 + "RFC 4007: IPv6 Scoped Address Architecture";
263 + }
264 +
265 + typedef ipv4-address-no-zone {
266 + type inet:ipv4-address {
267 + pattern '[0-9\.]*';
268 + }
269 + description
270 + "An IPv4 address without a zone index. This type, derived from
271 + ipv4-address, may be used in situations where the zone is
272 + known from the context and hence no zone index is needed.";
273 + }
274 +
275 + typedef ipv6-address-no-zone {
276 + type inet:ipv6-address {
277 + pattern '[0-9a-fA-F:\.]*';
278 + }
279 + description
280 + "An IPv6 address without a zone index. This type, derived from
281 + ipv6-address, may be used in situations where the zone is
282 + known from the context and hence no zone index is needed.";
283 + reference
284 + "RFC 4291: IP Version 6 Addressing Architecture
285 + RFC 4007: IPv6 Scoped Address Architecture
286 + RFC 5952: A Recommendation for IPv6 Address Text
287 + Representation";
288 + }
289 +
290 + typedef ip-prefix {
291 + type union {
292 + type inet:ipv4-prefix;
293 + type inet:ipv6-prefix;
294 + }
295 + description
296 + "The ip-prefix type represents an IP prefix and is IP
297 + version neutral. The format of the textual representations
298 + implies the IP version.";
299 + }
300 +
301 + typedef ipv4-prefix {
302 + type string {
303 + pattern
304 + '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
305 + + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
306 + + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
307 + }
308 + description
309 + "The ipv4-prefix type represents an IPv4 address prefix.
310 + The prefix length is given by the number following the
311 + slash character and must be less than or equal to 32.
312 +
313 + A prefix length value of n corresponds to an IP address
314 + mask that has n contiguous 1-bits from the most
315 + significant bit (MSB) and all other bits set to 0.
316 +
317 + The canonical format of an IPv4 prefix has all bits of
318 + the IPv4 address set to zero that are not part of the
319 + IPv4 prefix.";
320 + }
321 +
322 + typedef ipv6-prefix {
323 + type string {
324 + pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
325 + + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
326 + + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
327 + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
328 + + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
329 + pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
330 + + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
331 + + '(/.+)';
332 + }
333 +
334 +
335 + description
336 + "The ipv6-prefix type represents an IPv6 address prefix.
337 + The prefix length is given by the number following the
338 + slash character and must be less than or equal to 128.
339 +
340 + A prefix length value of n corresponds to an IP address
341 + mask that has n contiguous 1-bits from the most
342 + significant bit (MSB) and all other bits set to 0.
343 +
344 + The IPv6 address should have all bits that do not belong
345 + to the prefix set to zero.
346 +
347 + The canonical format of an IPv6 prefix has all bits of
348 + the IPv6 address set to zero that are not part of the
349 + IPv6 prefix. Furthermore, the IPv6 address is represented
350 + as defined in Section 4 of RFC 5952.";
351 + reference
352 + "RFC 5952: A Recommendation for IPv6 Address Text
353 + Representation";
354 + }
355 +
356 + /*** collection of domain name and URI types ***/
357 +
358 + typedef domain-name {
359 + type string {
360 + pattern
361 + '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*'
362 + + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)'
363 + + '|\.';
364 + length "1..253";
365 + }
366 + description
367 + "The domain-name type represents a DNS domain name. The
368 + name SHOULD be fully qualified whenever possible.
369 +
370 + Internet domain names are only loosely specified. Section
371 + 3.5 of RFC 1034 recommends a syntax (modified in Section
372 + 2.1 of RFC 1123). The pattern above is intended to allow
373 + for current practice in domain name use, and some possible
374 + future expansion. It is designed to hold various types of
375 + domain names, including names used for A or AAAA records
376 + (host names) and other records, such as SRV records. Note
377 + that Internet host names have a stricter syntax (described
378 + in RFC 952) than the DNS recommendations in RFCs 1034 and
379 + 1123, and that systems that want to store host names in
380 + schema nodes using the domain-name type are recommended to
381 + adhere to this stricter standard to ensure interoperability.
382 +
383 + The encoding of DNS names in the DNS protocol is limited
384 + to 255 characters. Since the encoding consists of labels
385 + prefixed by a length bytes and there is a trailing NULL
386 + byte, only 253 characters can appear in the textual dotted
387 + notation.
388 +
389 + The description clause of schema nodes using the domain-name
390 + type MUST describe when and how these names are resolved to
391 + IP addresses. Note that the resolution of a domain-name value
392 + may require to query multiple DNS records (e.g., A for IPv4
393 + and AAAA for IPv6). The order of the resolution process and
394 + which DNS record takes precedence can either be defined
395 + explicitly or may depend on the configuration of the
396 + resolver.
397 +
398 + Domain-name values use the US-ASCII encoding. Their canonical
399 + format uses lowercase US-ASCII characters. Internationalized
400 + domain names MUST be A-labels as per RFC 5890.";
401 + reference
402 + "RFC 952: DoD Internet Host Table Specification
403 + RFC 1034: Domain Names - Concepts and Facilities
404 + RFC 1123: Requirements for Internet Hosts -- Application
405 + and Support
406 + RFC 2782: A DNS RR for specifying the location of services
407 + (DNS SRV)
408 + RFC 5890: Internationalized Domain Names in Applications
409 + (IDNA): Definitions and Document Framework";
410 + }
411 +
412 + typedef host {
413 + type union {
414 + type inet:ip-address;
415 + type inet:domain-name;
416 + }
417 + description
418 + "The host type represents either an IP address or a DNS
419 + domain name.";
420 + }
421 +
422 + typedef uri {
423 + type string;
424 + description
425 + "The uri type represents a Uniform Resource Identifier
426 + (URI) as defined by STD 66.
427 +
428 + Objects using the uri type MUST be in US-ASCII encoding,
429 + and MUST be normalized as described by RFC 3986 Sections
430 + 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
431 + percent-encoding is removed, and all case-insensitive
432 + characters are set to lowercase except for hexadecimal
433 + digits, which are normalized to uppercase as described in
434 + Section 6.2.2.1.
435 +
436 + The purpose of this normalization is to help provide
437 + unique URIs. Note that this normalization is not
438 + sufficient to provide uniqueness. Two URIs that are
439 + textually distinct after this normalization may still be
440 + equivalent.
441 +
442 + Objects using the uri type may restrict the schemes that
443 + they permit. For example, 'data:' and 'urn:' schemes
444 + might not be appropriate.
445 +
446 + A zero-length URI is not a valid URI. This can be used to
447 + express 'URI absent' where required.
448 +
449 + In the value set and its semantics, this type is equivalent
450 + to the Uri SMIv2 textual convention defined in RFC 5017.";
451 + reference
452 + "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
453 + RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
454 + Group: Uniform Resource Identifiers (URIs), URLs,
455 + and Uniform Resource Names (URNs): Clarifications
456 + and Recommendations
457 + RFC 5017: MIB Textual Conventions for Uniform Resource
458 + Identifiers (URIs)";
459 + }
460 +
461 +}
1 +module ietf-network-topology {
2 + // yang-version 1.1;
3 + yang-version 1;
4 + namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
5 + prefix lnk;
6 + import ietf-inet-types {
7 + prefix inet;
8 + }
9 + import ietf-network {
10 + prefix nd;
11 + }
12 + organization
13 + "IETF I2RS (Interface to the Routing System) Working Group";
14 + contact
15 + "WG Web: <http: tools.ietf.org/wg/i2rs/>
16 + WG List: <mailto:i2rs@ietf.org>
17 + WG Chair: Susan Hares
18 + <mailto:shares@ndzh.com>
19 + WG Chair: Jeffrey Haas
20 + <mailto:jhaas@pfrc.org>
21 + Editor: Alexander Clemm
22 + <mailto:alex@cisco.com>
23 + Editor: Jan Medved
24 + <mailto:jmedved@cisco.com>
25 + Editor: Robert Varga
26 + <mailto:rovarga@cisco.com>
27 + Editor: Tony Tkacik
28 + <mailto:ttkacik@cisco.com>
29 + Editor: Nitin Bahadur
30 + <mailto:nitin_bahadur@yahoo.com>
31 + Editor: Hariharan Ananthakrishnan
32 + <mailto:hari@packetdesign.com>";
33 + description
34 + "This module defines a common base model for network topology,
35 + augmenting the base network model with links to connect nodes,
36 + as well as termination points to terminate links on nodes.
37 + Copyright (c) 2015 IETF Trust and the persons identified as
38 + authors of the code. All rights reserved.
39 + Redistribution and use in source and binary forms, with or
40 + without modification, is permitted pursuant to, and subject
41 + to the license terms contained in, the Simplified BSD License
42 + set forth in Section 4.c of the IETF Trust's Legal Provisions
43 + Relating to IETF Documents
44 + (http: trustee.ietf.org/license-info).
45 + This version of this YANG module is part of
46 + draft-ietf-i2rs-yang-network-topo-02;
47 + see the RFC itself for full legal notices.
48 + NOTE TO RFC EDITOR: Please replace above reference to
49 + draft-ietf-i2rs-yang-network-topo-02 with RFC
50 + number when published (i.e. RFC xxxx).";
51 + revision 2015-12-08 {
52 + description
53 + "Initial revision.
54 + NOTE TO RFC EDITOR: Please replace the following reference
55 + to draft-ietf-i2rs-yang-network-topo-02 with
56 + RFC number when published (i.e. RFC xxxx).";
57 + reference
58 + "draft-ietf-i2rs-yang-network-topo-02.";
59 + }
60 + typedef link-id {
61 + type inet:uri;
62 + description
63 + "An identifier for a link in a topology.
64 + The identifier SHOULD be chosen such that the same link in a
65 + real network topology will always be identified through the
66 + same identifier, even if the model is instantiated in
67 + separate datastores. An implementation MAY choose to capture
68 + semantics in the identifier, for example to indicate the type
69 + of link and/or the type of topology that the link is a part
70 + of.";
71 + }
72 + typedef tp-id {
73 + type inet:uri;
74 + description
75 + "An identifier for termination points on a node.
76 + The identifier SHOULD be chosen such that the same TP in a
77 + real network topology will always be identified through the
78 + same identifier, even if the model is instantiated in
79 + separate datastores. An implementation MAY choose to capture
80 + semantics in the identifier, for example to indicate the type
81 + of TP and/or the type of node and topology that the TP is a
82 + part of.";
83 + }
84 + grouping link-ref {
85 + description
86 + "References a link in a specific network.";
87 + leaf link-ref {
88 + type leafref {
89 + path "/nd:networks/nd:network[nd:network-id=current()/../"+
90 + "network-ref]/lnk:link/lnk:link-id";
91 + require-instance false;
92 + }
93 + description
94 + "A type for an absolute reference a link instance.
95 + (This type should not be used for relative references.
96 + In such a case, a relative path should be used instead.)";
97 + }
98 + uses nd:network-ref;
99 + }
100 + grouping tp-ref {
101 + description
102 + "References a termination point in a specific node.";
103 + leaf tp-ref {
104 + type leafref {
105 + path "/nd:networks/nd:network[nd:network-id=current()/../"+
106 + "network-ref]/nd:node[nd:node-id=current()/../"+
107 + "node-ref]/lnk:termination-point/lnk:tp-id";
108 + require-instance false;
109 + }
110 + description
111 + "A type for an absolute reference to a termination point.
112 + (This type should not be used for relative references.
113 + In such a case, a relative path should be used instead.)";
114 + }
115 + uses nd:node-ref;
116 + }
117 + augment "/nd:networks/nd:network" {
118 + description
119 + "Add links to the network model.";
120 + list link {
121 + key "link-id";
122 + description
123 + "A Network Link connects a by Local (Source) node and
124 + a Remote (Destination) Network Nodes via a set of the
125 + nodes' termination points.
126 + As it is possible to have several links between the same
127 + source and destination nodes, and as a link could
128 + potentially be re-homed between termination points, to
129 + ensure that we would always know to distinguish between
130 + links, every link is identified by a dedicated link
131 + identifier.
132 + Note that a link models a point-to-point link, not a
133 + multipoint link.
134 + Layering dependencies on links in underlay topologies are
135 + not represented as the layering information of nodes and of
136 + termination points is sufficient.";
137 + container source {
138 + description
139 + "This container holds the logical source of a particular
140 + link.";
141 + leaf source-node {
142 + type leafref {
143 + path "../../../nd:node/nd:node-id";
144 + }
145 + mandatory true;
146 + description
147 + "Source node identifier, must be in same topology.";
148 + }
149 + leaf source-tp {
150 + type leafref {
151 + path "../../../nd:node[nd:node-id=current()/../"+
152 + "source-node]/termination-point/tp-id";
153 + }
154 + description
155 + "Termination point within source node that terminates
156 + the link.";
157 + }
158 + }
159 + container destination {
160 + description
161 + "This container holds the logical destination of a
162 + particular link.";
163 + leaf dest-node {
164 + type leafref {
165 + path "../../../nd:node/nd:node-id";
166 + }
167 + mandatory true;
168 + description
169 + "Destination node identifier, must be in the same
170 + network.";
171 + }
172 + leaf dest-tp {
173 + type leafref {
174 + path "../../../nd:node[nd:node-id=current()/../"+
175 + "dest-node]/termination-point/tp-id";
176 + }
177 + description
178 + "Termination point within destination node that
179 + terminates the link.";
180 + }
181 + }
182 + leaf link-id {
183 + type link-id;
184 + description
185 + "The identifier of a link in the topology.
186 + A link is specific to a topology to which it belongs.";
187 + }
188 + list supporting-link {
189 + key "network-ref link-ref";
190 + description
191 + "Identifies the link, or links, that this link
192 + is dependent on.";
193 + leaf network-ref {
194 + type leafref {
195 + path "../../../nd:supporting-network/nd:network-ref";
196 + require-instance false;
197 + }
198 + description
199 + "This leaf identifies in which underlay topology
200 + supporting link is present.";
201 + }
202 + leaf link-ref {
203 + type leafref {
204 + path "/nd:networks/nd:network[nd:network-id=current()/"+
205 + "../network-ref]/link/link-id";
206 + require-instance false;
207 + }
208 + description
209 + "This leaf identifies a link which is a part
210 + of this link's underlay. Reference loops, in which
211 + a link identifies itself as its underlay, either
212 + directly or transitively, are not allowed.";
213 + }
214 + }
215 + }
216 + }
217 + augment "/nd:networks/nd:network/nd:node" {
218 + description
219 + "Augment termination points which terminate links.
220 + Termination points can ultimately be mapped to interfaces.";
221 + list termination-point {
222 + key "tp-id";
223 + description
224 + "A termination point can terminate a link.
225 + Depending on the type of topology, a termination point
226 + could, for example, refer to a port or an interface.";
227 + leaf tp-id {
228 + type tp-id;
229 + description
230 + "Termination point identifier.";
231 + }
232 + list supporting-termination-point {
233 + key "network-ref node-ref tp-ref";
234 + description
235 + "The leaf list identifies any termination points that
236 + the termination point is dependent on, or maps onto.
237 + Those termination points will themselves be contained
238 + in a supporting node.
239 + This dependency information can be inferred from
240 + the dependencies between links. For this reason,
241 + this item is not separately configurable. Hence no
242 + corresponding constraint needs to be articulated.
243 + The corresponding information is simply provided by the
244 + implementing system.";
245 + leaf network-ref {
246 + type leafref {
247 + path "../../../nd:supporting-node/nd:network-ref";
248 + require-instance false;
249 + }
250 + description
251 + "This leaf identifies in which topology the
252 + supporting termination point is present.";
253 + }
254 + leaf node-ref {
255 + type leafref {
256 + path "../../../nd:supporting-node/nd:node-ref";
257 + require-instance false;
258 + }
259 + description
260 + "This leaf identifies in which node the supporting
261 + termination point is present.";
262 + }
263 + leaf tp-ref {
264 + type leafref {
265 + path "/nd:networks/nd:network[nd:network-id=current()/"+
266 + "../network-ref]/nd:node[nd:node-id=current()/../"+
267 + "node-ref]/termination-point/tp-id";
268 + require-instance false;
269 + }
270 + description
271 + "Reference to the underlay node, must be in a
272 + different topology";
273 + }
274 + }
275 + }
276 + }
277 +}
1 +module ietf-network {
2 + // yang-version 1.1;
3 + yang-version 1;
4 + namespace "urn:ietf:params:xml:ns:yang:ietf-network";
5 + prefix nd;
6 + import ietf-inet-types {
7 + prefix inet;
8 + }
9 + organization
10 + "IETF I2RS (Interface to the Routing System) Working Group";
11 + contact
12 + "WG Web: <http: tools.ietf.org/wg/i2rs/>
13 + WG List: <mailto:i2rs@ietf.org>
14 + WG Chair: Susan Hares
15 + <mailto:shares@ndzh.com>
16 + WG Chair: Jeffrey Haas
17 + <mailto:jhaas@pfrc.org>
18 + Editor: Alexander Clemm
19 + <mailto:alex@cisco.com>
20 + Editor: Jan Medved
21 + <mailto:jmedved@cisco.com>
22 + Editor: Robert Varga
23 + <mailto:rovarga@cisco.com>
24 + Editor: Tony Tkacik
25 + <mailto:ttkacik@cisco.com>
26 + Editor: Nitin Bahadur
27 + <mailto:nitin_bahadur@yahoo.com>
28 + Editor: Hariharan Ananthakrishnan
29 + <mailto:hari@packetdesign.com>";
30 + description
31 + "This module defines a common base model for a collection
32 + of nodes in a network. Node definitions are further used
33 + in network topologies and inventories.
34 + Copyright (c) 2015 IETF Trust and the persons identified as
35 + authors of the code. All rights reserved.
36 + Redistribution and use in source and binary forms, with or
37 + without modification, is permitted pursuant to, and subject
38 + to the license terms contained in, the Simplified BSD License
39 + set forth in Section 4.c of the IETF Trust's Legal Provisions
40 + Relating to IETF Documents
41 + (http: trustee.ietf.org/license-info).
42 + This version of this YANG module is part of
43 + draft-ietf-i2rs-yang-network-topo-02;
44 + see the RFC itself for full legal notices.
45 + NOTE TO RFC EDITOR: Please replace above reference to
46 + draft-ietf-i2rs-yang-network-topo-02 with RFC
47 + number when published (i.e. RFC xxxx).";
48 + revision 2015-12-08 {
49 + description
50 + "Initial revision.
51 + NOTE TO RFC EDITOR: Please replace the following reference
52 + to draft-ietf-i2rs-yang-network-topo-02 with
53 + RFC number when published (i.e. RFC xxxx).";
54 + reference
55 + "draft-ietf-i2rs-yang-network-topo-02";
56 + }
57 + typedef node-id {
58 + type inet:uri;
59 + description
60 + "Identifier for a node.";
61 + }
62 + typedef network-id {
63 + type inet:uri;
64 + description
65 + "Identifier for a network.";
66 + }
67 + grouping network-ref {
68 + description
69 + "Contains the information necessary to reference a network,
70 + for example an underlay network.";
71 + leaf network-ref {
72 + type leafref {
73 + path "/nd:networks/nd:network/nd:network-id";
74 + require-instance false;
75 + }
76 + description
77 + "Used to reference a network, for example an underlay
78 + network.";
79 + }
80 + }
81 + grouping node-ref {
82 + description
83 + "Contains the information necessary to reference a node.";
84 + leaf node-ref {
85 + type leafref {
86 + path "/nd:networks/nd:network[nd:network-id=current()/../"+
87 + "network-ref]/nd:node/nd:node-id";
88 + require-instance false;
89 + }
90 + description
91 + "Used to reference a node.
92 + Nodes are identified relative to the network they are
93 + contained in.";
94 + }
95 + uses network-ref;
96 + }
97 + container networks {
98 + description
99 + "Serves as top-level container for a list of networks.";
100 + list network {
101 + key "network-id";
102 + description
103 + "Describes a network.
104 + A network typically contains an inventory of nodes,
105 + topological information (augmented through
106 + network-topology model), as well as layering
107 + information.";
108 + container network-types {
109 + description
110 + "Serves as an augmentation target.
111 + The network type is indicated through corresponding
112 + presence containers augmented into this container.";
113 + }
114 + leaf network-id {
115 + type network-id;
116 + description
117 + "Identifies a network.";
118 + }
119 + list supporting-network {
120 + key "network-ref";
121 + description
122 + "An underlay network, used to represent layered network
123 + topologies.";
124 + leaf network-ref {
125 + type leafref {
126 + path "/networks/network/network-id";
127 + require-instance false;
128 + }
129 + description
130 + "References the underlay network.";
131 + }
132 + }
133 + list node {
134 + key "node-id";
135 + description
136 + "The inventory of nodes of this network.";
137 + leaf node-id {
138 + type node-id;
139 + description
140 + "Identifies a node uniquely within the containing
141 + network.";
142 + }
143 + list supporting-node {
144 + key "network-ref node-ref";
145 + description
146 + "Represents another node, in an underlay network, that
147 + this node is supported by. Used to represent layering
148 + structure.";
149 + leaf network-ref {
150 + type leafref {
151 + path "../../../supporting-network/network-ref";
152 + require-instance false;
153 + }
154 + description
155 + "References the underlay network that the
156 + underlay node is part of.";
157 + }
158 + leaf node-ref {
159 + type leafref {
160 + path "/networks/network/node/node-id";
161 + require-instance false;
162 + }
163 + description
164 + "References the underlay node itself.";
165 + }
166 + }
167 + }
168 + }
169 + }
170 + container networks-state {
171 + config false;
172 + description
173 + "Serves as top-level container for a list of state information
174 + for networks";
175 + list network {
176 + key "network-ref";
177 + description
178 + "Data nodes representing operational data and state of
179 + networks.
180 + An instance is automatically created for every network
181 + in the corresponding list under the networks container.";
182 + uses network-ref;
183 + leaf server-provided {
184 + type boolean;
185 + description
186 + "Indicates whether the information concerning this
187 + particular network is populated by the server
188 + (server-provided true, the general case for network
189 + information discovered from the server),
190 + or whether it is configured by a client
191 + (server-provided true, possible e.g. for
192 + service overlays managed through a controller).";
193 + }
194 + }
195 + }
196 +}
1 +module ietf-schedule {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-schedule";
4 + // replace with IANA namespace when assigned
5 +
6 + prefix "sch";
7 +
8 + import ietf-yang-types {
9 + prefix "yang";
10 + }
11 +
12 + organization "TBD";
13 + contact "TBD";
14 + description
15 + "The model allows time scheduling parameters to be specified.";
16 +
17 + revision "2015-10-08" {
18 + description "Initial revision";
19 + reference "TBD";
20 + }
21 +
22 + /*
23 + * Groupings
24 + */
25 +
26 + grouping schedules {
27 + description
28 + "A list of schedules defining when a particular
29 + configuration takes effect.";
30 + container schedules {
31 + list schedule {
32 + key "schedule-id";
33 + description "A list of schedule elements.";
34 +
35 + leaf schedule-id {
36 + type uint32;
37 + description "Identifies the schedule element.";
38 + }
39 + leaf start {
40 + type yang:date-and-time;
41 + description "Start time.";
42 + }
43 + leaf schedule-duration {
44 + type string {
45 + pattern
46 + 'P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?(\d+S)?';
47 + }
48 + description "Schedule duration in ISO 8601 format.";
49 + }
50 + leaf repeat-interval {
51 + type string {
52 + pattern
53 + 'R\d*/P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?'
54 + + '(\d+S)?';
55 + }
56 + description "Repeat interval in ISO 8601 format.";
57 + }
58 + }
59 + }
60 + } // schedules
61 +}
1 +module ietf-te-topology {
2 + //yang-version 1.1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
4 + // replace with IANA namespace when assigned
5 +
6 + prefix "tet";
7 +
8 + import ietf-inet-types {
9 + prefix "inet";
10 + }
11 +
12 + import ietf-schedule {
13 + prefix "sch";
14 + }
15 +
16 + import ietf-te-types {
17 + prefix "te-types";
18 + }
19 +
20 + import ietf-network {
21 + prefix "nw";
22 + }
23 +
24 + import ietf-network-topology {
25 + prefix "nt";
26 + }
27 +
28 + organization
29 + "Traffic Engineering Architecture and Signaling (TEAS)
30 + Working Group";
31 +
32 + contact
33 + "WG Web: <http://tools.ietf.org/wg/teas/>
34 + WG List: <mailto:teas@ietf.org>
35 +
36 + WG Chair: Lou Berger
37 + <mailto:lberger@labn.net>
38 +
39 + WG Chair: Vishnu Pavan Beeram
40 + <mailto:vbeeram@juniper.net>
41 +
42 + Editor: Xufeng Liu
43 + <mailto:xliu@kuatrotech.com>
44 +
45 + Editor: Igor Bryskin
46 + <mailto:Igor.Bryskin@huawei.com>
47 +
48 + Editor: Vishnu Pavan Beeram
49 + <mailto:vbeeram@juniper.net>
50 +
51 + Editor: Tarek Saad
52 + <mailto:tsaad@cisco.com>
53 +
54 + Editor: Himanshu Shah
55 + <mailto:hshah@ciena.com>
56 +
57 + Editor: Oscar Gonzalez De Dios
58 + <mailto:oscar.gonzalezdedios@telefonica.com>";
59 +
60 + description "TE topology model";
61 +
62 + revision "2016-07-08" {
63 + description "Initial revision";
64 + reference "TBD";
65 + }
66 +
67 + /*
68 + * Features
69 + */
70 +
71 + feature configuration-schedule {
72 + description
73 + "This feature indicates that the system supports
74 + configuration scheduling.";
75 + }
76 +
77 + feature te-topology-hierarchy {
78 + description
79 + "This feature indicates that the system allows underlay
80 + and/or overlay TE topology hierarchy.";
81 + }
82 +
83 + feature te-performance-metric {
84 + description
85 + "This feature indicates that the system supports
86 + TE performance metric.";
87 + reference
88 + "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.
89 + RFC7810: IS-IS Traffic Engineering (TE) Metric Extensions.
90 + RFC7823: Performance-Based Path Selection for Explicitly
91 + Routed Label Switched Paths (LSPs) Using TE Metric
92 + Extensions";
93 + }
94 +
95 + feature template {
96 + description
97 + "This feature indicates that the system supports
98 + template configuration.";
99 + }
100 +
101 + /*
102 + * Typedefs
103 + */
104 +
105 + /*
106 + * Identities
107 + */
108 +
109 + /*
110 + * Groupings
111 + */
112 + grouping connectivity-label-restriction-list {
113 + description
114 + "List of abel restrictions specifying what labels may or may
115 + not be used on a link connectivity.";
116 + list label-restriction {
117 + key "inclusive-exclusive label-start";
118 + description
119 + "List of abel restrictions specifying what labels may or may
120 + not be used on a link connectivity.";
121 + reference
122 + "RFC7579: General Network Element Constraint Encoding
123 + for GMPLS-Controlled Networks";
124 + leaf inclusive-exclusive {
125 + type enumeration {
126 + enum inclusive {
127 + description "The label or label range is inclusive.";
128 + }
129 + enum exclusive {
130 + description "The label or label range is exclusive.";
131 + }
132 + }
133 + description
134 + "Whether the list item is inclusive or exclusive.";
135 + }
136 + leaf label-start {
137 + type te-types:generalized-label;
138 + description
139 + "This is the starting lable if a lable range is specified.
140 + This is the lable value if a single lable is specified,
141 + in which case, attribute 'label-end' is not set.";
142 + }
143 + leaf label-end {
144 + type te-types:generalized-label;
145 + description
146 + "The ending lable if a lable range is specified;
147 + This attribute is not set, If a single lable is specified.";
148 + }
149 + leaf range-bitmap {
150 + type binary;
151 + description
152 + "When there are gaps between label-start and label-end,
153 + this attribute is used to specified the possitions
154 + of the used labels.";
155 + }
156 + }
157 + } // connectivity-label-restrictions
158 +
159 + grouping information-source-attributes {
160 + description
161 + "The attributes identifying source that has provided the
162 + related information, and the source credibility.";
163 + leaf information-source {
164 + type enumeration {
165 + enum "unknown" {
166 + description "The source is unknown.";
167 + }
168 + enum "locally-configured" {
169 + description "Configured entity.";
170 + }
171 + enum "ospfv2" {
172 + description "OSPFv2.";
173 + }
174 + enum "ospfv3" {
175 + description "OSPFv3.";
176 + }
177 + enum "isis" {
178 + description "ISIS.";
179 + }
180 + enum "system-processed" {
181 + description "System processed entity.";
182 + }
183 + enum "other" {
184 + description "Other source.";
185 + }
186 + }
187 + description
188 + "Indicates the source of the information.";
189 + }
190 + container information-source-state {
191 + description
192 + "The container contains state attributes related to
193 + the information source.";
194 + leaf credibility-preference {
195 + type uint16;
196 + description
197 + "The preference value to calculate the traffic
198 + engineering database credibility value used for
199 + tie-break selection between different
200 + information-source values.
201 + Higher value is more preferable.";
202 + }
203 + container topology {
204 + description
205 + "When the information is processed by the system,
206 + the attributes in this container indicate which topology
207 + is used to process to generate the result information.";
208 + uses te-topology-ref;
209 + } // topology
210 + leaf routing-instance {
211 + type string;
212 + description
213 + "When applicable, this is the name of a routing instance
214 + from which the information is learned.";
215 + } // routing-information
216 + }
217 + } // information-source-attributes
218 +
219 + grouping interface-switching-capability-list {
220 + description
221 + "List of Interface Switching Capabilities Descriptors (ISCD)";
222 +
223 + list interface-switching-capability {
224 + key "switching-capability";
225 + description
226 + "List of Interface Switching Capabilities Descriptors (ISCD)
227 + for this link.";
228 + reference
229 + "RFC3471: Generalized Multi-Protocol Label Switching (GMPLS)
230 + Signaling Functional Description.
231 + RFC4203: OSPF Extensions in Support of Generalized
232 + Multi-Protocol Label Switching (GMPLS).";
233 + leaf switching-capability {
234 + type identityref {
235 + base te-types:switching-capabilities;
236 + }
237 + description
238 + "Switching Capability for this interface.";
239 + }
240 + leaf encoding {
241 + type identityref {
242 + base te-types:lsp-encoding-types;
243 + }
244 + description
245 + "Encoding supported by this interface.";
246 + }
247 + list max-lsp-bandwidth {
248 + key "priority";
249 + max-elements "8";
250 + description
251 + "Maximum LSP Bandwidth at priorities 0-7.";
252 + leaf priority {
253 + type uint8 {
254 + range "0..7";
255 + }
256 + description "Priority.";
257 + }
258 + leaf bandwidth {
259 + type decimal64 {
260 + fraction-digits 2;
261 + }
262 + description
263 + "Max LSP Bandwidth for this level";
264 + }
265 + }
266 + container time-division-multiplex-capable {
267 + when "../switching-capability = 'TDM'" {
268 + description "Valid only for TDM";
269 + }
270 + description
271 + "Interface has time-division multiplex capabilities.";
272 +
273 + leaf minimum-lsp-bandwidth {
274 + type decimal64 {
275 + fraction-digits 2;
276 + }
277 + description
278 + "Minimum LSP Bandwidth. Units in bytes per second.";
279 + }
280 + leaf indication {
281 + type enumeration {
282 + enum "standard" {
283 + description
284 + "Indicates support of standard SONET/SDH.";
285 + }
286 + enum "arbitrary" {
287 + description
288 + "Indicates support of arbitrary SONET/SDH.";
289 + }
290 + }
291 + description
292 + "Indication whether the interface supports Standard or
293 + Arbitrary SONET/SDH";
294 + }
295 + } // time-division-multiplex-capable
296 + } // interface-switching-capability
297 + } // interface-switching-capability-list
298 +
299 + grouping performance-metric-attributes {
300 + description
301 + "Link performance information in real time.";
302 + reference
303 + "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.
304 + RFC7810: IS-IS Traffic Engineering (TE) Metric Extensions.
305 + RFC7823: Performance-Based Path Selection for Explicitly
306 + Routed Label Switched Paths (LSPs) Using TE Metric
307 + Extensions";
308 + leaf unidirectional-delay {
309 + type uint32 {
310 + range 0..16777215;
311 + }
312 + description "Delay or latency in micro seconds.";
313 + }
314 + leaf unidirectional-min-delay {
315 + type uint32 {
316 + range 0..16777215;
317 + }
318 + description "Minimum delay or latency in micro seconds.";
319 + }
320 + leaf unidirectional-max-delay {
321 + type uint32 {
322 + range 0..16777215;
323 + }
324 + description "Maximum delay or latency in micro seconds.";
325 + }
326 + leaf unidirectional-delay-variation {
327 + type uint32 {
328 + range 0..16777215;
329 + }
330 + description "Delay variation in micro seconds.";
331 + }
332 + leaf unidirectional-packet-loss {
333 + type decimal64 {
334 + fraction-digits 6;
335 + range "0 .. 50.331642";
336 + }
337 + description
338 + "Packet loss as a percentage of the total traffic sent
339 + over a configurable interval. The finest precision is
340 + 0.000003%.";
341 + }
342 + leaf unidirectional-residual-bandwidth {
343 + type decimal64 {
344 + fraction-digits 2;
345 + }
346 + description
347 + "Residual bandwidth that subtracts tunnel
348 + reservations from Maximum Bandwidth (or link capacity)
349 + [RFC3630] and provides an aggregated remainder across QoS
350 + classes.";
351 + }
352 + leaf unidirectional-available-bandwidth {
353 + type decimal64 {
354 + fraction-digits 2;
355 + }
356 + description
357 + "Available bandwidth that is defined to be residual
358 + bandwidth minus the measured bandwidth used for the
359 + actual forwarding of non-RSVP-TE LSP packets. For a
360 + bundled link, available bandwidth is defined to be the
361 + sum of the component link available bandwidths.";
362 + }
363 + leaf unidirectional-utilized-bandwidth {
364 + type decimal64 {
365 + fraction-digits 2;
366 + }
367 + description
368 + "Bandwidth utilization that represents the actual
369 + utilization of the link (i.e. as measured in the router).
370 + For a bundled link, bandwidth utilization is defined to
371 + be the sum of the component link bandwidth
372 + utilizations.";
373 + }
374 + } // performance-metric-attributes
375 +
376 + grouping performance-metric-normality-attributes {
377 + description
378 + "Link performance metric normality attributes.";
379 + reference
380 + "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.
381 + RFC7810: IS-IS Traffic Engineering (TE) Metric Extensions.
382 + RFC7823: Performance-Based Path Selection for Explicitly
383 + Routed Label Switched Paths (LSPs) Using TE Metric
384 + Extensions";
385 + leaf unidirectional-delay {
386 + type te-types:performance-metric-normality;
387 + description "Delay normality.";
388 + }
389 + leaf unidirectional-min-delay {
390 + type te-types:performance-metric-normality;
391 + description "Minimum delay or latency normality.";
392 + }
393 + leaf unidirectional-max-delay {
394 + type te-types:performance-metric-normality;
395 + description "Maximum delay or latency normality.";
396 + }
397 + leaf unidirectional-delay-variation {
398 + type te-types:performance-metric-normality;
399 + description "Delay variation normality.";
400 + }
401 + leaf unidirectional-packet-loss {
402 + type te-types:performance-metric-normality;
403 + description "Packet loss normality.";
404 + }
405 + leaf unidirectional-residual-bandwidth {
406 + type te-types:performance-metric-normality;
407 + description "Residual bandwidth normality.";
408 + }
409 + leaf unidirectional-available-bandwidth {
410 + type te-types:performance-metric-normality;
411 + description "Available bandwidth normality.";
412 + }
413 + leaf unidirectional-utilized-bandwidth {
414 + type te-types:performance-metric-normality;
415 + description "Bandwidth utilization normality.";
416 + }
417 + } // performance-metric-normality-attributes
418 +
419 + grouping performance-metric-throttle-container {
420 + description
421 + "A container controlling performance metric throttle.";
422 + container performance-metric-throttle {
423 + if-feature te-performance-metric;
424 + must "suppression-interval >= measure-interval" {
425 + error-message
426 + "suppression-interval cannot be less then
427 + measure-interval.";
428 + description
429 + "Constraint on suppression-interval and
430 + measure-interval.";
431 + }
432 + description
433 + "Link performance information in real time.";
434 + reference
435 + "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.
436 + RFC7810: IS-IS Traffic Engineering (TE) Metric Extensions.
437 + RFC7823: Performance-Based Path Selection for Explicitly
438 + Routed Label Switched Paths (LSPs) Using TE Metric
439 + Extensions";
440 + leaf unidirectional-delay-offset {
441 + type uint32 {
442 + range 0..16777215;
443 + }
444 + description
445 + "Offset value to be added to the measured delay value.";
446 + }
447 + leaf measure-interval {
448 + type uint32;
449 + default 30;
450 + description
451 + "Interval in seconds to measure the extended metric
452 + values.";
453 + }
454 + leaf advertisement-interval {
455 + type uint32;
456 + description
457 + "Interval in seconds to advertise the extended metric
458 + values.";
459 + }
460 + leaf suppression-interval {
461 + type uint32 {
462 + range "1 .. max";
463 + }
464 + default 120;
465 + description
466 + "Interval in seconds to suppress advertising the extended
467 + metric values.";
468 + }
469 + container threshold-out {
470 + uses performance-metric-attributes;
471 + description
472 + "If the measured parameter falls outside an upper bound
473 + for all but the min delay metric (or lower bound for
474 + min-delay metric only) and the advertised value is not
475 + already outside that bound, anomalous announcement will be
476 + triggered.";
477 + }
478 + container threshold-in {
479 + uses performance-metric-attributes;
480 + description
481 + "If the measured parameter falls inside an upper bound
482 + for all but the min delay metric (or lower bound for
483 + min-delay metric only) and the advertised value is not
484 + already inside that bound, normal (anomalous-flag cleared)
485 + announcement will be triggered.";
486 + }
487 + container threshold-accelerated-advertisement {
488 + description
489 + "When the difference between the last advertised value and
490 + current measured value exceed this threshold, anomalous
491 + announcement will be triggered.";
492 + uses performance-metric-attributes;
493 + }
494 + }
495 + } // performance-metric-throttle-container
496 +
497 + grouping te-link-augment {
498 + description
499 + "Augmentation for TE link.";
500 +
501 + container te {
502 + presence "TE support.";
503 + description
504 + "Indicates TE support.";
505 +
506 + container config {
507 + description
508 + "Configuration data.";
509 + uses te-link-config;
510 + } // config
511 + container state {
512 + config false;
513 + description
514 + "Operational state data.";
515 + uses te-link-config;
516 + uses te-link-state-derived;
517 + } // state
518 + } // te
519 + } // te-link-augment
520 +
521 + grouping te-link-config {
522 + description
523 + "TE link configuration grouping.";
524 + choice bundle-stack-level {
525 + description
526 + "The TE link can be partitioned into bundled
527 + links, or component links.";
528 + case bundle {
529 + container bundled-links {
530 + description
531 + "A set of bundled links.";
532 + reference
533 + "RFC4201: Link Bundling in MPLS Traffic Engineering
534 + (TE).";
535 + list bundled-link {
536 + key "sequence";
537 + description
538 + "Specify a bundled interface that is
539 + further partitioned.";
540 + leaf sequence {
541 + type uint32;
542 + description
543 + "Identify the sequence in the bundle.";
544 + }
545 + leaf src-tp-ref {
546 + type leafref {
547 + path "../../../../../../nw:node[nw:node-id = "
548 + + "current()/../../../../../nt:source/"
549 + + "nt:source-node]/"
550 + + "nt:termination-point/nt:tp-id";
551 + require-instance true;
552 + }
553 + description
554 + "Reference to another TE termination point on the
555 + same souruce node.";
556 + }
557 + leaf des-tp-ref {
558 + type leafref {
559 + path "../../../../../../nw:node[nw:node-id = "
560 + + "current()/../../../../../nt:destination/"
561 + + "nt:dest-node]/"
562 + + "nt:termination-point/nt:tp-id";
563 + require-instance true;
564 + }
565 + description
566 + "Reference to another TE termination point on the
567 + same destination node.";
568 + }
569 + } // list bundled-link
570 + }
571 + }
572 + case component {
573 + container component-links {
574 + description
575 + "A set of component links";
576 + list component-link {
577 + key "sequence";
578 + description
579 + "Specify a component interface that is
580 + sufficient to unambiguously identify the
581 + appropriate resources";
582 +
583 + leaf sequence {
584 + type uint32;
585 + description
586 + "Identify the sequence in the bundle.";
587 + }
588 + leaf src-interface-ref {
589 + type string;
590 + description
591 + "Reference to component link interface on the
592 + source node.";
593 + }
594 + leaf des-interface-ref {
595 + type string;
596 + description
597 + "Reference to component link interface on the
598 + destinatioin node.";
599 + }
600 + }
601 + }
602 + }
603 + } // bundle-stack-level
604 +
605 + leaf-list te-link-template {
606 + if-feature template;
607 + type leafref {
608 + path "../../../../../te/templates/link-template/name";
609 + }
610 + description
611 + "The reference to a TE link template.";
612 + }
613 + uses te-link-config-attributes;
614 + } // te-link-config
615 +
616 + grouping te-link-config-attributes {
617 + description
618 + "Link configuration attributes in a TE topology.";
619 + container te-link-attributes {
620 + description "Link attributes in a TE topology.";
621 + uses sch:schedules;
622 + leaf access-type {
623 + type te-types:te-link-access-type;
624 + description
625 + "Link access type, which can be point-to-point or
626 + multi-access.";
627 + }
628 + container external-domain {
629 + description
630 + "For an inter-domain link, specify the attributes of
631 + the remote end of link, to facilitate the signalling at
632 + local end.";
633 + leaf remote-te-node-id {
634 + type te-types:te-node-id;
635 + description
636 + "Remote TE node identifier, used together with
637 + remote-te-link-id to identify the remote link
638 + termination point in a different domain.";
639 + }
640 + leaf remote-te-link-tp-id {
641 + type te-types:te-tp-id;
642 + description
643 + "Remote TE link termination point identifier, used
644 + together with remote-te-node-id to identify the remote
645 + link termination point in a different domain.";
646 + }
647 + leaf plug-id {
648 + type uint32;
649 + description
650 + "A topology-wide unique number that identifies on the
651 + network a connectivity supporting a given inter-domain
652 + TE link. This is more flexible alternative to specifying
653 + remote-te-node-id and remote-te-link-tp-id, when the
654 + provider does not know remote-te-node-id and
655 + remote-te-link-tp-id or need to give client the
656 + flexibility to mix-n-match multiple topologies.";
657 + }
658 + }
659 + leaf is-abstract {
660 + type empty;
661 + description "Present if the link is abstract.";
662 + }
663 + leaf name {
664 + type string;
665 + description "Link Name.";
666 + }
667 + container underlay {
668 + if-feature te-topology-hierarchy;
669 + presence
670 + "Indicates the underlay exists for this link.";
671 + description "Attributes of the te-link underlay.";
672 + reference
673 + "RFC4206: Label Switched Paths (LSP) Hierarchy with
674 + Generalized Multi-Protocol Label Switching (GMPLS)
675 + Traffic Engineering (TE)";
676 +
677 + uses te-link-underlay-attributes;
678 + } // underlay
679 + leaf admin-status {
680 + type te-types:te-admin-status;
681 + description
682 + "The administrative state of the link.";
683 + }
684 +
685 + uses performance-metric-throttle-container;
686 + uses te-link-info-attributes;
687 + } // te-link-attributes
688 + } // te-link-config-attributes
689 +
690 + grouping te-link-connectivity-attributes {
691 + description
692 + "Advertised TE connectivity attributes.";
693 + leaf max-link-bandwidth {
694 + type decimal64 {
695 + fraction-digits 2;
696 + }
697 + description
698 + "Maximum bandwidth that can be seen on this link in this
699 + direction. Units in bytes per second.";
700 + reference
701 + "RFC3630: Traffic Engineering (TE) Extensions to OSPF
702 + Version 2.
703 + RFC5305: IS-IS Extensions for Traffic Engineering.";
704 + }
705 + leaf max-resv-link-bandwidth {
706 + type decimal64 {
707 + fraction-digits 2;
708 + }
709 + description
710 + "Maximum amount of bandwidth that can be reserved in this
711 + direction in this link. Units in bytes per second.";
712 + reference
713 + "RFC3630: Traffic Engineering (TE) Extensions to OSPF
714 + Version 2.
715 + RFC5305: IS-IS Extensions for Traffic Engineering.";
716 + }
717 + list unreserved-bandwidth {
718 + key "priority";
719 + max-elements "8";
720 + description
721 + "Unreserved bandwidth for 0-7 priority levels. Units in
722 + bytes per second.";
723 + reference
724 + "RFC3630: Traffic Engineering (TE) Extensions to OSPF
725 + Version 2.
726 + RFC5305: IS-IS Extensions for Traffic Engineering.";
727 + leaf priority {
728 + type uint8 {
729 + range "0..7";
730 + }
731 + description "Priority.";
732 + }
733 + leaf bandwidth {
734 + type decimal64 {
735 + fraction-digits 2;
736 + }
737 + description
738 + "Unreserved bandwidth for this level.";
739 + }
740 + }
741 + leaf te-default-metric {
742 + type uint32;
743 + description
744 + "Traffic Engineering Metric.";
745 + }
746 + container performance-metric {
747 + if-feature te-performance-metric;
748 + description
749 + "Link performance information in real time.";
750 + reference
751 + "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.
752 + RFC7810: IS-IS Traffic Engineering (TE) Metric Extensions.
753 + RFC7823: Performance-Based Path Selection for Explicitly
754 + Routed Label Switched Paths (LSPs) Using TE Metric
755 + Extensions";
756 + container measurement {
757 + description
758 + "Measured performance metric values. Static configuration
759 + and manual overrides of these measurements are also
760 + allowed.";
761 + uses performance-metric-attributes;
762 + }
763 + container normality
764 + {
765 + description
766 + "Performance metric normality values.";
767 + uses performance-metric-normality-attributes;
768 + }
769 + }
770 + container te-srlgs {
771 + description
772 + "A list of SLRGs.";
773 + leaf-list value {
774 + type te-types:srlg;
775 + description "SRLG value.";
776 + reference
777 + "RFC4202: Routing Extensions in Support of
778 + Generalized Multi-Protocol Label Switching (GMPLS).";
779 + }
780 + }
781 + } // te-link-connectivity-attributes
782 +
783 + grouping te-link-info-attributes {
784 + description
785 + "Advertised TE information attributes.";
786 + leaf link-index {
787 + type uint64;
788 + description
789 + "The link identifier. If OSPF is used, this represents an
790 + ospfLsdbID. If IS-IS is used, this represents an isisLSPID.
791 + If a locally configured link is used, this object represents
792 + a unique value, which is locally defined in a router.";
793 + }
794 + leaf administrative-group {
795 + type te-types:admin-groups;
796 + description
797 + "Administrative group or color of the link.
798 + This attribute covers both administrative group (defined in
799 + RFC3630, RFC5329, and RFC5305), and extended administrative
800 + group (defined in RFC7308).";
801 + }
802 + uses interface-switching-capability-list;
803 + leaf link-protection-type {
804 + type enumeration {
805 + enum "unprotected" {
806 + description "Unprotected.";
807 + }
808 + enum "extra-traffic" {
809 + description "Extra traffic.";
810 + }
811 + enum "shared" {
812 + description "Shared.";
813 + }
814 + enum "1-for-1" {
815 + description "One for one protection.";
816 + }
817 + enum "1-plus-1" {
818 + description "One plus one protection.";
819 + }
820 + enum "enhanced" {
821 + description "Enhanced protection.";
822 + }
823 + }
824 + description
825 + "Link Protection Type desired for this link.";
826 + reference
827 + "RFC4202: Routing Extensions in Support of
828 + Generalized Multi-Protocol Label Switching (GMPLS).";
829 + }
830 + uses te-link-connectivity-attributes;
831 + } // te-link-info-attributes
832 +
833 + grouping te-link-state-derived {
834 + description
835 + "Link state attributes in a TE topology.";
836 + leaf oper-status {
837 + type te-types:te-oper-status;
838 + description
839 + "The current operational state of the link.";
840 + }
841 + leaf is-transitional {
842 + type empty;
843 + description
844 + "Present if the link is transitional, used as an
845 + alternative approach in lieu of inter-layer-lock-id
846 + for path computation in a TE topology covering multiple
847 + layers or multiple regions.";
848 + reference
849 + "RFC5212: Requirements for GMPLS-Based Multi-Region and
850 + Multi-Layer Networks (MRN/MLN).
851 + RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
852 + for Multi-Layer and Multi-Region Networks (MLN/MRN).";
853 + }
854 + uses information-source-attributes;
855 + list information-source-entry {
856 + key "information-source";
857 + description
858 + "A list of information sources learned, including the one
859 + used.";
860 + uses information-source-attributes;
861 + uses te-link-info-attributes;
862 + }
863 + container recovery {
864 + description
865 + "Status of the recovery process.";
866 + leaf restoration-status {
867 + type te-types:te-recovery-status;
868 + description
869 + "Restoration status.";
870 + }
871 + leaf protection-status {
872 + type te-types:te-recovery-status;
873 + description
874 + "Protection status.";
875 + }
876 + }
877 + container underlay {
878 + if-feature te-topology-hierarchy;
879 + description "State attributes for te-link underlay.";
880 + uses te-link-state-underlay-attributes;
881 + }
882 + } // te-link-state-derived
883 +
884 + grouping te-link-state-underlay-attributes {
885 + description "State attributes for te-link underlay.";
886 + leaf dynamic {
887 + type boolean;
888 + description
889 + "true if the underlay is dynamically created.";
890 + }
891 + leaf committed {
892 + type boolean;
893 + description
894 + "true if the underlay is committed.";
895 + }
896 + } // te-link-state-underlay-attributes
897 +
898 + grouping te-link-underlay-attributes {
899 + description "Attributes for te-link underlay.";
900 + reference
901 + "RFC4206: Label Switched Paths (LSP) Hierarchy with
902 + Generalized Multi-Protocol Label Switching (GMPLS)
903 + Traffic Engineering (TE)";
904 + container underlay-primary-path {
905 + description
906 + "The service path on the underlay topology that
907 + supports this link.";
908 + uses te-topology-ref;
909 + list path-element {
910 + key "path-element-id";
911 + description
912 + "A list of path elements describing the service path.";
913 + leaf path-element-id {
914 + type uint32;
915 + description "To identify the element in a path.";
916 + }
917 + uses te-path-element;
918 + }
919 + } // underlay-primary-path
920 + list underlay-backup-path {
921 + key "index";
922 + description
923 + "A list of backup service paths on the underlay topology that
924 + protect the underlay primary path. If the primary path is
925 + not protected, the list contains zero elements. If the
926 + primary path is protected, the list contains one or more
927 + elements.";
928 + leaf index {
929 + type uint32;
930 + description
931 + "A sequence number to identify a backup path.";
932 + }
933 + uses te-topology-ref;
934 + list path-element {
935 + key "path-element-id";
936 + description
937 + "A list of path elements describing the backup service
938 + path";
939 + leaf path-element-id {
940 + type uint32;
941 + description "To identify the element in a path.";
942 + }
943 + uses te-path-element;
944 + }
945 + } // underlay-backup-path
946 + leaf underlay-protection-type {
947 + type uint16;
948 + description
949 + "Underlay protection type desired for this link";
950 + }
951 + container underlay-trail-src {
952 + uses nt:tp-ref;
953 + description
954 + "Source TE link of the underlay trail.";
955 + }
956 + container underlay-trail-des {
957 + uses nt:tp-ref;
958 + description
959 + "Destination TE link of the underlay trail.";
960 + }
961 + } // te-link-underlay-attributes
962 +
963 + grouping te-node-augment {
964 + description
965 + "Augmentation for TE node.";
966 +
967 + container te {
968 + presence "TE support.";
969 + description
970 + "Indicates TE support.";
971 +
972 + leaf te-node-id {
973 + type te-types:te-node-id;
974 + mandatory true;
975 + description
976 + "The identifier of a node in the TE topology.
977 + A node is specific to a topology to which it belongs.";
978 + }
979 +
980 + container config {
981 + description
982 + "Configuration data.";
983 + uses te-node-config;
984 + } // config
985 + container state {
986 + config false;
987 + description
988 + "Operational state data.";
989 +
990 + uses te-node-config;
991 + uses te-node-state-derived;
992 + } // state
993 +
994 + list tunnel-termination-point {
995 + key "tunnel-tp-id";
996 + description
997 + "A termination point can terminate a tunnel.";
998 + leaf tunnel-tp-id {
999 + type binary;
1000 + description
1001 + "Tunnel termination point identifier.";
1002 + }
1003 +
1004 + container config {
1005 + description
1006 + "Configuration data.";
1007 + uses te-node-tunnel-termination-capability;
1008 + }
1009 +
1010 + container state {
1011 + config false;
1012 + description
1013 + "Operational state data.";
1014 +
1015 + uses te-node-tunnel-termination-capability;
1016 + } // state
1017 +
1018 + } // tunnel-termination-point
1019 + } // te
1020 + } // te-node-augment
1021 +
1022 + grouping te-node-config {
1023 + description "TE node configuration grouping.";
1024 +
1025 + leaf-list te-node-template {
1026 + if-feature template;
1027 + type leafref {
1028 + path "../../../../../te/templates/node-template/name";
1029 + }
1030 + description
1031 + "The reference to a TE node template.";
1032 + }
1033 + uses te-node-config-attributes;
1034 + } // te-node-config
1035 +
1036 + grouping te-node-config-attributes {
1037 + description "Configuration node attributes in a TE topology.";
1038 + container te-node-attributes {
1039 + description "Containing node attributes in a TE topology.";
1040 + uses sch:schedules;
1041 + leaf admin-status {
1042 + type te-types:te-admin-status;
1043 + description
1044 + "The administrative state of the link.";
1045 + }
1046 + uses te-node-connectivity-matrix;
1047 + uses te-node-info-attributes;
1048 + } // te-node-attributes
1049 + } // te-node-config-attributes
1050 +
1051 + grouping te-node-config-attributes-notification {
1052 + description
1053 + "Configuration node attributes for template in a TE topology.";
1054 + container te-node-attributes {
1055 + description "Containing node attributes in a TE topology.";
1056 + uses sch:schedules;
1057 + leaf admin-status {
1058 + type te-types:te-admin-status;
1059 + description
1060 + "The administrative state of the link.";
1061 + }
1062 + uses te-node-connectivity-matrix-abs;
1063 + uses te-node-info-attributes;
1064 + } // te-node-attributes
1065 + } // te-node-config-attributes-notification
1066 +
1067 + grouping te-node-config-attributes-template {
1068 + description
1069 + "Configuration node attributes for template in a TE topology.";
1070 + container te-node-attributes {
1071 + description "Containing node attributes in a TE topology.";
1072 + uses sch:schedules;
1073 + leaf admin-status {
1074 + type te-types:te-admin-status;
1075 + description
1076 + "The administrative state of the link.";
1077 + }
1078 + uses te-node-info-attributes;
1079 + } // te-node-attributes
1080 + } // te-node-config-attributes-template
1081 +
1082 + grouping te-node-connectivity-matrix {
1083 + description "Connectivity matrix on a TE node.";
1084 + list connectivity-matrix {
1085 + key "id";
1086 + description
1087 + "Represents node's switching limitations, i.e. limitations
1088 + in interconnecting network TE links across the node.";
1089 + reference
1090 + "RFC7579: General Network Element Constraint Encoding
1091 + for GMPLS-Controlled Networks.";
1092 + leaf id {
1093 + type uint32;
1094 + description "Identifies the connectivity-matrix entry.";
1095 + }
1096 + container from {
1097 + leaf tp-ref {
1098 + type leafref {
1099 + path "../../../../../../nt:termination-point/nt:tp-id";
1100 + }
1101 + description
1102 + "Relative reference to source termination point.";
1103 + }
1104 + description
1105 + "Reference to source NTP.";
1106 + }
1107 + container to {
1108 + leaf tp-ref {
1109 + type leafref {
1110 + path "../../../../../../nt:termination-point/nt:tp-id";
1111 + }
1112 + description
1113 + "Relative reference to destination termination point.";
1114 + }
1115 + description
1116 + "Reference to destination NTP.";
1117 + }
1118 + leaf is-allowed {
1119 + type boolean;
1120 + description
1121 + "true - switching is allowed,
1122 + false - switching is disallowed.";
1123 + }
1124 + uses connectivity-label-restriction-list;
1125 + uses te-link-connectivity-attributes;
1126 + }
1127 + } // te-node-connectivity-matrix
1128 +
1129 + grouping te-node-connectivity-matrix-abs {
1130 + description
1131 + "Connectivity matrix on a TE node, using absolute
1132 + paths to reference termination points.";
1133 + list connectivity-matrix {
1134 + key "id";
1135 + description
1136 + "Represents node's switching limitations, i.e. limitations
1137 + in interconnecting network TE links across the node.";
1138 + reference
1139 + "RFC7579: General Network Element Constraint Encoding
1140 + for GMPLS-Controlled Networks.";
1141 + leaf id {
1142 + type uint32;
1143 + description "Identifies the connectivity-matrix entry.";
1144 + }
1145 + container from {
1146 + uses nt:tp-ref;
1147 + description
1148 + "Reference to source NTP.";
1149 + }
1150 + container to {
1151 + uses nt:tp-ref;
1152 + description
1153 + "Reference to destination NTP.";
1154 + }
1155 + leaf is-allowed {
1156 + type boolean;
1157 + description
1158 + "true - switching is allowed,
1159 + false - switching is disallowed.";
1160 + }
1161 + }
1162 + } // te-node-connectivity-matrix-abs
1163 +
1164 + grouping te-node-info-attributes {
1165 + description
1166 + "Advertised TE information attributes.";
1167 + leaf domain-id {
1168 + type uint32;
1169 + description
1170 + "Identifies the domain that this node belongs.
1171 + This attribute is used to support inter-domain links.";
1172 + reference
1173 + "RFC5152: A Per-Domain Path Computation Method for
1174 + Establishing Inter-Domain Traffic Engineering (TE)
1175 + Label Switched Paths (LSPs).
1176 + RFC5392: OSPF Extensions in Support of Inter-Autonomous
1177 + System (AS) MPLS and GMPLS Traffic Engineering.
1178 + RFC5316: ISIS Extensions in Support of Inter-Autonomous
1179 + System (AS) MPLS and GMPLS Traffic Engineering.";
1180 + }
1181 + leaf is-abstract {
1182 + type empty;
1183 + description
1184 + "Present if the node is abstract, not present if the node
1185 + is actual.";
1186 + }
1187 + leaf name {
1188 + type inet:domain-name;
1189 + description "Node name.";
1190 + }
1191 + leaf-list signaling-address {
1192 + type inet:ip-address;
1193 + description "Node signaling address.";
1194 + }
1195 + container underlay-topology {
1196 + if-feature te-topology-hierarchy;
1197 + description
1198 + "When an abstract node encapsulates a topology,
1199 + the attributes in this container point to said topology.";
1200 + uses te-topology-ref;
1201 + }
1202 + } // te-node-info-attributes
1203 +
1204 + grouping te-node-state-derived {
1205 + description "Node state attributes in a TE topology.";
1206 + leaf oper-status {
1207 + type te-types:te-oper-status;
1208 + description
1209 + "The current operational state of the node.";
1210 + }
1211 + leaf is-multi-access-dr {
1212 + type empty;
1213 + description
1214 + "The presence of this attribute indicates that this TE node
1215 + is a pseudonode elected as a designated router.";
1216 + reference
1217 + "RFC3630: Traffic Engineering (TE) Extensions to OSPF
1218 + Version 2.
1219 + RFC1195: Use of OSI IS-IS for Routing in TCP/IP and Dual
1220 + Environments.";
1221 + }
1222 + uses information-source-attributes;
1223 + list information-source-entry {
1224 + key "information-source";
1225 + description
1226 + "A list of information sources learned, including the one
1227 + used.";
1228 + uses information-source-attributes;
1229 + uses te-node-connectivity-matrix;
1230 + uses te-node-info-attributes;
1231 + }
1232 + } // te-node-state-derived
1233 +
1234 + grouping te-node-state-derived-notification {
1235 + description "Node state attributes in a TE topology.";
1236 + leaf oper-status {
1237 + type te-types:te-oper-status;
1238 + description
1239 + "The current operational state of the node.";
1240 + }
1241 + leaf is-multi-access-dr {
1242 + type empty;
1243 + description
1244 + "The presence of this attribute indicates that this TE node
1245 + is a pseudonode elected as a designated router.";
1246 + reference
1247 + "RFC3630: Traffic Engineering (TE) Extensions to OSPF
1248 + Version 2.
1249 + RFC1195: Use of OSI IS-IS for Routing in TCP/IP and Dual
1250 + Environments.";
1251 + }
1252 + uses information-source-attributes;
1253 + list information-source-entry {
1254 + key "information-source";
1255 + description
1256 + "A list of information sources learned, including the one
1257 + used.";
1258 + uses information-source-attributes;
1259 + uses te-node-connectivity-matrix-abs;
1260 + uses te-node-info-attributes;
1261 + }
1262 + } // te-node-state-derived-notification
1263 +
1264 + grouping te-node-tunnel-termination-capability {
1265 + description
1266 + "Termination capability of a tunnel termination point on a
1267 + TE node.";
1268 +
1269 + leaf switching-capability {
1270 + type identityref {
1271 + base te-types:switching-capabilities;
1272 + }
1273 + description
1274 + "Switching Capability for this interface.";
1275 + }
1276 + leaf encoding {
1277 + type identityref {
1278 + base te-types:lsp-encoding-types;
1279 + }
1280 + description
1281 + "Encoding supported by this interface.";
1282 + }
1283 + leaf inter-layer-lock-id {
1284 + type uint32;
1285 + description
1286 + "Inter layer lock ID, used for path computation in a TE
1287 + topology covering multiple layers or multiple regions.";
1288 + reference
1289 + "RFC5212: Requirements for GMPLS-Based Multi-Region and
1290 + Multi-Layer Networks (MRN/MLN).
1291 + RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
1292 + for Multi-Layer and Multi-Region Networks (MLN/MRN).";
1293 + }
1294 + leaf protection-type {
1295 + type identityref {
1296 + base te-types:lsp-prot-type;
1297 + }
1298 + description
1299 + "The protection type that this tunnel termination point
1300 + is capable of.";
1301 + }
1302 +
1303 + list termination-capability {
1304 + key "link-tp";
1305 + description
1306 + "The termination capabilities between
1307 + tunnel-termination-point and link termination-point.
1308 + The capability information can be used to compute
1309 + the tunnel path.
1310 + The Interface Adjustment Capability Descriptors (IACD)
1311 + [RFC6001] on each link-tp can be derived from this
1312 + termination-capability list.";
1313 + reference
1314 + "RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
1315 + for Multi-Layer and Multi-Region Networks (MLN/MRN).";
1316 + leaf link-tp {
1317 + type leafref {
1318 + path "../../../../../nt:termination-point/nt:tp-id";
1319 + }
1320 + description
1321 + "Link termination point.";
1322 + }
1323 +
1324 + uses connectivity-label-restriction-list;
1325 +
1326 + list max-lsp-bandwidth {
1327 + key "priority";
1328 + max-elements "8";
1329 + description
1330 + "Maximum LSP Bandwidth at priorities 0-7.";
1331 + reference
1332 + "RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
1333 + for Multi-Layer and Multi-Region Networks (MLN/MRN).";
1334 + leaf priority {
1335 + type uint8 {
1336 + range "0..7";
1337 + }
1338 + description "Priority.";
1339 + }
1340 + leaf bandwidth {
1341 + type decimal64 {
1342 + fraction-digits 2;
1343 + }
1344 + description
1345 + "Max LSP Bandwidth for this level.";
1346 + }
1347 + } // max-lsp-bandwidth
1348 + } // termination-capability
1349 + } // te-node-tunnel-termination-capability
1350 +
1351 + grouping te-path-element {
1352 + description
1353 + "A group of attributes defining an element in a TE path
1354 + such as TE node, TE link, TE atomic resource or label.";
1355 + uses te-types:explicit-route-subobject;
1356 + } // te-path-element
1357 +
1358 + grouping te-termination-point-augment {
1359 + description
1360 + "Augmentation for TE termination point.";
1361 +
1362 + container te {
1363 + presence "TE support.";
1364 + description
1365 + "Indicates TE support.";
1366 +
1367 + leaf te-tp-id {
1368 + type te-types:te-tp-id;
1369 + mandatory true;
1370 + description
1371 + "An identifier to uniquely identify a TE termination
1372 + point.";
1373 + }
1374 +
1375 + container config {
1376 + description
1377 + "Configuration data.";
1378 + uses te-termination-point-config;
1379 + } // config
1380 + container state {
1381 + config false;
1382 + description
1383 + "Operational state data.";
1384 + uses te-termination-point-config;
1385 + } // state
1386 + } // te
1387 + } // te-termination-point-augment
1388 +
1389 + grouping te-termination-point-config {
1390 + description
1391 + "TE termination point configuration grouping.";
1392 + uses sch:schedules;
1393 + uses interface-switching-capability-list;
1394 + leaf inter-layer-lock-id {
1395 + type uint32;
1396 + description
1397 + "Inter layer lock ID, used for path computation in a TE
1398 + topology covering multiple layers or multiple regions.";
1399 + reference
1400 + "RFC5212: Requirements for GMPLS-Based Multi-Region and
1401 + Multi-Layer Networks (MRN/MLN).
1402 + RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
1403 + for Multi-Layer and Multi-Region Networks (MLN/MRN).";
1404 + }
1405 + } // te-termination-point-config
1406 +
1407 + grouping te-topologies-augment {
1408 + description
1409 + "Augmentation for TE topologies.";
1410 +
1411 + container te {
1412 + presence "TE support.";
1413 + description
1414 + "Indicates TE support.";
1415 +
1416 + container templates {
1417 + description
1418 + "Configuration parameters for templates used for TE
1419 + topology.";
1420 +
1421 + list node-template {
1422 + if-feature template;
1423 + key "name";
1424 + leaf name {
1425 + type te-types:te-template-name;
1426 + description
1427 + "The name to identify a TE node template.";
1428 + }
1429 + description
1430 + "The list of TE node templates used to define sharable
1431 + and reusable TE node attributes.";
1432 + uses template-attributes;
1433 + uses te-node-config-attributes-template;
1434 + } // node-template
1435 +
1436 + list link-template {
1437 + if-feature template;
1438 + key "name";
1439 + leaf name {
1440 + type te-types:te-template-name;
1441 + description
1442 + "The name to identify a TE link template.";
1443 + }
1444 + description
1445 + "The list of TE link templates used to define sharable
1446 + and reusable TE link attributes.";
1447 + uses template-attributes;
1448 + uses te-link-config-attributes;
1449 + } // link-template
1450 + } // templates
1451 + } // te
1452 + } // te-topologies-augment
1453 +
1454 + grouping te-topology-augment {
1455 + description
1456 + "Augmentation for TE topology.";
1457 +
1458 + container te {
1459 + presence "TE support.";
1460 + description
1461 + "Indicates TE support.";
1462 +
1463 + leaf provider-id {
1464 + type te-types:te-global-id;
1465 + mandatory true;
1466 + description
1467 + "An identifier to uniquely identify a provider.";
1468 + }
1469 + leaf client-id {
1470 + type te-types:te-global-id;
1471 + mandatory true;
1472 + description
1473 + "An identifier to uniquely identify a client.";
1474 + }
1475 + leaf te-topology-id {
1476 + type te-types:te-topology-id;
1477 + mandatory true;
1478 + description
1479 + "It is presumed that a datastore will contain many
1480 + topologies. To distinguish between topologies it is
1481 + vital to have UNIQUE topology identifiers.";
1482 + }
1483 +
1484 + container config {
1485 + description
1486 + "Configuration data.";
1487 + uses te-topology-config;
1488 + } // config
1489 + container state {
1490 + config false;
1491 + description
1492 + "Operational state data.";
1493 + uses te-topology-config;
1494 + } // state
1495 + } // te
1496 + } // te-topology-augment
1497 +
1498 + grouping te-topology-config {
1499 + description
1500 + "TE topology configuration grouping.";
1501 + uses sch:schedules;
1502 + leaf preference {
1503 + type uint8 {
1504 + range "1..255";
1505 + }
1506 + description
1507 + "Specifies a preference for this topology. A lower number
1508 + indicates a higher preference.";
1509 + }
1510 + leaf optimization-criterion {
1511 + type identityref {
1512 + base te-types:te-optimization-criterion;
1513 + }
1514 + description
1515 + "Optimization criterion applied to this topology.";
1516 + reference
1517 + "RFC3272: Overview and Principles of Internet Traffic
1518 + Engineering.";
1519 + }
1520 + } // te-topology-config
1521 +
1522 + grouping te-topology-ref {
1523 + description
1524 + "References a TE topology.";
1525 + leaf provider-id-ref {
1526 + type leafref {
1527 + path "/nw:networks/nw:network[nw:network-id = "
1528 + + "current()/../network-id-ref]/tet:te/tet:provider-id";
1529 + require-instance false;
1530 + }
1531 + description
1532 + "A reference to a provider-id.";
1533 + }
1534 + leaf client-id-ref {
1535 + type leafref {
1536 + path "/nw:networks/nw:network[nw:network-id = "
1537 + + "current()/../network-id-ref]/tet:te/tet:client-id";
1538 + require-instance false;
1539 + }
1540 + description
1541 + "A reference to a client-id.";
1542 + }
1543 + leaf te-topology-id-ref {
1544 + type leafref {
1545 + path "/nw:networks/nw:network[nw:network-id = "
1546 + + "current()/../network-id-ref]/tet:te/tet:te-topology-id";
1547 + require-instance false;
1548 + }
1549 + description
1550 + "A reference to a te-topology-id.";
1551 + }
1552 + leaf network-id-ref {
1553 + type leafref {
1554 + path "/nw:networks/nw:network/nw:network-id";
1555 + require-instance false;
1556 + }
1557 + description
1558 + "A reference to a network-id in base ietf-network module.";
1559 + }
1560 + } // te-topology-ref
1561 +
1562 + grouping te-topology-type {
1563 + description
1564 + "Identifies the TE topology type.";
1565 + container te-topology {
1566 + presence "Indicates TE topology.";
1567 + description
1568 + "Its presence identifies the TE topology type.";
1569 + }
1570 + } // te-topology-type
1571 +
1572 + grouping template-attributes {
1573 + description
1574 + "Common attributes for all templates.";
1575 +
1576 + leaf priority {
1577 + type uint16;
1578 + description
1579 + "The preference value to resolve conflicts between different
1580 + templates. When two or more templates specify values for
1581 + one configuration attribute, the value from the template
1582 + with the highest priority is used.";
1583 + }
1584 + leaf reference-change-policy {
1585 + type enumeration {
1586 + enum no-action {
1587 + description
1588 + "When an attribute changes in this template, the
1589 + configuration node referring to this template does
1590 + not take any action.";
1591 + }
1592 + enum not-allowed {
1593 + description
1594 + "When any configuration object has a reference to this
1595 + template, changing this template is not allowed.";
1596 + }
1597 + enum cascade {
1598 + description
1599 + "When an attribute changes in this template, the
1600 + configuration object referring to this template applies
1601 + the new attribute value to the corresponding
1602 + configuration.";
1603 + }
1604 + }
1605 + description
1606 + "This attribute specifies the action taken to a configuration
1607 + node that has a reference to this template.";
1608 + }
1609 + } // template-attributes
1610 +
1611 + /*
1612 + * Configuration data nodes
1613 + */
1614 + augment "/nw:networks/nw:network/nw:network-types" {
1615 + description
1616 + "Introduce new network type for TE topology.";
1617 + uses te-topology-type;
1618 + }
1619 +
1620 + augment "/nw:networks" {
1621 + description
1622 + "Augmentation parameters for TE topologies.";
1623 + uses te-topologies-augment;
1624 + }
1625 +
1626 + augment "/nw:networks/nw:network" {
1627 + when "nw:network-types/te-topology" {
1628 + description
1629 + "Augmentation parameters apply only for networks with
1630 + TE topology type.";
1631 + }
1632 + description
1633 + "Configuration parameters for TE topology.";
1634 + uses te-topology-augment;
1635 + }
1636 +
1637 + augment "/nw:networks/nw:network/nw:node" {
1638 + when "../nw:network-types/te-topology" {
1639 + description
1640 + "Augmentation parameters apply only for networks with
1641 + TE topology type.";
1642 + }
1643 + description
1644 + "Configuration parameters for TE at node level.";
1645 + uses te-node-augment;
1646 + }
1647 +
1648 + augment "/nw:networks/nw:network/nt:link" {
1649 + when "../nw:network-types/te-topology" {
1650 + description
1651 + "Augmentation parameters apply only for networks with
1652 + TE topology type.";
1653 + }
1654 + description
1655 + "Configuration parameters for TE at link level";
1656 + uses te-link-augment;
1657 + }
1658 +
1659 + augment "/nw:networks/nw:network/nw:node/"
1660 + + "nt:termination-point" {
1661 + when "../../nw:network-types/te-topology" {
1662 + description
1663 + "Augmentation parameters apply only for networks with
1664 + TE topology type.";
1665 + }
1666 + description
1667 + "Configuration parameters for TE at termination point level";
1668 + uses te-termination-point-augment;
1669 + }
1670 +
1671 + /*
1672 + * Operational state data nodes
1673 + */
1674 +
1675 + /*
1676 + * Notifications
1677 + */
1678 +
1679 + notification te-node-event {
1680 + description "Notification event for TE node.";
1681 + leaf event-type {
1682 + type te-types:te-topology-event-type;
1683 + description "Event type.";
1684 + }
1685 + uses nw:node-ref;
1686 + uses te-topology-type;
1687 + uses tet:te-node-config-attributes-notification;
1688 + uses tet:te-node-state-derived-notification;
1689 + }
1690 +
1691 + notification te-link-event {
1692 + description "Notification event for TE link.";
1693 + leaf event-type {
1694 + type te-types:te-topology-event-type;
1695 + description "Event type";
1696 + }
1697 + uses nt:link-ref;
1698 + uses te-topology-type;
1699 + uses tet:te-link-config-attributes;
1700 + uses tet:te-link-state-derived;
1701 + }
1702 +
1703 + augment "/te-link-event/te-link-attributes/underlay" {
1704 + description "Add state attributes to te-link underlay.";
1705 + uses te-link-state-underlay-attributes;
1706 + }
1707 +}
1 +module ietf-te-types {
2 +
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-te-types";
4 +
5 + /* Replace with IANA when assigned */
6 + prefix "te-types";
7 +
8 + import ietf-inet-types {
9 + prefix inet;
10 + }
11 +
12 + import ietf-yang-types {
13 + prefix "yang";
14 + }
15 +
16 + organization
17 + "IETF Traffic Engineering Architecture and Signaling (TEAS)
18 + Working Group";
19 +
20 + contact
21 + "WG Web: <http://tools.ietf.org/wg/teas/>
22 + WG List: <mailto:teas@ietf.org>
23 +
24 + WG Chair: Lou Berger
25 + <mailto:lberger@labn.net>
26 +
27 + WG Chair: Vishnu Pavan Beeram
28 + <mailto:vbeeram@juniper.net>
29 +
30 + Editor: Tarek Saad
31 + <mailto:tsaad@cisco.com>
32 +
33 + Editor: Rakesh Gandhi
34 + <mailto:rgandhi@cisco.com>
35 +
36 + Editor: Vishnu Pavan Beeram
37 + <mailto:vbeeram@juniper.net>
38 +
39 + Editor: Himanshu Shah
40 + <mailto:hshah@ciena.com>
41 +
42 + Editor: Xufeng Liu
43 + <mailto:xufeng.liu@ericsson.com>
44 +
45 + Editor: Xia Chen
46 + <mailto:jescia.chenxia@huawei.com>
47 +
48 + Editor: Raqib Jones
49 + <mailto:raqib@Brocade.com>
50 +
51 + Editor: Bin Wen
52 + <mailto:Bin_Wen@cable.comcast.com>";
53 +
54 + description
55 + "This module contains a collection of generally
56 + useful TE specific YANG data type defintions.";
57 +
58 + revision "2016-07-05" {
59 + description "Latest revision of TE basic types";
60 + reference "RFC3209";
61 + }
62 +
63 + /*
64 + * Identities
65 + */
66 + identity tunnel-type {
67 + description
68 + "Base identity from which specific tunnel types are
69 + derived.";
70 + }
71 +
72 + identity tunnel-p2p {
73 + base tunnel-type;
74 + description
75 + "TE point-to-point tunnel type.";
76 + }
77 +
78 + identity tunnel-p2mp {
79 + base tunnel-type;
80 + description
81 + "TE point-to-multipoint tunnel type.";
82 + }
83 +
84 + identity state-type {
85 + description
86 + "Base identity for TE states";
87 + }
88 +
89 + identity state-up {
90 + base state-type;
91 + description
92 + "State up";
93 + }
94 +
95 + identity state-down {
96 + base state-type;
97 + description
98 + "State down";
99 + }
100 +
101 + identity path-invalidation-action-type {
102 + description
103 + "Base identity for TE path invalidation action types";
104 + }
105 +
106 + identity tunnel-invalidation-action-drop-type {
107 + base path-invalidation-action-type;
108 + description
109 + "TE path invalidation action drop";
110 + }
111 +
112 + identity tunnel-invalidation-action-drop-tear {
113 + base path-invalidation-action-type;
114 + description
115 + "TE path invalidation action tear";
116 + }
117 +
118 + identity lsp-prot-type {
119 + description
120 + "Base identity from which LSP protection types are
121 + derived.";
122 + }
123 +
124 + identity lsp-prot-unprotected {
125 + base lsp-prot-type;
126 + description
127 + "LSP protection 'Unprotected'";
128 + reference "RFC4872";
129 + }
130 +
131 + identity lsp-prot-reroute-extra {
132 + base lsp-prot-type;
133 + description
134 + "LSP protection '(Full) Rerouting'";
135 + reference "RFC4872";
136 + }
137 +
138 + identity lsp-prot-reroute {
139 + base lsp-prot-type;
140 + description
141 + "LSP protection 'Rerouting without Extra-Traffic'";
142 + reference "RFC4872";
143 + }
144 +
145 + identity lsp-prot-1-for-n {
146 + base lsp-prot-type;
147 + description
148 + "LSP protection '1:N Protection with Extra-Traffic'";
149 + reference "RFC4872";
150 + }
151 +
152 + identity lsp-prot-unidir-1-to-1 {
153 + base lsp-prot-type;
154 + description
155 + "LSP protection '1+1 Unidirectional Protection'";
156 + reference "RFC4872";
157 + }
158 +
159 + identity lsp-prot-bidir-1-to-1 {
160 + base lsp-prot-type;
161 + description
162 + "LSP protection '1+1 Bidirectional Protection'";
163 + reference "RFC4872";
164 + }
165 +
166 + identity switching-capabilities {
167 + description
168 + "Base identity for interface switching capabilities";
169 + }
170 +
171 + identity switching-psc1 {
172 + base switching-capabilities;
173 + description
174 + "Packet-Switch Capable-1 (PSC-1)";
175 + }
176 +
177 + identity switching-evpl {
178 + base switching-capabilities;
179 + description
180 + "Ethernet Virtual Private Line (EVPL)";
181 + }
182 +
183 + identity switching-l2sc {
184 + base switching-capabilities;
185 + description
186 + "Layer-2 Switch Capable (L2SC)";
187 + }
188 +
189 + identity switching-tdm {
190 + base switching-capabilities;
191 + description
192 + "Time-Division-Multiplex Capable (TDM)";
193 + }
194 +
195 + identity switching-otn {
196 + base switching-capabilities;
197 + description
198 + "OTN-TDM capable";
199 + }
200 +
201 + identity switching-dcsc {
202 + base switching-capabilities;
203 + description
204 + "Data Channel Switching Capable (DCSC)";
205 + }
206 +
207 + identity switching-lsc {
208 + base switching-capabilities;
209 + description
210 + "Lambda-Switch Capable (LSC)";
211 + }
212 +
213 + identity switching-fsc {
214 + base switching-capabilities;
215 + description
216 + "Fiber-Switch Capable (FSC)";
217 + }
218 +
219 + identity lsp-encoding-types {
220 + description
221 + "Base identity for encoding types";
222 + }
223 +
224 + identity lsp-encoding-packet {
225 + base lsp-encoding-types;
226 + description
227 + "Packet LSP encoding";
228 + }
229 +
230 + identity lsp-encoding-ethernet {
231 + base lsp-encoding-types;
232 + description
233 + "Ethernet LSP encoding";
234 + }
235 +
236 + identity lsp-encoding-pdh {
237 + base lsp-encoding-types;
238 + description
239 + "ANSI/ETSI LSP encoding";
240 + }
241 +
242 + identity lsp-encoding-sdh {
243 + base lsp-encoding-types;
244 + description
245 + "SDH ITU-T G.707 / SONET ANSI T1.105 LSP encoding";
246 + }
247 +
248 + identity lsp-encoding-digital-wrapper {
249 + base lsp-encoding-types;
250 + description
251 + "Digital Wrapper LSP encoding";
252 + }
253 +
254 + identity lsp-encoding-lambda {
255 + base lsp-encoding-types;
256 + description
257 + "Lambda (photonic) LSP encoding";
258 + }
259 +
260 + identity lsp-encoding-fiber {
261 + base lsp-encoding-types;
262 + description
263 + "Fiber LSP encoding";
264 + }
265 +
266 + identity lsp-encoding-fiber-channel {
267 + base lsp-encoding-types;
268 + description
269 + "FiberChannel LSP encoding";
270 + }
271 +
272 + identity lsp-encoding-oduk {
273 + base lsp-encoding-types;
274 + description
275 + "G.709 ODUk (Digital Path)LSP encoding";
276 + }
277 +
278 + identity lsp-encoding-optical-channel {
279 + base lsp-encoding-types;
280 + description
281 + "Line (e.g., 8B/10B) LSP encoding";
282 + }
283 +
284 + identity lsp-encoding-line {
285 + base lsp-encoding-types;
286 + description
287 + "Line (e.g., 8B/10B) LSP encoding";
288 + }
289 +
290 + identity path-signaling-type {
291 + description
292 + "Base identity from which specific path signaling
293 + types are derived.";
294 + }
295 +
296 + identity path-signaling-rsvpte {
297 + base tunnel-type;
298 + description
299 + "RSVP-TE path signaling type";
300 + }
301 +
302 + identity path-signaling-sr {
303 + base tunnel-type;
304 + description
305 + "Segment-routing path signaling type";
306 + }
307 +
308 + /* TE basic features */
309 + feature p2mp-te {
310 + description
311 + "Indicates support for P2MP-TE";
312 + }
313 +
314 + feature frr-te {
315 + description
316 + "Indicates support for TE FastReroute (FRR)";
317 + }
318 +
319 + feature extended-admin-groups {
320 + description
321 + "Indicates support for TE link extended admin
322 + groups.";
323 + }
324 +
325 + feature named-path-affinities {
326 + description
327 + "Indicates support for named path affinities";
328 + }
329 +
330 + feature named-extended-admin-groups {
331 + description
332 + "Indicates support for named extended admin groups";
333 + }
334 +
335 + feature named-srlg-groups {
336 + description
337 + "Indicates support for named SRLG groups";
338 + }
339 +
340 + feature named-path-constraints {
341 + description
342 + "Indicates support for named path constraints";
343 + }
344 +
345 + grouping explicit-route-subobject {
346 + description
347 + "The explicit route subobject grouping";
348 + choice type {
349 + description
350 + "The explicit route subobject type";
351 + case ipv4-address {
352 + description
353 + "IPv4 address explicit route subobject";
354 + leaf v4-address {
355 + type inet:ipv4-address;
356 + description
357 + "An IPv4 address. This address is
358 + treated as a prefix based on the
359 + prefix length value below. Bits beyond
360 + the prefix are ignored on receipt and
361 + SHOULD be set to zero on transmission.";
362 + }
363 + leaf v4-prefix-length {
364 + type uint8;
365 + description
366 + "Length in bits of the IPv4 prefix";
367 + }
368 + leaf v4-loose {
369 + type boolean;
370 + description
371 + "Describes whether the object is loose
372 + if set, or otherwise strict";
373 + }
374 + }
375 + case ipv6-address {
376 + description
377 + "IPv6 address Explicit Route Object";
378 + leaf v6-address {
379 + type inet:ipv6-address;
380 + description
381 + "An IPv6 address. This address is
382 + treated as a prefix based on the
383 + prefix length value below. Bits
384 + beyond the prefix are ignored on
385 + receipt and SHOULD be set to zero
386 + on transmission.";
387 + }
388 + leaf v6-prefix-length {
389 + type uint8;
390 + description
391 + "Length in bits of the IPv4 prefix";
392 + }
393 + leaf v6-loose {
394 + type boolean;
395 + description
396 + "Describes whether the object is loose
397 + if set, or otherwise strict";
398 + }
399 + }
400 + case as-number {
401 + leaf as-number {
402 + type uint16;
403 + description "AS number";
404 + }
405 + description
406 + "Autonomous System explicit route subobject";
407 + }
408 + case unnumbered-link {
409 + leaf router-id {
410 + type inet:ip-address;
411 + description
412 + "A router-id address";
413 + }
414 + leaf interface-id {
415 + type uint32;
416 + description "The interface identifier";
417 + }
418 + description
419 + "Unnumbered link explicit route subobject";
420 + reference
421 + "RFC3477: Signalling Unnumbered Links in
422 + RSVP-TE";
423 + }
424 + case label {
425 + leaf value {
426 + type uint32;
427 + description "the label value";
428 + }
429 + description
430 + "The Label ERO subobject";
431 + }
432 + /* AS domain sequence..? */
433 + }
434 + }
435 +
436 + grouping record-route-subobject {
437 + description
438 + "The record route subobject grouping";
439 + choice type {
440 + description
441 + "The record route subobject type";
442 + case ipv4-address {
443 + leaf v4-address {
444 + type inet:ipv4-address;
445 + description
446 + "An IPv4 address. This address is
447 + treated as a prefix based on the prefix
448 + length value below. Bits beyond the
449 + prefix are ignored on receipt and
450 + SHOULD be set to zero on transmission.";
451 + }
452 + leaf v4-prefix-length {
453 + type uint8;
454 + description
455 + "Length in bits of the IPv4 prefix";
456 + }
457 + leaf v4-flags {
458 + type uint8;
459 + description
460 + "IPv4 address sub-object flags";
461 + reference "RFC3209";
462 + }
463 + }
464 + case ipv6-address {
465 + leaf v6-address {
466 + type inet:ipv6-address;
467 + description
468 + "An IPv6 address. This address is
469 + treated as a prefix based on the
470 + prefix length value below. Bits
471 + beyond the prefix are ignored on
472 + receipt and SHOULD be set to zero
473 + on transmission.";
474 + }
475 + leaf v6-prefix-length {
476 + type uint8;
477 + description
478 + "Length in bits of the IPv4 prefix";
479 + }
480 + leaf v6-flags {
481 + type uint8;
482 + description
483 + "IPv6 address sub-object flags";
484 + reference "RFC3209";
485 + }
486 + }
487 + case unnumbered-link {
488 + leaf router-id {
489 + type inet:ip-address;
490 + description
491 + "A router-id address";
492 + }
493 + leaf interface-id {
494 + type uint32;
495 + description "The interface identifier";
496 + }
497 + description
498 + "Unnumbered link record route subobject";
499 + reference
500 + "RFC3477: Signalling Unnumbered Links in
501 + RSVP-TE";
502 + }
503 + case label {
504 + leaf value {
505 + type uint32;
506 + description "the label value";
507 + }
508 + leaf flags {
509 + type uint8;
510 + description
511 + "Label sub-object flags";
512 + reference "RFC3209";
513 + }
514 + description
515 + "The Label ERO subobject";
516 + }
517 + }
518 + }
519 +
520 + identity route-usage-type {
521 + description
522 + "Base identity for route usage";
523 + }
524 +
525 + identity route-include-ero {
526 + base route-usage-type;
527 + description
528 + "Include ERO from route";
529 + }
530 +
531 + identity route-exclude-ero {
532 + base route-usage-type;
533 + description
534 + "Exclude ERO from route";
535 + }
536 +
537 + identity route-exclude-srlg {
538 + base route-usage-type;
539 + description
540 + "Exclude SRLG from route";
541 + }
542 +
543 + identity path-metric-type {
544 + description
545 + "Base identity for path metric type";
546 + }
547 +
548 + identity path-metric-te {
549 + base path-metric-type;
550 + description
551 + "TE path metric";
552 + }
553 +
554 + identity path-metric-igp {
555 + base path-metric-type;
556 + description
557 + "IGP path metric";
558 + }
559 +
560 + identity path-tiebreaker-type {
561 + description
562 + "Base identity for path tie-breaker type";
563 + }
564 +
565 + identity path-tiebreaker-minfill {
566 + base path-tiebreaker-type;
567 + description
568 + "Min-Fill LSP path placement";
569 + }
570 +
571 + identity path-tiebreaker-maxfill {
572 + base path-tiebreaker-type;
573 + description
574 + "Max-Fill LSP path placement";
575 + }
576 +
577 + identity path-tiebreaker-randoom {
578 + base path-tiebreaker-type;
579 + description
580 + "Random LSP path placement";
581 + }
582 +
583 + identity bidir-provisioning-mode {
584 + description
585 + "Base identity for bidirectional provisioning
586 + mode.";
587 + }
588 +
589 + identity bidir-provisioning-single-sided {
590 + base bidir-provisioning-mode;
591 + description
592 + "Single-sided bidirectional provioning mode";
593 + }
594 +
595 + identity bidir-provisioning-double-sided {
596 + base bidir-provisioning-mode;
597 + description
598 + "Double-sided bidirectional provioning mode";
599 + }
600 +
601 + identity bidir-association-type {
602 + description
603 + "Base identity for bidirectional association type";
604 + }
605 +
606 + identity bidir-assoc-corouted {
607 + base bidir-association-type;
608 + description
609 + "Co-routed bidirectional association type";
610 + }
611 +
612 + identity bidir-assoc-non-corouted {
613 + base bidir-association-type;
614 + description
615 + "Non co-routed bidirectional association type";
616 + }
617 +
618 + identity resource-affinities-type {
619 + description
620 + "Base identity for resource affinities";
621 + }
622 +
623 + identity resource-aff-include-all {
624 + base resource-affinities-type;
625 + description
626 + "The set of attribute filters associated with a
627 + tunnel all of which must be present for a link
628 + to be acceptable";
629 + }
630 +
631 + identity resource-aff-include-any {
632 + base resource-affinities-type;
633 + description
634 + "The set of attribute filters associated with a
635 + tunnel any of which must be present for a link
636 + to be acceptable";
637 + }
638 +
639 + identity resource-aff-exclude-any {
640 + base resource-affinities-type;
641 + description
642 + "The set of attribute filters associated with a
643 + tunnel any of which renders a link unacceptable";
644 + }
645 +
646 + identity te-optimization-criterion {
647 + description
648 + "Base identity for TE optimization criterion.";
649 + reference
650 + "RFC3272: Overview and Principles of Internet Traffic
651 + Engineering.";
652 + }
653 +
654 + identity not-optimized {
655 + base te-optimization-criterion;
656 + description "Optimization is not applied.";
657 + }
658 +
659 + identity cost {
660 + base te-optimization-criterion;
661 + description "Optimized on cost.";
662 + }
663 +
664 + identity delay {
665 + base te-optimization-criterion;
666 + description "Optimized on delay.";
667 + }
668 +
669 + /*
670 + * Typedefs
671 + */
672 + typedef performance-metric-normality {
673 + type enumeration {
674 + enum "unknown" {
675 + value 0;
676 + description
677 + "Unknown.";
678 + }
679 + enum "normal" {
680 + value 1;
681 + description
682 + "Normal.";
683 + }
684 + enum "abnormal" {
685 + value 2;
686 + description
687 + "Abnormal. The anomalous bit is set.";
688 + }
689 + }
690 + description
691 + "Indicates whether a performance metric is normal, abnormal, or
692 + unknown.";
693 + reference
694 + "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.
695 + RFC7810: IS-IS Traffic Engineering (TE) Metric Extensions.
696 + RFC7823: Performance-Based Path Selection for Explicitly
697 + Routed Label Switched Paths (LSPs) Using TE Metric
698 + Extensions";
699 + }
700 +
701 + typedef te-admin-status {
702 + type enumeration {
703 + enum up {
704 + description
705 + "Enabled.";
706 + }
707 + enum down {
708 + description
709 + "Disabled.";
710 + }
711 + enum testing {
712 + description
713 + "In some test mode.";
714 + }
715 + enum preparing-maintenance {
716 + description
717 + "Resource is disabled in the control plane to prepare for
718 + graceful shutdown for maintenance purposes.";
719 + reference
720 + "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
721 + Traffic Engineering Networks";
722 + }
723 + enum maintenance {
724 + description
725 + "Resource is disabled in the data plane for maintenance
726 + purposes.";
727 + }
728 + }
729 + description
730 + "Defines a type representing the administrative status of
731 + a TE resource.";
732 + }
733 +
734 + typedef te-global-id {
735 + type uint32;
736 + description
737 + "An identifier to uniquely identify an operator, which can be
738 + either a provider or a client.
739 + The definition of this type is taken from RFC6370 and RFC5003.
740 + This attribute type is used solely to provide a globally
741 + unique context for TE topologies.";
742 + }
743 +
744 + typedef te-link-access-type {
745 + type enumeration {
746 + enum point-to-point {
747 + description
748 + "The link is point-to-point.";
749 + }
750 + enum multi-access {
751 + description
752 + "The link is multi-access, including broacast and NBMA.";
753 + }
754 + }
755 + description
756 + "Defines a type representing the access type of a TE link.";
757 + reference
758 + "RFC3630: Traffic Engineering (TE) Extensions to OSPF
759 + Version 2.";
760 + }
761 +
762 + typedef te-node-id {
763 + type yang:dotted-quad;
764 + description
765 + "An identifier for a node in a topology.
766 + The identifier is represented as 32-bit unsigned integer in
767 + the dotted-quad notation.
768 + This attribute is mapped to Router ID in
769 + RFC3630, RFC5329, RFC5305, and RFC6119.";
770 + }
771 +
772 + typedef te-oper-status {
773 + type enumeration {
774 + enum up {
775 + description
776 + "Operational up.";
777 + }
778 + enum down {
779 + description
780 + "Operational down.";
781 + }
782 + enum testing {
783 + description
784 + "In some test mode.";
785 + }
786 + enum unknown {
787 + description
788 + "Status cannot be determined for some reason.";
789 + }
790 + enum preparing-maintenance {
791 + description
792 + "Resource is disabled in the control plane to prepare for
793 + graceful shutdown for maintenance purposes.";
794 + reference
795 + "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
796 + Traffic Engineering Networks";
797 + }
798 + enum maintenance {
799 + description
800 + "Resource is disabled in the data plane for maintenance
801 + purposes.";
802 + }
803 + }
804 + description
805 + "Defines a type representing the operational status of
806 + a TE resource.";
807 + }
808 +
809 + typedef te-recovery-status {
810 + type enumeration {
811 + enum normal {
812 + description
813 + "Both the recovery and working spans are fully
814 + allocated and active, data traffic is being
815 + transported over (or selected from) the working
816 + span, and no trigger events are reported.";
817 + }
818 + enum recovery-started {
819 + description
820 + "The recovery action has been started, but not completed.";
821 + }
822 + enum recovery-succeeded {
823 + description
824 + "The recovery action has succeeded. The working span has
825 + reported a failure/degrade condition and the user traffic
826 + is being transported (or selected) on the recovery span.";
827 + }
828 + enum recovery-failed {
829 + description
830 + "The recovery action has failed.";
831 + }
832 + enum reversion-started {
833 + description
834 + "The reversion has started.";
835 + }
836 + enum reversion-failed {
837 + description
838 + "The reversion has failed.";
839 + }
840 + enum recovery-unavailable {
841 + description
842 + "The recovery is unavailable -- either as a result of an
843 + operator Lockout command or a failure condition detected
844 + on the recovery span.";
845 + }
846 + enum recovery-admin {
847 + description
848 + "The operator has issued a command switching the user
849 + traffic to the recovery span.";
850 + }
851 + enum wait-to-restore {
852 + description
853 + "The recovery domain is recovering from a failuer/degrade
854 + condition on the working span that is being controlled by
855 + the Wait-to-Restore (WTR) timer.";
856 + }
857 + }
858 + description
859 + "Defines the status of a recovery action.";
860 + reference
861 + "RFC4427: Recovery (Protection and Restoration) Terminology
862 + for Generalized Multi-Protocol Label Switching (GMPLS).
863 + RFC6378: MPLS Transport Profile (MPLS-TP) Linear Protection";
864 + }
865 +
866 + typedef te-template-name {
867 + type string {
868 + pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
869 + }
870 + description
871 + "A type for the name of a TE node template or TE link
872 + template.";
873 + }
874 +
875 + typedef te-topology-event-type {
876 + type enumeration {
877 + enum "add" {
878 + value 0;
879 + description
880 + "A TE node or te-link has been added.";
881 + }
882 + enum "remove" {
883 + value 1;
884 + description
885 + "A TE node or te-link has been removed.";
886 + }
887 + enum "update" {
888 + value 2;
889 + description
890 + "A TE node or te-link has been updated.";
891 + }
892 + }
893 + description "TE Event type for notifications";
894 + } // te-topology-event-type
895 +
896 + typedef te-topology-id {
897 + type string {
898 + pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
899 + }
900 + description
901 + "An identifier for a topology.";
902 + }
903 +
904 + typedef te-tp-id {
905 + type union {
906 + type uint32; // Unnumbered
907 + type inet:ip-address; // IPv4 or IPv6 address
908 + }
909 + description
910 + "An identifier for a TE link endpoint on a node.
911 + This attribute is mapped to local or remote link identifier in
912 + RFC3630 and RFC5305.";
913 + }
914 +
915 + typedef generalized-label {
916 + type binary;
917 + description
918 + "Generalized label. Nodes sending and receiving the
919 + Generalized Label know what kinds of link they are
920 + using, the Generalized Label does not identify its
921 + type. Instead, nodes are expected to know from the
922 + context what type of label to expect.";
923 + reference "rfc3471: section 3.2";
924 + }
925 +
926 + typedef admin-group {
927 + type binary {
928 + length 32;
929 + }
930 + description
931 + "Administrative group/Resource class/Color.";
932 + }
933 +
934 + typedef extended-admin-group {
935 + type binary;
936 + description
937 + "Extended administrative group/Resource class/Color.";
938 + }
939 +
940 + typedef admin-groups {
941 + type union {
942 + type admin-group;
943 + type extended-admin-group;
944 + }
945 + description "TE administrative group derived type";
946 + }
947 +
948 + typedef srlg {
949 + type uint32;
950 + description "SRLG type";
951 + }
952 +
953 + identity path-computation-srlg-type {
954 + description
955 + "Base identity for SRLG path computation";
956 + }
957 +
958 + identity srlg-ignore {
959 + base path-computation-srlg-type;
960 + description
961 + "Ignores SRLGs in path computation";
962 + }
963 +
964 + identity srlg-strict {
965 + base path-computation-srlg-type;
966 + description
967 + "Include strict SRLG check in path computation";
968 + }
969 +
970 + identity srlg-preferred {
971 + base path-computation-srlg-type;
972 + description
973 + "Include preferred SRLG check in path computation";
974 + }
975 +
976 + identity srlg-weighted {
977 + base path-computation-srlg-type;
978 + description
979 + "Include weighted SRLG check in path computation";
980 + }
981 +
982 + typedef te-metric {
983 + type uint32;
984 + description
985 + "TE link metric";
986 + }
987 +
988 + /**
989 + * TE tunnel generic groupings
990 + **/
991 +
992 + /* Tunnel path selection parameters */
993 + grouping tunnel-path-selection {
994 + description
995 + "Tunnel path selection properties grouping";
996 + container path-selection {
997 + description
998 + "Tunnel path selection properties container";
999 + leaf topology-id {
1000 + type te-types:te-topology-id;
1001 + description
1002 + "The tunnel path is computed using the specific
1003 + topology identified by this identifier";
1004 + }
1005 + leaf cost-limit {
1006 + type uint32 {
1007 + range "1..4294967295";
1008 + }
1009 + description
1010 + "The tunnel path cost limit.";
1011 + }
1012 + leaf hop-limit {
1013 + type uint8 {
1014 + range "1..255";
1015 + }
1016 + description
1017 + "The tunnel path hop limit.";
1018 + }
1019 + leaf metric-type {
1020 + type identityref {
1021 + base path-metric-type;
1022 + }
1023 + default path-metric-te;
1024 + description
1025 + "The tunnel path metric type.";
1026 + }
1027 + leaf tiebreaker-type {
1028 + type identityref {
1029 + base path-tiebreaker-type;
1030 + }
1031 + default path-tiebreaker-maxfill;
1032 + description
1033 + "The tunnel path computation tie breakers.";
1034 + }
1035 + leaf ignore-overload {
1036 + type boolean;
1037 + description
1038 + "The tunnel path can traverse overloaded node.";
1039 + }
1040 + uses tunnel-path-affinities;
1041 + uses tunnel-path-srlgs;
1042 + }
1043 + }
1044 +
1045 + grouping tunnel-path-affinities {
1046 + description
1047 + "Path affinities grouping";
1048 + container tunnel-path-affinities {
1049 + if-feature named-path-affinities;
1050 + description
1051 + "Path affinities container";
1052 + choice style {
1053 + description
1054 + "Path affinities representation style";
1055 + case values {
1056 + leaf value {
1057 + type uint32 {
1058 + range "0..4294967295";
1059 + }
1060 + description
1061 + "Affinity value";
1062 + }
1063 + leaf mask {
1064 + type uint32 {
1065 + range "0..4294967295";
1066 + }
1067 + description
1068 + "Affinity mask";
1069 + }
1070 + }
1071 + case named {
1072 + list constraints {
1073 + key "usage";
1074 + leaf usage {
1075 + type identityref {
1076 + base resource-affinities-type;
1077 + }
1078 + description "Affinities usage";
1079 + }
1080 + container constraint {
1081 + description
1082 + "Container for named affinities";
1083 + list affinity-names {
1084 + key "name";
1085 + leaf name {
1086 + type string;
1087 + description
1088 + "Affinity name";
1089 + }
1090 + description
1091 + "List of named affinities";
1092 + }
1093 + }
1094 + description
1095 + "List of named affinity constraints";
1096 + }
1097 + }
1098 + }
1099 + }
1100 + }
1101 +
1102 + grouping tunnel-path-srlgs {
1103 + description
1104 + "Path SRLG properties grouping";
1105 + container tunnel-path-srlgs {
1106 + description
1107 + "Path SRLG properties container";
1108 + choice style {
1109 + description
1110 + "Type of SRLG representation";
1111 + case values {
1112 + leaf usage {
1113 + type identityref {
1114 + base route-exclude-srlg;
1115 + }
1116 + description "SRLG usage";
1117 + }
1118 + leaf-list values {
1119 + type te-types:srlg;
1120 + description "SRLG value";
1121 + }
1122 + }
1123 + case named {
1124 + list constraints {
1125 + key "usage";
1126 + leaf usage {
1127 + type identityref {
1128 + base route-exclude-srlg;
1129 + }
1130 + description "SRLG usage";
1131 + }
1132 + container constraint {
1133 + description
1134 + "Container for named SRLG list";
1135 + list srlg-names {
1136 + key "name";
1137 + leaf name {
1138 + type string;
1139 + description
1140 + "The SRLG name";
1141 + }
1142 + description
1143 + "List named SRLGs";
1144 + }
1145 + }
1146 + description
1147 + "List of named SRLG constraints";
1148 + }
1149 + }
1150 + }
1151 + }
1152 + }
1153 +
1154 + grouping tunnel-bidir-assoc-properties {
1155 + description
1156 + "TE tunnel associated bidirectional properties
1157 + grouping";
1158 + container bidirectional {
1159 + description
1160 + "TE tunnel associated bidirectional attributes.";
1161 + container association {
1162 + description
1163 + "Tunnel bidirectional association properties";
1164 + leaf id {
1165 + type uint16;
1166 + description
1167 + "The TE tunnel association identifier.";
1168 + }
1169 + leaf source {
1170 + type inet:ip-address;
1171 + description
1172 + "The TE tunnel association source.";
1173 + }
1174 + leaf global-source {
1175 + type inet:ip-address;
1176 + description
1177 + "The TE tunnel association global
1178 + source.";
1179 + }
1180 + leaf type {
1181 + type identityref {
1182 + base bidir-association-type;
1183 + }
1184 + default bidir-assoc-non-corouted;
1185 + description
1186 + "The TE tunnel association type.";
1187 + }
1188 + leaf provisioing {
1189 + type identityref {
1190 + base bidir-provisioning-mode;
1191 + }
1192 + description
1193 + "Describes the provisioning model of the
1194 + associated bidirectional LSP";
1195 + reference
1196 + "draft-ietf-teas-mpls-tp-rsvpte-ext-
1197 + associated-lsp, section-3.2";
1198 + }
1199 + }
1200 + }
1201 + }
1202 + /*** End of TE tunnel groupings ***/
1203 +
1204 + /**
1205 + * TE interface generic groupings
1206 + **/
1207 +}
1 +module ietf-yang-types {
2 +
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
4 + prefix "yang";
5 +
6 + organization
7 + "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/netmod/>
11 + WG List: <mailto:netmod@ietf.org>
12 +
13 + WG Chair: David Kessens
14 + <mailto:david.kessens@nsn.com>
15 +
16 + WG Chair: Juergen Schoenwaelder
17 + <mailto:j.schoenwaelder@jacobs-university.de>
18 +
19 + Editor: Juergen Schoenwaelder
20 + <mailto:j.schoenwaelder@jacobs-university.de>";
21 +
22 + description
23 + "This module contains a collection of generally useful derived
24 + YANG data types.
25 +
26 + Copyright (c) 2013 IETF Trust and the persons identified as
27 + authors of the code. All rights reserved.
28 +
29 + Redistribution and use in source and binary forms, with or
30 + without modification, is permitted pursuant to, and subject
31 + to the license terms contained in, the Simplified BSD License
32 + set forth in Section 4.c of the IETF Trust's Legal Provisions
33 + Relating to IETF Documents
34 + (http://trustee.ietf.org/license-info).
35 +
36 + This version of this YANG module is part of RFC 6991; see
37 + the RFC itself for full legal notices.";
38 +
39 + revision 2013-07-15 {
40 + description
41 + "This revision adds the following new data types:
42 + - yang-identifier
43 + - hex-string
44 + - uuid
45 + - dotted-quad";
46 + reference
47 + "RFC 6991: Common YANG Data Types";
48 + }
49 +
50 + revision 2010-09-24 {
51 + description
52 + "Initial revision.";
53 + reference
54 + "RFC 6021: Common YANG Data Types";
55 + }
56 +
57 + /*** collection of counter and gauge types ***/
58 +
59 + typedef counter32 {
60 + type uint32;
61 + description
62 + "The counter32 type represents a non-negative integer
63 + that monotonically increases until it reaches a
64 + maximum value of 2^32-1 (4294967295 decimal), when it
65 + wraps around and starts increasing again from zero.
66 +
67 + Counters have no defined 'initial' value, and thus, a
68 + single value of a counter has (in general) no information
69 + content. Discontinuities in the monotonically increasing
70 + value normally occur at re-initialization of the
71 + management system, and at other times as specified in the
72 + description of a schema node using this type. If such
73 + other times can occur, for example, the creation of
74 + a schema node of type counter32 at times other than
75 + re-initialization, then a corresponding schema node
76 + should be defined, with an appropriate type, to indicate
77 + the last discontinuity.
78 +
79 + The counter32 type should not be used for configuration
80 + schema nodes. A default statement SHOULD NOT be used in
81 + combination with the type counter32.
82 +
83 + In the value set and its semantics, this type is equivalent
84 + to the Counter32 type of the SMIv2.";
85 + reference
86 + "RFC 2578: Structure of Management Information Version 2
87 + (SMIv2)";
88 + }
89 +
90 + typedef zero-based-counter32 {
91 + type yang:counter32;
92 + default "0";
93 + description
94 + "The zero-based-counter32 type represents a counter32
95 + that has the defined 'initial' value zero.
96 +
97 + A schema node of this type will be set to zero (0) on creation
98 + and will thereafter increase monotonically until it reaches
99 + a maximum value of 2^32-1 (4294967295 decimal), when it
100 + wraps around and starts increasing again from zero.
101 +
102 + Provided that an application discovers a new schema node
103 + of this type within the minimum time to wrap, it can use the
104 + 'initial' value as a delta. It is important for a management
105 + station to be aware of this minimum time and the actual time
106 + between polls, and to discard data if the actual time is too
107 + long or there is no defined minimum time.
108 +
109 + In the value set and its semantics, this type is equivalent
110 + to the ZeroBasedCounter32 textual convention of the SMIv2.";
111 + reference
112 + "RFC 4502: Remote Network Monitoring Management Information
113 + Base Version 2";
114 + }
115 +
116 + typedef counter64 {
117 + type uint64;
118 + description
119 + "The counter64 type represents a non-negative integer
120 + that monotonically increases until it reaches a
121 + maximum value of 2^64-1 (18446744073709551615 decimal),
122 + when it wraps around and starts increasing again from zero.
123 +
124 + Counters have no defined 'initial' value, and thus, a
125 + single value of a counter has (in general) no information
126 + content. Discontinuities in the monotonically increasing
127 + value normally occur at re-initialization of the
128 + management system, and at other times as specified in the
129 + description of a schema node using this type. If such
130 + other times can occur, for example, the creation of
131 + a schema node of type counter64 at times other than
132 + re-initialization, then a corresponding schema node
133 + should be defined, with an appropriate type, to indicate
134 + the last discontinuity.
135 +
136 + The counter64 type should not be used for configuration
137 + schema nodes. A default statement SHOULD NOT be used in
138 + combination with the type counter64.
139 +
140 + In the value set and its semantics, this type is equivalent
141 + to the Counter64 type of the SMIv2.";
142 + reference
143 + "RFC 2578: Structure of Management Information Version 2
144 + (SMIv2)";
145 + }
146 +
147 + typedef zero-based-counter64 {
148 + type yang:counter64;
149 + default "0";
150 + description
151 + "The zero-based-counter64 type represents a counter64 that
152 + has the defined 'initial' value zero.
153 +
154 +
155 +
156 +
157 + A schema node of this type will be set to zero (0) on creation
158 + and will thereafter increase monotonically until it reaches
159 + a maximum value of 2^64-1 (18446744073709551615 decimal),
160 + when it wraps around and starts increasing again from zero.
161 +
162 + Provided that an application discovers a new schema node
163 + of this type within the minimum time to wrap, it can use the
164 + 'initial' value as a delta. It is important for a management
165 + station to be aware of this minimum time and the actual time
166 + between polls, and to discard data if the actual time is too
167 + long or there is no defined minimum time.
168 +
169 + In the value set and its semantics, this type is equivalent
170 + to the ZeroBasedCounter64 textual convention of the SMIv2.";
171 + reference
172 + "RFC 2856: Textual Conventions for Additional High Capacity
173 + Data Types";
174 + }
175 +
176 + typedef gauge32 {
177 + type uint32;
178 + description
179 + "The gauge32 type represents a non-negative integer, which
180 + may increase or decrease, but shall never exceed a maximum
181 + value, nor fall below a minimum value. The maximum value
182 + cannot be greater than 2^32-1 (4294967295 decimal), and
183 + the minimum value cannot be smaller than 0. The value of
184 + a gauge32 has its maximum value whenever the information
185 + being modeled is greater than or equal to its maximum
186 + value, and has its minimum value whenever the information
187 + being modeled is smaller than or equal to its minimum value.
188 + If the information being modeled subsequently decreases
189 + below (increases above) the maximum (minimum) value, the
190 + gauge32 also decreases (increases).
191 +
192 + In the value set and its semantics, this type is equivalent
193 + to the Gauge32 type of the SMIv2.";
194 + reference
195 + "RFC 2578: Structure of Management Information Version 2
196 + (SMIv2)";
197 + }
198 +
199 + typedef gauge64 {
200 + type uint64;
201 + description
202 + "The gauge64 type represents a non-negative integer, which
203 + may increase or decrease, but shall never exceed a maximum
204 + value, nor fall below a minimum value. The maximum value
205 + cannot be greater than 2^64-1 (18446744073709551615), and
206 + the minimum value cannot be smaller than 0. The value of
207 + a gauge64 has its maximum value whenever the information
208 + being modeled is greater than or equal to its maximum
209 + value, and has its minimum value whenever the information
210 + being modeled is smaller than or equal to its minimum value.
211 + If the information being modeled subsequently decreases
212 + below (increases above) the maximum (minimum) value, the
213 + gauge64 also decreases (increases).
214 +
215 + In the value set and its semantics, this type is equivalent
216 + to the CounterBasedGauge64 SMIv2 textual convention defined
217 + in RFC 2856";
218 + reference
219 + "RFC 2856: Textual Conventions for Additional High Capacity
220 + Data Types";
221 + }
222 +
223 + /*** collection of identifier-related types ***/
224 +
225 + typedef object-identifier {
226 + type string {
227 + pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))'
228 + + '(\.(0|([1-9]\d*)))*';
229 + }
230 + description
231 + "The object-identifier type represents administratively
232 + assigned names in a registration-hierarchical-name tree.
233 +
234 + Values of this type are denoted as a sequence of numerical
235 + non-negative sub-identifier values. Each sub-identifier
236 + value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
237 + are separated by single dots and without any intermediate
238 + whitespace.
239 +
240 + The ASN.1 standard restricts the value space of the first
241 + sub-identifier to 0, 1, or 2. Furthermore, the value space
242 + of the second sub-identifier is restricted to the range
243 + 0 to 39 if the first sub-identifier is 0 or 1. Finally,
244 + the ASN.1 standard requires that an object identifier
245 + has always at least two sub-identifiers. The pattern
246 + captures these restrictions.
247 +
248 + Although the number of sub-identifiers is not limited,
249 + module designers should realize that there may be
250 + implementations that stick with the SMIv2 limit of 128
251 + sub-identifiers.
252 +
253 + This type is a superset of the SMIv2 OBJECT IDENTIFIER type
254 + since it is not restricted to 128 sub-identifiers. Hence,
255 + this type SHOULD NOT be used to represent the SMIv2 OBJECT
256 + IDENTIFIER type; the object-identifier-128 type SHOULD be
257 + used instead.";
258 + reference
259 + "ISO9834-1: Information technology -- Open Systems
260 + Interconnection -- Procedures for the operation of OSI
261 + Registration Authorities: General procedures and top
262 + arcs of the ASN.1 Object Identifier tree";
263 + }
264 +
265 + typedef object-identifier-128 {
266 + type object-identifier {
267 + pattern '\d*(\.\d*){1,127}';
268 + }
269 + description
270 + "This type represents object-identifiers restricted to 128
271 + sub-identifiers.
272 +
273 + In the value set and its semantics, this type is equivalent
274 + to the OBJECT IDENTIFIER type of the SMIv2.";
275 + reference
276 + "RFC 2578: Structure of Management Information Version 2
277 + (SMIv2)";
278 + }
279 +
280 + typedef yang-identifier {
281 + type string {
282 + length "1..max";
283 + pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
284 + pattern '.|..|[^xX].*|.[^mM].*|..[^lL].*';
285 + }
286 + description
287 + "A YANG identifier string as defined by the 'identifier'
288 + rule in Section 12 of RFC 6020. An identifier must
289 + start with an alphabetic character or an underscore
290 + followed by an arbitrary sequence of alphabetic or
291 + numeric characters, underscores, hyphens, or dots.
292 +
293 + A YANG identifier MUST NOT start with any possible
294 + combination of the lowercase or uppercase character
295 + sequence 'xml'.";
296 + reference
297 + "RFC 6020: YANG - A Data Modeling Language for the Network
298 + Configuration Protocol (NETCONF)";
299 + }
300 +
301 + /*** collection of types related to date and time***/
302 +
303 + typedef date-and-time {
304 + type string {
305 + pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
306 + + '(Z|[\+\-]\d{2}:\d{2})';
307 + }
308 + description
309 + "The date-and-time type is a profile of the ISO 8601
310 + standard for representation of dates and times using the
311 + Gregorian calendar. The profile is defined by the
312 + date-time production in Section 5.6 of RFC 3339.
313 +
314 + The date-and-time type is compatible with the dateTime XML
315 + schema type with the following notable exceptions:
316 +
317 + (a) The date-and-time type does not allow negative years.
318 +
319 + (b) The date-and-time time-offset -00:00 indicates an unknown
320 + time zone (see RFC 3339) while -00:00 and +00:00 and Z
321 + all represent the same time zone in dateTime.
322 +
323 + (c) The canonical format (see below) of data-and-time values
324 + differs from the canonical format used by the dateTime XML
325 + schema type, which requires all times to be in UTC using
326 + the time-offset 'Z'.
327 +
328 + This type is not equivalent to the DateAndTime textual
329 + convention of the SMIv2 since RFC 3339 uses a different
330 + separator between full-date and full-time and provides
331 + higher resolution of time-secfrac.
332 +
333 + The canonical format for date-and-time values with a known time
334 + zone uses a numeric time zone offset that is calculated using
335 + the device's configured known offset to UTC time. A change of
336 + the device's offset to UTC time will cause date-and-time values
337 + to change accordingly. Such changes might happen periodically
338 + in case a server follows automatically daylight saving time
339 + (DST) time zone offset changes. The canonical format for
340 + date-and-time values with an unknown time zone (usually
341 + referring to the notion of local time) uses the time-offset
342 + -00:00.";
343 + reference
344 + "RFC 3339: Date and Time on the Internet: Timestamps
345 + RFC 2579: Textual Conventions for SMIv2
346 + XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
347 + }
348 +
349 + typedef timeticks {
350 + type uint32;
351 + description
352 + "The timeticks type represents a non-negative integer that
353 + represents the time, modulo 2^32 (4294967296 decimal), in
354 + hundredths of a second between two epochs. When a schema
355 + node is defined that uses this type, the description of
356 + the schema node identifies both of the reference epochs.
357 +
358 + In the value set and its semantics, this type is equivalent
359 + to the TimeTicks type of the SMIv2.";
360 + reference
361 + "RFC 2578: Structure of Management Information Version 2
362 + (SMIv2)";
363 + }
364 +
365 + typedef timestamp {
366 + type yang:timeticks;
367 + description
368 + "The timestamp type represents the value of an associated
369 + timeticks schema node at which a specific occurrence
370 + happened. The specific occurrence must be defined in the
371 + description of any schema node defined using this type. When
372 + the specific occurrence occurred prior to the last time the
373 + associated timeticks attribute was zero, then the timestamp
374 + value is zero. Note that this requires all timestamp values
375 + to be reset to zero when the value of the associated timeticks
376 + attribute reaches 497+ days and wraps around to zero.
377 +
378 + The associated timeticks schema node must be specified
379 + in the description of any schema node using this type.
380 +
381 + In the value set and its semantics, this type is equivalent
382 + to the TimeStamp textual convention of the SMIv2.";
383 + reference
384 + "RFC 2579: Textual Conventions for SMIv2";
385 + }
386 +
387 + /*** collection of generic address types ***/
388 +
389 + typedef phys-address {
390 + type string {
391 + pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
392 + }
393 +
394 +
395 +
396 +
397 + description
398 + "Represents media- or physical-level addresses represented
399 + as a sequence octets, each octet represented by two hexadecimal
400 + numbers. Octets are separated by colons. The canonical
401 + representation uses lowercase characters.
402 +
403 + In the value set and its semantics, this type is equivalent
404 + to the PhysAddress textual convention of the SMIv2.";
405 + reference
406 + "RFC 2579: Textual Conventions for SMIv2";
407 + }
408 +
409 + typedef mac-address {
410 + type string {
411 + pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
412 + }
413 + description
414 + "The mac-address type represents an IEEE 802 MAC address.
415 + The canonical representation uses lowercase characters.
416 +
417 + In the value set and its semantics, this type is equivalent
418 + to the MacAddress textual convention of the SMIv2.";
419 + reference
420 + "IEEE 802: IEEE Standard for Local and Metropolitan Area
421 + Networks: Overview and Architecture
422 + RFC 2579: Textual Conventions for SMIv2";
423 + }
424 +
425 + /*** collection of XML-specific types ***/
426 +
427 + typedef xpath1.0 {
428 + type string;
429 + description
430 + "This type represents an XPATH 1.0 expression.
431 +
432 + When a schema node is defined that uses this type, the
433 + description of the schema node MUST specify the XPath
434 + context in which the XPath expression is evaluated.";
435 + reference
436 + "XPATH: XML Path Language (XPath) Version 1.0";
437 + }
438 +
439 + /*** collection of string types ***/
440 +
441 + typedef hex-string {
442 + type string {
443 + pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
444 + }
445 + description
446 + "A hexadecimal string with octets represented as hex digits
447 + separated by colons. The canonical representation uses
448 + lowercase characters.";
449 + }
450 +
451 + typedef uuid {
452 + type string {
453 + pattern '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-'
454 + + '[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
455 + }
456 + description
457 + "A Universally Unique IDentifier in the string representation
458 + defined in RFC 4122. The canonical representation uses
459 + lowercase characters.
460 +
461 + The following is an example of a UUID in string representation:
462 + f81d4fae-7dec-11d0-a765-00a0c91e6bf6
463 + ";
464 + reference
465 + "RFC 4122: A Universally Unique IDentifier (UUID) URN
466 + Namespace";
467 + }
468 +
469 + typedef dotted-quad {
470 + type string {
471 + pattern
472 + '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
473 + + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
474 + }
475 + description
476 + "An unsigned 32-bit number expressed in the dotted-quad
477 + notation, i.e., four octets written as decimal numbers
478 + and separated with the '.' (full stop) character.";
479 + }
480 +}