Permalink
Browse files

Add ROADM application

Change-Id: I50fa93cf3a69122f6434b46e831b254771159294
  • Loading branch information...
1 parent 7f872a7 commit da878fcbf0dbf6d4d196d799d0180d7652dd56db @yjimmyy yjimmyy committed with y-higuchi Sep 2, 2016
Showing with 3,195 additions and 2 deletions.
  1. +1 −0 apps/pom.xml
  2. +24 −0 apps/roadm/BUCK
  3. +150 −0 apps/roadm/pom.xml
  4. +102 −0 apps/roadm/src/main/java/org/onosproject/roadm/ChannelData.java
  5. +101 −0 apps/roadm/src/main/java/org/onosproject/roadm/DistributedRoadmStore.java
  6. +84 −0 apps/roadm/src/main/java/org/onosproject/roadm/RoadmComponent.java
  7. +115 −0 apps/roadm/src/main/java/org/onosproject/roadm/RoadmDeviceViewMessageHandler.java
  8. +421 −0 apps/roadm/src/main/java/org/onosproject/roadm/RoadmFlowViewMessageHandler.java
  9. +530 −0 apps/roadm/src/main/java/org/onosproject/roadm/RoadmManager.java
  10. +235 −0 apps/roadm/src/main/java/org/onosproject/roadm/RoadmPortViewMessageHandler.java
  11. +283 −0 apps/roadm/src/main/java/org/onosproject/roadm/RoadmService.java
  12. +67 −0 apps/roadm/src/main/java/org/onosproject/roadm/RoadmStore.java
  13. +20 −0 apps/roadm/src/main/java/org/onosproject/roadm/package-info.java
  14. +39 −0 apps/roadm/src/main/resources/app/view/roadmDevice/roadmDevice.css
  15. +70 −0 apps/roadm/src/main/resources/app/view/roadmDevice/roadmDevice.html
  16. +49 −0 apps/roadm/src/main/resources/app/view/roadmDevice/roadmDevice.js
  17. +132 −0 apps/roadm/src/main/resources/app/view/roadmFlow/roadmFlow.css
  18. +118 −0 apps/roadm/src/main/resources/app/view/roadmFlow/roadmFlow.html
  19. +324 −0 apps/roadm/src/main/resources/app/view/roadmFlow/roadmFlow.js
  20. +69 −0 apps/roadm/src/main/resources/app/view/roadmPort/roadmPort.css
  21. +73 −0 apps/roadm/src/main/resources/app/view/roadmPort/roadmPort.html
  22. +168 −0 apps/roadm/src/main/resources/app/view/roadmPort/roadmPort.js
  23. +3 −0 apps/roadm/src/main/resources/webgui/css.html
  24. +3 −0 apps/roadm/src/main/resources/webgui/js.html
  25. +2 −2 core/api/src/main/java/org/onosproject/net/ChannelSpacing.java
  26. +11 −0 drivers/optical/src/main/java/org/onosproject/driver/optical/power/OplinkRoadmPowerConfig.java
  27. +1 −0 modules.defs
