Adding wavelenght to port view and MHz to command
Change-Id: Iecdf46c82cd2df4fe1b46f759d32a1c49a7dd9d6
(cherry picked from commit 02e2eb4ee23b7032e4d3f56b5087d169edac2e46)
diff --git a/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmManager.java b/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmManager.java
index 191f608..d6812ba 100644
--- a/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmManager.java
+++ b/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmManager.java
@@ -17,6 +17,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Range;
+import org.onlab.util.Frequency;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.net.ChannelSpacing;
@@ -48,7 +49,9 @@
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criteria;
+import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
+import org.onosproject.net.flow.instructions.L0ModificationInstruction;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
@@ -64,6 +67,7 @@
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
+import java.util.stream.StreamSupport;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.net.optical.OpticalAnnotations.INPUT_PORT_STATUS;
@@ -375,8 +379,8 @@
@Override
public FlowId createConnection(DeviceId deviceId, int priority, boolean isPermanent,
- int timeout, PortNumber inPort, PortNumber outPort,
- OchSignal ochSignal, Double attenuation) {
+ int timeout, PortNumber inPort, PortNumber outPort,
+ OchSignal ochSignal, Double attenuation) {
checkNotNull(deviceId);
checkNotNull(inPort);
checkNotNull(outPort);
@@ -386,6 +390,39 @@
}
@Override
+ public Frequency getWavelength(DeviceId deviceId, PortNumber portNumber) {
+ checkNotNull(deviceId);
+ checkNotNull(portNumber);
+ Optional<FlowEntry> optFlow = StreamSupport
+ .stream(flowRuleService.getFlowEntries(deviceId).spliterator(), false)
+ .filter(flow -> {
+ return flow.treatment().allInstructions().stream().filter(instr -> {
+ if (instr.type().equals(Instruction.Type.OUTPUT)) {
+ return ((Instructions.OutputInstruction) instr).port().equals(portNumber);
+ } else if (instr.type().equals(Instruction.Type.L0MODIFICATION)) {
+ return ((L0ModificationInstruction) instr).subtype()
+ .equals(L0ModificationInstruction.L0SubType.OCH);
+ }
+ return false;
+ }).count() == 2;
+ }).findFirst();
+ if (optFlow.isPresent()) {
+ Optional<Instruction> instruction = optFlow.get().treatment().allInstructions().stream().filter(instr -> {
+ if (instr.type().equals(Instruction.Type.L0MODIFICATION)) {
+ return ((L0ModificationInstruction) instr).subtype()
+ .equals(L0ModificationInstruction.L0SubType.OCH);
+ }
+ return false;
+ }).findAny();
+ if (instruction.isPresent()) {
+ return ((L0ModificationInstruction.ModOchSignalInstruction) instruction.get()).lambda()
+ .centralFrequency();
+ }
+ }
+ return null;
+ }
+
+ @Override
public void removeConnection(DeviceId deviceId, FlowId flowId) {
checkNotNull(deviceId);
checkNotNull(flowId);
diff --git a/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmPortViewMessageHandler.java b/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmPortViewMessageHandler.java
index 1a27fd3..3a648c4 100644
--- a/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmPortViewMessageHandler.java
+++ b/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmPortViewMessageHandler.java
@@ -85,6 +85,7 @@
private static final String MIN_FREQ = "minFreq";
private static final String MAX_FREQ = "maxFreq";
private static final String GRID = "grid";
+ private static final String CURR_FREQ = "currFreq";
private static final String POWER_RANGE = "powerRange";
private static final String CURRENT_POWER = "currentPower";
private static final String CURRENT_INPUT_POWER = "currentInputPower";
@@ -94,7 +95,7 @@
private static final String SERVICE_STATE = "serviceState";
private static final String[] COLUMN_IDS = {
- ID, REVERSE_PORT, TYPE, NAME, ENABLED, MIN_FREQ, MAX_FREQ, GRID, POWER_RANGE,
+ ID, REVERSE_PORT, TYPE, NAME, ENABLED, MIN_FREQ, MAX_FREQ, GRID, CURR_FREQ, POWER_RANGE,
CURRENT_POWER, CURRENT_INPUT_POWER, SERVICE_STATE, TARGET_POWER, MODULATION, HAS_TARGET_POWER
};
@@ -161,6 +162,7 @@
.cell(MIN_FREQ, RoadmUtil.asTHz(minFreq))
.cell(MAX_FREQ, RoadmUtil.asTHz(maxFreq))
.cell(GRID, RoadmUtil.asGHz(channelSpacing))
+ .cell(CURR_FREQ, getWavelength(deviceId, portNum))
.cell(POWER_RANGE, getPowerRange(deviceId, portNum))
.cell(CURRENT_POWER, getCurrentPower(deviceId, portNum))
.cell(CURRENT_INPUT_POWER, getCurrentInputPower(deviceId, portNum))
@@ -187,7 +189,7 @@
return RoadmUtil.UNKNOWN;
}
- private Frequency minFreq = null, maxFreq = null, channelSpacing = null;
+ private Frequency minFreq = null, maxFreq = null, channelSpacing = null, currFreq = null;
// Gets min frequency, max frequency, channel spacing
private void getFrequencyLimit(DeviceId deviceId, PortNumber portNumber) {
@@ -253,6 +255,17 @@
}
return RoadmUtil.objectToString(modulation, RoadmUtil.UNKNOWN);
}
+
+ // Returns modulation as a string, Unknown if modulation is expected but
+ // cannot be found
+ private String getWavelength(DeviceId deviceId, PortNumber portNumber) {
+ Frequency currentFrequency = roadmService.getWavelength(deviceId, portNumber);
+ if (currentFrequency == null) {
+ return "0";
+ } else {
+ return String.valueOf(currentFrequency.asTHz());
+ }
+ }
}
diff --git a/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmService.java b/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmService.java
index 7662626..0b31e71 100644
--- a/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmService.java
+++ b/apps/roadm/app/src/main/java/org/onosproject/roadm/RoadmService.java
@@ -16,6 +16,7 @@
package org.onosproject.roadm;
import com.google.common.collect.Range;
+import org.onlab.util.Frequency;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.ModulationScheme;
@@ -29,19 +30,19 @@
/**
* ROADM service interface. Provides an interface for ROADM power configuration.
- *
+ * <p>
* This application relies on the PowerConfig and LambdaQuery behaviours.
- *
+ * <p>
* The device's PowerConfig implementation should be parameterized as
* {@code PowerConfig<Object>} in order to support both Direction and OchSignal.
* For a reference implementation of PowerConfig, please see
* OplinkRoadmPowerConfig
- *
+ * <p>
* In this application, a "connection" refers to the selection of a channel
* to direct from an input to an output port. Connections are implemented
* using FlowRules with an input port selector, optical channel selector,
* and output port treatment (see RoadmManager#createConnection()).
- *
+ * <p>
* This application currently only supports fixed grid channels.
*/
public interface RoadmService {
@@ -50,7 +51,7 @@
* Attempts to manually switch working path to the one specified by {@code index}.
*
* @param deviceId DeviceId of the device to configure
- * @param index working path index to switch to
+ * @param index working path index to switch to
* @deprecated 1.11.0
*/
@Deprecated
@@ -59,7 +60,7 @@
/**
* Retrieves protection switch specified port's service status.
*
- * @param deviceId DeviceId of the device to configure
+ * @param deviceId DeviceId of the device to configure
* @param portNumber the port
* @return port service status
* @deprecated 1.11.0
@@ -70,15 +71,16 @@
/**
* Attempts to config protection switch by specified {@code operation} and {@code index}.
*
- * @param deviceId DeviceId of the device to configure
- * @param operation switch configuration, automatic, force or manual
+ * @param deviceId DeviceId of the device to configure
+ * @param operation switch configuration, automatic, force or manual
* @param identifier {@link ConnectPoint} for the virtual Port representing protected path endpoint
- * @param index working path index to switch to
+ * @param index working path index to switch to
*/
void configProtectionSwitch(DeviceId deviceId, String operation, ConnectPoint identifier, int index);
/**
* Retrieves protection switch endpoint states.
+ *
* @param deviceId DeviceId of the device to configure
* @return map groups of underlying paths
*/
@@ -87,16 +89,16 @@
/**
* Set target power for a port if the port has configurable target power.
*
- * @param deviceId DeviceId of the device to configure
+ * @param deviceId DeviceId of the device to configure
* @param portNumber PortNumber of the port to configure
- * @param power value to set target power to
+ * @param power value to set target power to
*/
void setTargetPortPower(DeviceId deviceId, PortNumber portNumber, double power);
/**
* Returns the target power stored in storage for a port if the port has configurable target power.
*
- * @param deviceId DeviceId of the device to configure
+ * @param deviceId DeviceId of the device to configure
* @param portNumber PortNumber of the port to configure
* @return the target power if the port has a target power, null otherwise
*/
@@ -104,7 +106,8 @@
/**
* Sync-up the target power for a port if the operator want to check the configuration.
- * @param deviceId DeviceId of the device to configure
+ *
+ * @param deviceId DeviceId of the device to configure
* @param portNumber PortNumber of the port to configure
* @return the target power if the port has a target power, null otherwise
*/
@@ -114,9 +117,9 @@
* Sets the attenuation of a connection. This does not check that attenuation
* is within the acceptable range.
*
- * @param deviceId DeviceId of the device to configure
- * @param portNumber PortNumber of either the input or output port
- * @param ochSignal channel to set attenuation for
+ * @param deviceId DeviceId of the device to configure
+ * @param portNumber PortNumber of either the input or output port
+ * @param ochSignal channel to set attenuation for
* @param attenuation attenuation value to set to
*/
void setAttenuation(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal, double attenuation);
@@ -124,9 +127,9 @@
/**
* Returns the attenuation of a connection.
*
- * @param deviceId DeviceId of the device
+ * @param deviceId DeviceId of the device
* @param portNumber PortNumber of either the input or output port
- * @param ochSignal channel to search for
+ * @param ochSignal channel to search for
* @return attenuation if found, null otherwise
*/
Double getAttenuation(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal);
@@ -134,7 +137,7 @@
/**
* Returns the current port power.
*
- * @param deviceId DeviceId of the device
+ * @param deviceId DeviceId of the device
* @param portNumber PortNumber of the port
* @return current power if found, null otherwise
*/
@@ -143,9 +146,9 @@
/**
* Returns the current channel power.
*
- * @param deviceId DeviceId of the device
+ * @param deviceId DeviceId of the device
* @param portNumber PortNumber of either the input or output port of the connection
- * @param ochSignal channel to search for
+ * @param ochSignal channel to search for
* @return channel power if found, null otherwise
*/
Double getCurrentChannelPower(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal);
@@ -153,7 +156,7 @@
/**
* Returns the channels supported by a port.
*
- * @param deviceId DeviceId of the device
+ * @param deviceId DeviceId of the device
* @param portNumber PortNumber of the port
* @return the set of supported channels
*/
@@ -162,7 +165,7 @@
/**
* Set modulation for a port if the port has configurable modulation.
*
- * @param deviceId DeviceId of the device to configure
+ * @param deviceId DeviceId of the device to configure
* @param portNumber PortNumber of the port to configure
* @param modulation value to set modulation to
*/
@@ -171,7 +174,7 @@
/**
* Get modulation for a port if the port has configurable modulation.
*
- * @param deviceId DeviceId of the device to configure
+ * @param deviceId DeviceId of the device to configure
* @param portNumber PortNumber of the port to configure
* @return modulation scheme
*/
@@ -181,43 +184,52 @@
* Creates a new internal connection on a device without attenuation. This does
* not check that the connection is actually valid (e.g. an input port to an
* output port).
- *
+ * <p>
* Connections are represented as flows with an input port, output port, and
* channel.
*
- * @param deviceId DeviceId of the device to create this connection for
- * @param priority priority of the flow
+ * @param deviceId DeviceId of the device to create this connection for
+ * @param priority priority of the flow
* @param isPermanent permanence of the flow
- * @param timeout timeout in seconds
- * @param inPort input port
- * @param outPort output port
- * @param ochSignal channel to use
+ * @param timeout timeout in seconds
+ * @param inPort input port
+ * @param outPort output port
+ * @param ochSignal channel to use
* @return FlowId of the FlowRule representing the connection
*/
FlowId createConnection(DeviceId deviceId, int priority, boolean isPermanent,
- int timeout, PortNumber inPort, PortNumber outPort, OchSignal ochSignal);
+ int timeout, PortNumber inPort, PortNumber outPort, OchSignal ochSignal);
/**
* Creates a new internal connection on a device with attenuation. This does
* not check that the connection is actually valid (e.g. an input port to an
* output port, attenuation if within the acceptable range).
- *
+ * <p>
* Connections are represented as flows with an input port, output port, and
* channel. Implementation of attenuation is up to the vendor.
*
- * @param deviceId DeviceId of the device to create this connection for
- * @param priority priority of the flow
+ * @param deviceId DeviceId of the device to create this connection for
+ * @param priority priority of the flow
* @param isPermanent permanence of the flow
- * @param timeout timeout in seconds
- * @param inPort input port
- * @param outPort output port
- * @param ochSignal channel to use
+ * @param timeout timeout in seconds
+ * @param inPort input port
+ * @param outPort output port
+ * @param ochSignal channel to use
* @param attenuation attenuation of the connection
* @return FlowId of the FlowRule representing the connection
*/
FlowId createConnection(DeviceId deviceId, int priority, boolean isPermanent,
- int timeout, PortNumber inPort, PortNumber outPort,
- OchSignal ochSignal, Double attenuation);
+ int timeout, PortNumber inPort, PortNumber outPort,
+ OchSignal ochSignal, Double attenuation);
+
+ /**
+ * Get wavelength for a port if the port has configurable modulation.
+ *
+ * @param deviceId DeviceId of the device to configure
+ * @param portNumber PortNumber of the port to configure
+ * @return the frequency
+ */
+ Frequency getWavelength(DeviceId deviceId, PortNumber portNumber);
/**
* Removes an internal connection from a device by matching the FlowId and
@@ -225,14 +237,14 @@
* from any device so FlowId should correspond with a connection flow.
*
* @param deviceId DeviceId of the device to remove the connection from
- * @param flowId FlowId of the flow representing the connection to remove
+ * @param flowId FlowId of the flow representing the connection to remove
*/
void removeConnection(DeviceId deviceId, FlowId flowId);
/**
* Returns true if the target power for this port can be configured.
*
- * @param deviceId DeviceId of the device
+ * @param deviceId DeviceId of the device
* @param portNumber PortNumber of the port to check
* @return true if the target power for this port can be configured, false
* otherwise
@@ -244,9 +256,9 @@
* Returns false if the port does not have a configurable target
* power.
*
- * @param deviceId DeviceId of the device to check
+ * @param deviceId DeviceId of the device to check
* @param portNumber PortNumber of the port to check
- * @param power value to check
+ * @param power value to check
* @return true if value is within the acceptable target power range, false
* otherwise
*/
@@ -258,9 +270,9 @@
* attenuation. The attenuation range is determined by either the input
* or output port of the connection.
*
- * @param deviceId DeviceId of the device to check
+ * @param deviceId DeviceId of the device to check
* @param portNumber PortNumber of either the input or output port of the connection
- * @param att value to check
+ * @param att value to check
* @return true if value is within the acceptable attenuation range, false
* otherwise
*/
@@ -269,7 +281,7 @@
/**
* Returns true if the port is an input port.
*
- * @param deviceId DeviceId of the device to check
+ * @param deviceId DeviceId of the device to check
* @param portNumber PortNumber of the port to check
* @return true if the port is an input port, false otherwise
*/
@@ -278,7 +290,7 @@
/**
* Returns true if the port is an output port.
*
- * @param deviceId DeviceId of the device to check
+ * @param deviceId DeviceId of the device to check
* @param portNumber PortNumber of the port to check
* @return true if the port is an output port, false otherwise
*/
@@ -288,9 +300,9 @@
* Returns true if the channel is supported by the port. The port can be either
* an input or output port.
*
- * @param deviceId DeviceId of the device to check
+ * @param deviceId DeviceId of the device to check
* @param portNumber PortNumber of the port to check
- * @param ochSignal channel to check
+ * @param ochSignal channel to check
* @return true if the channel is supported by the port, false otherwise
*/
boolean validChannel(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal);
@@ -299,7 +311,7 @@
* Returns true if the channel is not being used by a connection on the
* device.
*
- * @param deviceId DeviceId of the device to check
+ * @param deviceId DeviceId of the device to check
* @param ochSignal channel to check
* @return true if the channel is not in use, false otherwise
*/
@@ -311,8 +323,8 @@
* respectively, valid input and output ports.
*
* @param deviceId DeviceId of the device to check
- * @param inPort input port of the connection
- * @param outPort output port of the connection
+ * @param inPort input port of the connection
+ * @param outPort output port of the connection
* @return true if the connection is valid, false otherwise
*/
boolean validConnection(DeviceId deviceId, PortNumber inPort, PortNumber outPort);
@@ -320,7 +332,7 @@
/**
* Returns the acceptable target port power range for a port.
*
- * @param deviceId DeviceId of the device
+ * @param deviceId DeviceId of the device
* @param portNumber PortNumber of the port
* @return range if found, null otherwise
*/
@@ -329,9 +341,9 @@
/**
* Returns the acceptable attenuation range for a connection.
*
- * @param deviceId DeviceId of the device
+ * @param deviceId DeviceId of the device
* @param portNumber PortNumber of either the input or output port
- * @param ochSignal channel to check
+ * @param ochSignal channel to check
* @return range if found, null otherwise
*/
Range<Double> attenuationRange(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal);
@@ -339,7 +351,7 @@
/**
* Returns the expected input power range for an input port.
*
- * @param deviceId DeviceId of the device
+ * @param deviceId DeviceId of the device
* @param portNumber PortNumber of an input port
* @return range if found, null otherwise
*/
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.html b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.html
index 1e16d57..26420ca 100644
--- a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.html
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.html
@@ -70,6 +70,7 @@
<td colId="minFreq">MIN FREQ (THz)</td>
<td colId="maxFreq">MAX FREQ (THz)</td>
<td colId="grid">GRID (GHz)</td>
+ <td colId="currentFreq">CURRENT FREQ (THz)</td>
<td colId="modulation">MODULATION</td>
<td colId="powerRange">POWER RANGE (dBm)</td>
<td colId="currentPower">CURRENT POWER (dBm)</td>
@@ -96,6 +97,7 @@
<td [ngClass]="(isDelta() ? 'delta' : '')">{{port.type=='OCH'?port.minFreq:""}}</td>
<td [ngClass]="(isDelta() ? 'delta' : '')">{{port.type=='OCH'?port.maxFreq:""}}</td>
<td [ngClass]="(isDelta() ? 'delta' : '')">{{port.type=='OCH'?port.grid:""}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.type=='OCH'?port.currFreq:""}}</td>
<td [ngClass]="(isDelta() ? 'delta' : '')">
<form [formGroup]="modulationForm" (ngSubmit)="submitModulation(devId, port.id)" *ngIf="port.type=='OCH'">
<select [(ngModel)]="port.modulation" formControlName="newModulation">
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.ts b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.ts
index 4a0d36e..56bd85c 100644
--- a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.ts
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.ts
@@ -44,6 +44,7 @@
minFreq: string;
maxFreq: string;
grid: string;
+ currFreq: string;
powerRange: string;
currentPower: string;
targetPower: string;