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 1603 additions and 0 deletions
......@@ -79,6 +79,7 @@
<module>tetopology</module>
<module>rabbitmq</module>
<module>learning-switch</module>
<module>tenbi</module>
</modules>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2016-present Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
<version>1.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-tenbi</artifactId>
<packaging>pom</packaging>
<modules>
<module>topology</module>
<module>yangmodel</module>
<module>utils</module>
</modules>
<description>TE YANG NBI Application</description>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2015 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<app name="org.onosproject.tenbi.topology" origin="HUAWEI" version="${project.version}"
featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
features="${project.artifactId}">
<description>${project.description}</description>
<artifact>mvn:${project.groupId}/${project.artifactId}/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-tenbi-yangmodel/${project.version}</artifact>
</app>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ Copyright 2015 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
<repository>mvn:${project.groupId}/onos-app-tenbi-yangmodel/${project.version}/xml/features</repository>
<feature name="${project.artifactId}" version="${project.version}" description="${project.description}">
<feature>onos-api</feature>
<feature>onos-app-tenbi-yangmodel</feature>
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-tetopology/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-yms-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-tenbi-utils/${project.version}</bundle>
</feature>
</features>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2016 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-tenbi</artifactId>
<version>1.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-tenbi-topology</artifactId>
<packaging>bundle</packaging>
<description>IETF TE Topology NBI</description>
<properties>
<onos.app.name>tenbi.topology</onos.app.name>
<onos.app.origin>HUAWEI</onos.app.origin>
</properties>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-tenbi-yangmodel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-tenbi-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-tetopology</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-yms-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.tenbi.topology.impl;
import static com.google.common.base.Preconditions.checkNotNull;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.event.AbstractListenerManager;
import org.onosproject.tetopology.management.api.TeTopologyService;
import org.onosproject.teyang.api.OperationType;
import org.onosproject.teyang.utils.topology.NetworkConverter;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetwork;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetworkOpParam;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetworkService;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.Networks;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NetworksState;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.IetfNetworkTopology;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
.IetfNetworkTopologyOpParam;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
.IetfNetworkTopologyService;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.IetfTeTopology;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.IetfTeTopologyOpParam;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
.IetfTeTopologyService;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
.ietftetopology.IetfTeTopologyEvent;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
.ietftetopology.IetfTeTopologyEventListener;
import org.onosproject.yms.ymsm.YmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The IETF TE Topology NBI Manager implementation.
*/
@Component(immediate = true)
@Service
public class TeTopologyNbiManager
extends AbstractListenerManager<IetfTeTopologyEvent, IetfTeTopologyEventListener>
implements IetfNetworkService, IetfNetworkTopologyService, IetfTeTopologyService {
private final Logger log = LoggerFactory.getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected TeTopologyService teTopologyService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected YmsService ymsService;
@Activate
protected void activate() {
// Register 3 services with YMS.
ymsService.registerService(this, IetfNetworkService.class, null);
ymsService.registerService(this, IetfNetworkTopologyService.class, null);
ymsService.registerService(this, IetfTeTopologyService.class, null);
log.info("Started");
}
@Deactivate
protected void deactivate() {
// Unregister 3 services.
ymsService.unRegisterService(this, IetfNetworkService.class);
ymsService.unRegisterService(this, IetfNetworkTopologyService.class);
ymsService.unRegisterService(this, IetfTeTopologyService.class);
log.info("Stopped");
}
@Override
public IetfNetwork getIetfNetwork(IetfNetworkOpParam ietfNetwork) {
log.info("getIetfNetwork: input {}", ietfNetwork);
checkNotNull(ietfNetwork, "getIetfNetwork: ietfNetwork cannot be null");
// Get the entire data tree from TE Subsystem core.
org.onosproject.tetopology.management.api.Networks teNetworks = teTopologyService.getNetworks();
// Convert the TE Subsystem core data into YANG Objects.
Networks networks = NetworkConverter.teSubsystem2YangNetworks(teNetworks, OperationType.QUERY);
NetworksState networkStates = NetworkConverter.teSubsystem2YangNetworkStates(teNetworks, OperationType.QUERY);
IetfNetworkOpParam.IetfNetworkBuilder builder = new IetfNetworkOpParam.IetfNetworkBuilder();
IetfNetwork newNetwork = builder.networks(networks)
.networksState(networkStates)
.onosYangNodeOperationType(IetfNetworkOpParam.OnosYangNodeOperationType.NONE)
.build();
// processSubtreeFiltering() filters the entire data tree based on the
// user's query and returns the filtered data.
return ietfNetwork.processSubtreeFiltering(newNetwork, false);
}
@Override
public void setIetfNetwork(IetfNetworkOpParam ietfNetwork) {
// In H release, topology is discovered from south, no NBI Set is supported.
}
@Override
public IetfTeTopology getIetfTeTopology(IetfTeTopologyOpParam ietfTeTopology) {
// unused method.
return ietfTeTopology;
}
@Override
public void setIetfTeTopology(IetfTeTopologyOpParam ietfTeTopology) {
// unused methods.
}
@Override
public IetfTeTopology getAugmentedIetfTeTopologyTeLinkEvent(IetfTeTopologyOpParam ietfTeTopology) {
// unused methods.
return ietfTeTopology;
}
@Override
public void setAugmentedIetfTeTopologyTeLinkEvent(IetfTeTopologyOpParam augmentedIetfTeTopologyTeLinkEvent) {
// unused methods.
}
@Override
public IetfNetworkTopology getIetfNetworkTopology(IetfNetworkTopologyOpParam ietfNetworkTopology) {
// unused methods.
return ietfNetworkTopology;
}
@Override
public void setIetfNetworkTopology(IetfNetworkTopologyOpParam ietfNetworkTopology) {
// unused methods.
}
@Override
public IetfNetwork getAugmentedIetfNetworkNetworks(IetfNetworkOpParam ietfNetwork) {
// unused methods.
return ietfNetwork;
}
@Override
public void setAugmentedIetfNetworkNetworks(IetfNetworkOpParam augmentedIetfNetworkNetworks) {
// unused methods.
}
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The implementations of IETF TE Topology YANG NBI.
*/
package org.onosproject.tenbi.topology.impl;
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2016 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-tenbi</artifactId>
<version>1.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-tenbi-utils</artifactId>
<packaging>bundle</packaging>
<description>IETF TE NBI Utilities</description>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-tenbi-yangmodel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-tetopology</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.teyang.api;
/**
* The operation type.
*/
public enum OperationType {
/**
* The configuration data identified by the element
* containing this attribute is merged with the configuration
* at the corresponding level in the configuration datastore.
*/
MERGE,
/**
* The configuration data identified by the element
* containing this attribute replaces any related configuration
* in the configuration datastore. If no such configuration
* data exists in the configuration datastore, it is created.
*/
REPLACE,
/**
* The configuration data identified by the element
* containing this attribute is added to the configuration if
* and only if the configuration data does not already exist in
* the configuration datastore. If the configuration data
* exists, an error is returned.
*/
CREATE,
/**
* The configuration data identified by the element
* containing this attribute is deleted from the configuration
* if and only if the configuration data currently exists in
* the configuration datastore. If the configuration data does
* not exist, an error is returned".
*/
DELETE,
/**
* The configuration data identified by the element
* containing this attribute is deleted from the configuration
* if the configuration data currently exists in the
* configuration datastore. If the configuration data does not
* exist, the "remove" operation is silently ignored by the
* server.
*/
REMOVE,
/**
* The node is used as a containment node to reach the child node,
* There is no change in the data store for the values of this node in the
* edit request.
*/
NONE,
// /**
// * The YANG based request is to edit a config node / subtree in the data
// * store.
// */
// EDIT_CONFIG,
//
// /**
// * The YANG based request is to query a config node / subtree in the data
// * store.
// */
// QUERY_CONFIG,
//
/**
* The YANG based request is to query a node / subtree in the data store.
*/
QUERY,
// /**
// * The YANG based request is to execute an RPC defined in YANG.
// */
// RPC,
//
// /**
// * The YANG based request is to execute an RPC defined in YANG.
// */
// NOTIFICATION
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The utility APIs.
*/
package org.onosproject.teyang.api;
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.teyang.utils.topology;
import org.onosproject.tetopology.management.api.node.TeStatus;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeAdminStatus;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeOperStatus;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.teadminstatus.TeAdminStatusEnum;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.teoperstatus.TeOperStatusEnum;
/**
* The Enum conversion functions.
*/
public final class EnumConverter {
// no instantiation
private EnumConverter() {
}
/**
* Converts YANG Operation Status Enum to TE Topology TeStatus Enum.
*
* @param opStatus YANG Operation Status
* @return the equivalent Enum from TE Topology TeStatus or null if not
* found
*/
public static TeStatus yang2TeSubsystemOpStatus(TeOperStatus opStatus) {
switch (opStatus.enumeration()) {
case DOWN:
return TeStatus.DOWN;
case UP:
return TeStatus.UP;
case MAINTENANCE:
return TeStatus.MAINTENANCE;
case PREPARING_MAINTENANCE:
return TeStatus.PREPARING_MAINTENANCE;
case TESTING:
return TeStatus.TESTING;
case UNKNOWN:
return TeStatus.UNKNOWN;
default:
return null;
}
}
/**
* Converts YANG TeAdminStatus Enum to TE Topology TeStatus Enum.
*
* @param adminStatus YANG Admin Status
* @return the equivalent Enum from TE Topology TeStatus or null if not
* found
*/
public static TeStatus yang2TeSubsystemAdminStatus(TeAdminStatus adminStatus) {
switch (adminStatus.enumeration()) {
case DOWN:
return TeStatus.DOWN;
case UP:
return TeStatus.UP;
case TESTING:
return TeStatus.TESTING;
case MAINTENANCE:
return TeStatus.MAINTENANCE;
case PREPARING_MAINTENANCE:
return TeStatus.PREPARING_MAINTENANCE;
default:
return TeStatus.UNKNOWN;
}
}
/**
* Converts TE Topology TeStatus Enum to YANG TeAdminStatus Enum.
*
* @param adminStatus TE Topology admin status
* @return the equivalent Enum from YANG TeAdminStatus or null if not found
*/
public static TeAdminStatus teSubsystem2YangAdminStatus(TeStatus adminStatus) {
switch (adminStatus) {
case DOWN:
return TeAdminStatus.of(TeAdminStatusEnum.DOWN);
case UP:
return TeAdminStatus.of(TeAdminStatusEnum.UP);
case TESTING:
return TeAdminStatus.of(TeAdminStatusEnum.TESTING);
case MAINTENANCE:
return TeAdminStatus.of(TeAdminStatusEnum.MAINTENANCE);
case PREPARING_MAINTENANCE:
return TeAdminStatus.of(TeAdminStatusEnum.PREPARING_MAINTENANCE);
case UNKNOWN:
return null;
default:
return null;
}
}
/**
* Converts TE Topology TeStatus Enum to YANG TeOperStatus Enum.
*
* @param opStatus TE Topology operation status
* @return the equivalent Enum from YANG TeOperStatus or null if not found
*/
public static TeOperStatus teSubsystem2YangOperStatus(TeStatus opStatus) {
switch (opStatus) {
case DOWN:
return TeOperStatus.of(TeOperStatusEnum.DOWN);
case UP:
return TeOperStatus.of(TeOperStatusEnum.UP);
case TESTING:
return TeOperStatus.of(TeOperStatusEnum.TESTING);
case MAINTENANCE:
return TeOperStatus.of(TeOperStatusEnum.MAINTENANCE);
case PREPARING_MAINTENANCE:
return TeOperStatus.of(TeOperStatusEnum.PREPARING_MAINTENANCE);
case UNKNOWN:
return TeOperStatus.of(TeOperStatusEnum.UNKNOWN);
default:
return null;
}
}
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The utilities for conversions between TE Topology core subsystem and
* IETF TE Topology Yang generated Java code.
*/
package org.onosproject.teyang.utils.topology;
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.teyang.utils.topology;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.onosproject.teyang.api.OperationType;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network
.rev20151208.ietfnetwork.networks.Network;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology.networks.network.node.AugmentedNwNode;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeAdminStatus;
import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.teadminstatus.TeAdminStatusEnum;
/**
* Unit tests for converter functions.
*/
public class ConverterTest {
Network output;
@Before
public void setUp() {
output = NetworkConverter.teSubsystem2YangNetwork(
DefaultBuilder.sampleTeSubsystemNetworkBuilder(),
OperationType.NONE);
}
@Test
public void basics() {
assertEquals("Wrong networkId",
output.networkId().uri().string(),
"HUAWEI_NETWORK_NEW");
assertEquals("Wrong 1st nodeId",
output.node().get(0).nodeId().uri().string(),
"HUAWEI_ROADM_1");
assertEquals("Wrong 2dn nodeId",
output.node().get(1).nodeId().uri().string(),
"HUAWEI_ROADM_2");
AugmentedNwNode augmentedNode = (AugmentedNwNode) output.node().get(0)
.yangAugmentedInfo(AugmentedNwNode.class);
assertEquals("Wrong adminStatus",
augmentedNode.te().config().teNodeAttributes().adminStatus(),
TeAdminStatus.of(TeAdminStatusEnum.UP));
}
}
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.teyang.utils.topology;
import java.math.BigInteger;
import java.util.List;
import org.onosproject.tetopology.management.api.DefaultNetwork;
import org.onosproject.tetopology.management.api.DefaultNetworks;
import org.onosproject.tetopology.management.api.KeyId;
import org.onosproject.tetopology.management.api.Network;
import org.onosproject.tetopology.management.api.Networks;
import org.onosproject.tetopology.management.api.TeTopologyId;
import org.onosproject.tetopology.management.api.link.DefaultNetworkLink;
import org.onosproject.tetopology.management.api.link.LinkProtectionType;
import org.onosproject.tetopology.management.api.link.NetworkLink;
import org.onosproject.tetopology.management.api.link.TeLink;
import org.onosproject.tetopology.management.api.link.TeLinkAccessType;
import org.onosproject.tetopology.management.api.node.ConnectivityMatrix;
import org.onosproject.tetopology.management.api.node.DefaultNetworkNode;
import org.onosproject.tetopology.management.api.node.DefaultTerminationPoint;
import org.onosproject.tetopology.management.api.node.NetworkNode;
import org.onosproject.tetopology.management.api.node.TeNetworkTopologyId;
import org.onosproject.tetopology.management.api.node.TeNode;
import org.onosproject.tetopology.management.api.node.TeStatus;
import org.onosproject.tetopology.management.api.node.TerminationPoint;
import org.onosproject.tetopology.management.api.node.TerminationPointKey;
import com.google.common.collect.Lists;
/**
* Builds a sample Topology, which consists of two Nodes, one link,
* and each node has two termination points.
*/
public final class DefaultBuilder {
private static final String HUAWEI_NETWORK_NEW = "HUAWEI_NETWORK_NEW";
private static final String HUAWEI_ROADM_1 = "HUAWEI_ROADM_1";
private static final String CLIENT1_NODE1 = "CLIENT1_NODE1";
private static final String LINE1_NODE1 = "LINE1_NODE1";
private static final String NODE1_IP = "10.11.12.33";
private static final String HUAWEI_ROADM_2 = "HUAWEI_ROADM_2";
private static final String CLIENT1_NODE2 = "CLIENT1_NODE2";
private static final String LINE1_NODE2 = "LINE1_NODE2";
private static final String NODE2_IP = "10.11.12.34";
private static final String LINK1FORNETWORK1 = "LINK1FORNETWORK1";
private static final String HUAWEI_TE_TOPOLOGY_NEW = "HUAWEI_TE_TOPOLOGY_NEW";
// no instantiation
private DefaultBuilder() {
}
/**
* Returns a sample TeSubsystem Networks object.
*
* @return the Networks object
*/
public static Networks sampleTeSubsystemNetworksBuilder() {
DefaultNetworks defaultNetworks = new DefaultNetworks();
List<Network> networks = Lists.newArrayList();
networks.add(sampleTeSubsystemNetworkBuilder());
defaultNetworks.setNetworks(networks);
return defaultNetworks;
}
/**
* Returns a sample TeSubsystem Network object.
*
* @return the Network object
*/
public static Network sampleTeSubsystemNetworkBuilder() {
DefaultNetwork huaweiNetworkNew = new DefaultNetwork(KeyId.keyId(HUAWEI_NETWORK_NEW));
huaweiNetworkNew.setServerProvided(true);
List<NetworkNode> nodes = Lists.newArrayList();
DefaultNetworkNode node1 = new DefaultNetworkNode(KeyId.keyId(HUAWEI_ROADM_1));
DefaultTerminationPoint tp11 = new DefaultTerminationPoint(KeyId.keyId(CLIENT1_NODE1));
DefaultTerminationPoint tp12 = new DefaultTerminationPoint(KeyId.keyId(LINE1_NODE1));
List<TerminationPoint> tps1 = Lists.newArrayList();
tps1.add(tp11);
tps1.add(tp12);
node1.setTerminationPoints(tps1);
TeNode teNode1 = new TeNode(NODE1_IP);
teNode1.setAdminStatus(TeStatus.UP);
teNode1.setAbstract(false);
ConnectivityMatrix cMatrix1 =
new ConnectivityMatrix(1,
new TerminationPointKey(huaweiNetworkNew.networkId(),
node1.nodeId(), tp11.id()),
new TerminationPointKey(huaweiNetworkNew.networkId(),
node1.nodeId(), tp12.id()),
true);
List<ConnectivityMatrix> connMatrices = Lists.newArrayList();
connMatrices.add(cMatrix1);
teNode1.setConnectivityMatrices(connMatrices);
node1.setTe(teNode1);
DefaultNetworkNode node2 = new DefaultNetworkNode(KeyId.keyId(HUAWEI_ROADM_2));
DefaultTerminationPoint tp21 = new DefaultTerminationPoint(KeyId.keyId(CLIENT1_NODE2));
DefaultTerminationPoint tp22 = new DefaultTerminationPoint(KeyId.keyId(LINE1_NODE2));
List<TerminationPoint> tps2 = Lists.newArrayList();
tps2.add(tp21);
tps2.add(tp22);
node2.setTerminationPoints(tps2);
TeNode teNode2 = new TeNode(NODE2_IP);
teNode1.setAdminStatus(TeStatus.UP);
teNode1.setAbstract(false);
ConnectivityMatrix cMatrix2 =
new ConnectivityMatrix(1,
new TerminationPointKey(huaweiNetworkNew.networkId(),
node2.nodeId(), tp21.id()),
new TerminationPointKey(huaweiNetworkNew.networkId(),
node2.nodeId(), tp22.id()),
true);
List<ConnectivityMatrix> connMatrices2 = Lists.newArrayList();
connMatrices.add(cMatrix2);
teNode1.setConnectivityMatrices(connMatrices2);
node2.setTe(teNode2);
nodes.add(node1);
nodes.add(node2);
huaweiNetworkNew.setNodes(nodes);
List<NetworkLink> links = Lists.newArrayList();
DefaultNetworkLink link1 = new DefaultNetworkLink(KeyId.keyId(LINK1FORNETWORK1));
link1.setSource(new TerminationPointKey(huaweiNetworkNew.networkId(),
node1.nodeId(),
tp11.id()));
link1.setDestination(new TerminationPointKey(huaweiNetworkNew.networkId(),
node2.nodeId(),
tp21.id()));
TeLink teLink1 = new TeLink(BigInteger.valueOf(1));
teLink1.setIsAbstract(false);
teLink1.setAdminStatus(TeStatus.UP);
teLink1.setAccessType(TeLinkAccessType.POINT_TO_POINT);
teLink1.setLinkProtectionType(LinkProtectionType.UNPROTECTED);
List<Long> teSrlgs = Lists.newArrayList();
teSrlgs.add(1000L);
teSrlgs.add(2000L);
teLink1.setTeSrlgs(teSrlgs);
link1.setTe(teLink1);
links.add(link1);
huaweiNetworkNew.setLinks(links);
TeNetworkTopologyId teNetwork =
new TeNetworkTopologyId(new TeTopologyId(22222L, 44444L, HUAWEI_TE_TOPOLOGY_NEW));
huaweiNetworkNew.setTeTopologyId(teNetwork.getTopologyId());
return huaweiNetworkNew;
}
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The topology utilities test functions.
*
*/
package org.onosproject.teyang.utils.topology;
COMPILE = [
'//lib:guava',
]
#yang_library(
# deps = COMPILE,
# name = 'onos-app-tenbi-yangmodel',
# srcs = glob(['src/main/**/*.yang']),
#)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ Copyright 2015 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="@PROJECT-ARTIFACTID-@ONOS-VERSION" >
<feature name="@PROJECT-ARTIFACTID" version="@ONOS-VERSION"
description="@PROJECT-DESCRIPTION" >
<bundle>mvn:@PROJECT-GROUPID/@PROJECT-ARTIFACTID/@ONOS-VERSION</bundle>
</feature>
</features>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2016 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-tenbi</artifactId>
<version>1.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-tenbi-yangmodel</artifactId>
<packaging>bundle</packaging>
<description>IETF TE YANG models</description>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-yang-maven-plugin</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-yang-datamodel</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.onosproject</groupId>
<artifactId>onos-yang-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<goals>
<goal>yang2java</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${pom.basedir}/features.xml</file>
<outputFile>${pom.basedir}/target/features.xml</outputFile>
<replacements>
<replacement>
<token>@ONOS-VERSION</token>
<value>${project.version}</value>
</replacement>
<replacement>
<token>@PROJECT-GROUPID</token>
<value>${project.groupId}</value>
</replacement>
<replacement>
<token>@PROJECT-ARTIFACTID</token>
<value>${project.artifactId}</value>
</replacement>
<replacement>
<token>@PROJECT-DESCRIPTION</token>
<value>${project.description}</value>
</replacement>
<replacement>
<token>@FEATURE-VERSION</token>
<value>${project.version}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>target/features.xml</file>
<type>xml</type>
<classifier>features</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This diff is collapsed. Click to expand it.
module ietf-network-topology {
// yang-version 1.1;
yang-version 1;
namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
prefix lnk;
import ietf-inet-types {
prefix inet;
}
import ietf-network {
prefix nd;
}
organization
"IETF I2RS (Interface to the Routing System) Working Group";
contact
"WG Web: <http: tools.ietf.org/wg/i2rs/>
WG List: <mailto:i2rs@ietf.org>
WG Chair: Susan Hares
<mailto:shares@ndzh.com>
WG Chair: Jeffrey Haas
<mailto:jhaas@pfrc.org>
Editor: Alexander Clemm
<mailto:alex@cisco.com>
Editor: Jan Medved
<mailto:jmedved@cisco.com>
Editor: Robert Varga
<mailto:rovarga@cisco.com>
Editor: Tony Tkacik
<mailto:ttkacik@cisco.com>
Editor: Nitin Bahadur
<mailto:nitin_bahadur@yahoo.com>
Editor: Hariharan Ananthakrishnan
<mailto:hari@packetdesign.com>";
description
"This module defines a common base model for network topology,
augmenting the base network model with links to connect nodes,
as well as termination points to terminate links on nodes.
Copyright (c) 2015 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD License
set forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(http: trustee.ietf.org/license-info).
This version of this YANG module is part of
draft-ietf-i2rs-yang-network-topo-02;
see the RFC itself for full legal notices.
NOTE TO RFC EDITOR: Please replace above reference to
draft-ietf-i2rs-yang-network-topo-02 with RFC
number when published (i.e. RFC xxxx).";
revision 2015-12-08 {
description
"Initial revision.
NOTE TO RFC EDITOR: Please replace the following reference
to draft-ietf-i2rs-yang-network-topo-02 with
RFC number when published (i.e. RFC xxxx).";
reference
"draft-ietf-i2rs-yang-network-topo-02.";
}
typedef link-id {
type inet:uri;
description
"An identifier for a link in a topology.
The identifier SHOULD be chosen such that the same link in a
real network topology will always be identified through the
same identifier, even if the model is instantiated in
separate datastores. An implementation MAY choose to capture
semantics in the identifier, for example to indicate the type
of link and/or the type of topology that the link is a part
of.";
}
typedef tp-id {
type inet:uri;
description
"An identifier for termination points on a node.
The identifier SHOULD be chosen such that the same TP in a
real network topology will always be identified through the
same identifier, even if the model is instantiated in
separate datastores. An implementation MAY choose to capture
semantics in the identifier, for example to indicate the type
of TP and/or the type of node and topology that the TP is a
part of.";
}
grouping link-ref {
description
"References a link in a specific network.";
leaf link-ref {
type leafref {
path "/nd:networks/nd:network[nd:network-id=current()/../"+
"network-ref]/lnk:link/lnk:link-id";
require-instance false;
}
description
"A type for an absolute reference a link instance.
(This type should not be used for relative references.
In such a case, a relative path should be used instead.)";
}
uses nd:network-ref;
}
grouping tp-ref {
description
"References a termination point in a specific node.";
leaf tp-ref {
type leafref {
path "/nd:networks/nd:network[nd:network-id=current()/../"+
"network-ref]/nd:node[nd:node-id=current()/../"+
"node-ref]/lnk:termination-point/lnk:tp-id";
require-instance false;
}
description
"A type for an absolute reference to a termination point.
(This type should not be used for relative references.
In such a case, a relative path should be used instead.)";
}
uses nd:node-ref;
}
augment "/nd:networks/nd:network" {
description
"Add links to the network model.";
list link {
key "link-id";
description
"A Network Link connects a by Local (Source) node and
a Remote (Destination) Network Nodes via a set of the
nodes' termination points.
As it is possible to have several links between the same
source and destination nodes, and as a link could
potentially be re-homed between termination points, to
ensure that we would always know to distinguish between
links, every link is identified by a dedicated link
identifier.
Note that a link models a point-to-point link, not a
multipoint link.
Layering dependencies on links in underlay topologies are
not represented as the layering information of nodes and of
termination points is sufficient.";
container source {
description
"This container holds the logical source of a particular
link.";
leaf source-node {
type leafref {
path "../../../nd:node/nd:node-id";
}
mandatory true;
description
"Source node identifier, must be in same topology.";
}
leaf source-tp {
type leafref {
path "../../../nd:node[nd:node-id=current()/../"+
"source-node]/termination-point/tp-id";
}
description
"Termination point within source node that terminates
the link.";
}
}
container destination {
description
"This container holds the logical destination of a
particular link.";
leaf dest-node {
type leafref {
path "../../../nd:node/nd:node-id";
}
mandatory true;
description
"Destination node identifier, must be in the same
network.";
}
leaf dest-tp {
type leafref {
path "../../../nd:node[nd:node-id=current()/../"+
"dest-node]/termination-point/tp-id";
}
description
"Termination point within destination node that
terminates the link.";
}
}
leaf link-id {
type link-id;
description
"The identifier of a link in the topology.
A link is specific to a topology to which it belongs.";
}
list supporting-link {
key "network-ref link-ref";
description
"Identifies the link, or links, that this link
is dependent on.";
leaf network-ref {
type leafref {
path "../../../nd:supporting-network/nd:network-ref";
require-instance false;
}
description
"This leaf identifies in which underlay topology
supporting link is present.";
}
leaf link-ref {
type leafref {
path "/nd:networks/nd:network[nd:network-id=current()/"+
"../network-ref]/link/link-id";
require-instance false;
}
description
"This leaf identifies a link which is a part
of this link's underlay. Reference loops, in which
a link identifies itself as its underlay, either
directly or transitively, are not allowed.";
}
}
}
}
augment "/nd:networks/nd:network/nd:node" {
description
"Augment termination points which terminate links.
Termination points can ultimately be mapped to interfaces.";
list termination-point {
key "tp-id";
description
"A termination point can terminate a link.
Depending on the type of topology, a termination point
could, for example, refer to a port or an interface.";
leaf tp-id {
type tp-id;
description
"Termination point identifier.";
}
list supporting-termination-point {
key "network-ref node-ref tp-ref";
description
"The leaf list identifies any termination points that
the termination point is dependent on, or maps onto.
Those termination points will themselves be contained
in a supporting node.
This dependency information can be inferred from
the dependencies between links. For this reason,
this item is not separately configurable. Hence no
corresponding constraint needs to be articulated.
The corresponding information is simply provided by the
implementing system.";
leaf network-ref {
type leafref {
path "../../../nd:supporting-node/nd:network-ref";
require-instance false;
}
description
"This leaf identifies in which topology the
supporting termination point is present.";
}
leaf node-ref {
type leafref {
path "../../../nd:supporting-node/nd:node-ref";
require-instance false;
}
description
"This leaf identifies in which node the supporting
termination point is present.";
}
leaf tp-ref {
type leafref {
path "/nd:networks/nd:network[nd:network-id=current()/"+
"../network-ref]/nd:node[nd:node-id=current()/../"+
"node-ref]/termination-point/tp-id";
require-instance false;
}
description
"Reference to the underlay node, must be in a
different topology";
}
}
}
}
}
module ietf-network {
// yang-version 1.1;
yang-version 1;
namespace "urn:ietf:params:xml:ns:yang:ietf-network";
prefix nd;
import ietf-inet-types {
prefix inet;
}
organization
"IETF I2RS (Interface to the Routing System) Working Group";
contact
"WG Web: <http: tools.ietf.org/wg/i2rs/>
WG List: <mailto:i2rs@ietf.org>
WG Chair: Susan Hares
<mailto:shares@ndzh.com>
WG Chair: Jeffrey Haas
<mailto:jhaas@pfrc.org>
Editor: Alexander Clemm
<mailto:alex@cisco.com>
Editor: Jan Medved
<mailto:jmedved@cisco.com>
Editor: Robert Varga
<mailto:rovarga@cisco.com>
Editor: Tony Tkacik
<mailto:ttkacik@cisco.com>
Editor: Nitin Bahadur
<mailto:nitin_bahadur@yahoo.com>
Editor: Hariharan Ananthakrishnan
<mailto:hari@packetdesign.com>";
description
"This module defines a common base model for a collection
of nodes in a network. Node definitions are further used
in network topologies and inventories.
Copyright (c) 2015 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD License
set forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(http: trustee.ietf.org/license-info).
This version of this YANG module is part of
draft-ietf-i2rs-yang-network-topo-02;
see the RFC itself for full legal notices.
NOTE TO RFC EDITOR: Please replace above reference to
draft-ietf-i2rs-yang-network-topo-02 with RFC
number when published (i.e. RFC xxxx).";
revision 2015-12-08 {
description
"Initial revision.
NOTE TO RFC EDITOR: Please replace the following reference
to draft-ietf-i2rs-yang-network-topo-02 with
RFC number when published (i.e. RFC xxxx).";
reference
"draft-ietf-i2rs-yang-network-topo-02";
}
typedef node-id {
type inet:uri;
description
"Identifier for a node.";
}
typedef network-id {
type inet:uri;
description
"Identifier for a network.";
}
grouping network-ref {
description
"Contains the information necessary to reference a network,
for example an underlay network.";
leaf network-ref {
type leafref {
path "/nd:networks/nd:network/nd:network-id";
require-instance false;
}
description
"Used to reference a network, for example an underlay
network.";
}
}
grouping node-ref {
description
"Contains the information necessary to reference a node.";
leaf node-ref {
type leafref {
path "/nd:networks/nd:network[nd:network-id=current()/../"+
"network-ref]/nd:node/nd:node-id";
require-instance false;
}
description
"Used to reference a node.
Nodes are identified relative to the network they are
contained in.";
}
uses network-ref;
}
container networks {
description
"Serves as top-level container for a list of networks.";
list network {
key "network-id";
description
"Describes a network.
A network typically contains an inventory of nodes,
topological information (augmented through
network-topology model), as well as layering
information.";
container network-types {
description
"Serves as an augmentation target.
The network type is indicated through corresponding
presence containers augmented into this container.";
}
leaf network-id {
type network-id;
description
"Identifies a network.";
}
list supporting-network {
key "network-ref";
description
"An underlay network, used to represent layered network
topologies.";
leaf network-ref {
type leafref {
path "/networks/network/network-id";
require-instance false;
}
description
"References the underlay network.";
}
}
list node {
key "node-id";
description
"The inventory of nodes of this network.";
leaf node-id {
type node-id;
description
"Identifies a node uniquely within the containing
network.";
}
list supporting-node {
key "network-ref node-ref";
description
"Represents another node, in an underlay network, that
this node is supported by. Used to represent layering
structure.";
leaf network-ref {
type leafref {
path "../../../supporting-network/network-ref";
require-instance false;
}
description
"References the underlay network that the
underlay node is part of.";
}
leaf node-ref {
type leafref {
path "/networks/network/node/node-id";
require-instance false;
}
description
"References the underlay node itself.";
}
}
}
}
}
container networks-state {
config false;
description
"Serves as top-level container for a list of state information
for networks";
list network {
key "network-ref";
description
"Data nodes representing operational data and state of
networks.
An instance is automatically created for every network
in the corresponding list under the networks container.";
uses network-ref;
leaf server-provided {
type boolean;
description
"Indicates whether the information concerning this
particular network is populated by the server
(server-provided true, the general case for network
information discovered from the server),
or whether it is configured by a client
(server-provided true, possible e.g. for
service overlays managed through a controller).";
}
}
}
}
module ietf-schedule {
yang-version 1;
namespace "urn:ietf:params:xml:ns:yang:ietf-schedule";
// replace with IANA namespace when assigned
prefix "sch";
import ietf-yang-types {
prefix "yang";
}
organization "TBD";
contact "TBD";
description
"The model allows time scheduling parameters to be specified.";
revision "2015-10-08" {
description "Initial revision";
reference "TBD";
}
/*
* Groupings
*/
grouping schedules {
description
"A list of schedules defining when a particular
configuration takes effect.";
container schedules {
list schedule {
key "schedule-id";
description "A list of schedule elements.";
leaf schedule-id {
type uint32;
description "Identifies the schedule element.";
}
leaf start {
type yang:date-and-time;
description "Start time.";
}
leaf schedule-duration {
type string {
pattern
'P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?(\d+S)?';
}
description "Schedule duration in ISO 8601 format.";
}
leaf repeat-interval {
type string {
pattern
'R\d*/P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?'
+ '(\d+S)?';
}
description "Repeat interval in ISO 8601 format.";
}
}
}
} // schedules
}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.