Aihua Guo
Committed by Gerrit Code Review

API definitions for the TE Topology Core App.

This APP creates and manages a hierarchy of TE topologies received from SBI TE provider and from user configurations from NBI.
The API contains internal data structures for TE attributes that are aligned with the TE attributes definition in standard IETF YANG TE topology model (https://tools.ietf.org/html/draft-ietf-teas-yang-te-topo-05).

This commit includes the following interface definitions:
- TE topology provider service, which is called by the TE topology provider from SB to pass TE topologies to the TE topology core APP
- TE topology service, which provides service APIs for an external APP to get/set TE topologies and their attributes.
- Network, Node, Link definitions for TE networks and their default class implementation

Change-Id: Iafcf6911b8d9e494397e3a255cae282bbca74d5c
Showing 58 changed files with 4872 additions and 0 deletions
......@@ -76,6 +76,7 @@
<module>scalablegateway</module>
<module>bmv2-demo</module>
<module>yms</module>
<module>tetopology</module>
<module>rabbitmq</module>
<module>learning-switch</module>
</modules>
......
COMPILE_DEPS = [
'//lib:CORE_DEPS',
]
osgi_jar_with_tests (
deps = COMPILE_DEPS,
)
onos_app (
title = 'TE Topology Core App',
category = 'Traffic Steering',
url = 'http://onosproject.org',
description = 'Application to create and manage hierarchical TE topologies.',
)
<?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.tetopology" 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>
</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}">
<feature name="${project.artifactId}" version="${project.version}"
description="${project.description}">
<feature>onos-api</feature>
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
</feature>
</features>
<?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-tetopology</artifactId>
<version>1.8.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<description>IETF TE Management</description>
<properties>
<onos.app.name>org.onosproject.tetopology</onos.app.name>
<onos.app.category>Application</onos.app.category>
<onos.app.url>http://onosproject.org</onos.app.url>
<onos.app.readme>IETF TE Management.</onos.app.readme>
<!-- onos.app.requires>com.huawei.tsdn.yang</onos.app.requires -->
</properties>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-core-serializers</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-osgi</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-api</artifactId>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-incubator-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-misc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-core-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-core-common</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</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.tetopology.management.api;
import java.util.List;
import org.onosproject.tetopology.management.api.link.NetworkLink;
import org.onosproject.tetopology.management.api.node.NetworkNode;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Default Network implementation.
* <p>
* The Set/Get methods below are defined to accept and pass references because
* the object class is treated as a "composite" object class that holds
* references to various member objects and their relationships, forming a
* data tree. Internal routines of the TE topology manager may use the
* following example methods to construct and manipulate any piece of data in
* the data tree:
* <pre>
* newNode.getTe().setAdminStatus(), or
* newNode.getSupportingNodeIds().add(nodeId), etc.
* </pre>
* Same for constructors where, for example, a child list may be constructed
* first and passed in by reference to its parent object constructor.
*/
public class DefaultNetwork implements Network {
private KeyId networkId;
private List<KeyId> supportingNetworkIds;
private List<NetworkNode> nodes;
private List<NetworkLink> links;
private TeTopologyId teTopologyId;
private boolean serverProvided;
/**
* Constructor with all fields.
*
* @param networkId network identifier
* @param supportingNetworkIds supporting network identifier
* @param nodes list of nodes within the network
* @param links list of links within the network
* @param teTopologyId TE topology identifier
* @param serverProvided whether the network is received from server
*/
public DefaultNetwork(KeyId networkId, List<KeyId> supportingNetworkIds,
List<NetworkNode> nodes, List<NetworkLink> links, TeTopologyId teTopologyId,
boolean serverProvided) {
this.networkId = networkId;
this.supportingNetworkIds = supportingNetworkIds;
this.nodes = nodes;
this.links = links;
this.teTopologyId = teTopologyId;
this.serverProvided = serverProvided;
}
/**
* Constructor with key only.
*
* @param networkId network identifier
*/
public DefaultNetwork(KeyId networkId) {
this.networkId = networkId;
}
/**
* Creates an instance of DefaultNetwork from an existing Network object.
*
* @param network network identifier
*/
public DefaultNetwork(Network network) {
this.networkId = network.networkId();
this.supportingNetworkIds = network.getSupportingNetworkIds();
this.nodes = network.getNodes();
this.links = network.getLinks();
this.teTopologyId = network.getTeTopologyId();
this.serverProvided = network.isServerProvided();
}
@Override
public KeyId networkId() {
return networkId;
}
@Override
public List<KeyId> getSupportingNetworkIds() {
return supportingNetworkIds;
}
@Override
public List<NetworkNode> getNodes() {
return nodes;
}
@Override
public NetworkNode getNode(KeyId nodeId) {
for (NetworkNode node : nodes) {
if (node.nodeId().equals(nodeId)) {
return node;
}
}
return null;
}
@Override
public List<NetworkLink> getLinks() {
return links;
}
@Override
public NetworkLink getLink(KeyId linkId) {
for (NetworkLink link : links) {
if (link.linkId().equals(linkId)) {
return link;
}
}
return null;
}
@Override
public boolean isServerProvided() {
return serverProvided;
}
@Override
public TeTopologyId getTeTopologyId() {
return teTopologyId;
}
/**
* Sets the supporting network keys.
*
* @param supportingNetworkIds the supportingNetworkIds to set
*/
public void setSupportingNetworkIds(List<KeyId> supportingNetworkIds) {
this.supportingNetworkIds = supportingNetworkIds;
}
/**
* Sets the list of nodes .
*
* @param nodes the nodes to set
*/
public void setNodes(List<NetworkNode> nodes) {
this.nodes = nodes;
}
/**
* Sets the links.
*
* @param links the links to set
*/
public void setLinks(List<NetworkLink> links) {
this.links = links;
}
/**
* Sets the attribute serverProvided.
*
* @param serverProvided the attribute to set
*/
public void setServerProvided(boolean serverProvided) {
this.serverProvided = serverProvided;
}
/**
* Sets the TE Topology Id.
*
* @param teTopologyId the teTopologyId to set
*/
public void setTeTopologyId(TeTopologyId teTopologyId) {
this.teTopologyId = teTopologyId;
}
@Override
public int hashCode() {
return Objects.hashCode(networkId, supportingNetworkIds,
nodes, links, serverProvided, teTopologyId);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof DefaultNetwork) {
DefaultNetwork that = (DefaultNetwork) object;
return Objects.equal(this.networkId, that.networkId) &&
Objects.equal(this.supportingNetworkIds, that.supportingNetworkIds) &&
Objects.equal(this.nodes, that.nodes) &&
Objects.equal(this.links, that.links) &&
Objects.equal(this.serverProvided, that.serverProvided) &&
Objects.equal(this.teTopologyId, that.teTopologyId);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("networkId", networkId)
.add("supportingNetworkIds", supportingNetworkIds)
.add("nodes", nodes)
.add("links", links)
.add("serverProvided", serverProvided)
.add("teTopologyId", teTopologyId)
.toString();
}
}
/*
* 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.tetopology.management.api;
import java.util.List;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Default Networks implementation.
* <p>
* The Set/Get methods below are defined to accept and pass references because
* the object class is treated as a "composite" object class that holds
* references to various member objects and their relationships, forming a
* data tree. Internal routines of the TE topology manager may use the
* following example methods to construct and manipulate any piece of data in
* the data tree:
* <pre>
* newNode.getTe().setAdminStatus(), or
* newNode.getSupportingNodeIds().add(nodeId), etc.
* </pre>
* Same for constructors where, for example, a child list may be constructed
* first and passed in by reference to its parent object constructor.
*/
public class DefaultNetworks implements Networks, TeTopologyEventSubject {
private List<Network> networks;
/**
* Creates an instance of DefaultNetworks.
*/
public DefaultNetworks() {
}
/**
* Constructor with all fields.
*
* @param networks list of networks
*/
public DefaultNetworks(List<Network> networks) {
this.networks = networks;
}
@Override
public List<Network> networks() {
return networks;
}
/**
* Sets the networks.
*
* @param networks the networks to set
*/
public void setNetworks(List<Network> networks) {
this.networks = networks;
}
@Override
public int hashCode() {
return Objects.hashCode(networks);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof DefaultNetworks) {
DefaultNetworks that = (DefaultNetworks) object;
return Objects.equal(this.networks, that.networks);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("networks", networks)
.toString();
}
}
/*
* 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.tetopology.management.api;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Internal TE Network implementation.
*/
public class InternalTeNetwork extends DefaultNetwork {
private TeTopologyType teTopologyType;
/**
* Constructor with all fields.
*
* @param teTopologyType TE topology type
* @param network network object
*/
public InternalTeNetwork(TeTopologyType teTopologyType, Network network) {
super(network);
this.teTopologyType = teTopologyType;
}
/**
* Returns the TE topoology type.
*
* @return TE topology type
*/
public TeTopologyType getTeTopologyType() {
return this.teTopologyType;
}
@Override
public int hashCode() {
return Objects.hashCode(super.hashCode(), teTopologyType);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof InternalTeNetwork) {
if (!super.equals(object)) {
return false;
}
InternalTeNetwork that = (InternalTeNetwork) object;
return Objects.equal(this.teTopologyType, that.teTopologyType);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("teTopologyType", teTopologyType)
.add("DefaultNetwork", super.toString())
.toString();
}
}
/*
* 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.tetopology.management.api;
import java.net.URI;
import java.util.Objects;
/**
* Representation of an key identifier in URI.
*
*/
public class KeyId {
/**
* Represents either no uri, or an unspecified uri.
*/
public static final KeyId NONE = keyId("none:none");
private final URI uri;
private final String str;
// Public construction is prohibited
private KeyId(URI uri) {
this.uri = uri;
//this.str = uri.toString().toLowerCase();
this.str = uri.toString();
}
/**
* Default constructor for serialization of KeyId.
*/
protected KeyId() {
this.uri = null;
this.str = null;
}
/**
* Returns the backing URI.
*
* @return backing URI
*/
public URI uri() {
return uri;
}
@Override
public int hashCode() {
return str.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof KeyId) {
KeyId that = (KeyId) obj;
return this.getClass() == that.getClass() &&
Objects.equals(this.str, that.str);
}
return false;
}
@Override
public String toString() {
return str;
}
/**
* Creates a uri id using the supplied URI.
*
* @param uri URI
* @return UriId
*/
public static KeyId keyId(URI uri) {
return new KeyId(uri);
}
/**
* Creates a uri id using the supplied URI string.
*
* @param string URI string
* @return UriId
*/
public static KeyId keyId(String string) {
return keyId(URI.create(string));
}
}
/*
* 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.tetopology.management.api;
import java.util.List;
import org.onosproject.tetopology.management.api.link.NetworkLink;
import org.onosproject.tetopology.management.api.node.NetworkNode;
/**
* Abstraction of a network element.
*/
public interface Network extends TeTopologyEventSubject {
/**
* Returns the network identifier / key of this element.
*
* @return network identifier
*/
KeyId networkId();
/**
* Returns the attribute of supporting Network.
*
* @return list of the ids of the supporting networks
*/
List<KeyId> getSupportingNetworkIds();
/**
* Returns a collection of nodes in the network identified by the specified
* network id.
*
* @return a collection of currently known nodes
*/
List<NetworkNode> getNodes();
/**
* Returns the node.
*
* @param nodeId node id URI format
* @return value of node
*/
NetworkNode getNode(KeyId nodeId);
/**
* Returns a collection of links in the network identified by the specified
* network id.
*
* @return a collection of currently known links
*/
List<NetworkLink> getLinks();
/**
* Returns the link.
*
* @param linkId link id in URI format
* @return value of link
*/
NetworkLink getLink(KeyId linkId);
/**
* Returns if the network is provided by a server or is configured by a
* client.
*
* @return true if the network is provided by a server; false otherwise
*/
boolean isServerProvided();
/**
* Returns the TE topology Id.
*
* @return TE topology id for this network
*/
TeTopologyId getTeTopologyId();
}
/*
* 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.tetopology.management.api;
import java.util.List;
/**
* Abstraction of an entity which represents the functionality of networks.
*/
public interface Networks {
/**
* Returns the list of networks.
*
* @return list of networks
*/
List<Network> networks();
}
/*
* 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.tetopology.management.api;
import org.onosproject.event.AbstractEvent;
/**
* TE network topology event.
*/
public class TeTopologyEvent
extends AbstractEvent<TeTopologyEvent.Type, TeTopologyEventSubject> {
/**
* Type of TE topology events.
*/
public enum Type {
/** Designates addition of a network. */
NETWORK_ADDED,
/** Designates update of a network. */
NETWORK_UPDATED,
/** Designates removal of a network. */
NETWORK_REMOVED,
/** Designates addition of a node. */
NODE_ADDED,
/** Designates update of a node. */
NODE_UPDATED,
/** Designates removal of a node. */
NODE_REMOVED,
/** Designates addition of a termination point. */
TP_ADDED,
/** Designates update of a termination point. */
TP_UPDATED,
/** Designates removal of a termination point. */
TP_REMOVED,
/** Designates addition of a link. */
LINK_ADDED,
/** Designates update of a link. */
LINK_UPDATED,
/** Designates removal of a link. */
LINK_REMOVED;
}
/**
* Constructor for TeTopologyEvent.
*
* @param type type of topology event
* @param subject event subject interface
*/
public TeTopologyEvent(Type type, TeTopologyEventSubject subject) {
super(type, subject);
}
/**
* Constructor for TeTopologyEvent.
*
* @param type type of topology event
* @param subject event subject interface
* @param time event time
*/
public TeTopologyEvent(Type type, TeTopologyEventSubject subject, long time) {
super(type, subject, time);
}
}
/*
* 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.tetopology.management.api;
/**
* Abstraction of TE network topology event subject.
*/
public interface TeTopologyEventSubject {
}
/*
* 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.tetopology.management.api;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* TE Topology identifiers.
*/
public class TeTopologyId {
private final long providerId;
private final long clientId;
private final String topologyId;
/**
* Creates an instance of TE topology identifier.
*
* @param providerId value of provider identifier
* @param clientId value of client identifier
* @param topologyId value of topology identifier
*/
public TeTopologyId(long providerId, long clientId, String topologyId) {
this.providerId = providerId;
this.clientId = clientId;
this.topologyId = topologyId;
}
/**
* Returns the provider identifier.
*
* @return provider identifier
*/
public long providerId() {
return providerId;
}
/**
* Returns the client identifier.
*
* @return client identifier
*/
public long clientId() {
return clientId;
}
/**
* Returns the topology identifier.
*
* @return topology identifier
*/
public String topologyId() {
return topologyId;
}
@Override
public int hashCode() {
return Objects.hashCode(providerId, clientId, topologyId);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof TeTopologyId) {
TeTopologyId that = (TeTopologyId) object;
return Objects.equal(this.providerId, that.providerId) &&
Objects.equal(this.clientId, that.clientId) &&
Objects.equal(this.topologyId, that.topologyId);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("providerId", providerId)
.add("clientId", clientId)
.add("topologyId", topologyId)
.toString();
}
}
/*
* 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.tetopology.management.api;
import org.onosproject.event.EventListener;
/**
* Entity capable of receiving TE network Topology related events.
*/
public interface TeTopologyListener extends EventListener<TeTopologyEvent> {
}
/*
* 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.tetopology.management.api;
import org.onosproject.net.provider.Provider;
/**
* Abstraction of an IETF network provider.
* APIs for Manager to signal Provider.
*/
public interface TeTopologyProvider extends Provider {
/**
* TODO:
*
* Signals provider that abstract networks/network/link/node has been created/updated/deleted.
* It's used by producers.
*
*/
// TODO: Need to look at the following functions are required for TE Nodes
// TODO: consider how dirty the triggerProbe gets; if it costs too much, let's drop it
/**
* Triggers an asynchronous probe of the specified device, intended to
* determine whether the device is present or not. An indirect result of this
* should be invocation of
* {@link org.onosproject.net.device.DeviceProviderService#deviceConnected} )} or
* {@link org.onosproject.net.device.DeviceProviderService#deviceDisconnected}
* at some later point in time.
*
* @param deviceId ID of device to be probed
*/
//void triggerProbe(DeviceId deviceId);
/**
* Notifies the provider of a mastership role change for the specified
* device as decided by the core.
*
* @param deviceId device identifier
* @param newRole newly determined mastership role
*/
//void roleChanged(DeviceId deviceId, MastershipRole newRole);
/**
* Checks the reachability (connectivity) of a device from this provider.
*
* @param deviceId device identifier
* @return true if reachable, false otherwise
*/
//boolean isReachable(DeviceId deviceId);
}
/*
* 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.tetopology.management.api;
import org.onosproject.net.provider.ProviderRegistry;
/**
* Abstraction of IETF networks topology provider registry.
*/
public interface TeTopologyProviderRegistry
extends ProviderRegistry<TeTopologyProvider, TeTopologyProviderService> {
}
/*
* 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.tetopology.management.api;
import org.onosproject.net.provider.ProviderService;
import org.onosproject.tetopology.management.api.link.NetworkLink;
import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
import org.onosproject.tetopology.management.api.node.NetworkNode;
import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
import org.onosproject.tetopology.management.api.node.TerminationPoint;
import org.onosproject.tetopology.management.api.node.TerminationPointKey;
/**
* APIs for Provider to notify Manager about the network topology updates.
*/
public interface TeTopologyProviderService
extends ProviderService<TeTopologyProvider> {
/**
* Signals that a Network has been created/updated.
*
* @param network value of the network to be updated
*/
void networkUpdated(Network network);
/**
* Signals that a Network has been removed.
*
* @param networkId network id in URI format
*/
void networkRemoved(KeyId networkId);
/**
* Signals that a Link has been created/updated.
*
* @param linkKey link id
* @param link link object to be updated
*/
void linkUpdated(NetworkLinkKey linkKey, NetworkLink link);
/**
* Signals that a Network has been removed.
*
* @param linkKey link id
*/
void linkRemoved(NetworkLinkKey linkKey);
/**
* Signals that a Node has been created/updated.
*
* @param nodeKey node id
* @param node node object to be updated
*/
void nodeUpdated(NetworkNodeKey nodeKey, NetworkNode node);
/**
* Signals that a Node has been removed.
*
* @param nodeKey node id
*/
void nodeRemoved(NetworkNodeKey nodeKey);
/**
* Signals that a TerminationPoint has been created/updated.
*
* @param terminationPointKey termination point id
* @param terminationPoint termination point object to be updated
*/
void terminationPointUpdated(TerminationPointKey terminationPointKey,
TerminationPoint terminationPoint);
/**
* Signals that a TerminationPoint has been removed.
*
* @param terminationPointKey termination point id
*/
void terminationPointRemoved(TerminationPointKey terminationPointKey);
}
/*
* 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.tetopology.management.api;
import org.onosproject.event.ListenerService;
/**
* TE Topology Service API.
*/
public interface TeTopologyService
extends ListenerService<TeTopologyEvent, TeTopologyListener> {
/**
* Returns a collection of currently known networks.
*
* @return a collection of networks
*/
Networks getNetworks();
/**
* Returns the network identified by its network id.
*
* @param networkId network id in URI format
* @return value of network
*/
Network getNetwork(KeyId networkId);
/**
* Updates the network.
*
* @param network network to be updated
*/
void updateNetwork(Network network);
/**
* Removes the network.
*
* @param networkId network id in URI format
*/
void removeNetwork(KeyId networkId);
}
/*
* 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.tetopology.management.api;
import java.util.List;
import org.onosproject.store.Store;
/**
* Inventory of TE network topology.
*/
public interface TeTopologyStore
extends Store<TeTopologyEvent, TeTopologyStoreDelegate> {
/**
* Returns a collection of currently known networks.
*
* @param type TE topology type
* @return a collection of stored internal TE networks
*/
List<InternalTeNetwork> getNetworks(TeTopologyType type);
/**
* Returns the network.
*
* @param networkId network id in URI format
* @return value of internal TE network
*/
InternalTeNetwork getNetwork(KeyId networkId);
/**
* Updates the network.
*
* @param network value of the network to be updated
*/
void updateNetwork(InternalTeNetwork network);
/**
* Removes the network.
*
* @param networkId network id in URI format
*/
void removeNetwork(KeyId networkId);
}
/*
* 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.tetopology.management.api;
import org.onosproject.store.StoreDelegate;
/**
* Abstraction of TE networks store delegate.
*/
public interface TeTopologyStoreDelegate extends StoreDelegate<TeTopologyEvent> {
}
/*
* 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.tetopology.management.api;
/**
* TE Topology type enumeration.
*/
public enum TeTopologyType {
/**
* Native topology.
*/
NATIVE(0),
/**
* Customized topology.
*/
CUSTOMIZED(1),
/**
* Subordinate TE topology received from SB.
*/
SUBORDINATE(2),
/**
* Configured TE topology received from NB.
*/
CONFIGURED(3),
/**
* ANY - default value, used for topology filtering based on topology type.
*/
ANY(4);
private int teTopologyType;
/**
* Creates an instance of teTopologyType.
*
* @param value value of teTopologyType
*/
TeTopologyType(int value) {
teTopologyType = value;
}
/**
* Returns the attribute teTopologyType.
*
* @return value of teTopologyType
*/
public int teTopologyType() {
return teTopologyType;
}
/**
* Returns the object of teTopologyType from input String. Returns null
* when string conversion fails or value is not recognized.
*
* @param valInString input String
* @return Object of teTopologyType
*/
public static TeTopologyType of(String valInString) {
try {
int tmpVal = Integer.parseInt(valInString);
return of(tmpVal);
} catch (Exception e) {
}
return null;
}
/**
* Returns the object of teTopologyType from input integer. Returns null
* when the integer value is not recognized.
*
* @param value value of teTopologyType
* @return Object of corresponding TE topology type
*/
public static TeTopologyType of(int value) {
switch (value) {
case 0:
return TeTopologyType.NATIVE;
case 1:
return TeTopologyType.CUSTOMIZED;
case 2:
return TeTopologyType.SUBORDINATE;
case 3:
return TeTopologyType.CONFIGURED;
case 4:
return TeTopologyType.ANY;
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.
*/
package org.onosproject.tetopology.management.api.link;
import java.util.Objects;
import com.google.common.base.MoreObjects;
/**
* Implementation of Automous System (AS) number as an ElementType.
*/
public class AsNumber implements ElementType {
private final int asNumber;
/**
* Creates an instance of AsNumber.
*
* @param asNumber value of autonomous system number
*/
public AsNumber(int asNumber) {
this.asNumber = asNumber;
}
/**
* Returns the asNumber.
*
* @return value of the autonomous system number
*/
public int getAsNumber() {
return asNumber;
}
@Override
public int hashCode() {
return Objects.hash(asNumber);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof AsNumber) {
AsNumber other = (AsNumber) obj;
return Objects.equals(asNumber, other.asNumber);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("asNumber", asNumber)
.toString();
}
}
/*
* 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.tetopology.management.api.link;
import java.util.List;
import org.onosproject.tetopology.management.api.KeyId;
import org.onosproject.tetopology.management.api.node.TerminationPointKey;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* NetworkLink implementation.
* <p>
* The Set/Get methods below are defined to accept and pass references because
* the object class is treated as a "composite" object class that holds
* references to various member objects and their relationships, forming a
* data tree. Internal routines of the TE topology manager may use the
* following example methods to construct and manipulate any piece of data in
* the data tree:
*<pre>
* newNode.getTe().setAdminStatus(), or
* newNode.getSupportingNodeIds().add(nodeId), etc.
*</pre>
* Same for constructors where, for example, a child list may be constructed
* first and passed in by reference to its parent object constructor.
*/
public class DefaultNetworkLink implements NetworkLink {
private final KeyId linkId;
private TerminationPointKey source;
private TerminationPointKey destination;
private List<NetworkLinkKey> supportingLinkIds;
private TeLink te;
/**
* Creates an instance of DefaultNetworkLink.
*
* @param linkId link identifier
*/
public DefaultNetworkLink(KeyId linkId) {
this.linkId = linkId;
}
/**
* Sets the link source point.
*
* @param source the source to set
*/
public void setSource(TerminationPointKey source) {
this.source = source;
}
/**
* Sets the link destination point.
*
* @param destination the destination to set
*/
public void setDestination(TerminationPointKey destination) {
this.destination = destination;
}
/**
* Sets the supporting link Ids.
*
* @param supportingLinkIds the supportingLinkIds to set
*/
public void setSupportingLinkIds(List<NetworkLinkKey> supportingLinkIds) {
this.supportingLinkIds = supportingLinkIds;
}
/**
* Sets the te extension.
*
* @param te the te to set
*/
public void setTe(TeLink te) {
this.te = te;
}
@Override
public KeyId linkId() {
return linkId;
}
@Override
public TerminationPointKey getSource() {
return source;
}
@Override
public TerminationPointKey getDestination() {
return destination;
}
@Override
public List<NetworkLinkKey> getSupportingLinkIds() {
return supportingLinkIds;
}
@Override
public TeLink getTe() {
return te;
}
@Override
public int hashCode() {
return Objects.hashCode(linkId, source, destination, supportingLinkIds, te);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof DefaultNetworkLink) {
DefaultNetworkLink that = (DefaultNetworkLink) object;
return Objects.equal(this.linkId, that.linkId) &&
Objects.equal(this.source, that.source) &&
Objects.equal(this.destination, that.destination) &&
Objects.equal(this.supportingLinkIds, that.supportingLinkIds) &&
Objects.equal(this.te, that.te);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("linkId", linkId)
.add("source", source)
.add("destination", destination)
.add("supportingLinkIds", supportingLinkIds)
.add("te", te)
.toString();
}
}
/*
* 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.tetopology.management.api.link;
/**
* Abstraction of a path element type.
*/
public interface ElementType {
}
/*
* 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.tetopology.management.api.link;
import org.onosproject.tetopology.management.api.KeyId;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Representation of an external domain link.
*/
public class ExternalDomain {
private final KeyId remoteTeNodeId;
private final KeyId remoteTeLinkTpId;
private final long plugId;
/**
* Creates an instance of ExternalDomain.
*
* @param remoteTeNodeId remote TE node identifier
* @param remoteTeLinkTpId remote TE link termination point identifier
* @param plugId global plug id
*/
public ExternalDomain(KeyId remoteTeNodeId, KeyId remoteTeLinkTpId, long plugId) {
this.remoteTeNodeId = remoteTeNodeId;
this.remoteTeLinkTpId = remoteTeLinkTpId;
this.plugId = plugId;
}
/**
* Creates an instance of ExternalDomain with remote TE node and tp.
*
* @param remoteTeNodeId remote TE node identifier
* @param remoteTeLinkTpId remote TE link termination point identifier
*/
public ExternalDomain(KeyId remoteTeNodeId, KeyId remoteTeLinkTpId) {
this.remoteTeNodeId = remoteTeNodeId;
this.remoteTeLinkTpId = remoteTeLinkTpId;
this.plugId = 0L;
}
/**
* Creates an instance of ExternalDomain with plugId.
*
* @param plugId global plug id
*/
public ExternalDomain(long plugId) {
this.remoteTeNodeId = null;
this.remoteTeLinkTpId = null;
this.plugId = plugId;
}
/**
* Returns the remote TeNode Id.
*
* @return value of the remote TE node identifier
*/
public KeyId remoteTeNodeId() {
return remoteTeNodeId;
}
/**
* Returns the remote TeLink TpId.
*
* @return value of the remote TE link identifier
*/
public KeyId remoteTeLinkTpId() {
return remoteTeLinkTpId;
}
/**
* Returns the plugId.
*
* @return value of the global plug id
*/
public long plugId() {
return plugId;
}
@Override
public int hashCode() {
return Objects.hashCode(remoteTeNodeId, remoteTeLinkTpId, remoteTeLinkTpId);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof ExternalDomain) {
ExternalDomain that = (ExternalDomain) object;
return Objects.equal(this.remoteTeNodeId, that.remoteTeNodeId) &&
Objects.equal(this.remoteTeLinkTpId, that.remoteTeLinkTpId) &&
Objects.equal(this.remoteTeLinkTpId, that.remoteTeLinkTpId);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("remoteTeNodeId", remoteTeNodeId)
.add("remoteTeLinkTpId", remoteTeLinkTpId)
.add("remoteTeLinkTpId", remoteTeLinkTpId)
.toString();
}
}
/*
* 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.tetopology.management.api.link;
import java.util.Objects;
import com.google.common.base.MoreObjects;
/**
* Implementation of Label as an ElementType.
*/
public class Label implements ElementType {
private final long value;
/**
* Creates an instance of Label.
*
* @param label label value
*/
public Label(long label) {
this.value = label;
}
/**
* Returns the label.
*
* @return value of the label
*/
public long label() {
return value;
}
@Override
public int hashCode() {
return Objects.hash(value);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof Label) {
Label other = (Label) obj;
return
Objects.equals(value, other.value);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("value", value)
.toString();
}
}
/*
* 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.tetopology.management.api.link;
/**
* Represents ENUM data of linkProtectionType.
*/
public enum LinkProtectionType {
/**
* Represents unprotected.
*/
UNPROTECTED(0),
/**
* Represents extraTraffic.
*/
EXTRA_TRAFFIC(1),
/**
* Represents shared.
*/
SHARED(2),
/**
* Represents yangAutoPrefix1For1.
*/
YANGAUTOPREFIX1_FOR_1(3),
/**
* Represents yangAutoPrefix1Plus1.
*/
YANGAUTOPREFIX1_PLUS_1(4),
/**
* Represents enhanced.
*/
ENHANCED(5);
private int linkProtectionType;
LinkProtectionType(int value) {
linkProtectionType = value;
}
/**
* Returns the attribute linkProtectionType.
*
* @return value of linkProtectionType
*/
public int linkProtectionType() {
return linkProtectionType;
}
/**
* Returns the object of linkProtectionType from input String. Returns null
* when string conversion fails or converted integer value is not recognized.
*
* @param valInString input String
* @return Object of linkProtectionType
*/
public static LinkProtectionType of(String valInString) {
try {
int tmpVal = Integer.parseInt(valInString);
return of(tmpVal);
} catch (NumberFormatException e) {
}
return null;
}
/**
* Returns the object of linkProtectionType from input integer. Returns null
* when the integer value is not recognized.
*
* @param value value of linkProtectionTypeForTypeInt
* @return Object of linkProtectionTypeForTypeInt
*/
public static LinkProtectionType of(int value) {
switch (value) {
case 0:
return LinkProtectionType.UNPROTECTED;
case 1:
return LinkProtectionType.EXTRA_TRAFFIC;
case 2:
return LinkProtectionType.SHARED;
case 3:
return LinkProtectionType.YANGAUTOPREFIX1_FOR_1;
case 4:
return LinkProtectionType.YANGAUTOPREFIX1_PLUS_1;
case 5:
return LinkProtectionType.ENHANCED;
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.
*/
package org.onosproject.tetopology.management.api.link;
import java.util.List;
import org.onosproject.tetopology.management.api.KeyId;
import org.onosproject.tetopology.management.api.TeTopologyEventSubject;
import org.onosproject.tetopology.management.api.node.TerminationPointKey;
/**
* Abstraction of a base network link.
*/
public interface NetworkLink extends TeTopologyEventSubject {
/**
* Returns the link id.
*
* @return link identifier
*/
KeyId linkId();
/**
* Returns the link source termination point.
*
* @return source link termination point id
*/
TerminationPointKey getSource();
/**
* Returns the link destination termination point.
*
* @return destination link termination point id
*/
TerminationPointKey getDestination();
/**
* Returns the supporting link ids.
*
* @return list of the ids of the supporting links
*/
List<NetworkLinkKey> getSupportingLinkIds();
/**
* Returns the link te extension.
*
* @return TE link attributes
*/
TeLink getTe();
}
/*
* 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.tetopology.management.api.link;
import org.onosproject.tetopology.management.api.KeyId;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Representation of a link key or link reference.
*/
public class NetworkLinkKey {
private final KeyId networkId;
private final KeyId linkId;
/**
* Creates an instance of NetworkLinkKey.
*
* @param networkId network identifier
* @param linkId link identifier
*/
public NetworkLinkKey(KeyId networkId, KeyId linkId) {
this.networkId = networkId;
this.linkId = linkId;
}
/**
* Returns the network identifier.
*
* @return network identifier
*/
public KeyId networkId() {
return networkId;
}
/**
* Returns the link identifier.
*
* @return link identifier
*/
public KeyId linkId() {
return linkId;
}
@Override
public int hashCode() {
return Objects.hashCode(networkId, linkId);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof NetworkLinkKey) {
NetworkLinkKey that = (NetworkLinkKey) object;
return Objects.equal(this.networkId, that.networkId) &&
Objects.equal(this.linkId, that.linkId);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("networkId", networkId)
.add("linkId", linkId)
.toString();
}
}
/*
* 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.tetopology.management.api.link;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Represent a path element.
*/
public class PathElement {
private final long pathElementId;
private final ElementType type;
/**
* Creates an instance of PathElement.
*
* @param pathElementId path element identifier
* @param type path element type
*/
public PathElement(long pathElementId, ElementType type) {
this.pathElementId = pathElementId;
this.type = type;
}
/**
* Returns the path element identifier.
*
* @return path element id
*/
public long pathElementId() {
return pathElementId;
}
/**
* Returns the path element type.
*
* @return path element type
*/
public ElementType type() {
return type;
}
@Override
public int hashCode() {
return Objects.hashCode(pathElementId, type);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof PathElement) {
PathElement that = (PathElement) object;
return Objects.equal(this.pathElementId, that.pathElementId) &&
Objects.equal(this.type, that.type);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("pathElementId", pathElementId)
.add("type", type)
.toString();
}
}
/**
* 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.tetopology.management.api.link;
import java.util.Objects;
import org.onlab.packet.Ip4Address;
import com.google.common.base.MoreObjects;
/**
* Implementation of IPv4 address as an ElementType.
*/
public class TeIpv4 implements ElementType {
private Ip4Address v4Address;
private short v4PrefixLength;
private boolean v4Loose;
/**
* Creates an instance of TeIpv4.
*/
public TeIpv4() {
}
/**
* Sets the v4 address.
*
* @param v4Address the v4Address to set
*/
public void setV4Address(Ip4Address v4Address) {
this.v4Address = v4Address;
}
/**
* Sets the prefix length.
*
* @param v4PrefixLength the v4PrefixLength to set
*/
public void setV4PrefixLength(short v4PrefixLength) {
this.v4PrefixLength = v4PrefixLength;
}
/**
* Sets the loose flag.
*
* @param v4Loose the v4Loose to set
*/
public void setV4Loose(boolean v4Loose) {
this.v4Loose = v4Loose;
}
/**
* Returns the v4Address.
*
* @return IPv4 address
*/
public Ip4Address v4Address() {
return v4Address;
}
/**
* Returns the v4PrefixLength.
*
* @return IPv4 address prefix length
*/
public short v4PrefixLength() {
return v4PrefixLength;
}
/**
* Returns the v4Loose.
*
* @return true if the address specifies a loose hop; false otherwise
*/
public boolean v4Loose() {
return v4Loose;
}
@Override
public int hashCode() {
return Objects.hash(v4Address, v4PrefixLength, v4Loose);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof TeIpv4) {
TeIpv4 other = (TeIpv4) obj;
return Objects.equals(v4Address, other.v4Address) &&
Objects.equals(v4PrefixLength, other.v4PrefixLength) &&
Objects.equals(v4Loose, other.v4Loose);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("v4Address", v4Address)
.add("v4PrefixLength", v4PrefixLength)
.add("v4Loose", v4Loose)
.toString();
}
}
/*
* 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.tetopology.management.api.link;
import java.util.Objects;
import org.onlab.packet.Ip6Address;
import com.google.common.base.MoreObjects;
/**
* Implementation of IPv6 address as an ElementType.
*/
public class TeIpv6 implements ElementType {
private Ip6Address v6Address;
private short v6PrefixLength;
private boolean v6Loose;
/**
* Creates an instance of TeIpv6.
*/
public TeIpv6() {
}
/**
* Sets the v6 address.
*
* @param v6Address the v6Address to set
*/
public void setV6Address(Ip6Address v6Address) {
this.v6Address = v6Address;
}
/**
* Sets the prefix length.
*
* @param v6PrefixLength the v6PrefixLength to set
*/
public void setV6PrefixLength(short v6PrefixLength) {
this.v6PrefixLength = v6PrefixLength;
}
/**
* Sets the loose flag.
*
* @param v6Loose the v6Loose to set
*/
public void setv6Loose(boolean v6Loose) {
this.v6Loose = v6Loose;
}
/**
* Returns the v6Address.
*
* @return IPv6 address
*/
public Ip6Address v6Address() {
return v6Address;
}
/**
* Returns the v6PrefixLength.
*
* @return IPv6 address prefix length
*/
public short v6PrefixLength() {
return v6PrefixLength;
}
/**
* Returns the v6Loose.
*
* @return true if the address specifies a loose hop; false otherwise
*/
public boolean v6Loose() {
return v6Loose;
}
@Override
public int hashCode() {
return Objects.hash(v6Address, v6PrefixLength, v6Loose);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof TeIpv6) {
TeIpv6 other = (TeIpv6) obj;
return Objects.equals(v6Address, other.v6Address) &&
Objects.equals(v6PrefixLength, other.v6PrefixLength) &&
Objects.equals(v6Loose, other.v6Loose);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("v6Address", v6Address)
.add("v6PrefixLength", v6PrefixLength)
.add("v6Loose", v6Loose)
.toString();
}
}
/*
* 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.tetopology.management.api.link;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
import org.onosproject.tetopology.management.api.node.TeStatus;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Link TE extension.
* <p>
* The Set/Get methods below are defined to accept and pass references because
* the object class is treated as a "composite" object class that holds
* references to various member objects and their relationships, forming a
* data tree. Internal routines of the TE topology manager may use the
* following example methods to construct and manipulate any piece of data in
* the data tree:
*<pre>
* newNode.getTe().setAdminStatus(), or
* newNode.getSupportingNodeIds().add(nodeId), etc.
*</pre>
* Same for constructors where, for example, a child list may be constructed
* first and passed in by reference to its parent object constructor.
*/
public class TeLink {
// See org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.
// topology.rev20160708.ietftetopology
// .augmentedntlink.te.config.DefaultTeLinkAttributes for reference
private BigInteger linkIndex;
private String name;
private TeStatus adminStatus;
private TeStatus opStatus;
private TeLinkAccessType accessType;
//private administrativeGroup
private LinkProtectionType linkProtectionType;
private BigDecimal maxLinkBandwidth;
private BigDecimal maxResvLinkBandwidth;
private List<UnreservedBandwidth> unreservedBandwidths;
private long teDefaultMetric;
private ExternalDomain externalDomain;
private List<Long> teSrlgs;
private boolean isAbstract;
private UnderlayPath underlayPath;
/**
* Creates an instance of TeLink.
*
* @param linkIndex TE link index
*/
public TeLink(BigInteger linkIndex) {
this.linkIndex = linkIndex;
}
/**
* Sets the name.
*
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets the administrative status.
*
* @param adminStatus the adminStatus to set
*/
public void setAdminStatus(TeStatus adminStatus) {
this.adminStatus = adminStatus;
}
/**
* Sets the operational status.
*
* @param opStatus the opStatus to set
*/
public void setOpStatus(TeStatus opStatus) {
this.opStatus = opStatus;
}
/**
* Sets the access type.
*
* @param accessType the accessType to set
*/
public void setAccessType(TeLinkAccessType accessType) {
this.accessType = accessType;
}
/**
* Sets the protection type.
*
* @param type the linkProtectionType to set
*/
public void setLinkProtectionType(LinkProtectionType type) {
this.linkProtectionType = type;
}
/**
* Sets the link maximum bandwidth.
*
* @param bw the maxLinkBandwidth to set
*/
public void setMaxLinkBandwidth(BigDecimal bw) {
this.maxLinkBandwidth = bw;
}
/**
* Sets the link maximum reservable bandwidth.
*
* @param bw the maxResvLinkBandwidth to set
*/
public void setMaxResvLinkBandwidth(BigDecimal bw) {
this.maxResvLinkBandwidth = bw;
}
/**
* Sets the list of link unreserved bandwidths.
*
* @param bwList the unreservedBandwidths to set
*/
public void setUnreservedBandwidths(List<UnreservedBandwidth> bwList) {
this.unreservedBandwidths = bwList;
}
/**
* Sets the default metric.
*
* @param metric the teDefaultMetric to set
*/
public void setTeDefaultMetric(long metric) {
this.teDefaultMetric = metric;
}
/**
* Sets the external domain link.
*
* @param extDomain the externalDomain to set
*/
public void setExternalDomain(ExternalDomain extDomain) {
this.externalDomain = extDomain;
}
/**
* Sets the list of SRLGs.
*
* @param teSrlgs the teSrlgs to set
*/
public void setTeSrlgs(List<Long> teSrlgs) {
this.teSrlgs = teSrlgs;
}
/**
* Sets the isAbstract flag.
*
* @param isAbstract the isAbstract to set
*/
public void setIsAbstract(boolean isAbstract) {
this.isAbstract = isAbstract;
}
/**
* Sets the link underlay path.
*
* @param underlayPath the underlay path to set
*/
public void setUnderlayPath(UnderlayPath underlayPath) {
this.underlayPath = underlayPath;
}
/**
* Returns the link index.
*
* @return link index
*/
public BigInteger linkIndex() {
return linkIndex;
}
/**
* Returns the name.
*
* @return name of the TE link
*/
public String name() {
return name;
}
/**
* Returns the administrative status.
*
* @return link admin status
*/
public TeStatus adminStatus() {
return adminStatus;
}
/**
* Returns the operational status.
*
* @return link operational status
*/
public TeStatus opStatus() {
return opStatus;
}
/**
* Returns the access type.
*
* @return link access type
*/
public TeLinkAccessType accessType() {
return accessType;
}
/**
* Returns the link protection type.
*
* @return link protection type
*/
public LinkProtectionType linkProtectionType() {
return linkProtectionType;
}
/**
* Returns the link maximum bandwidth.
*
* @return link maximum bandwidth
*/
public BigDecimal maxLinkBandwidth() {
return maxLinkBandwidth;
}
/**
* Returns the maximum reservable bandwidth.
*
* @return link maximum reservable bandwidth
*/
public BigDecimal maxResvLinkBandwidth() {
return maxResvLinkBandwidth;
}
/**
* Returns the list of link unreserved bandwidths.
*
* @return link unreserved bandwidth
*/
public List<UnreservedBandwidth> unreservedBandwidths() {
return unreservedBandwidths;
}
/**
* Returns the te default metric.
*
* @return link TE metric
*/
public long teDefaultMetric() {
return teDefaultMetric;
}
/**
* Returns the external domain link.
*
* @return external domain
*/
public ExternalDomain externalDomain() {
return externalDomain;
}
/**
* Returns the list of SRLGs.
*
* @return link SRLG
*/
public List<Long> teSrlgs() {
return teSrlgs;
}
/**
* Returns the flag isAbstract.
*
* @return true or false if link is abstract
*/
public boolean isAbstract() {
return isAbstract;
}
/**
* Returns the underlay path data.
*
* @return link underlay TE path
*/
public UnderlayPath underlayPath() {
return underlayPath;
}
@Override
public int hashCode() {
return Objects.hashCode(linkIndex, name, adminStatus, opStatus, accessType,
linkProtectionType, maxLinkBandwidth, maxResvLinkBandwidth, unreservedBandwidths,
teDefaultMetric, externalDomain, teSrlgs, isAbstract, underlayPath);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof TeLink) {
TeLink that = (TeLink) object;
return Objects.equal(this.linkIndex, that.linkIndex) &&
Objects.equal(this.name, that.name) &&
Objects.equal(this.adminStatus, that.adminStatus) &&
Objects.equal(this.opStatus, that.opStatus) &&
Objects.equal(this.accessType, that.accessType) &&
Objects.equal(this.linkProtectionType, that.linkProtectionType) &&
Objects.equal(this.maxLinkBandwidth, that.maxLinkBandwidth) &&
Objects.equal(this.maxResvLinkBandwidth, that.maxResvLinkBandwidth) &&
Objects.equal(this.unreservedBandwidths, that.unreservedBandwidths) &&
Objects.equal(this.teDefaultMetric, that.teDefaultMetric) &&
Objects.equal(this.externalDomain, that.externalDomain) &&
Objects.equal(this.teSrlgs, that.teSrlgs) &&
Objects.equal(this.isAbstract, that.isAbstract) &&
Objects.equal(this.underlayPath, that.underlayPath);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("linkIndex", linkIndex)
.add("name", name)
.add("adminStatus", adminStatus)
.add("opStatus", opStatus)
.add("accessType", accessType)
.add("linkProtectionType", linkProtectionType)
.add("maxLinkBandwidth", maxLinkBandwidth)
.add("maxResvLinkBandwidth", maxResvLinkBandwidth)
.add("unreservedBandwidths", unreservedBandwidths)
.add("teDefaultMetric", teDefaultMetric)
.add("externalDomain", externalDomain)
.add("teSrlgs", teSrlgs)
.add("isAbstract", isAbstract)
.add("underlayPath", underlayPath)
.toString();
}
}
/*
* 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.tetopology.management.api.link;
/**
* Represents ENUM data of teLinkAccessType.
*/
public enum TeLinkAccessType {
/**
* Represents pointToPoint.
*/
POINT_TO_POINT(0),
/**
* Represents multiAccess.
*/
MULTI_ACCESS(1);
private int teLinkAccessType;
TeLinkAccessType(int value) {
teLinkAccessType = value;
}
/**
* Returns the attribute teLinkAccessType.
*
* @return value of teLinkAccessType
*/
public int teLinkAccessType() {
return teLinkAccessType;
}
/**
* Returns the object of teLinkAccessType from input String. Returns null
* when string conversion fails or converted integer value is not recognized.
*
* @param valInString input String
* @return Object of teLinkAccessType
*/
public static TeLinkAccessType of(String valInString) {
try {
int tmpVal = Integer.parseInt(valInString);
return of(tmpVal);
} catch (NumberFormatException e) {
}
return null;
}
/**
* Returns the object of teLinkAccessTypeForTypeInt. Returns null
* when the integer value is not recognized.
*
* @param value value of teLinkAccessTypeForTypeInt
* @return Object of teLinkAccessTypeForTypeInt
*/
public static TeLinkAccessType of(int value) {
switch (value) {
case 0:
return TeLinkAccessType.POINT_TO_POINT;
case 1:
return TeLinkAccessType.MULTI_ACCESS;
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.
*/
package org.onosproject.tetopology.management.api.link;
import java.util.List;
import java.util.Objects;
import org.onosproject.tetopology.management.api.node.TeNetworkTopologyId;
import com.google.common.base.MoreObjects;
/**
* Represents the common defintion of an underlay path that supports a TE link.
*/
public class UnderlayAbstractPath {
private TeNetworkTopologyId ref;
private List<PathElement> pathElements;
/**
* Creates an instance of UnderlayAbstractPath.
*/
public UnderlayAbstractPath() {
}
/**
* Sets the TE Topology reference.
*
* @param ref the ref to set
*/
public void setRef(TeNetworkTopologyId ref) {
this.ref = ref;
}
/**
* Sets the list of path elements.
*
* @param pathElements the pathElement to set
*/
public void setPathElement(List<PathElement> pathElements) {
this.pathElements = pathElements;
}
/**
* Returns the TE Topology reference.
*
* @return value of TE network topology identifier
*/
public TeNetworkTopologyId ref() {
return ref;
}
/**
* Returns the list of path elements.
*
* @return list of path elements
*/
public List<PathElement> pathElements() {
return pathElements;
}
@Override
public int hashCode() {
return Objects.hash(ref, pathElements);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof UnderlayAbstractPath) {
UnderlayAbstractPath other = (UnderlayAbstractPath) obj;
return Objects.equals(ref, other.ref) &&
Objects.equals(pathElements, other.pathElements);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("ref", ref)
.add("pathElements", pathElements)
.toString();
}
}
/*
* 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.tetopology.management.api.link;
import java.util.Objects;
import com.google.common.base.MoreObjects;
/**
* Represents a list of backup service paths on the underlay topology that
* protect the underlay primary path.
*/
public class UnderlayBackupPath extends UnderlayAbstractPath {
private long index;
/**
* Sets the index.
*
* @param index the index to set
*/
public void setIndex(long index) {
this.index = index;
}
/**
* Returns the index.
*
* @return path index
*/
public long index() {
return index;
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), index);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof UnderlayBackupPath) {
if (!super.equals(obj)) {
return false;
}
UnderlayBackupPath that = (UnderlayBackupPath) obj;
return this.index == that.index;
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("index", index)
.add("ref", ref())
.add("pathElements", pathElements())
.toString();
}
}
/*
* 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.tetopology.management.api.link;
import java.util.List;
import org.onosproject.tetopology.management.api.node.TerminationPointKey;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Represents the TE link underlay path data.
*/
public class UnderlayPath {
private int protectionType;
private UnderlayPrimaryPath primaryPath;
private List<UnderlayBackupPath> backupPaths;
private TerminationPointKey trailSrc;
private TerminationPointKey trailDes;
/**
* Creates an instance of Underlay.
*/
public UnderlayPath() {
}
/**
* Sets the protection type.
*
* @param protectionType the protectionType to set
*/
public void setProtectionType(int protectionType) {
this.protectionType = protectionType;
}
/**
* Sets the primary path.
*
* @param primaryPath the primaryPath to set
*/
public void setPrimaryPath(UnderlayPrimaryPath primaryPath) {
this.primaryPath = primaryPath;
}
/**
* Sets the link of backup paths.
*
* @param backupPaths the backupPath to set
*/
public void setBackupPath(List<UnderlayBackupPath> backupPaths) {
this.backupPaths = backupPaths;
}
/**
* Sets the trail source.
*
* @param trailSrc the trailSrc to set
*/
public void setTrailSrc(TerminationPointKey trailSrc) {
this.trailSrc = trailSrc;
}
/**
* Sets the trail destination.
*
* @param trailDes the trailDes to set
*/
public void setTrailDes(TerminationPointKey trailDes) {
this.trailDes = trailDes;
}
/**
* Returns the protection type.
*
* @return path protection type
*/
public int protectionType() {
return protectionType;
}
/**
* Returns the primary path.
*
* @return underlay primary path
*/
public UnderlayPrimaryPath primaryPath() {
return primaryPath;
}
/**
* Returns the backup paths.
*
* @return list of underlay backup paths
*/
public List<UnderlayBackupPath> backupPaths() {
return backupPaths;
}
/**
* Returns the trail source.
*
* @return trail source
*/
public TerminationPointKey trailSrc() {
return trailSrc;
}
/**
* Returns the trail destination.
*
* @return trail destination
*/
public TerminationPointKey trailDes() {
return trailDes;
}
@Override
public int hashCode() {
return Objects.hashCode(protectionType, primaryPath,
backupPaths, trailSrc, trailDes);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof UnderlayPath) {
UnderlayPath that = (UnderlayPath) object;
return Objects.equal(this.protectionType, that.protectionType) &&
Objects.equal(this.primaryPath, that.primaryPath) &&
Objects.equal(this.backupPaths, that.backupPaths) &&
Objects.equal(this.trailSrc, that.trailSrc) &&
Objects.equal(this.trailDes, that.trailDes);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("protectionType", protectionType)
.add("primaryPath", primaryPath)
.add("backupPaths", backupPaths)
.add("trailSrc", trailSrc)
.add("trailDes", trailDes)
.toString();
}
}
/*
* 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.tetopology.management.api.link;
/**
* Represents the underlay primary path that supports a TE link.
*/
public class UnderlayPrimaryPath extends UnderlayAbstractPath {
/*
* Underlay primary path currently has the same data structure defined in
* the underlay abstract path. It may be extended per standard definitions.
*/
}
/*
* 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.tetopology.management.api.link;
import java.util.Objects;
import org.onlab.packet.IpAddress;
import com.google.common.base.MoreObjects;
/**
* Implementation of unnumbered link as an ElementType.
*/
public class UnnumberedLink implements ElementType {
private IpAddress routerId;
private long interfaceId;
/**
* Creates an instance of UnnumberedLink.
*/
public UnnumberedLink() {
}
/**
* Sets the router Id.
*
* @param routerId the routerId to set
*/
public void setRouterId(IpAddress routerId) {
this.routerId = routerId;
}
/**
* Sets the interface Id.
*
* @param interfaceId the interfaceId to set
*/
public void setInterfaceId(long interfaceId) {
this.interfaceId = interfaceId;
}
/**
* Returns the router Id.
*
* @return router identifier
*/
public IpAddress routerId() {
return routerId;
}
/**
* Returns the interface Id.
*
* @return interface identifier
*/
public long interfaceId() {
return interfaceId;
}
@Override
public int hashCode() {
return Objects.hash(routerId, interfaceId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof UnnumberedLink) {
UnnumberedLink other = (UnnumberedLink) obj;
return
Objects.equals(routerId, other.routerId) &&
Objects.equals(interfaceId, other.interfaceId);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("routerId", routerId)
.add("interfaceId", interfaceId)
.toString();
}
}
/*
* 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.tetopology.management.api.link;
import java.math.BigDecimal;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Representation of a link's unreserved bandwidth.
*/
public class UnreservedBandwidth {
private final short priority;
private final BigDecimal bandwidth;
/**
* Create an instance of UnreservedBandwidth.
*
* @param priority allocatable priority of unreserved bandwidth
* @param bandwidth bandwidth
*/
public UnreservedBandwidth(short priority, BigDecimal bandwidth) {
this.priority = priority;
this.bandwidth = bandwidth;
}
/**
* Returns the priority.
*
* @return the priority
*/
public short priority() {
return priority;
}
/**
* Returns the bandwidth.
*
* @return the bandwidth
*/
public BigDecimal bandwidth() {
return bandwidth;
}
@Override
public int hashCode() {
return Objects.hashCode(priority, bandwidth);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof UnreservedBandwidth) {
UnreservedBandwidth that = (UnreservedBandwidth) object;
return Objects.equal(this.priority, that.priority) &&
Objects.equal(this.bandwidth, that.bandwidth);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("priority", priority)
.add("bandwidth", bandwidth)
.toString();
}
}
/*
* 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.
*/
/**
* TE link API.
*/
package org.onosproject.tetopology.management.api.link;
\ No newline at end of file
/*
* 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.tetopology.management.api.node;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Represents node's switching limitations.
*/
public class ConnectivityMatrix {
private final long id;
private TerminationPointKey from;
private TerminationPointKey to;
private boolean isAllowed;
/**
* Creates an instance of ConnectivityMatrix.
*
* @param id connectivity matrix identifier
* @param from from termination point key
* @param to to termination point key
* @param isAllowed indicate whether this connectivity matrix is useable
*/
public ConnectivityMatrix(long id, TerminationPointKey from,
TerminationPointKey to, boolean isAllowed) {
this.id = id;
this.from = from;
this.to = to;
this.isAllowed = isAllowed;
}
/**
* Constructor with id only.
*
* @param id connectivity matrix id
*/
public ConnectivityMatrix(long id) {
this.id = id;
}
/**
* Returns the id.
*
* @return connectivity matrix id
*/
public long id() {
return id;
}
/**
* Returns the "from" of a connectivity matrix.
*
* @return the "from" of a connectivity matrix
*/
public TerminationPointKey from() {
return from;
}
/**
* Returns the "to" of a connectivity matrix.
*
* @return the "to" of a connectivity matrix
*/
public TerminationPointKey to() {
return to;
}
/**
* Returns true if the connectivity matrix is allowed; false otherwise.
*
* @return true if the connectivity matrix is allowed; false otherwise
*/
public boolean isAllowed() {
return isAllowed;
}
/**
* Sets the from termination point.
*
* @param from the from to set
*/
public void setFrom(TerminationPointKey from) {
this.from = from;
}
/**
* Sets the to termination point.
*
* @param to the to to set
*/
public void setTo(TerminationPointKey to) {
this.to = to;
}
/**
* Sets isAllowed.
*
* @param isAllowed the isAllowed to set
*/
public void setIsAllowed(boolean isAllowed) {
this.isAllowed = isAllowed;
}
@Override
public int hashCode() {
return Objects.hashCode(id, from, to, isAllowed);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof ConnectivityMatrix) {
ConnectivityMatrix that = (ConnectivityMatrix) object;
return Objects.equal(this.id, that.id) &&
Objects.equal(this.from, that.from) &&
Objects.equal(this.to, that.to) &&
Objects.equal(this.isAllowed, that.isAllowed);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", id)
.add("from", from)
.add("to", to)
.add("isAllowed", isAllowed)
.toString();
}
}
/*
* 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.tetopology.management.api.node;
import java.util.List;
import org.onosproject.tetopology.management.api.KeyId;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* NetworkNode implementation.
* <p>
* The Set/Get methods below are defined to accept and pass references because
* the object class is treated as a "composite" object class that holds
* references to various member objects and their relationships, forming a
* data tree. Internal routines of the TE topology manager may use the
* following example methods to construct and manipulate any piece of data in
* the data tree:
*<pre>
* newNode.getTe().setAdminStatus(), or
* newNode.getSupportingNodeIds().add(nodeId), etc.
*</pre>
* Same for constructors where, for example, a child list may be constructed
* first and passed in by reference to its parent object constructor.
*/
public class DefaultNetworkNode implements NetworkNode {
private final KeyId id;
private List<NetworkNodeKey> supportingNodeIds;
private TeNode te;
private List<TerminationPoint> tps;
/**
* Creates an instance of DefaultNetworkNode using Id.
*
* @param id network node identifier
*/
public DefaultNetworkNode(KeyId id) {
this.id = id;
}
/**
* Creates an instance of DefaultNetworkNode.
*
* @param id network node identifier
* @param nodeIds support node identifiers
* @param te te parameter of the node
*/
public DefaultNetworkNode(KeyId id, List<NetworkNodeKey> nodeIds, TeNode te) {
this.id = id;
this.supportingNodeIds = nodeIds;
this.te = te;
}
/**
* Sets the list of supporting node ids.
*
* @param ids the supporting node ids to set
*/
public void setSupportingNodeIds(List<NetworkNodeKey> ids) {
this.supportingNodeIds = ids;
}
/**
* Sets the te attribute.
*
* @param te the te to set
*/
public void setTe(TeNode te) {
this.te = te;
}
/**
* Sets the TerminationPoints.
*
* @param tps the tps to set
*/
public void setTerminationPoints(List<TerminationPoint> tps) {
this.tps = tps;
}
/**
* Returns the node identifier.
*
* @return node identifier
*/
@Override
public KeyId nodeId() {
return id;
}
/**
* Returns the supportingNodeIds.
*
* @return list of supporting node identifiers for this node
*/
@Override
public List<NetworkNodeKey> getSupportingNodeIds() {
return supportingNodeIds;
}
/**
* Returns the te attribute value.
*
* @return TE attributes of this node
*/
@Override
public TeNode getTe() {
return te;
}
/**
* Returns the list of termination points.
*
* @return a list of termination points associated with this node
*/
@Override
public List<TerminationPoint> getTerminationPoints() {
return tps;
}
/**
* Returns the termination point.
*
* @return the termination point
*/
@Override
public TerminationPoint getTerminationPoint(KeyId tpId) {
for (TerminationPoint tp : tps) {
if (tp.id().equals(tpId)) {
return tp;
}
}
return null;
}
@Override
public int hashCode() {
return Objects.hashCode(id, supportingNodeIds, te, tps);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof DefaultNetworkNode) {
DefaultNetworkNode that = (DefaultNetworkNode) object;
return Objects.equal(this.id, that.id) &&
Objects.equal(this.supportingNodeIds, that.supportingNodeIds) &&
Objects.equal(this.te, that.te) &&
Objects.equal(this.tps, that.tps);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", id)
.add("supportingNodeIds", supportingNodeIds)
.add("te", te)
.add("tps", tps)
.toString();
}
}
/*
* 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.tetopology.management.api.node;
import java.util.List;
import org.onosproject.tetopology.management.api.KeyId;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Represent a termination point.
* <p>
* The Set/Get methods below are defined to accept and pass references because
* the object class is treated as a "composite" object class that holds
* references to various member objects and their relationships, forming a
* data tree. Internal routines of the TE topology manager may use the
* following example methods to construct and manipulate any piece of data in
* the data tree:
*<pre>
* newNode.getTe().setAdminStatus(), or
* newNode.getSupportingNodeIds().add(nodeId), etc.
*</pre>
* Same for constructors where, for example, a child list may be constructed
* first and passed in by reference to its parent object constructor.
*/
public class DefaultTerminationPoint implements TerminationPoint {
private KeyId id;
private List<TerminationPointKey> supportingTpIds;
private TeTerminationPoint te;
/**
* Creates an instance of DefaultTerminationPoint.
*
* @param id termination point identifier
* @param tps support termination point identifier
* @param te te parameters of the terminiation point
*/
public DefaultTerminationPoint(KeyId id, List<TerminationPointKey> tps,
TeTerminationPoint te) {
this.id = id;
this.supportingTpIds = tps;
this.te = te;
}
/**
* Creates an instance of DefaultTerminationPoint with teTpId only.
*
* @param id termination point identifier
*/
public DefaultTerminationPoint(KeyId id) {
this.id = id;
}
@Override
public KeyId id() {
return id;
}
@Override
public List<TerminationPointKey> getSupportingTpIds() {
return supportingTpIds;
}
@Override
public TeTerminationPoint getTe() {
return te;
}
/**
* Sets the Id.
*
* @param id the id to set
*/
public void setId(KeyId id) {
this.id = id;
}
/**
* Sets the supportingTpIds.
*
* @param tps the supportingTpIds to set
*/
public void setSupportingTpIds(List<TerminationPointKey> tps) {
this.supportingTpIds = tps;
}
/**
* Sets the te extension.
*
* @param te the te to set
*/
public void setTe(TeTerminationPoint te) {
this.te = te;
}
@Override
public int hashCode() {
return Objects.hashCode(id, supportingTpIds, te);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof DefaultTerminationPoint) {
DefaultTerminationPoint that = (DefaultTerminationPoint) object;
return Objects.equal(this.id, that.id) &&
Objects.equal(this.supportingTpIds, that.supportingTpIds) &&
Objects.equal(this.te, that.te);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", id)
.add("supportingTpIds", supportingTpIds)
.add("te", te)
.toString();
}
}
/*
* 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.tetopology.management.api.node;
/**
* Interface switching capability representation.
*/
public class InterfaceSwitchingCapability {
// Should include switching capability, lsp encoding, max_lsp-bandwidth
}
/*
* 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.tetopology.management.api.node;
import java.util.List;
import org.onosproject.tetopology.management.api.KeyId;
import org.onosproject.tetopology.management.api.TeTopologyEventSubject;
/**
* Abstraction of a network node.
*/
public interface NetworkNode extends TeTopologyEventSubject {
/**
* Returns the node id.
*
* @return node identifier
*/
KeyId nodeId();
/**
* Returns the supporting node ids.
*
* @return list of the ids of the supporting nodes
*/
List<NetworkNodeKey> getSupportingNodeIds();
/**
* Returns the node TE extension attributes.
*
* @return node TE extension attributes
*/
TeNode getTe();
/**
* Returns a collection of currently known termination points.
*
* @return a collection of termination points associated with this node
*/
List<TerminationPoint> getTerminationPoints();
/**
* Returns the termination point.
*
* @param tpId termination point id
* @return value of termination point
*/
TerminationPoint getTerminationPoint(KeyId tpId);
}
/*
* 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.tetopology.management.api.node;
import org.onosproject.tetopology.management.api.KeyId;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* Representation of a node key or node reference.
*/
public class NetworkNodeKey {
private final KeyId networkId;
private final KeyId nodeId;
/**
* Creates an instance of NetworkNodeKey.
*
* @param networkId network identifier
* @param nodeId node identifier
*/
public NetworkNodeKey(KeyId networkId, KeyId nodeId) {
this.networkId = networkId;
this.nodeId = nodeId;
}
/**
* Returns the network identifier.
*
* @return network identifier
*/
public KeyId networkId() {
return networkId;
}
/**
* Returns the node identifier.
*
* @return node identifier
*/
public KeyId nodeId() {
return nodeId;
}
@Override
public int hashCode() {
return Objects.hashCode(networkId, nodeId);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof NetworkNodeKey) {
NetworkNodeKey that = (NetworkNodeKey) object;
return Objects.equal(this.networkId, that.networkId) &&
Objects.equal(this.nodeId, that.nodeId);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("networkId", networkId)
.add("nodeId", nodeId)
.toString();
}
}
/*
* 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.tetopology.management.api.node;
import org.onosproject.tetopology.management.api.KeyId;
import org.onosproject.tetopology.management.api.TeTopologyId;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* TE Network Topology identifiers.
*/
public class TeNetworkTopologyId {
private final KeyId networkId;
private final TeTopologyId topologyId;
/**
* Creates an instance of TeNetworkTopologyId.
*
* @param networkId network identifier
* @param topologyId topology identifier
*/
public TeNetworkTopologyId(KeyId networkId, TeTopologyId topologyId) {
this.networkId = networkId;
this.topologyId = topologyId;
}
/**
* Creates TeNetworkTopologyId with networkId.
*
* @param networkId network identifier
*/
public TeNetworkTopologyId(KeyId networkId) {
this.networkId = networkId;
this.topologyId = null;
}
/**
* Creates TeNetworkTopologyId with topologyId.
*
* @param topologyId topology identifier
*/
public TeNetworkTopologyId(TeTopologyId topologyId) {
this.networkId = null;
this.topologyId = topologyId;
}
/**
* Returns the network identifier.
*
* @return network id
*/
public KeyId getNetworkId() {
return networkId;
}
/**
* Returns the topology identifier.
*
* @return TE topology id
*/
public TeTopologyId getTopologyId() {
return topologyId;
}
@Override
public int hashCode() {
return Objects.hashCode(networkId, topologyId);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof TeNetworkTopologyId) {
TeNetworkTopologyId that = (TeNetworkTopologyId) object;
return Objects.equal(this.networkId, that.networkId) &&
Objects.equal(this.topologyId, that.topologyId);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("networkId", networkId)
.add("topologyId", topologyId)
.toString();
}
}
/*
* 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.tetopology.management.api.node;
import java.util.List;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* TE Node representation.
* <p>
* The Set/Get methods below are defined to accept and pass references because
* the object class is treated as a "composite" object class that holds
* references to various member objects and their relationships, forming a
* data tree. Internal routines of the TE topology manager may use the
* following example methods to construct and manipulate any piece of data in
* the data tree:
* <pre>
* newNode.getTe().setAdminStatus(), or
* newNode.getSupportingNodeIds().add(nodeId), etc.
* </pre>
* Same for constructors where, for example, a child list may be constructed
* first and passed in by reference to its parent object constructor.
*/
public class TeNode {
// See org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.
// topology.rev20160708.ietftetopology
// .augmentednwnode.te.config.DefaultTeNodeAttributes for reference
private String teNodeId;
private String name;
private TeStatus adminStatus;
private TeStatus opStatus;
private boolean isAbstract;
private List<ConnectivityMatrix> connMatrices;
private TeNetworkTopologyId underlayTopology;
private List<TunnelTerminationPoint> tunnelTerminationPoints;
/**
* Creates an instance of TeNode.
*
* @param teNodeId TE node identifier
*/
public TeNode(String teNodeId) {
this.teNodeId = teNodeId;
}
/**
* Sets the node name.
*
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets the node administrative status.
*
* @param adminStatus the adminStatus to set
*/
public void setAdminStatus(TeStatus adminStatus) {
this.adminStatus = adminStatus;
}
/**
* Sets the node operational status.
*
* @param opStatus the opStatus to set
*/
public void setOpStatus(TeStatus opStatus) {
this.opStatus = opStatus;
}
/**
* Sets the node is an abstract node or not.
*
* @param isAbstract the isAbstract to set
*/
public void setAbstract(boolean isAbstract) {
this.isAbstract = isAbstract;
}
/**
* Set connectivity matrix table.
*
* @param connMatrices connectivity matrix table
*/
public void setConnectivityMatrices(List<ConnectivityMatrix> connMatrices) {
this.connMatrices = connMatrices;
}
/**
* Sets the node underlay TE topology.
*
* @param topo the underlayTopology to set
*/
public void setUnderlayTopology(TeNetworkTopologyId topo) {
this.underlayTopology = topo;
}
/**
* Sets the list of tunnel termination points.
*
* @param ttps the tunnelTerminationPoints to set
*/
public void setTunnelTerminationPoints(List<TunnelTerminationPoint> ttps) {
this.tunnelTerminationPoints = ttps;
}
/**
* Returns the teNodeId.
*
* @return TE node id
*/
public String teNodeId() {
return teNodeId;
}
/**
* Returns the name.
*
* @return TE node name
*/
public String name() {
return name;
}
/**
* Returns the adminStatus.
*
* @return TE node admin status
*/
public TeStatus adminStatus() {
return adminStatus;
}
/**
* Returns the opStatus.
*
* @return TE node operational status
*/
public TeStatus opStatus() {
return opStatus;
}
/**
* Returns the isAbstract.
*
* @return true or false if the TE node is abstract
*/
public boolean isAbstract() {
return isAbstract;
}
/**
* Returns the connectivity matrix table.
*
* @return node connectivity matrix table
*/
public List<ConnectivityMatrix> connectivityMatrices() {
return connMatrices;
}
/**
* Returns the underlay topology.
*
* @return node underlay topology
*/
public TeNetworkTopologyId underlayTopology() {
return underlayTopology;
}
/**
* Returns the tunnelTerminationPoints.
*
* @return list of tunnel terminational points
*/
public List<TunnelTerminationPoint> tunnelTerminationPoints() {
return tunnelTerminationPoints;
}
@Override
public int hashCode() {
return Objects.hashCode(teNodeId, name, adminStatus, opStatus, isAbstract,
connMatrices, underlayTopology, tunnelTerminationPoints);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof TeNode) {
TeNode that = (TeNode) object;
return Objects.equal(this.teNodeId, that.teNodeId) &&
Objects.equal(this.name, that.name) &&
Objects.equal(this.adminStatus, that.adminStatus) &&
Objects.equal(this.opStatus, that.opStatus) &&
Objects.equal(this.isAbstract, that.isAbstract) &&
Objects.equal(this.connMatrices, that.connMatrices) &&
Objects.equal(this.underlayTopology, that.underlayTopology) &&
Objects.equal(this.tunnelTerminationPoints, that.tunnelTerminationPoints);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("teNodeId", teNodeId)
.add("name", name)
.add("adminStatus", adminStatus)
.add("opStatus", opStatus)
.add("isAbstract", isAbstract)
.add("connMatrices", connMatrices)
.add("underlayTopology", underlayTopology)
.add("tunnelTerminationPoints", tunnelTerminationPoints)
.toString();
}
}
/*
* 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.tetopology.management.api.node;
/**
* Represents ENUM data of teStatus.
*/
public enum TeStatus {
/**
* Represents up.
*/
UP(0),
/**
* Represents down.
*/
DOWN(1),
/**
* Represents testing.
*/
TESTING(2),
/**
* Represents preparingMaintenance.
*/
PREPARING_MAINTENANCE(3),
/**
* Represents maintenance.
*/
MAINTENANCE(4),
/**
* Status cannot be determined for some reason.
*/
UNKNOWN(5);
private int teStatus;
/**
* Creates an instance of teStatus.
*
* @param value value of teStatus
*/
TeStatus(int value) {
teStatus = value;
}
/**
* Returns the attribute teStatus.
*
* @return value of teStatus
*/
public int teStatus() {
return teStatus;
}
/**
* Returns the object of teStatus fromString input String. Returns null
* when the integer value is not recognized.
*
* @param valInString input String
* @return Object of teStatus
*/
public static TeStatus of(String valInString) {
try {
int tmpVal = Integer.parseInt(valInString);
return of(tmpVal);
} catch (NumberFormatException e) {
}
return null;
}
/**
* Returns the object of teAdminStatusEnumForTypeInt.Returns null
* when string conversion fails or converted integer value is not
* recognized.
*
* @param value value of teAdminStatusEnumForTypeInt
* @return Object of teAdminStatusEnumForTypeInt
*/
public static TeStatus of(int value) {
switch (value) {
case 0:
return TeStatus.UP;
case 1:
return TeStatus.DOWN;
case 2:
return TeStatus.TESTING;
case 3:
return TeStatus.PREPARING_MAINTENANCE;
case 4:
return TeStatus.MAINTENANCE;
case 5:
return TeStatus.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.
*/
package org.onosproject.tetopology.management.api.node;
import java.util.List;
import org.onosproject.tetopology.management.api.KeyId;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/**
* TE termination point representation.
*/
public class TeTerminationPoint {
private KeyId teTpId;
private List<InterfaceSwitchingCapability> capabilities;
private long interLayerLockId;
/**
* Creates an instance of TeTerminationPoint.
*
* @param teTpId TE termination point identifier
* @param capabilities capability descriptor for termination point
* @param interLayerLockId inter-layer lock identifier
*/
public TeTerminationPoint(KeyId teTpId,
List<InterfaceSwitchingCapability> capabilities, long interLayerLockId) {
this.teTpId = teTpId;
this.capabilities = capabilities;
this.interLayerLockId = interLayerLockId;
}
/**
* Creates an instance of TeTerminationPoint with teTpId only.
*
* @param teTpId TE termination point id
*/
public TeTerminationPoint(KeyId teTpId) {
this.teTpId = teTpId;
}
/**
* Returns the TE termination point id.
*
* @return value of teTpId
*/
public KeyId teTpId() {
return teTpId;
}
/**
* Returns the interface switching capabilities.
*
* @return interface switching capabilities
*/
public List<InterfaceSwitchingCapability> interfaceSwitchingCapabilities() {
return capabilities;
}
/**
* Returns the interLayerLockId.
*
* @return interlayer lock id
*/
public long getInterLayerLockId() {
return interLayerLockId;
}
/**
* Sets the te tp Id.
*
* @param teTpId the teTpId to set
*/
public void setTeTpId(KeyId teTpId) {
this.teTpId = teTpId;
}
/**
* Sets the interface switching capabilities.
*
* @param capabilities the capabilities to set
*/
public void setInterfaceSwitchingCapabilities(List<InterfaceSwitchingCapability> capabilities) {
this.capabilities = capabilities;
}
/**
* Sets the inter layer lockId.
*
* @param interLayerLockId the interLayerLockId to set
*/
public void setInterLayerLockId(long interLayerLockId) {
this.interLayerLockId = interLayerLockId;
}
@Override
public int hashCode() {
return Objects.hashCode(teTpId, capabilities, interLayerLockId);
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof TeTerminationPoint) {
TeTerminationPoint that = (TeTerminationPoint) object;
return Objects.equal(this.teTpId, that.teTpId) &&
Objects.equal(this.capabilities, that.capabilities) &&
Objects.equal(this.interLayerLockId, that.interLayerLockId);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("teTpId", teTpId)
.add("capabilities", capabilities)
.add("interLayerLockId", interLayerLockId)
.toString();
}
}
/*
* 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.tetopology.management.api.node;
/**
* The termination capabilities between tunnel-termination-point
* and link termination-point.
*/
public class TerminationCapability {
// See reference - org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang
// .ietf.te.topology.rev20160708.ietftetopology.augmentednwnode.te
//.tunnelterminationpoint.config.DefaultTerminationCapability
private TerminationPointKey linkTpId;
//List<MaxLspBandwidth> maxLspBandwidth
// TODO - to be extended per future standard definitions
}
/*
* 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.tetopology.management.api.node;
import java.util.List;
import org.onosproject.tetopology.management.api.KeyId;
import org.onosproject.tetopology.management.api.TeTopologyEventSubject;
/**
* Abstraction of a termination point.
*/
public interface TerminationPoint extends TeTopologyEventSubject {
/**
* Returns the termination point id.
*
* @return termination point id
*/
KeyId id();
/**
* Returns list of supporting termination point ids.
*
* @return the supportingTpIds
*/
List<TerminationPointKey> getSupportingTpIds();
/**
* Returns TE attributes for this termination point.
*
* @return the te attribute
*/
TeTerminationPoint getTe();
}
/*
* 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.tetopology.management.api.node;
import static com.google.common.base.MoreObjects.toStringHelper;
import org.onosproject.tetopology.management.api.KeyId;
import com.google.common.base.Objects;
/**
* Representation of a termination point key or reference.
*/
public class TerminationPointKey extends NetworkNodeKey {
private final KeyId tpId;
/**
* Creates an instance of TerminationPointKey.
*
* @param networkId network identifier
* @param nodeId node identifier
* @param tpId termination point identifier
*/
public TerminationPointKey(KeyId networkId, KeyId nodeId, KeyId tpId) {
super(networkId, nodeId);
this.tpId = tpId;
}
/**
* Returns the termination point Id.
*
* @return termination point identifier
*/
public KeyId tpId() {
return tpId;
}
@Override
public int hashCode() {
return Objects.hashCode(super.hashCode(), tpId);
}
@Override
public boolean equals(Object object) {
if (object instanceof TerminationPointKey) {
if (!super.equals(object)) {
return false;
}
TerminationPointKey that = (TerminationPointKey) object;
return Objects.equal(this.tpId, that.tpId);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this)
.add("networkId", networkId())
.add("nodeId", nodeId())
.add("tpId", tpId)
.toString();
}
}