View
@@ -31,6 +31,7 @@
<modules>
<module>acl</module>
+ <module>roadm</module>
<module>faultmanagement</module>
<module>fwd</module>
<module>mobility</module>
View
@@ -0,0 +1,24 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//core/store/serializers:onos-core-serializers',
+ '//apps/optical-model:onos-apps-optical-model',
+]
+
+TEST_DEPS = [
+ '//lib:TEST_REST',
+ '//core/api:onos-api-tests',
+]
+
+osgi_jar_with_tests (
+ deps = COMPILE_DEPS,
+ test_deps = TEST_DEPS,
+)
+
+onos_app (
+ title = 'ROADM App',
+ category = 'Optical',
+ url = 'http://onosproject.org',
+ description = """This application provides an interface and web GUI for monitoring
+ and configuring power on ROADM devices.""",
+ required_apps = [ 'org.onosproject.optical-model' ],
+)
View
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2016-present Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ --><project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-apps-roadm</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>Application for ROADM device management</description>
+ <url>http://onosproject.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <onos.version>1.9.0-SNAPSHOT</onos.version>
+ <onos.app.name>org.onosproject.roadm</onos.app.name>
+ <onos.app.title>ROADM Application</onos.app.title>
+ <onos.app.category>Utility</onos.app.category>
+ <onos.app.readme>
+ This application provides an interface and web GUI for monitoring
+ and configuring power on ROADM devices.
+ </onos.app.readme>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-optical-model</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-scr-srcdescriptor</id>
+ <goals>
+ <goal>scr</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <supportedProjectTypes>
+ <supportedProjectType>bundle</supportedProjectType>
+ <supportedProjectType>war</supportedProjectType>
+ </supportedProjectTypes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>cfg</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>cfg</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>swagger</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>swagger</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>app</id>
+ <phase>package</phase>
+ <goals>
+ <goal>app</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.roadm;
+
+import org.onosproject.net.OchSignal;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.flow.FlowRule;
+import org.onosproject.net.flow.criteria.Criterion;
+import org.onosproject.net.flow.criteria.OchSignalCriterion;
+import org.onosproject.net.flow.criteria.PortCriterion;
+import org.onosproject.net.flow.instructions.Instruction;
+import org.onosproject.net.flow.instructions.Instructions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+
+/**
+ * Representation of an internal ROADM connection.
+ */
+public final class ChannelData {
+ private PortNumber inPort;
+ private PortNumber outPort;
+ private OchSignal ochSignal;
+
+ private ChannelData(PortNumber inPort, PortNumber outPort, OchSignal ochSignal) {
+ this.inPort = inPort;
+ this.outPort = outPort;
+ this.ochSignal = ochSignal;
+ }
+
+ /**
+ * Returns a ChannelData representation from a flow rule. The rule must contain
+ * a Criterion.Type.IN_PORT selector, Criterion.Type.OCH_SIGID selector, and
+ * Instruction.Type.OUTPUT instruction.
+ *
+ * @param rule the flow rule representing the connection
+ * @return ChannelData representation of the connection
+ */
+ public static ChannelData fromFlow(FlowRule rule) {
+ checkNotNull(rule);
+
+ Criterion in = rule.selector().getCriterion(Criterion.Type.IN_PORT);
+ checkNotNull(in);
+ PortNumber inPort = ((PortCriterion) in).port();
+
+ Criterion och = rule.selector().getCriterion(Criterion.Type.OCH_SIGID);
+ checkNotNull(och);
+ OchSignal ochSignal = ((OchSignalCriterion) och).lambda();
+
+ PortNumber outPort = null;
+ List<Instruction> instructions = rule.treatment().allInstructions();
+ for (Instruction ins : instructions) {
+ if (ins.type() == Instruction.Type.OUTPUT) {
+ outPort = ((Instructions.OutputInstruction) ins).port();
+ }
+ }
+ checkNotNull(outPort);
+
+ return new ChannelData(inPort, outPort, ochSignal);
+ }
+
+ /**
+ * Returns the input port.
+ *
+ * @return input port
+ */
+ public PortNumber inPort() {
+ return inPort;
+ }
+
+ /**
+ * Returns the output port.
+ *
+ * @return output port
+ */
+ public PortNumber outPort() {
+ return outPort;
+ }
+
+ /**
+ * Returns the channel signal.
+ *
+ * @return channel signal
+ */
+ public OchSignal ochSignal() {
+ return ochSignal;
+ }
+}
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.roadm;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Manages the port target powers for ROADM devices.
+ */
+@Component(immediate = true)
+@Service
+public class DistributedRoadmStore implements RoadmStore {
+ private static Logger log = LoggerFactory.getLogger(DistributedRoadmStore.class);
+
+ private ConsistentMap<DeviceId, Map<PortNumber, Long>> distPowerMap;
+ private Map<DeviceId, Map<PortNumber, Long>> powerMap;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected StorageService storageService;
+
+ @Activate
+ public void activate() {
+ distPowerMap = storageService.<DeviceId, Map<PortNumber, Long>>consistentMapBuilder()
+ .withName("onos-roadm-distributed-store")
+ .withSerializer(Serializer.using(KryoNamespaces.API))
+ .build();
+ powerMap = distPowerMap.asJavaMap();
+
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ log.info("Stopped");
+ }
+
+ // Add a map to the store for a device if not already added.
+ // Powers still need to be initialized with calls to setTargetPower().
+ @Override
+ public void addDevice(DeviceId deviceId) {
+ powerMap.putIfAbsent(deviceId, new HashMap<>());
+ log.info("Initializing {}", deviceId);
+ }
+
+ // Returns true if Map for device exists in ConsistentMap
+ @Override
+ public boolean deviceAvailable(DeviceId deviceId) {
+ return powerMap.get(deviceId) != null;
+ }
+
+
+ @Override
+ public void setTargetPower(DeviceId deviceId, PortNumber portNumber, long targetPower) {
+ Map<PortNumber, Long> portMap = powerMap.get(deviceId);
+ if (portMap != null) {
+ portMap.put(portNumber, targetPower);
+ powerMap.put(deviceId, portMap);
+ } else {
+ log.info("Device {} not found in store", deviceId);
+ }
+ }
+
+ @Override
+ public Long getTargetPower(DeviceId deviceId, PortNumber portNumber) {
+ Map<PortNumber, Long> portMap = powerMap.get(deviceId);
+ if (portMap != null) {
+ return portMap.get(portNumber);
+ }
+ return null;
+ }
+}
Oops, something went wrong.

0 comments on commit da878fc

Please sign in to comment.