diff options
author | CNlucius <lukai1@huawei.com> | 2016-09-13 11:40:12 +0800 |
---|---|---|
committer | CNlucius <lukai1@huawei.com> | 2016-09-13 11:41:53 +0800 |
commit | b731e2f1dd0972409b136aebc7b463dd72c9cfad (patch) | |
tree | 5107d7d80c19ad8076c2c97c2b5ef8d1cf3ab903 /framework/src/onos/providers/pcep | |
parent | ee93993458266114c29271a481ef9ce7ce621b2a (diff) |
ONOSFW-171
O/S-SFC-ONOS scenario documentation
Change-Id: I51ae1cf736ea24ab6680f8edca1b2bf5dd598365
Signed-off-by: CNlucius <lukai1@huawei.com>
Diffstat (limited to 'framework/src/onos/providers/pcep')
24 files changed, 0 insertions, 3638 deletions
diff --git a/framework/src/onos/providers/pcep/app/app.xml b/framework/src/onos/providers/pcep/app/app.xml deleted file mode 100644 index ea3d1d17..00000000 --- a/framework/src/onos/providers/pcep/app/app.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?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.pcep" origin="ON.Lab" version="${project.version}" - featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features" - features="${project.artifactId}"> - <description>${project.description}</description> - <artifact>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</artifact> - <artifact>mvn:${project.groupId}/onos-pcepio/${project.version}</artifact> - <artifact>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</artifact> - <artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact> - <artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact> - <artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact> -</app> diff --git a/framework/src/onos/providers/pcep/app/features.xml b/framework/src/onos/providers/pcep/app/features.xml deleted file mode 100644 index ad344cd7..00000000 --- a/framework/src/onos/providers/pcep/app/features.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?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}/onos-app-pcep-api/${project.version}</bundle> - <bundle>mvn:${project.groupId}/onos-pcepio/${project.version}</bundle> - <bundle>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</bundle> - <bundle>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</bundle> - <bundle>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</bundle> - <bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle> - </feature> -</features> diff --git a/framework/src/onos/providers/pcep/app/pom.xml b/framework/src/onos/providers/pcep/app/pom.xml deleted file mode 100644 index 62a87453..00000000 --- a/framework/src/onos/providers/pcep/app/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ -<!-- - ~ 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. - --> -<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-pcep-providers</artifactId> - <version>1.4.0-rc1</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>onos-pcep</artifactId> - <packaging>pom</packaging> - <description>PCEP protocol southbound providers</description> - - <dependencies> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onos-app-pcep-api</artifactId> - </dependency> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onos-pcepio</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onos-pcep-controller-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onos-pcep-controller-impl</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onos-pcep-provider-topology</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onos-pcep-provider-tunnel</artifactId> - <version>${project.version}</version> - </dependency> - - </dependencies> -</project> diff --git a/framework/src/onos/providers/pcep/pom.xml b/framework/src/onos/providers/pcep/pom.xml deleted file mode 100644 index 4cde516a..00000000 --- a/framework/src/onos/providers/pcep/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ -<!-- - ~ 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. - --> -<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-providers</artifactId> - <version>1.4.0-rc1</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>onos-pcep-providers</artifactId> - <packaging>pom</packaging> - <description>PCEP protocol providers root</description> - <modules> - <module>topology</module> - <module>tunnel</module> - <module>app</module> - </modules> -</project>
\ No newline at end of file diff --git a/framework/src/onos/providers/pcep/topology/pom.xml b/framework/src/onos/providers/pcep/topology/pom.xml deleted file mode 100644 index cb8e0034..00000000 --- a/framework/src/onos/providers/pcep/topology/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ -<!-- - ~ 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. - --> -<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-pcep-providers</artifactId> - <version>1.4.0-rc1</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>onos-pcep-provider-topology</artifactId> - <packaging>bundle</packaging> - <description>PCEP topology provider</description> - <dependencies> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onos-app-pcep-api</artifactId> - </dependency> - </dependencies> -</project>
\ No newline at end of file diff --git a/framework/src/onos/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProvider.java b/framework/src/onos/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProvider.java deleted file mode 100644 index 38eaf1fe..00000000 --- a/framework/src/onos/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProvider.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * 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. - */ -package org.onosproject.provider.pcep.topology.impl; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.onlab.packet.ChassisId; -import org.onosproject.cluster.ClusterService; -import org.onosproject.mastership.MastershipAdminService; -import org.onosproject.mastership.MastershipService; -import org.onosproject.net.ConnectPoint; -import org.onosproject.net.DefaultAnnotations; -import org.onosproject.net.Device; -import org.onosproject.net.DeviceId; -import org.onosproject.net.Link.Type; -import org.onosproject.net.MastershipRole; -import org.onosproject.net.OchPort; -import org.onosproject.net.OduCltPort; -import org.onosproject.net.OmsPort; -import org.onosproject.net.Port; -import org.onosproject.net.device.DefaultDeviceDescription; -import org.onosproject.net.device.DefaultPortDescription; -import org.onosproject.net.device.DeviceDescription; -import org.onosproject.net.device.DeviceProvider; -import org.onosproject.net.device.DeviceProviderRegistry; -import org.onosproject.net.device.DeviceProviderService; -import org.onosproject.net.device.DeviceService; -import org.onosproject.net.device.OchPortDescription; -import org.onosproject.net.device.OduCltPortDescription; -import org.onosproject.net.device.OmsPortDescription; -import org.onosproject.net.device.PortDescription; -import org.onosproject.net.link.DefaultLinkDescription; -import org.onosproject.net.link.LinkDescription; -import org.onosproject.net.link.LinkProvider; -import org.onosproject.net.link.LinkProviderRegistry; -import org.onosproject.net.link.LinkProviderService; -import org.onosproject.net.link.LinkService; -import org.onosproject.net.provider.AbstractProvider; -import org.onosproject.net.provider.ProviderId; -import org.onosproject.pcep.api.PcepController; -import org.onosproject.pcep.api.PcepDpid; -import org.onosproject.pcep.api.PcepLink; -import org.onosproject.pcep.api.PcepLink.PortType; -import org.onosproject.pcep.api.PcepLinkListener; -import org.onosproject.pcep.api.PcepOperator.OperationType; -import org.onosproject.pcep.api.PcepSwitch; -import org.onosproject.pcep.api.PcepSwitchListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.onosproject.net.DeviceId.deviceId; -import static org.onosproject.pcep.api.PcepDpid.uri; - -/** - * Provider which uses an PCEP controller to detect network infrastructure - * topology. - */ -@Component(immediate = true) -public class PcepTopologyProvider extends AbstractProvider - implements LinkProvider, DeviceProvider { - - public PcepTopologyProvider() { - super(new ProviderId("pcep", "org.onosproject.provider.pcep")); - } - - private static final Logger log = LoggerFactory - .getLogger(PcepTopologyProvider.class); - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected LinkProviderRegistry linkProviderRegistry; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected DeviceProviderRegistry deviceProviderRegistry; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected PcepController controller; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected DeviceService deviceService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected LinkService linkService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected MastershipAdminService mastershipAdminService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected MastershipService mastershipService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected ClusterService clusterService; - - private DeviceProviderService deviceProviderService; - private LinkProviderService linkProviderService; - - private HashMap<Long, List<PortDescription>> portMap = new HashMap<>(); - private InternalLinkProvider listener = new InternalLinkProvider(); - - @Activate - public void activate() { - linkProviderService = linkProviderRegistry.register(this); - deviceProviderService = deviceProviderRegistry.register(this); - controller.addListener(listener); - controller.addLinkListener(listener); - } - - @Deactivate - public void deactivate() { - linkProviderRegistry.unregister(this); - linkProviderService = null; - controller.removeListener(listener); - controller.removeLinkListener(listener); - } - - private List<PortDescription> buildPortDescriptions(PcepDpid dpid, - Port port, - PortType portType) { - - List<PortDescription> portList; - - if (portMap.containsKey(dpid.value())) { - portList = portMap.get(dpid.value()); - } else { - portList = new ArrayList<>(); - } - if (port != null && portType != null) { - portList.add(buildPortDescription(port, portType)); - } - - portMap.put(dpid.value(), portList); - return portList; - } - - private PortDescription buildPortDescription(Port port, PortType portType) { - PortDescription portDescription; - - switch (portType) { - case OCH_PORT: - OchPort ochp = (OchPort) port; - portDescription = new OchPortDescription(ochp.number(), ochp.isEnabled(), - ochp.signalType(), ochp.isTunable(), - ochp.lambda()); - break; - case ODU_PORT: - OduCltPort odup = (OduCltPort) port; - portDescription = new OduCltPortDescription(odup.number(), odup.isEnabled(), - odup.signalType()); - break; - case OMS_PORT: - OmsPort op = (OmsPort) port; - portDescription = new OmsPortDescription(op.number(), op.isEnabled(), op.minFrequency(), - op.maxFrequency(), op.grid()); - break; - default: - portDescription = new DefaultPortDescription(port.number(), port.isEnabled()); - break; - } - return portDescription; - } - - /** - * Build a link description from a pcep link. - * - * @param pceLink pcep link - * @return LinkDescription onos link description - */ - private LinkDescription buildLinkDescription(PcepLink pceLink) { - LinkDescription ld; - checkNotNull(pceLink); - DeviceId srcDeviceID = deviceId(uri(pceLink.linkSrcDeviceID())); - DeviceId dstDeviceID = deviceId(uri(pceLink.linkDstDeviceId())); - - deviceProviderService - .updatePorts(srcDeviceID, - buildPortDescriptions(pceLink.linkSrcDeviceID(), - pceLink.linkSrcPort(), pceLink.portType())); - - deviceProviderService - .updatePorts(dstDeviceID, - buildPortDescriptions(pceLink.linkDstDeviceId(), - pceLink.linkDstPort(), pceLink.portType())); - - ConnectPoint src = new ConnectPoint(srcDeviceID, pceLink.linkSrcPort().number()); - - ConnectPoint dst = new ConnectPoint(dstDeviceID, pceLink.linkDstPort().number()); - - DefaultAnnotations extendedAttributes = DefaultAnnotations - .builder() - .set("subType", String.valueOf(pceLink.linkSubType())) - .set("workState", pceLink.linkState()) - .set("distance", String.valueOf(pceLink.linkDistance())) - .set("capType", pceLink.linkCapacityType().toLowerCase()) - .set("avail_" + pceLink.linkCapacityType().toLowerCase(), - String.valueOf(pceLink.linkAvailValue())) - .set("max_" + pceLink.linkCapacityType().toLowerCase(), - String.valueOf(pceLink.linkMaxValue())).build(); - // construct the link - ld = new DefaultLinkDescription(src, dst, Type.OPTICAL, extendedAttributes); - return ld; - } - - private class InternalLinkProvider - implements PcepSwitchListener, PcepLinkListener { - - @Override - public void switchAdded(PcepDpid dpid) { - if (deviceProviderService == null) { - return; - } - DeviceId deviceId = deviceId(uri(dpid)); - PcepSwitch sw = controller.getSwitch(dpid); - checkNotNull(sw, "device should not null."); - // The default device type is switch. - ChassisId cId = new ChassisId(dpid.value()); - Device.Type deviceType; - - switch (sw.getDeviceType()) { - case ROADM: - deviceType = Device.Type.ROADM; - break; - case OTN: - deviceType = Device.Type.SWITCH; - break; - case ROUTER: - deviceType = Device.Type.ROUTER; - break; - default: - deviceType = Device.Type.OTHER; - } - - DeviceDescription description = new DefaultDeviceDescription( - deviceId.uri(), - deviceType, - sw.manufacturerDescription(), - sw.hardwareDescription(), - sw.softwareDescription(), - sw.serialNumber(), - cId); - deviceProviderService.deviceConnected(deviceId, description); - - } - - @Override - public void switchRemoved(PcepDpid dpid) { - if (deviceProviderService == null || linkProviderService == null) { - return; - } - deviceProviderService.deviceDisconnected(deviceId(uri(dpid))); - - linkProviderService.linksVanished(DeviceId.deviceId(uri(dpid))); - } - - @Override - public void switchChanged(PcepDpid dpid) { - // TODO Auto-generated method stub - - } - - @Override - public void handlePCEPlink(PcepLink link) { - - OperationType operType = link.getOperationType(); - LinkDescription ld = buildLinkDescription(link); - if (ld == null) { - log.error("Invalid link info."); - return; - } - switch (operType) { - case ADD: - case UPDATE: - linkProviderService.linkDetected(ld); - break; - - case DELETE: - linkProviderService.linkVanished(ld); - break; - - default: - break; - - } - } - - } - - @Override - public void triggerProbe(DeviceId deviceId) { - // TODO Auto-generated method stub - } - - @Override - public void roleChanged(DeviceId deviceId, MastershipRole newRole) { - } - - @Override - public boolean isReachable(DeviceId deviceId) { - // TODO Auto-generated method stub - return true; - } -} diff --git a/framework/src/onos/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/package-info.java b/framework/src/onos/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/package-info.java deleted file mode 100644 index c119266d..00000000 --- a/framework/src/onos/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/package-info.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ -/** - *Provider that uses PCEP controller as a means of infrastructure topology discovery. - */ -package org.onosproject.provider.pcep.topology.impl;
\ No newline at end of file diff --git a/framework/src/onos/providers/pcep/tunnel/pom.xml b/framework/src/onos/providers/pcep/tunnel/pom.xml deleted file mode 100644 index af303f89..00000000 --- a/framework/src/onos/providers/pcep/tunnel/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ -<!-- - ~ 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. - --> -<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-pcep-providers</artifactId> - <version>1.4.0-rc1</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>onos-pcep-provider-tunnel</artifactId> - <packaging>bundle</packaging> - <description>PCEP-based tunnel provider</description> - <dependencies> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onos-app-pcep-api</artifactId> - </dependency> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onos-pcep-controller-api</artifactId> - </dependency> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.compendium</artifactId> - </dependency> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onos-api</artifactId> - <classifier>tests</classifier> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onosproject</groupId> - <artifactId>onos-incubator-net</artifactId> - <version>${project.version} </version> - <scope>test</scope> - </dependency> - </dependencies> -</project>
\ No newline at end of file diff --git a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelApiMapper.java b/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelApiMapper.java deleted file mode 100644 index b7aa3bda..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelApiMapper.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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. - */ -package org.onosproject.provider.pcep.tunnel.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.collections.map.MultiKeyMap; -import org.onosproject.incubator.net.tunnel.TunnelId; -import org.onosproject.incubator.net.tunnel.TunnelProviderService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Entity to provide tunnel DB and mapping for request/response between CORE to PCEP - * and PCEP to PCC. - */ -public class PcepTunnelApiMapper { - protected static final Logger log = LoggerFactory.getLogger(PcepTunnelApiMapper.class); - - static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; - // Map to store all the tunnel requests. - private Map<Integer, PcepTunnelData> tunnelRequestQueue; - //Map to store all core related tunnel requests. - private Map<TunnelId, PcepTunnelData> coreTunnelRequestQueue; - //Map to store all the created tunnels. - private Map<Integer, PcepTunnelData> tunnelDB; - // Map to store the tunnel ids, given by core and given by pcc. - private Map<TunnelId, Integer> tunnelIdMap; - //Map to store all the learnt tunnels. - private MultiKeyMap pccTunnelDB = new MultiKeyMap(); - - TunnelProviderService tunnelApiMapperservice; - - /** - * Default constructor. - */ - public PcepTunnelApiMapper() { - //TODO check if the map need to initialize - tunnelRequestQueue = new HashMap<Integer, PcepTunnelData>(); - coreTunnelRequestQueue = new HashMap<TunnelId, PcepTunnelData>(); - tunnelDB = new HashMap<Integer, PcepTunnelData>(); - tunnelIdMap = new HashMap<TunnelId, Integer>(); - } - - /** - * Add tunnels to tunnel Request queues. - * - * @param srpId srp id - * @param pcepTunnelData pcep tunnel data - */ - public void addToTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) { - tunnelRequestQueue.put(new Integer(srpId), pcepTunnelData); - log.debug("Tunnel Added to TunnelRequestQueue"); - } - - /** - * Map between Tunnel ID and pcc provided Tunnel ID. - * - * @param pcepTunnelData pcep tunnel data - */ - public void addToTunnelIdMap(PcepTunnelData pcepTunnelData) { - int value = pcepTunnelData.statefulIpv4IndentifierTlv().getTunnelId() & 0xFFFF; - tunnelIdMap.put(pcepTunnelData.tunnel().tunnelId(), (new Integer(value))); - log.debug("Tunnel ID Added to tunnelIdMap"); - } - - /** - * Add tunnels to core tunnel request queue. - * - * @param pcepTunnelData pcep tunnel data - */ - public void addToCoreTunnelRequestQueue(PcepTunnelData pcepTunnelData) { - coreTunnelRequestQueue.put(pcepTunnelData.tunnel().tunnelId(), pcepTunnelData); - log.debug("Tunnel Added to CoreTunnelRequestQueue"); - } - - /** - * Removes tunnels from the core tunnel request queue. - * - * @param tunnelId tunnel id - */ - public void removeFromCoreTunnelRequestQueue(TunnelId tunnelId) { - coreTunnelRequestQueue.remove(tunnelId); - log.debug("Tunnnel create response sent to core and removed from CoreTunnelRequestQueue"); - } - - /** - * Handle the report which comes after initiate message. - * - * @param srpId srp id - * @param pcepTunnelData pcep tunnel data - */ - public void handleCreateTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) { - - int value = tunnelIdMap.get(pcepTunnelData.tunnel().tunnelId()); - tunnelDB.put(new Integer(value), pcepTunnelData); - tunnelRequestQueue.remove(new Integer(srpId), pcepTunnelData); - log.debug("Tunnel Added to TunnelDBQueue and removed from TunnelRequestQueue. tunnel id {}" - + (new Integer(value)).toString()); - } - - /** - * Handle report which comes for update message. - * - * @param srpId srp id - * @param pcepTunnelData pcep tunnel data - */ - public void handleUpdateTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) { - if (pcepTunnelData.rptFlag()) { - pcepTunnelData.setRptFlag(false); - int value = tunnelIdMap.get(pcepTunnelData.tunnel().tunnelId()); - tunnelDB.put(new Integer(value), pcepTunnelData); - tunnelRequestQueue.remove(new Integer(srpId), pcepTunnelData); - log.debug("Tunnel Added to TunnelDBQueue and removed from TunnelRequestQueue. tunnel id {}" , - (new Integer(value)).toString()); - } else { - pcepTunnelData.setRptFlag(true); - tunnelRequestQueue.put(new Integer(srpId), pcepTunnelData); - log.debug("Tunnel updated in TunnelRequestQueue"); - } - } - - /** - * Handle report for tunnel Release request. - * - * @param srpId srp id - * @param pcepTunnelData pcep tunnel data - */ - public void handleRemoveFromTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) { - - int value = tunnelIdMap.get(pcepTunnelData.tunnel().tunnelId()); - tunnelIdMap.remove(pcepTunnelData.tunnel().tunnelId()); - tunnelDB.remove(new Integer(value)); - tunnelRequestQueue.remove(srpId); - log.debug("Tunnel removed from TunnelDBQueue and TunnelRequestQueue"); - } - - /** - * Returns PcepTunnelData from the tunnel request queue. - * - * @param srpId srp id - * @return PcepTunnelData pcep tunnel data - */ - public PcepTunnelData getDataFromTunnelRequestQueue(int srpId) { - return tunnelRequestQueue.get(new Integer(srpId)); - - } - - /** - * Returns PcepTunnelData from the tunnel DB. - * - * @param tunnelId tunnel id - * @return PcepTunnelData pcep tunnel data - */ - public PcepTunnelData getDataFromTunnelDBQueue(TunnelId tunnelId) { - int value = tunnelIdMap.get(tunnelId); - return tunnelDB.get((new Integer(value))); - } - - /** - * Checks whether the tunnel exist in tunnel request queue. - * - * @param srpId srp id - * @return true if tunnel exist in reuest queue, false otherwise - */ - public boolean checkFromTunnelRequestQueue(int srpId) { - boolean retValue = tunnelRequestQueue.containsKey(srpId); - return retValue; - } - - /** - * Returns whether tunnel exist in tunnel db. - * - * @param tunnelId tunnel id - * @return true/false if the tunnel exists in the tunnel db - */ - public boolean checkFromTunnelDBQueue(TunnelId tunnelId) { - int value = tunnelIdMap.get(tunnelId); - boolean retValue = tunnelDB.containsKey((new Integer(value))); - return retValue; - } - - /** - * Add Learnt tunnels to pcc tunnel DB. - * - * @param pcepTunnelData pcep tunnel data - */ - public void addPccTunnelDB(PcepTunnelData pcepTunnelData) { - pccTunnelDB.put(pcepTunnelData.statefulIpv4IndentifierTlv().getTunnelId() & 0xFFFFL, - pcepTunnelData.statefulIpv4IndentifierTlv().getIpv4IngressAddress(), pcepTunnelData); - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelData.java b/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelData.java deleted file mode 100644 index f796a2de..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelData.java +++ /dev/null @@ -1,386 +0,0 @@ -/* - * 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. - */ -package org.onosproject.provider.pcep.tunnel.impl; - -import java.util.Objects; - -import org.onosproject.incubator.net.tunnel.Tunnel; -import org.onosproject.net.ElementId; -import org.onosproject.net.Path; -import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; - -import com.google.common.base.MoreObjects; - -/** - * To store all tunnel related information from Core and Path computation client. - */ -public class PcepTunnelData { - - private Tunnel tunnel; - private Path path; - private int plspId; - private ElementId elementId; - private RequestType requestType; - private boolean rptFlag; - - // data need to store from LSP object - private boolean lspAFlag; - private boolean lspDFlag; - private byte lspOFlag; - private short tunnelId; - private int extTunnelId; - private short lspId; - private StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv; - - /** - * Default constructor. - */ - public PcepTunnelData() { - this.elementId = null; - this.tunnel = null; - this.path = null; - this.requestType = null; - this.rptFlag = false; - this.plspId = 0; - } - - /** - * Constructor to initialize Tunnel, Path and Request type. - * - * @param tunnel mpls tunnel - * @param path Path in network - * @param requestType request type for tunnel - */ - public PcepTunnelData(Tunnel tunnel, Path path, RequestType requestType) { - this.tunnel = tunnel; - this.path = path; - this.requestType = requestType; - } - - /** - * Constructor to initialize ElemendId, Tunnel, Path and Request type. - * - * @param elementId Ip element id - * @param tunnel mpls tunnel - * @param path Path in network - * @param requestType request type for tunnel - */ - public PcepTunnelData(ElementId elementId, Tunnel tunnel, Path path, RequestType requestType) { - this.elementId = elementId; - this.tunnel = tunnel; - this.path = path; - this.requestType = requestType; - } - - /** - * Constructor to initialize Tunnel and Request type. - * - * @param tunnel Tunnel from core - * @param requestType request type for tunnel - */ - public PcepTunnelData(Tunnel tunnel, RequestType requestType) { - this.tunnel = tunnel; - this.requestType = requestType; - } - - /** - * Constructor to initialize ElementId, Tunnel and Request type. - * - * @param elementId Ip element id - * @param tunnel mpls tunnel - * @param requestType request type for tunnel - */ - public PcepTunnelData(ElementId elementId, Tunnel tunnel, RequestType requestType) { - this.elementId = elementId; - this.tunnel = tunnel; - this.requestType = requestType; - } - - /** - * Sets ip element id. - * - * @param elementId Ip element id - */ - public void setElementId(ElementId elementId) { - this.elementId = elementId; - } - - /** - * Sets tunnel. - * - * @param tunnel mpls tunnel - */ - public void setTunnel(Tunnel tunnel) { - this.tunnel = tunnel; - } - - /** - * Sets Path. - * - * @param path Path in network - */ - public void setPath(Path path) { - this.path = path; - } - - /** - * Request type for tunnel. - * - * @param requestType request type for tunnel - */ - public void setRequestType(RequestType requestType) { - this.requestType = requestType; - } - - /** - * Sets plspid generated from pcc. - * - * @param plspId plsp identifier - */ - public void setPlspId(int plspId) { - this.plspId = plspId; - } - - /** - * Sets A flag from lsp object. - * - * @param value A flag value - */ - public void setLspAFlag(boolean value) { - this.lspAFlag = value; - } - - /** - * Sets OF flag from lsp object. - * - * @param value OF flag value - */ - public void setLspOFlag(byte value) { - this.lspOFlag = value; - } - - /** - * Sets tunnel id from PCC. - * - * @param value tunnel id value - */ - public void setTunnelId(short value) { - this.tunnelId = value; - } - - /** - * Sets extended tunnel id from PCC. - * - * @param value extended tunnel id value - */ - public void setExtTunnelId(int value) { - this.extTunnelId = value; - } - - /** - * Sets lsp id from pcc. - * - * @param value lsp id - */ - public void setLspId(short value) { - this.lspId = value; - } - - /** - * Sets statefulIpv4Identifiers tlv. - * @param value statefulIpv4Identifiers tlv - */ - public void setStatefulIpv4IndentifierTlv(StatefulIPv4LspIdentidiersTlv value) { - this.statefulIpv4IndentifierTlv = value; - } - - /** - * Sets report flag. - * - * @param rptFlag report flag - */ - public void setRptFlag(boolean rptFlag) { - this.rptFlag = rptFlag; - } - - /** - * Sets D flag from lsp object. - * - * @param value D flag value - */ - public void setLspDFlag(boolean value) { - this.lspDFlag = value; - } - - /** - * To get Ip element id. - * - * @return Ip elemend id - */ - public ElementId elementId() { - return this.elementId; - } - - /** - * To get Tunnel. - * - * @return tunnel - */ - public Tunnel tunnel() { - return this.tunnel; - } - - /** - * To get Path. - * - * @return path - */ - public Path path() { - return this.path; - } - - /** - * To get request type. - * - * @return request type - */ - public RequestType requestType() { - return this.requestType; - } - - /** - * To get pLspId. - * - * @return pLspId - */ - public int plspId() { - return this.plspId; - } - - /** - * To get A flag. - * - * @return A flag - */ - public boolean lspAFlag() { - return this.lspAFlag; - } - - /** - * To get OF flag. - * - * @return OF flag - */ - public byte lspOFlag() { - return this.lspOFlag; - } - - /** - * To get tunnel id. - * - * @return tunnel id - */ - public short tunnelId() { - return this.tunnelId; - } - - /** - * To get extended tunnel id. - * - * @return extended tunnel id - */ - public int extTunnelId() { - return this.extTunnelId; - } - - /** - * To get pLspId. - * - * @return pLspId - */ - public short lspId() { - return this.lspId; - } - - /** - * To get D Flag. - * - * @return d flag - */ - public boolean lspDFlag() { - return this.lspDFlag; - } - - /** - * To get statefulIpv4Indentifier tlv. - * - * @return statefulIpv4Indentifier tlv - */ - public StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv() { - return this.statefulIpv4IndentifierTlv; - } - - /** - * To get report flag. - * - * @return report flag - */ - public boolean rptFlag() { - return this.rptFlag; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof PcepTunnelData) { - PcepTunnelData other = (PcepTunnelData) obj; - return Objects.equals(tunnel, other.tunnel) - && Objects.equals(path, other.path) - && Objects.equals(plspId, other.plspId) - && Objects.equals(elementId, other.elementId) - && Objects.equals(requestType, other.requestType) - && Objects.equals(rptFlag, other.rptFlag) - && Objects.equals(lspAFlag, other.lspAFlag) - && Objects.equals(lspDFlag, other.lspDFlag) - && Objects.equals(lspOFlag, other.lspOFlag) - && Objects.equals(tunnelId, other.tunnelId) - && Objects.equals(extTunnelId, other.extTunnelId) - && Objects.equals(lspId, other.lspId) - && Objects.equals(statefulIpv4IndentifierTlv, other.statefulIpv4IndentifierTlv); - } - - return false; - } - - @Override - public int hashCode() { - return Objects.hash(tunnel, path, plspId, elementId, requestType, rptFlag, lspAFlag, - lspDFlag, lspOFlag, tunnelId, extTunnelId, lspId, statefulIpv4IndentifierTlv); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).add("Tunnel", tunnel) - .add("Path", path).add("PlspId", plspId).add("ElementId", elementId) - .add("RequestType", requestType).add("RptFlag", rptFlag).add("LspAFlag", lspAFlag) - .add("LspDFlag", lspDFlag).add("LspOFlag", lspOFlag).add("TunnelId", tunnelId) - .add("ExtTunnelid", extTunnelId).add("LspId", lspId) - .add("StatefulIpv4IndentifierTlv", statefulIpv4IndentifierTlv).toString(); - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java b/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java deleted file mode 100644 index 648e500b..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java +++ /dev/null @@ -1,1230 +0,0 @@ -/* - * 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. - */ -package org.onosproject.provider.pcep.tunnel.impl; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Strings.isNullOrEmpty; -import static org.onosproject.net.DefaultAnnotations.EMPTY; -import static org.onlab.util.Tools.get; -import static org.onosproject.net.DeviceId.deviceId; -import static org.onosproject.net.PortNumber.portNumber; -import static org.onosproject.pcep.api.PcepDpid.uri; -import static org.slf4j.LoggerFactory.getLogger; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Dictionary; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.Optional; - -import com.google.common.collect.Maps; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.apache.felix.scr.annotations.Service; -import org.onlab.packet.IpAddress; -import org.onosproject.cfg.ComponentConfigService; -import org.onosproject.core.DefaultGroupId; -import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint; -import org.onosproject.incubator.net.tunnel.DefaultTunnel; -import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription; -import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; -import org.onosproject.incubator.net.tunnel.DefaultTunnelStatistics; -import org.onosproject.incubator.net.tunnel.OpticalLogicId; -import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; -import org.onosproject.incubator.net.tunnel.Tunnel; -import org.onosproject.incubator.net.tunnel.TunnelDescription; -import org.onosproject.incubator.net.tunnel.TunnelEndPoint; -import org.onosproject.incubator.net.tunnel.TunnelId; -import org.onosproject.incubator.net.tunnel.TunnelName; -import org.onosproject.incubator.net.tunnel.TunnelProvider; -import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry; -import org.onosproject.incubator.net.tunnel.TunnelProviderService; -import org.onosproject.incubator.net.tunnel.TunnelService; -import org.onosproject.incubator.net.tunnel.TunnelStatistics; -import org.onosproject.net.ConnectPoint; -import org.onosproject.net.DefaultAnnotations; -import org.onosproject.net.DefaultLink; -import org.onosproject.net.DefaultPath; -import org.onosproject.net.DeviceId; -import org.onosproject.net.ElementId; -import org.onosproject.net.IpElementId; -import org.onosproject.net.Link; -import org.onosproject.net.Path; -import org.onosproject.net.PortNumber; -import org.onosproject.net.SparseAnnotations; -import org.onosproject.net.provider.AbstractProvider; -import org.onosproject.net.provider.ProviderId; -import org.onosproject.pcep.api.PcepController; -import org.onosproject.pcep.api.PcepDpid; -import org.onosproject.pcep.api.PcepHopNodeDescription; -import org.onosproject.pcep.api.PcepOperator.OperationType; -import org.onosproject.pcep.api.PcepTunnel; -import org.onosproject.pcep.api.PcepTunnel.PATHTYPE; -import org.onosproject.pcep.api.PcepTunnel.PathState; -import org.onosproject.pcep.api.PcepTunnelListener; -import org.onosproject.pcep.api.PcepTunnelStatistics; -import org.osgi.service.component.annotations.Modified; -import org.onosproject.pcep.controller.PccId; -import org.onosproject.pcep.controller.PcepClient; -import org.onosproject.pcep.controller.PcepClientController; -import org.onosproject.pcep.controller.PcepClientListener; -import org.onosproject.pcep.controller.PcepEventListener; -import org.onosproject.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcInitiatedLspRequest; -import org.onosproject.pcepio.protocol.PcepAttribute; -import org.onosproject.pcepio.protocol.PcepBandwidthObject; -import org.onosproject.pcepio.protocol.PcepEndPointsObject; -import org.onosproject.pcepio.protocol.PcepEroObject; -import org.onosproject.pcepio.protocol.PcepInitiateMsg; -import org.onosproject.pcepio.protocol.PcepLspObject; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMsgPath; -import org.onosproject.pcepio.protocol.PcepReportMsg; -import org.onosproject.pcepio.protocol.PcepRroObject; -import org.onosproject.pcepio.protocol.PcepSrpObject; -import org.onosproject.pcepio.protocol.PcepStateReport; -import org.onosproject.pcepio.protocol.PcepUpdateMsg; -import org.onosproject.pcepio.protocol.PcepUpdateRequest; -import org.onosproject.pcepio.types.IPv4SubObject; -import org.onosproject.pcepio.types.PcepValueType; -import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; -import org.onosproject.pcepio.types.SymbolicPathNameTlv; -import org.slf4j.Logger; -import org.osgi.service.component.ComponentContext; - -/** - * Provider which uses an PCEP controller to detect, update, create network - * tunnels. - */ -@Component(immediate = true) -@Service -public class PcepTunnelProvider extends AbstractProvider implements TunnelProvider { - - private static final Logger log = getLogger(PcepTunnelProvider.class); - private static final long MAX_BANDWIDTH = 99999744; - private static final long MIN_BANDWIDTH = 64; - private static final String BANDWIDTH_UINT = "kbps"; - static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; - - static final int POLL_INTERVAL = 10; - @Property(name = "tunnelStatsPollFrequency", intValue = POLL_INTERVAL, - label = "Frequency (in seconds) for polling tunnel statistics") - private int tunnelStatsPollFrequency = POLL_INTERVAL; - - private static final String TUNNLE_NOT_NULL = "Create failed,The given port may be wrong or has been occupied."; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected TunnelProviderRegistry tunnelProviderRegistry; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected PcepController controller; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected PcepClientController pcepClientController; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected TunnelService tunnelService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected ComponentConfigService cfgService; - - TunnelProviderService service; - - HashMap<String, TunnelId> tunnelMap = new HashMap<String, TunnelId>(); - HashMap<TunnelId, TunnelStatistics> tunnelStatisticsMap = new HashMap<>(); - private HashMap<Long, TunnelStatsCollector> collectors = Maps.newHashMap(); - - private InnerTunnelProvider listener = new InnerTunnelProvider(); - - protected PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); - private static final int DEFAULT_BANDWIDTH_VALUE = 10; - - /** - * Creates a Tunnel provider. - */ - public PcepTunnelProvider() { - super(new ProviderId("pcep", PROVIDER_ID)); - } - - @Activate - public void activate() { - cfgService.registerProperties(getClass()); - service = tunnelProviderRegistry.register(this); - controller.addTunnelListener(listener); - pcepClientController.addListener(listener); - pcepClientController.addEventListener(listener); - tunnelService.queryAllTunnels().forEach(tunnel -> { - String pcepTunnelId = getPCEPTunnelKey(tunnel.tunnelId()); - TunnelStatsCollector tsc = new TunnelStatsCollector(pcepTunnelId, tunnelStatsPollFrequency); - tsc.start(); - collectors.put(tunnel.tunnelId().id(), tsc); - - }); - - log.info("Started"); - } - - @Deactivate - public void deactivate() { - tunnelProviderRegistry.unregister(this); - controller.removeTunnelListener(listener); - collectors.values().forEach(TunnelStatsCollector::stop); - pcepClientController.removeListener(listener); - log.info("Stopped"); - } - - @Modified - public void modified(ComponentContext context) { - Dictionary<?, ?> properties = context.getProperties(); - int newTunnelStatsPollFrequency; - try { - String s = get(properties, "tunnelStatsPollFrequency"); - newTunnelStatsPollFrequency = isNullOrEmpty(s) ? tunnelStatsPollFrequency : Integer.parseInt(s.trim()); - - } catch (NumberFormatException | ClassCastException e) { - newTunnelStatsPollFrequency = tunnelStatsPollFrequency; - } - - if (newTunnelStatsPollFrequency != tunnelStatsPollFrequency) { - tunnelStatsPollFrequency = newTunnelStatsPollFrequency; - collectors.values().forEach(tsc -> tsc.adjustPollInterval(tunnelStatsPollFrequency)); - log.info("New setting: tunnelStatsPollFrequency={}", tunnelStatsPollFrequency); - } - - } - - @Override - public void setupTunnel(Tunnel tunnel, Path path) { - if (tunnel.type() != Tunnel.Type.MPLS) { - log.error("Tunnel Type MPLS is only supported"); - return; - } - - // check for tunnel end points - if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) { - log.error("Tunnel source or destination is not valid"); - return; - } - - // Get the pcc client - PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip())); - - if (!(pc instanceof PcepClient)) { - log.error("There is no PCC connected with ip addresss {}" - + ((IpTunnelEndPoint) tunnel.src()).ip().toString()); - return; - } - pcepSetupTunnel(tunnel, path, pc); - } - - @Override - public void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path) { - - if (tunnel.type() != Tunnel.Type.MPLS) { - log.error("Tunnel Type MPLS is only supported"); - return; - } - - if (!(srcElement instanceof IpElementId)) { - log.error("Element id is not valid"); - return; - } - - // check for tunnel end points - if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) { - log.error("Tunnel source or destination is not valid"); - return; - } - - PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpElementId) srcElement).ipAddress())); - - if (!(pc instanceof PcepClient)) { - log.error("There is no PCC connected with ip addresss {}" - + ((IpElementId) srcElement).ipAddress().toString()); - return; - } - pcepSetupTunnel(tunnel, path, pc); - } - - @Override - public void releaseTunnel(Tunnel tunnel) { - - if (tunnel.type() != Tunnel.Type.MPLS) { - log.error("Tunnel Type MPLS is only supported"); - return; - } - - // check for tunnel end points - if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) { - log.error("Tunnel source or destination is not valid"); - return; - } - - PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip())); - - if (!(pc instanceof PcepClient)) { - log.error("There is no PCC connected with ip addresss {}" - + ((IpTunnelEndPoint) tunnel.src()).ip().toString()); - return; - } - pcepReleaseTunnel(tunnel, pc); - } - - @Override - public void releaseTunnel(ElementId srcElement, Tunnel tunnel) { - if (tunnel.type() != Tunnel.Type.MPLS) { - log.error("Tunnel Type MPLS is only supported"); - return; - } - - if (!(srcElement instanceof IpElementId)) { - log.error("Element id is not valid"); - return; - } - - // check for tunnel end points - if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) { - log.error("Tunnel source or destination is not valid"); - return; - } - - PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpElementId) srcElement).ipAddress())); - - if (!(pc instanceof PcepClient)) { - log.error("There is no PCC connected with ip addresss {}" - + ((IpElementId) srcElement).ipAddress().toString()); - return; - } - pcepReleaseTunnel(tunnel, pc); - } - - @Override - public void updateTunnel(Tunnel tunnel, Path path) { - if (tunnel.type() != Tunnel.Type.MPLS) { - log.error("Tunnel Type MPLS is only supported"); - return; - } - - // check for tunnel end points - if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) { - log.error("Tunnel source or destination is not valid"); - return; - } - - PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip())); - - if (!(pc instanceof PcepClient)) { - log.error("There is no PCC connected with ip addresss {}" - + ((IpTunnelEndPoint) tunnel.src()).ip().toString()); - return; - } - pcepUpdateTunnel(tunnel, path, pc); - } - - @Override - public void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path) { - - if (tunnel.type() != Tunnel.Type.MPLS) { - log.error("Tunnel Type MPLS is only supported"); - return; - } - - if (!(srcElement instanceof IpElementId)) { - log.error("Element id is not valid"); - return; - } - - // check for tunnel end points - if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) { - log.error("Tunnel source or destination is not valid"); - return; - } - - PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpElementId) srcElement).ipAddress())); - - if (!(pc instanceof PcepClient)) { - log.error("There is no PCC connected with ip addresss {}" - + ((IpElementId) srcElement).ipAddress().toString()); - return; - } - pcepUpdateTunnel(tunnel, path, pc); - } - - @Override - public TunnelId tunnelAdded(TunnelDescription tunnel) { - if (tunnel.type() == Tunnel.Type.MPLS) { - pcepTunnelAPIMapper.removeFromCoreTunnelRequestQueue(tunnel.id()); - return service.tunnelAdded(tunnel); - } - - long bandwidth = Long - .parseLong(tunnel.annotations().value("bandwidth")); - - if (bandwidth < MIN_BANDWIDTH || bandwidth > MAX_BANDWIDTH) { - error("Update failed, invalid bandwidth."); - return null; - } - - // endpoints - OpticalTunnelEndPoint src = (org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint) tunnel - .src(); - OpticalTunnelEndPoint dst = (OpticalTunnelEndPoint) tunnel.dst(); - // devices - DeviceId srcId = (DeviceId) src.elementId().get(); - DeviceId dstId = (DeviceId) dst.elementId().get(); - - // ports - long srcPort = src.portNumber().get().toLong(); - long dstPort = dst.portNumber().get().toLong(); - - // type - if (tunnel.type() != Tunnel.Type.VLAN) { - error("Illegal tunnel type. Only support VLAN tunnel creation."); - return null; - } - - PcepTunnel pcepTunnel = controller.applyTunnel(srcId, dstId, srcPort, - dstPort, bandwidth, - tunnel.tunnelName() - .value()); - - checkNotNull(pcepTunnel, TUNNLE_NOT_NULL); - TunnelDescription tunnelAdded = buildOpticalTunnel(pcepTunnel, null); - TunnelId tunnelId = service.tunnelAdded(tunnelAdded); - - tunnelMap.put(String.valueOf(pcepTunnel.id()), tunnelId); - return tunnelId; - } - - @Override - public void tunnelRemoved(TunnelDescription tunnel) { - if (tunnel.type() == Tunnel.Type.MPLS) { - pcepTunnelAPIMapper.removeFromCoreTunnelRequestQueue(tunnel.id()); - service.tunnelRemoved(tunnel); - } - - Tunnel tunnelOld = tunnelQueryById(tunnel.id()); - checkNotNull(tunnelOld, "The tunnel id is not exsited."); - if (tunnelOld.type() != Tunnel.Type.VLAN) { - error("Illegal tunnel type. Only support VLAN tunnel deletion."); - return; - } - String pcepTunnelId = getPCEPTunnelKey(tunnel.id()); - checkNotNull(pcepTunnelId, "The tunnel id is not exsited."); - if (!controller.deleteTunnel(pcepTunnelId)) { - error("Delete tunnel failed, Maybe some devices have been disconnected."); - return; - } - tunnelMap.remove(pcepTunnelId); - service.tunnelRemoved(tunnel); - } - - @Override - public void tunnelUpdated(TunnelDescription tunnel) { - if (tunnel.type() == Tunnel.Type.MPLS) { - pcepTunnelAPIMapper.removeFromCoreTunnelRequestQueue(tunnel.id()); - service.tunnelUpdated(tunnel); - } - - Tunnel tunnelOld = tunnelQueryById(tunnel.id()); - if (tunnelOld.type() != Tunnel.Type.VLAN) { - error("Illegal tunnel type. Only support VLAN tunnel update."); - return; - } - long bandwidth = Long - .parseLong(tunnel.annotations().value("bandwidth")); - if (bandwidth < MIN_BANDWIDTH || bandwidth > MAX_BANDWIDTH) { - error("Update failed, invalid bandwidth."); - return; - } - String pcepTunnelId = getPCEPTunnelKey(tunnel.id()); - - checkNotNull(pcepTunnelId, "Invalid tunnel id"); - if (!controller.updateTunnelBandwidth(pcepTunnelId, bandwidth)) { - - error("Update failed,maybe invalid bandwidth."); - return; - - } - service.tunnelUpdated(tunnel); - } - - private void error(String info) { - System.err.println(info); - } - - // Short-hand for creating a connection point. - private ConnectPoint connectPoint(PcepDpid id, long port) { - return new ConnectPoint(deviceId(uri(id)), portNumber(port)); - } - - // Short-hand for creating a link. - private Link link(PcepDpid src, long sp, PcepDpid dst, long dp) { - return new DefaultLink(id(), connectPoint(src, sp), connectPoint(dst, - dp), - Link.Type.TUNNEL); - } - - // Creates a path that leads through the given devices. - private Path createPath(List<PcepHopNodeDescription> hopList, - PATHTYPE pathtype, PathState pathState) { - if (hopList == null || hopList.size() == 0) { - return null; - } - List<Link> links = new ArrayList<>(); - for (int i = 1; i < hopList.size() - 1; i = i + 2) { - links.add(link(hopList.get(i).getDeviceId(), hopList.get(i) - .getPortNum(), hopList.get(i + 1).getDeviceId(), hopList - .get(i + 1).getPortNum())); - } - - int hopNum = hopList.size() - 2; - DefaultAnnotations extendAnnotations = DefaultAnnotations.builder() - .set("pathNum", String.valueOf(hopNum)) - .set("pathState", String.valueOf(pathState)) - .set("pathType", String.valueOf(pathtype)).build(); - return new DefaultPath(id(), links, hopNum, extendAnnotations); - } - - // convert the path description to a string. - public String pathToString(List<Link> links) { - StringBuilder builder = new StringBuilder(); - builder.append("{"); - for (Link link : links) { - builder.append("(Device:" + link.src().deviceId() + " Port:" - + link.src().port().toLong()); - builder.append(" Device:" + link.dst().deviceId() + " Port:" - + link.dst().port().toLong()); - builder.append(")"); - } - builder.append("}"); - return builder.toString(); - } - - // build a TunnelDescription. - private TunnelDescription buildOpticalTunnel(PcepTunnel pcepTunnel, - TunnelId tunnelId) { - TunnelEndPoint srcPoint = null; - TunnelEndPoint dstPoint = null; - Tunnel.Type tunnelType = null; - TunnelName name = TunnelName.tunnelName(pcepTunnel.name()); - - // add path after codes of tunnel's path merged - Path path = createPath(pcepTunnel.getHopList(), - pcepTunnel.getPathType(), - pcepTunnel.getPathState()); - - OpticalTunnelEndPoint.Type endPointType = null; - switch (pcepTunnel.type()) { - case OCH: - tunnelType = Tunnel.Type.OCH; - endPointType = OpticalTunnelEndPoint.Type.LAMBDA; - break; - - case OTN: - tunnelType = Tunnel.Type.ODUK; - endPointType = OpticalTunnelEndPoint.Type.TIMESLOT; - break; - - case UNI: - tunnelType = Tunnel.Type.VLAN; - endPointType = null; - break; - - default: - break; - } - DeviceId srcDid = deviceId(uri(pcepTunnel.srcDeviceID())); - DeviceId dstDid = deviceId(uri(pcepTunnel.dstDeviceId())); - PortNumber srcPort = PortNumber.portNumber(pcepTunnel.srcPort()); - PortNumber dstPort = PortNumber.portNumber(pcepTunnel.dstPort()); - - srcPoint = new DefaultOpticalTunnelEndPoint(id(), Optional.of(srcDid), - Optional.of(srcPort), null, - endPointType, - OpticalLogicId.logicId(0), - true); - dstPoint = new DefaultOpticalTunnelEndPoint(id(), Optional.of(dstDid), - Optional.of(dstPort), null, - endPointType, - OpticalLogicId.logicId(0), - true); - - // basic annotations - DefaultAnnotations annotations = DefaultAnnotations - .builder() - .set("SLA", String.valueOf(pcepTunnel.getSla())) - .set("bandwidth", - String.valueOf(pcepTunnel.bandWidth()) + BANDWIDTH_UINT) - .set("index", String.valueOf(pcepTunnel.id())).build(); - - // a VLAN tunnel always carry OCH tunnel, this annotation is the index - // of a OCH tunnel. - if (pcepTunnel.underlayTunnelId() != 0) { - DefaultAnnotations extendAnnotations = DefaultAnnotations - .builder() - .set("underLayTunnelIndex", - String.valueOf(pcepTunnel.underlayTunnelId())).build(); - annotations = DefaultAnnotations.merge(annotations, - extendAnnotations); - - } - TunnelDescription tunnel = new DefaultTunnelDescription( - tunnelId, - srcPoint, - dstPoint, - tunnelType, - new DefaultGroupId( - 0), - id(), name, - path, - annotations); - return tunnel; - - } - - /** - * Get the tunnelID according to the tunnel key. - * - * @param tunnelKey tunnel key - * @return corresponding tunnel id of the a tunnel key. - */ - private TunnelId getTunnelId(String tunnelKey) { - for (String key : tunnelMap.keySet()) { - if (key.equals(tunnelKey)) { - return tunnelMap.get(key); - } - } - return null; - } - - /** - * Get the tunnel key according to the tunnelID. - * - * @param tunnelId tunnel id - * @return corresponding a tunnel key of the tunnel id. - */ - private String getPCEPTunnelKey(TunnelId tunnelId) { - for (String key : tunnelMap.keySet()) { - if (tunnelMap.get(key).id() == tunnelId.id()) { - return key; - } - } - return null; - - } - - /** - * Build a DefaultTunnelStatistics from a PcepTunnelStatistics. - * - * @param statistics statistics data from a PCEP tunnel - * @return TunnelStatistics - */ - private TunnelStatistics buildTunnelStatistics(PcepTunnelStatistics statistics) { - DefaultTunnelStatistics.Builder builder = new DefaultTunnelStatistics.Builder(); - DefaultTunnelStatistics tunnelStatistics = builder.setBwUtilization(statistics.bandwidthUtilization()) - .setPacketLossRatio(statistics.packetLossRate()) - .setFlowDelay(statistics.flowDelay()) - .setAlarms(statistics.alarms()) - .build(); - return tunnelStatistics; - } - /** - * Creates list of hops for ERO object from Path. - * - * @param path network path - * @return list of ipv4 subobjects - */ - private LinkedList<PcepValueType> createPcepPath(Path path) { - LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); - List<Link> listLink = path.links(); - ConnectPoint source = null; - ConnectPoint destination = null; - IpAddress ipDstAddress = null; - IpAddress ipSrcAddress = null; - PcepValueType subObj = null; - - for (Link link : listLink) { - source = link.src(); - if (!(source.equals(destination))) { - //set IPv4SubObject for ERO object - ipSrcAddress = source.ipElementId().ipAddress(); - subObj = new IPv4SubObject(ipSrcAddress.getIp4Address().toInt()); - llSubObjects.add(subObj); - } - - destination = link.dst(); - ipDstAddress = destination.ipElementId().ipAddress(); - subObj = new IPv4SubObject(ipDstAddress.getIp4Address().toInt()); - llSubObjects.add(subObj); - } - return llSubObjects; - } - - /** - * Creates PcInitiated lsp request list for setup tunnel. - * - * @param tunnel mpls tunnel - * @param path network path - * @param pc pcep client - * @param srpId unique id for pcep message - * @return list of PcInitiatedLspRequest - * @throws PcepParseException while building pcep objects fails - */ - LinkedList<PcInitiatedLspRequest> createPcInitiatedLspReqList(Tunnel tunnel, Path path, - PcepClient pc, int srpId) - throws PcepParseException { - PcepValueType tlv; - LinkedList<PcepValueType> llSubObjects = createPcepPath(path); - - if (llSubObjects == null || llSubObjects.size() == 0) { - log.error("There is no link information to create tunnel"); - return null; - } - - //build SRP object - PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(false).build(); - - LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); - LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = new LinkedList<PcInitiatedLspRequest>(); - // set LSP identifiers TLV - tlv = new StatefulIPv4LspIdentidiersTlv((((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt()), - (short) 0, (short) 0, 0, - (((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt())); - llOptionalTlv.add(tlv); - //set SymbolicPathNameTlv of LSP object - tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); - llOptionalTlv.add(tlv); - - //build LSP object - PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true).setOFlag((byte) 0).setPlspId(0) - .setOptionalTlv(llOptionalTlv).build(); - - //build ENDPOINTS object - PcepEndPointsObject endpointsobj = pc.factory().buildEndPointsObject() - .setSourceIpAddress(((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt()) - .setDestIpAddress(((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt()) - .setPFlag(true).build(); - - //build ERO object - PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); - - int iBandwidth = DEFAULT_BANDWIDTH_VALUE; - if (tunnel.annotations().value("bandwidth") != null) { - iBandwidth = Integer.parseInt(tunnel.annotations().value("bandwidth")); - } - // build bandwidth object - PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); - // build pcep attribute - PcepAttribute pcepAttribute = pc.factory().buildPcepAttribute().setBandwidthObject(bandwidthObject).build(); - - PcInitiatedLspRequest initiateLspRequest = pc.factory().buildPcInitiatedLspRequest().setSrpObject(srpobj) - .setLspObject(lspobj).setEndPointsObject(endpointsobj).setEroObject(eroobj) - .setPcepAttribute(pcepAttribute).build(); - llPcInitiatedLspRequestList.add(initiateLspRequest); - return llPcInitiatedLspRequestList; - } - - /** - * To send initiate tunnel message to pcc. - * - * @param tunnel mpls tunnel info - * @param path explicit route for the tunnel - * @param pc pcep client to send message - */ - private void pcepSetupTunnel(Tunnel tunnel, Path path, PcepClient pc) { - try { - int srpId = SrpIdGenerators.create(); - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.CREATE); - - pcepTunnelAPIMapper.addToCoreTunnelRequestQueue(pcepTunnelData); - - LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = createPcInitiatedLspReqList(tunnel, path, - pc, srpId); - if (llPcInitiatedLspRequestList == null || llPcInitiatedLspRequestList.size() == 0) { - log.error("Failed to create PcInitiatedLspRequestList"); - return; - } - - //build PCInitiate message - PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg() - .setPcInitiatedLspRequestList(llPcInitiatedLspRequestList) - .build(); - - pc.sendMessage(Collections.singletonList(pcInitiateMsg)); - - pcepTunnelAPIMapper.addToTunnelRequestQueue(srpId, pcepTunnelData); - } catch (PcepParseException e) { - log.error("PcepParseException occurred while processing setup tunnel {}", e.getMessage()); - } - } - - /** - * To send Release tunnel message to pcc. - * - * @param tunnel mpls tunnel info - * @param pc pcep client to send message - */ - private void pcepReleaseTunnel(Tunnel tunnel, PcepClient pc) { - try { - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, RequestType.DELETE); - pcepTunnelAPIMapper.addToCoreTunnelRequestQueue(pcepTunnelData); - int srpId = SrpIdGenerators.create(); - TunnelId tunnelId = tunnel.tunnelId(); - int plspId = 0; - StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv = null; - - if (!(pcepTunnelAPIMapper.checkFromTunnelDBQueue(tunnelId))) { - log.error("Tunnel doesnot exists. Tunnel id {}" + tunnelId.toString()); - return; - } else { - PcepTunnelData pcepTunnelDbData = pcepTunnelAPIMapper.getDataFromTunnelDBQueue(tunnelId); - plspId = pcepTunnelDbData.plspId(); - statefulIpv4IndentifierTlv = pcepTunnelDbData.statefulIpv4IndentifierTlv(); - } - // build srp object - PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(true).build(); - - PcepValueType tlv; - LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); - LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = new LinkedList<PcInitiatedLspRequest>(); - - if (statefulIpv4IndentifierTlv != null) { - tlv = statefulIpv4IndentifierTlv; - } else { - tlv = new StatefulIPv4LspIdentidiersTlv(( - ((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt()), - (short) 0, (short) 0, 0, - (((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt())); - } - llOptionalTlv.add(tlv); - tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); - llOptionalTlv.add(tlv); - // build lsp object, set r flag as false to delete the tunnel - PcepLspObject lspobj = pc.factory().buildLspObject().setRFlag(false).setPlspId(plspId) - .setOptionalTlv(llOptionalTlv).build(); - - PcInitiatedLspRequest releaseLspRequest = pc.factory().buildPcInitiatedLspRequest().setSrpObject(srpobj) - .setLspObject(lspobj).build(); - - llPcInitiatedLspRequestList.add(releaseLspRequest); - - PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg() - .setPcInitiatedLspRequestList(llPcInitiatedLspRequestList).build(); - - pc.sendMessage(Collections.singletonList(pcInitiateMsg)); - - pcepTunnelAPIMapper.addToTunnelRequestQueue(srpId, pcepTunnelData); - } catch (PcepParseException e) { - log.error("PcepParseException occurred while processing release tunnel {}", e.getMessage()); - } - } - - /** - * To send Update tunnel request message to pcc. - * - * @param tunnel mpls tunnel info - * @param path explicit route for the tunnel - * @param pc pcep client to send message - */ - private void pcepUpdateTunnel(Tunnel tunnel, Path path, PcepClient pc) { - try { - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE); - pcepTunnelAPIMapper.addToCoreTunnelRequestQueue(pcepTunnelData); - int srpId = SrpIdGenerators.create(); - TunnelId tunnelId = tunnel.tunnelId(); - PcepValueType tlv; - int plspId = 0; - - LinkedList<PcepValueType> llSubObjects = createPcepPath(path); - LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); - LinkedList<PcepUpdateRequest> llUpdateRequestList = new LinkedList<PcepUpdateRequest>(); - - //build SRP object - PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(false).build(); - - if (!(pcepTunnelAPIMapper.checkFromTunnelDBQueue(tunnelId))) { - log.error("Tunnel doesnot exists in DB"); - return; - } else { - PcepTunnelData pcepTunnelDBData = pcepTunnelAPIMapper.getDataFromTunnelDBQueue(tunnelId); - plspId = pcepTunnelDBData.plspId(); - } - - tlv = new StatefulIPv4LspIdentidiersTlv((((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt()), - (short) 0, (short) 0, 0, - (((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt())); - llOptionalTlv.add(tlv); - - if (tunnel.tunnelName().value() != null) { - tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); - llOptionalTlv.add(tlv); - } - - // build lsp object - PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true).setPlspId(plspId) - .setOptionalTlv(llOptionalTlv).build(); - // build ero object - PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); - - int iBandwidth = DEFAULT_BANDWIDTH_VALUE; - if (tunnel.annotations().value("bandwidth") != null) { - iBandwidth = Integer.parseInt(tunnel.annotations().value("bandwidth")); - } - // build bandwidth object - PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); - // build pcep attribute - PcepAttribute pcepAttribute = pc.factory().buildPcepAttribute().setBandwidthObject(bandwidthObject).build(); - // build pcep msg path - PcepMsgPath msgPath = pc.factory().buildPcepMsgPath().setEroObject(eroobj).setPcepAttribute(pcepAttribute) - .build(); - - PcepUpdateRequest updateRequest = pc.factory().buildPcepUpdateRequest().setSrpObject(srpobj) - .setLspObject(lspobj).setMsgPath(msgPath).build(); - - llUpdateRequestList.add(updateRequest); - - PcepUpdateMsg pcUpdateMsg = pc.factory().buildUpdateMsg().setUpdateRequestList(llUpdateRequestList).build(); - - pc.sendMessage(Collections.singletonList(pcUpdateMsg)); - pcepTunnelAPIMapper.addToTunnelRequestQueue(srpId, pcepTunnelData); - } catch (PcepParseException e) { - log.error("PcepParseException occurred while processing release tunnel {}", e.getMessage()); - } - } - - - - private class InnerTunnelProvider implements PcepTunnelListener, PcepEventListener, PcepClientListener { - - @Override - public void handlePCEPTunnel(PcepTunnel pcepTunnel) { - TunnelDescription tunnel = null; - // instance and id identify a tunnel together - String tunnelKey = String.valueOf(pcepTunnel.getInstance()) - + String.valueOf(pcepTunnel.id()); - - if (tunnelKey == null || "".equals(tunnelKey)) { - log.error("Invalid PCEP tunnel"); - return; - } - - TunnelId tunnelId = getTunnelId(tunnelKey); - - tunnel = buildOpticalTunnel(pcepTunnel, tunnelId); - - OperationType operType = pcepTunnel.getOperationType(); - switch (operType) { - case ADD: - tunnelId = service.tunnelAdded(tunnel); - tunnelMap.put(tunnelKey, tunnelId); - break; - - case UPDATE: - service.tunnelUpdated(tunnel); - break; - - case DELETE: - service.tunnelRemoved(tunnel); - tunnelMap.remove(tunnelKey); - break; - - default: - log.error("Invalid tunnel operation"); - } - } - - @Override - public void handleMessage(PccId pccId, PcepMessage msg) { - try { - log.debug("tunnel provider handle message {}", msg.getType().toString()); - switch (msg.getType()) { - case REPORT: - int srpId = 0; - LinkedList<PcepStateReport> llStateReportList = null; - llStateReportList = ((PcepReportMsg) msg).getStateReportList(); - ListIterator<PcepStateReport> listIterator = llStateReportList.listIterator(); - PcepSrpObject srpObj = null; - PcepLspObject lspObj = null; - while (listIterator.hasNext()) { - PcepStateReport stateRpt = listIterator.next(); - srpObj = stateRpt.getSrpObject(); - lspObj = stateRpt.getLspObject(); - - if (srpObj instanceof PcepSrpObject) { - srpId = srpObj.getSrpID(); - } - - log.debug("Plsp ID in handle message " + lspObj.getPlspId()); - log.debug("SRP ID in handle message " + srpId); - - if (!(pcepTunnelAPIMapper.checkFromTunnelRequestQueue(srpId))) { - - // Check the sync status - if (lspObj.getSFlag()) { - handleSyncReport(stateRpt); - } else if (!pcepClientController.getClient(pccId).isSyncComplete()) { - // sync is done - pcepClientController.getClient(pccId).setIsSyncComplete(true); - } - continue; - } - - handleReportMessage(srpId, lspObj); - } - break; - - default: - log.debug("Received unsupported message type {}", msg.getType().toString()); - } - } catch (Exception e) { - log.error("Exception occured while processing report message {}", e.getMessage()); - } - } - - /** - * Handles report message for setup/update/delete tunnel request. - * - * @param srpId unique identifier for pcep message - * @param lspObj lsp object - */ - private void handleReportMessage(int srpId, PcepLspObject lspObj) { - ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); - PcepTunnelData pcepTunnelData = pcepTunnelAPIMapper.getDataFromTunnelRequestQueue(srpId); - SparseAnnotations annotations = (SparseAnnotations) pcepTunnelData.tunnel().annotations(); - - // store the values required from report message - pcepTunnelData.setPlspId(lspObj.getPlspId()); - pcepTunnelData.setLspAFlag(lspObj.getAFlag()); - pcepTunnelData.setLspOFlag(lspObj.getOFlag()); - pcepTunnelData.setLspDFlag(lspObj.getDFlag()); - - StatefulIPv4LspIdentidiersTlv ipv4LspTlv = null; - ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator(); - while (listTlvIterator.hasNext()) { - PcepValueType tlv = listTlvIterator.next(); - if (tlv.getType() == StatefulIPv4LspIdentidiersTlv.TYPE) { - ipv4LspTlv = (StatefulIPv4LspIdentidiersTlv) tlv; - break; - } - } - if (ipv4LspTlv != null) { - pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspTlv); - } - - Path path = pcepTunnelData.path(); - Tunnel tunnel = pcepTunnelData.tunnel(); - DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), - tunnel.dst(), tunnel.type(), tunnel.groupId(), - providerId, tunnel.tunnelName(), path, - annotations); - - if (RequestType.CREATE == pcepTunnelData.requestType()) { - log.debug("Report received for create request"); - - pcepTunnelAPIMapper.handleCreateTunnelRequestQueue(srpId, pcepTunnelData); - if (0 == lspObj.getOFlag()) { - log.warn("The tunnel is in down state"); - } - tunnelAdded(td); - } - if (RequestType.DELETE == pcepTunnelData.requestType()) { - log.debug("Report received for delete request"); - pcepTunnelAPIMapper.handleRemoveFromTunnelRequestQueue(srpId, pcepTunnelData); - tunnelRemoved(td); - } - - if (RequestType.UPDATE == pcepTunnelData.requestType()) { - log.debug("Report received for update request"); - pcepTunnelData.setRptFlag(true); - pcepTunnelAPIMapper.addToTunnelIdMap(pcepTunnelData); - pcepTunnelAPIMapper.handleUpdateTunnelRequestQueue(srpId, pcepTunnelData); - - if (0 == lspObj.getOFlag()) { - log.warn("The tunnel is in down state"); - } - if (!(pcepTunnelAPIMapper.checkFromTunnelRequestQueue(srpId))) { - tunnelUpdated(td); - } - } - } - - /** - * Handles sync report received from pcc. - * - * @param stateRpt pcep state report - */ - private void handleSyncReport(PcepStateReport stateRpt) { - PcepLspObject lspObj = stateRpt.getLspObject(); - PcepStateReport.PcepMsgPath msgPath = stateRpt.getMsgPath(); - checkNotNull(msgPath); - PcepRroObject rroObj = msgPath.getRroObject(); - if (rroObj == null) { - log.debug("RRO object is null in sate report"); - return; - } - int bandwidth = 0; - - log.debug("Handle Sync report received from PCC."); - - if (0 == lspObj.getOFlag()) { - log.warn("The PCC reported tunnel is in down state"); - } - log.debug("Sync report received"); - - if (msgPath.getBandwidthObject() != null) { - bandwidth = msgPath.getBandwidthObject().getBandwidth(); - } - - buildAndStorePcepTunnelData(lspObj, rroObj, bandwidth); - } - - /** - * To build Path in network from RRO object. - * - * @param rroObj rro object - * @param providerId provider id - * @return path object - */ - private Path buildPathFromRroObj(PcepRroObject rroObj, ProviderId providerId) { - checkNotNull(rroObj); - List<Link> links = new ArrayList<Link>(); - LinkedList<PcepValueType> llSubObj = rroObj.getSubObjects(); - if (0 == llSubObj.size()) { - log.error("RRO in report message does not have hop information"); - } - ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator(); - - ConnectPoint src = null; - ConnectPoint dst = null; - boolean isSrcSet = false; - while (tlvIterator.hasNext()) { - PcepValueType subObj = tlvIterator.next(); - switch (subObj.getType()) { - - case IPv4SubObject.TYPE: - - IPv4SubObject ipv4SubObj = (IPv4SubObject) subObj; - if (!isSrcSet) { - IpAddress srcIp = IpAddress.valueOf(ipv4SubObj.getIpAddress()); - src = new ConnectPoint(IpElementId.ipElement(srcIp), PortNumber.portNumber(0)); - isSrcSet = true; - } else { - IpAddress dstIp = IpAddress.valueOf(ipv4SubObj.getIpAddress()); - dst = new ConnectPoint(IpElementId.ipElement(dstIp), PortNumber.portNumber(0)); - Link link = new DefaultLink(providerId, src, dst, Link.Type.DIRECT, EMPTY); - links.add(link); - src = dst; - } - break; - default: - // the other sub objects are not required - } - } - return new DefaultPath(providerId, links, 0, EMPTY); - } - - /** - * To build pcepTunnelData and informs core about the pcc reported tunnel. - * - * @param lspObj pcep lsp object - * @param rroObj pcep rro object - * @param bandwidth bandwidth of tunnel - */ - private void buildAndStorePcepTunnelData(PcepLspObject lspObj, PcepRroObject rroObj, - int bandwidth) { - - ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); - - // StatefulIPv4LspIdentidiersTlv in LSP object will have the source and destination address. - StatefulIPv4LspIdentidiersTlv lspIdenTlv = null; - SymbolicPathNameTlv pathNameTlv = null; - LinkedList<PcepValueType> llOptionalTlv = lspObj.getOptionalTlv(); - ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); - while (listIterator.hasNext()) { - PcepValueType tlv = listIterator.next(); - switch (tlv.getType()) { - case StatefulIPv4LspIdentidiersTlv.TYPE: - lspIdenTlv = (StatefulIPv4LspIdentidiersTlv) tlv; - break; - case SymbolicPathNameTlv.TYPE: - pathNameTlv = (SymbolicPathNameTlv) tlv; - break; - default: - // currently this tlv is not required - } - } - - IpTunnelEndPoint tunnelEndPointSrc; - tunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(lspIdenTlv.getIpv4IngressAddress())); - IpTunnelEndPoint tunnelEndPointDst; - tunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(lspIdenTlv.getIpv4EgressAddress())); - - Path path = buildPathFromRroObj(rroObj, providerId); - - SparseAnnotations annotations = DefaultAnnotations.builder() - .set("bandwidth", (new Integer(bandwidth)).toString()) - .build(); - - DefaultTunnelDescription td = new DefaultTunnelDescription(null, tunnelEndPointSrc, - tunnelEndPointDst, Tunnel.Type.MPLS, - new DefaultGroupId(0), providerId, - TunnelName.tunnelName(pathNameTlv.toString()), - path, annotations); - TunnelId tId = tunnelAdded(td); - - Tunnel tunnel = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, Tunnel.Type.MPLS, - new DefaultGroupId(0), tId, - TunnelName.tunnelName(pathNameTlv.toString()), path, annotations); - - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.LSP_STATE_RPT); - pcepTunnelData.setStatefulIpv4IndentifierTlv(lspIdenTlv); - pcepTunnelAPIMapper.addPccTunnelDB(pcepTunnelData); - pcepTunnelAPIMapper.addToTunnelIdMap(pcepTunnelData); - } - - @Override - public void clientConnected(PccId pccId) { - // TODO - } - - @Override - public void clientDisconnected(PccId pccId) { - // TODO - } - - - - @Override - public void handlePcepTunnelStatistics(PcepTunnelStatistics pcepTunnelStatistics) { - TunnelId id = getTunnelId(String.valueOf(pcepTunnelStatistics.id())); - TunnelStatistics tunnelStatistics = buildTunnelStatistics(pcepTunnelStatistics); - tunnelStatisticsMap.put(id, tunnelStatistics); - } - } - - @Override - public Tunnel tunnelQueryById(TunnelId tunnelId) { - return service.tunnelQueryById(tunnelId); - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/RequestType.java b/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/RequestType.java deleted file mode 100644 index 51854451..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/RequestType.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. - */ -package org.onosproject.provider.pcep.tunnel.impl; - -/** - * Enum of request types between pcc and pcep. - */ -public enum RequestType { - /** - * Specifies the request type for PCC is to create new tunnel. - */ - CREATE, - - /** - * Specifies the request type for PCC is to update existing tunnel. - */ - UPDATE, - - /** - * Specifies the request type for PCC is to delete existing tunnel. - */ - DELETE, - - /** - * Specifies the request type for PCC to report existing tunnel. - */ - LSP_STATE_RPT; -}
\ No newline at end of file diff --git a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/SrpIdGenerators.java b/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/SrpIdGenerators.java deleted file mode 100644 index 5b5a5fb2..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/SrpIdGenerators.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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. - */ -package org.onosproject.provider.pcep.tunnel.impl; - -import static org.slf4j.LoggerFactory.getLogger; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.slf4j.Logger; - -/** - * Unique Srp Id generator for pcep messages. - */ -public final class SrpIdGenerators { - - private static final Logger log = getLogger(SrpIdGenerators.class); - private static final AtomicInteger SRP_ID_GEN = new AtomicInteger(); - private static final int MAX_SRP_ID = 0x7FFFFFFF; - private static int srpId; - - /** - * Default constructor. - */ - private SrpIdGenerators() { - } - - /** - * Get the next srp id. - * - * @return srp id - */ - public static int create() { - do { - if (srpId >= MAX_SRP_ID) { - if (SRP_ID_GEN.get() >= MAX_SRP_ID) { - SRP_ID_GEN.set(0); - } - } - srpId = SRP_ID_GEN.incrementAndGet(); - } while (srpId > MAX_SRP_ID); - return srpId; - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/TunnelStatsCollector.java b/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/TunnelStatsCollector.java deleted file mode 100644 index cab2bf4c..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/TunnelStatsCollector.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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. - */ - -package org.onosproject.provider.pcep.tunnel.impl; - - -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.jboss.netty.util.HashedWheelTimer; -import org.jboss.netty.util.Timeout; -import org.jboss.netty.util.TimerTask; -import org.onlab.util.Timer; -import org.onosproject.pcep.api.PcepController; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.TimeUnit; - -/* - * Sends Stats Request and collect the tunnel statistics with a time interval. - */ -public class TunnelStatsCollector implements TimerTask { - private final Logger log = LoggerFactory.getLogger(getClass()); - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected PcepController controller; - - private int refreshInterval; - private final HashedWheelTimer timer = Timer.getTimer(); - - private String pcepTunnelId; - private Timeout timeout; - private volatile boolean stopped; - - - /** - * Greate a tunnel status collector object. - * - * @param id tunnel whose status data will be collected - * @param refreshInterval time interval for collecting statistic - */ - public TunnelStatsCollector(String id, int refreshInterval) { - this.pcepTunnelId = id; - this.refreshInterval = refreshInterval; - } - - @Override - public void run(Timeout timeout) throws Exception { - if (stopped || timeout.isCancelled()) { - return; - } - log.trace("Collecting stats for {}", pcepTunnelId); - - sendTunnelStatistic(); - if (!stopped && !timeout.isCancelled()) { - log.trace("Scheduling stats collection in {} seconds for {}", - this.refreshInterval, pcepTunnelId); - timeout.getTimer().newTimeout(this, refreshInterval, TimeUnit.SECONDS); - } - - } - - private void sendTunnelStatistic() { - controller.getTunnelStatistics(pcepTunnelId); - - } - - synchronized void adjustPollInterval(int pollInterval) { - this.refreshInterval = pollInterval; - } - - /** - * Starts the collector. - */ - public synchronized void start() { - log.info("Starting Tunnel Stats collection thread for {}", pcepTunnelId); - stopped = false; - timeout = timer.newTimeout(this, 1, TimeUnit.SECONDS); - } - - /** - * Stops the collector. - */ - public synchronized void stop() { - log.info("Stopping Tunnel Stats collection thread for {}", pcepTunnelId); - stopped = true; - timeout.cancel(); - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/package-info.java b/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/package-info.java deleted file mode 100644 index 5074eecb..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/package-info.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ -/** - *Provider that uses PCEP controller as a means of infrastructure tunnel discovery. - */ -package org.onosproject.provider.pcep.tunnel.impl;
\ No newline at end of file diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java deleted file mode 100644 index 5b010f51..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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. - */ -package org.onosproject.provider.pcep.tunnel.impl; - -import static org.junit.Assert.assertNotNull; - -import java.util.List; -import java.util.concurrent.RejectedExecutionException; - -import org.jboss.netty.channel.Channel; -import org.onosproject.pcep.controller.PccId; -import org.onosproject.pcep.controller.PcepClient; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepFactory; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepVersion; - -public class PcepClientAdapter implements PcepClient { - - private Channel channel; - protected String channelId; - - private boolean connected; - private PccId pccId; - - private PcepVersion pcepVersion; - - public void init(PccId pccId, PcepVersion pcepVersion) { - this.pccId = pccId; - this.pcepVersion = pcepVersion; - } - - @Override - public final void disconnectClient() { - this.channel.close(); - } - - @Override - public final void sendMessage(PcepMessage m) { - } - - @Override - public final void sendMessage(List<PcepMessage> msgs) { - try { - PcepMessage pcepMsg = msgs.get(0); - assertNotNull("PCEP MSG should be created.", pcepMsg); - } catch (RejectedExecutionException e) { - throw e; - } - } - - @Override - public final boolean isConnected() { - return this.connected; - } - - @Override - public String channelId() { - return channelId; - } - - @Override - public final PccId getPccId() { - return this.pccId; - }; - - @Override - public final String getStringId() { - return this.pccId.toString(); - } - - @Override - public final void handleMessage(PcepMessage m) { - } - - @Override - public boolean isOptical() { - return false; - } - - @Override - public PcepFactory factory() { - return PcepFactories.getFactory(pcepVersion); - } - - @Override - public final boolean isSyncComplete() { - return false; - } - - @Override - public final void setIsSyncComplete(boolean value) { - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java deleted file mode 100644 index 2d2aaafe..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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. - */ -package org.onosproject.provider.pcep.tunnel.impl; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Deactivate; -import org.onlab.packet.IpAddress; -import org.onosproject.pcep.controller.PccId; -import org.onosproject.pcep.controller.PcepClient; -import org.onosproject.pcep.controller.PcepClientController; -import org.onosproject.pcep.controller.PcepClientListener; -import org.onosproject.pcep.controller.PcepEventListener; -import org.onosproject.pcep.controller.driver.PcepAgent; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepVersion; - -import com.google.common.collect.Sets; - -public class PcepClientControllerAdapter implements PcepClientController { - - protected ConcurrentHashMap<PccId, PcepClient> connectedClients = - new ConcurrentHashMap<PccId, PcepClient>(); - - protected PcepClientAgent agent = new PcepClientAgent(); - protected Set<PcepClientListener> pcepClientListener = new HashSet<>(); - - protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet(); - - @Activate - public void activate() { - } - - @Deactivate - public void deactivate() { - } - - @Override - public Collection<PcepClient> getClients() { - return connectedClients.values(); - } - - @Override - public PcepClient getClient(PccId pccId) { - //return connectedClients.get(pccIpAddress); - PcepClientAdapter pc = new PcepClientAdapter(); - pc.init(PccId.pccId(IpAddress.valueOf(0xac000001)), PcepVersion.PCEP_1); - return pc; - } - - @Override - public void addListener(PcepClientListener listener) { - if (!pcepClientListener.contains(listener)) { - this.pcepClientListener.add(listener); - } - } - - @Override - public void removeListener(PcepClientListener listener) { - this.pcepClientListener.remove(listener); - } - - @Override - public void addEventListener(PcepEventListener listener) { - pcepEventListener.add(listener); - } - - @Override - public void removeEventListener(PcepEventListener listener) { - pcepEventListener.remove(listener); - } - - @Override - public void writeMessage(PccId pccId, PcepMessage msg) { - this.getClient(pccId).sendMessage(msg); - } - - @Override - public void processClientMessage(PccId pccId, PcepMessage msg) { - - PcepClient pc = getClient(pccId); - - switch (msg.getType()) { - case NONE: - break; - case OPEN: - break; - case KEEP_ALIVE: - //log.debug("Sending Keep Alive Message to {" + pccIpAddress.toString() + "}"); - pc.sendMessage(Collections.singletonList(pc.factory().buildKeepaliveMsg().build())); - break; - case PATH_COMPUTATION_REQUEST: - break; - case PATH_COMPUTATION_REPLY: - break; - case NOTIFICATION: - break; - case ERROR: - break; - case CLOSE: - //log.debug("Sending Close Message to { }", pccIpAddress.toString()); - pc.sendMessage(Collections.singletonList(pc.factory().buildCloseMsg().build())); - break; - case REPORT: - for (PcepEventListener l : pcepEventListener) { - l.handleMessage(pccId, msg); - } - break; - case UPDATE: - for (PcepEventListener l : pcepEventListener) { - l.handleMessage(pccId, msg); - } - break; - case INITIATE: - for (PcepEventListener l : pcepEventListener) { - l.handleMessage(pccId, msg); - } - break; - case LABEL_UPDATE: - break; - case MAX: - break; - case END: - break; - default: - break; - } - } - - @Override - public void closeConnectedClients() { - PcepClient pc; - for (PccId id : connectedClients.keySet()) { - pc = getClient(id); - pc.disconnectClient(); - } - } - - /** - * Implementation of an Pcep Agent which is responsible for - * keeping track of connected clients and the state in which - * they are. - */ - public class PcepClientAgent implements PcepAgent { - - @Override - public boolean addConnectedClient(PccId pccId, PcepClient pc) { - - if (connectedClients.get(pccId) != null) { - return false; - } else { - connectedClients.put(pccId, pc); - for (PcepClientListener l : pcepClientListener) { - l.clientConnected(pccId); - } - return true; - } - } - - @Override - public boolean validActivation(PccId pccId) { - if (connectedClients.get(pccId) == null) { - //log.error("Trying to activate client but is not in " - // + "connected switches: pccIp {}. Aborting ..", pccIpAddress.toString()); - return false; - } - - return true; - } - - @Override - public void removeConnectedClient(PccId pccId) { - connectedClients.remove(pccId); - for (PcepClientListener l : pcepClientListener) { - //log.warn("removal for {}", pccIpAddress.toString()); - l.clientDisconnected(pccId); - } - } - - @Override - public void processPcepMessage(PccId pccId, PcepMessage m) { - processClientMessage(pccId, m); - } - } - -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepControllerAdapter.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepControllerAdapter.java deleted file mode 100644 index 65266116..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepControllerAdapter.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2014 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.provider.pcep.tunnel.impl; - -import org.onosproject.net.DeviceId; -import org.onosproject.pcep.api.PcepController; -import org.onosproject.pcep.api.PcepDpid; -import org.onosproject.pcep.api.PcepLinkListener; -import org.onosproject.pcep.api.PcepSwitch; -import org.onosproject.pcep.api.PcepSwitchListener; -import org.onosproject.pcep.api.PcepTunnel; -import org.onosproject.pcep.api.PcepTunnelListener; - -public class PcepControllerAdapter implements PcepController { - - @Override - public Iterable<PcepSwitch> getSwitches() { - return null; - } - - @Override - public PcepSwitch getSwitch(PcepDpid did) { - return null; - } - - @Override - public void addListener(PcepSwitchListener listener) { - - } - - @Override - public void removeListener(PcepSwitchListener listener) { - } - - @Override - public void addLinkListener(PcepLinkListener listener) { - } - - @Override - public void removeLinkListener(PcepLinkListener listener) { - } - - @Override - public void addTunnelListener(PcepTunnelListener listener) { - } - - @Override - public void removeTunnelListener(PcepTunnelListener listener) { - } - - @Override - public PcepTunnel applyTunnel(DeviceId srcDid, DeviceId dstDid, long srcPort, long dstPort, long bandwidth, - String name) { - return null; - } - - @Override - public Boolean deleteTunnel(String id) { - return null; - } - - @Override - public Boolean updateTunnelBandwidth(String id, long bandwidth) { - return null; - } - - @Override - public void getTunnelStatistics(String pcepTunnelId) { - - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepReleaseTunnelProviderTest.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepReleaseTunnelProviderTest.java deleted file mode 100644 index e3861381..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepReleaseTunnelProviderTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2014 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.provider.pcep.tunnel.impl; - -import static org.onosproject.net.DefaultAnnotations.EMPTY; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.Test; -import org.onlab.packet.IpAddress; -import org.onosproject.cfg.ComponentConfigAdapter; -import org.onosproject.core.DefaultGroupId; -import org.onosproject.incubator.net.tunnel.DefaultTunnel; -import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; -import org.onosproject.incubator.net.tunnel.Tunnel; -import org.onosproject.incubator.net.tunnel.TunnelId; -import org.onosproject.incubator.net.tunnel.TunnelName; -import org.onosproject.net.ConnectPoint; -import org.onosproject.net.DefaultLink; -import org.onosproject.net.DefaultPath; -import org.onosproject.net.IpElementId; -import org.onosproject.net.Link; -import org.onosproject.net.Path; -import org.onosproject.net.PortNumber; -import org.onosproject.net.provider.ProviderId; -import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; - - -public class PcepReleaseTunnelProviderTest { - - static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; - PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); - private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); - private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); - private final PcepControllerAdapter ctl = new PcepControllerAdapter(); - private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); - private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); - - @Test - public void testCasePcepReleaseTunnel() { - tunnelProvider.tunnelProviderRegistry = registry; - tunnelProvider.pcepClientController = controller; - tunnelProvider.controller = ctl; - tunnelProvider.tunnelService = tunnelService; - tunnelProvider.pcepTunnelAPIMapper = pcepTunnelAPIMapper; - tunnelProvider.cfgService = new ComponentConfigAdapter(); - tunnelProvider.activate(); - - Tunnel tunnel; - Path path; - List<Link> links = new ArrayList<Link>(); - - ProviderId pid = new ProviderId("pcep", PROVIDER_ID); - - IpAddress srcIp = IpAddress.valueOf(0xB6024E20); - IpElementId srcElementId = IpElementId.ipElement(srcIp); - - IpAddress dstIp = IpAddress.valueOf(0xB6024E21); - IpElementId dstElementId = IpElementId.ipElement(dstIp); - - IpTunnelEndPoint ipTunnelEndPointSrc; - ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); - - IpTunnelEndPoint ipTunnelEndPointDst; - ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); - - ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); - - ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); - - Link link = new DefaultLink(pid, src, dst, Link.Type.DIRECT, EMPTY); - links.add(link); - - path = new DefaultPath(pid, links, 20, EMPTY); - - tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, - new DefaultGroupId(0), TunnelId.valueOf(1), TunnelName.tunnelName("T123"), - path, EMPTY); - - // for releasing tunnel tunnel should exist in db - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE); - pcepTunnelData.setPlspId(1); - StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4); - pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); - tunnelProvider.pcepTunnelAPIMapper.addToTunnelIdMap(pcepTunnelData); - - tunnelProvider.pcepTunnelAPIMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); - - tunnelProvider.releaseTunnel(tunnel); - } - - - @After - public void tearDown() throws IOException { - tunnelProvider.deactivate(); - tunnelProvider.controller = null; - tunnelProvider.pcepClientController = null; - tunnelProvider.tunnelProviderRegistry = null; - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepSetupTunnelProviderTest.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepSetupTunnelProviderTest.java deleted file mode 100644 index ef4816ec..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepSetupTunnelProviderTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2014 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.provider.pcep.tunnel.impl; - -import static org.onosproject.net.DefaultAnnotations.EMPTY; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.Test; -import org.onlab.packet.IpAddress; -import org.onosproject.cfg.ComponentConfigAdapter; -import org.onosproject.core.DefaultGroupId; -import org.onosproject.incubator.net.tunnel.DefaultTunnel; -import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; -import org.onosproject.incubator.net.tunnel.Tunnel; -import org.onosproject.incubator.net.tunnel.TunnelId; -import org.onosproject.incubator.net.tunnel.TunnelName; -import org.onosproject.net.ConnectPoint; -import org.onosproject.net.DefaultLink; -import org.onosproject.net.DefaultPath; -import org.onosproject.net.IpElementId; -import org.onosproject.net.Link; -import org.onosproject.net.Path; -import org.onosproject.net.PortNumber; -import org.onosproject.net.provider.ProviderId; - -public class PcepSetupTunnelProviderTest { - - static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; - PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); - private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); - private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); - private final PcepControllerAdapter ctl = new PcepControllerAdapter(); - private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); - - @Test - public void testCasePcepSetupTunnel() { - - tunnelProvider.tunnelProviderRegistry = registry; - tunnelProvider.pcepClientController = controller; - tunnelProvider.controller = ctl; - tunnelProvider.cfgService = new ComponentConfigAdapter(); - tunnelProvider.tunnelService = tunnelService; - tunnelProvider.activate(); - - - Tunnel tunnel; - Path path; - ProviderId pid = new ProviderId("pcep", PROVIDER_ID); - List<Link> links = new ArrayList<Link>(); - IpAddress srcIp = IpAddress.valueOf(0xC010101); - IpElementId srcElementId = IpElementId.ipElement(srcIp); - - IpAddress dstIp = IpAddress.valueOf(0xC010102); - IpElementId dstElementId = IpElementId.ipElement(dstIp); - - IpTunnelEndPoint ipTunnelEndPointSrc; - ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); - - IpTunnelEndPoint ipTunnelEndPointDst; - ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); - - ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); - - ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); - - Link link = new DefaultLink(pid, src, dst, Link.Type.DIRECT, EMPTY); - links.add(link); - - path = new DefaultPath(pid, links, 10, EMPTY); - - tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, - new DefaultGroupId(0), TunnelId.valueOf(1), TunnelName.tunnelName("T123"), - path, EMPTY); - - tunnelProvider.setupTunnel(tunnel, path); - } - - @After - public void tearDown() throws IOException { - tunnelProvider.deactivate(); - tunnelProvider.controller = null; - tunnelProvider.pcepClientController = null; - tunnelProvider.tunnelProviderRegistry = null; - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProviderTest.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProviderTest.java deleted file mode 100644 index 0fcd1447..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProviderTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2014 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.provider.pcep.tunnel.impl; - -import static org.onosproject.net.DefaultAnnotations.EMPTY; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.Test; -import org.onlab.packet.IpAddress; -import org.onosproject.core.DefaultGroupId; -import org.onosproject.incubator.net.tunnel.DefaultTunnel; -import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; -import org.onosproject.incubator.net.tunnel.Tunnel; -import org.onosproject.incubator.net.tunnel.TunnelId; -import org.onosproject.incubator.net.tunnel.TunnelName; -import org.onosproject.net.ConnectPoint; -import org.onosproject.net.DefaultLink; -import org.onosproject.net.DefaultPath; -import org.onosproject.net.IpElementId; -import org.onosproject.net.Link; -import org.onosproject.net.Path; -import org.onosproject.net.PortNumber; -import org.onosproject.net.provider.ProviderId; -import org.onosproject.cfg.ComponentConfigAdapter; - -public class PcepTunnelProviderTest { - - static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; - PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); - private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); - private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); - private final PcepControllerAdapter ctl = new PcepControllerAdapter(); - private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); - - @Test - public void testCasePcepSetupTunnel() { - - tunnelProvider.tunnelProviderRegistry = registry; - tunnelProvider.pcepClientController = controller; - tunnelProvider.controller = ctl; - tunnelProvider.cfgService = new ComponentConfigAdapter(); - tunnelProvider.tunnelService = tunnelService; - tunnelProvider.activate(); - - Tunnel tunnel; - Path path; - ProviderId pid = new ProviderId("pcep", PROVIDER_ID); - List<Link> links = new ArrayList<Link>(); - IpAddress srcIp = IpAddress.valueOf(0xC010101); - IpElementId srcElementId = IpElementId.ipElement(srcIp); - - IpAddress dstIp = IpAddress.valueOf(0xC010102); - IpElementId dstElementId = IpElementId.ipElement(dstIp); - - IpTunnelEndPoint ipTunnelEndPointSrc; - ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); - - IpTunnelEndPoint ipTunnelEndPointDst; - ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); - - ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); - - ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); - - Link link = new DefaultLink(pid, src, dst, Link.Type.DIRECT, EMPTY); - links.add(link); - - path = new DefaultPath(pid, links, 10, EMPTY); - - tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, - new DefaultGroupId(0), TunnelId.valueOf(1), TunnelName.tunnelName("T123"), - path, EMPTY); - - tunnelProvider.setupTunnel(tunnel, path); - } - - @After - public void tearDown() throws IOException { - tunnelProvider.deactivate(); - tunnelProvider.controller = null; - tunnelProvider.pcepClientController = null; - tunnelProvider.tunnelProviderRegistry = null; - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepUpdateTunnelProviderTest.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepUpdateTunnelProviderTest.java deleted file mode 100644 index 1bcf99dd..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepUpdateTunnelProviderTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2014 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.provider.pcep.tunnel.impl; - -import static org.onosproject.net.DefaultAnnotations.EMPTY; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.Test; -import org.onlab.packet.IpAddress; -import org.onosproject.cfg.ComponentConfigAdapter; -import org.onosproject.core.DefaultGroupId; -import org.onosproject.incubator.net.tunnel.DefaultTunnel; -import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; -import org.onosproject.incubator.net.tunnel.Tunnel; -import org.onosproject.incubator.net.tunnel.TunnelId; -import org.onosproject.incubator.net.tunnel.TunnelName; -import org.onosproject.net.ConnectPoint; -import org.onosproject.net.DefaultLink; -import org.onosproject.net.DefaultPath; -import org.onosproject.net.IpElementId; -import org.onosproject.net.Link; -import org.onosproject.net.Path; -import org.onosproject.net.PortNumber; -import org.onosproject.net.provider.ProviderId; -import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; - - -public class PcepUpdateTunnelProviderTest { - - static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; - PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); - private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); - private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); - private final PcepControllerAdapter ctl = new PcepControllerAdapter(); - private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); - private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); - - - @Test - public void testCasePcepUpdateTunnel() { - tunnelProvider.tunnelProviderRegistry = registry; - tunnelProvider.pcepClientController = controller; - tunnelProvider.controller = ctl; - tunnelProvider.pcepTunnelAPIMapper = pcepTunnelAPIMapper; - tunnelProvider.cfgService = new ComponentConfigAdapter(); - tunnelProvider.tunnelService = tunnelService; - tunnelProvider.activate(); - - Tunnel tunnel; - Path path; - ProviderId pid = new ProviderId("pcep", PROVIDER_ID); - List<Link> links = new ArrayList<Link>(); - IpAddress srcIp = IpAddress.valueOf(0xD010101); - IpElementId srcElementId = IpElementId.ipElement(srcIp); - - IpAddress dstIp = IpAddress.valueOf(0xD010102); - IpElementId dstElementId = IpElementId.ipElement(dstIp); - - IpTunnelEndPoint ipTunnelEndPointSrc; - ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); - - IpTunnelEndPoint ipTunnelEndPointDst; - ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); - - ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); - - ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); - - Link link = new DefaultLink(pid, src, dst, Link.Type.DIRECT, EMPTY); - links.add(link); - - path = new DefaultPath(pid, links, 20, EMPTY); - - tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, - new DefaultGroupId(0), TunnelId.valueOf(1), TunnelName.tunnelName("T123"), - path, EMPTY); - - // for updating tunnel tunnel should exist in db - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE); - pcepTunnelData.setPlspId(1); - StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4); - pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); - tunnelProvider.pcepTunnelAPIMapper.addToTunnelIdMap(pcepTunnelData); - - tunnelProvider.pcepTunnelAPIMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); - - tunnelProvider.updateTunnel(tunnel, path); - } - - @After - public void tearDown() throws IOException { - tunnelProvider.deactivate(); - tunnelProvider.controller = null; - tunnelProvider.pcepClientController = null; - tunnelProvider.tunnelProviderRegistry = null; - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelProviderRegistryAdapter.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelProviderRegistryAdapter.java deleted file mode 100644 index 0de914c5..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelProviderRegistryAdapter.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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. - */ -package org.onosproject.provider.pcep.tunnel.impl; - -import java.util.Set; - -import org.onosproject.incubator.net.tunnel.Tunnel; -import org.onosproject.incubator.net.tunnel.TunnelDescription; -import org.onosproject.incubator.net.tunnel.TunnelId; -import org.onosproject.incubator.net.tunnel.TunnelProvider; -import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry; -import org.onosproject.incubator.net.tunnel.TunnelProviderService; -import org.onosproject.net.provider.ProviderId; - -public class TunnelProviderRegistryAdapter implements TunnelProviderRegistry { - TunnelProvider provider; - - @Override - public TunnelProviderService register(TunnelProvider provider) { - this.provider = provider; - return new TestProviderService(); - } - - @Override - public void unregister(TunnelProvider provider) { - } - - @Override - public Set<ProviderId> getProviders() { - return null; - } - - private class TestProviderService implements TunnelProviderService { - - @Override - public TunnelProvider provider() { - return null; - } - - @Override - public TunnelId tunnelAdded(TunnelDescription tunnel) { - return null; - } - - @Override - public void tunnelRemoved(TunnelDescription tunnel) { - } - - @Override - public void tunnelUpdated(TunnelDescription tunnel) { - } - - @Override - public Tunnel tunnelQueryById(TunnelId tunnelId) { - return null; - } - } -} diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelServiceAdapter.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelServiceAdapter.java deleted file mode 100644 index 0603cb3d..00000000 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelServiceAdapter.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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. - */ -package org.onosproject.provider.pcep.tunnel.impl; - -import org.onosproject.core.ApplicationId; -import org.onosproject.incubator.net.tunnel.Tunnel; -import org.onosproject.incubator.net.tunnel.TunnelEndPoint; -import org.onosproject.incubator.net.tunnel.TunnelId; -import org.onosproject.incubator.net.tunnel.TunnelListener; -import org.onosproject.incubator.net.tunnel.TunnelName; -import org.onosproject.incubator.net.tunnel.TunnelService; -import org.onosproject.incubator.net.tunnel.TunnelSubscription; -import org.onosproject.net.Annotations; -import org.onosproject.net.DeviceId; - -import java.util.Collection; -import java.util.Collections; - -public class TunnelServiceAdapter implements TunnelService { - @Override - public Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) { - return null; - } - - @Override - public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelName tunnelName, - Annotations... annotations) { - return null; - } - - @Override - public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, - Annotations... annotations) { - return null; - } - - @Override - public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, - Tunnel.Type type, Annotations... annotations) { - return null; - } - - @Override - public boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) { - return false; - } - - @Override - public boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName, Annotations... annotations) { - return false; - } - - @Override - public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, - Tunnel.Type type, Annotations... annotations) { - return false; - } - - @Override - public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, - Annotations... annotations) { - return false; - } - - @Override - public Tunnel queryTunnel(TunnelId tunnelId) { - return null; - } - - @Override - public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) { - return null; - } - - @Override - public Collection<Tunnel> queryTunnel(Tunnel.Type type) { - return null; - } - - @Override - public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) { - return null; - } - - @Override - public Collection<Tunnel> queryAllTunnels() { - return Collections.emptyList(); - } - - @Override - public int tunnelCount() { - return 0; - } - - @Override - public Iterable<Tunnel> getTunnels(DeviceId deviceId) { - return null; - } - - @Override - public void addListener(TunnelListener listener) { - - } - - @Override - public void removeListener(TunnelListener listener) { - - } -} |