[ONOS-4513] Slice optical-model into separate bundle (1/3)
- net and cli bundle has dependency to optical-model bundle,
which should be removed in the longer run. (ONOS-4626)
Change-Id: Ieff43ef2002ee21f4578a6e2a729cd35ce3eae3d
diff --git a/core/api/src/main/java/org/onosproject/net/optical/DefaultOpticalDevice.java b/core/api/src/main/java/org/onosproject/net/optical/DefaultOpticalDevice.java
deleted file mode 100644
index c5b1ff0..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/DefaultOpticalDevice.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.optical;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Map;
-import java.util.Optional;
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onosproject.net.Device;
-import org.onosproject.net.Port;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.driver.AbstractBehaviour;
-import org.onosproject.net.driver.DriverData;
-import org.onosproject.net.optical.device.port.OchPortMapper;
-import org.onosproject.net.optical.device.port.OduCltPortMapper;
-import org.onosproject.net.optical.device.port.OmsPortMapper;
-import org.onosproject.net.optical.device.port.OtuPortMapper;
-import org.onosproject.net.optical.device.port.PortMapper;
-import org.onosproject.net.utils.ForwardingDevice;
-import org.slf4j.Logger;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Implementation of {@link OpticalDevice}.
- * <p>
- * Currently supports
- * <ul>
- * <li> {@link OchPort}
- * <li> {@link OmsPort}
- * <li> {@link OduCltPort}
- * <li> {@link OtuPort}
- * </ul>
- */
-@Beta
-public class DefaultOpticalDevice
- extends AbstractBehaviour
- implements OpticalDevice, ForwardingDevice {
-
- private static final Logger log = getLogger(DefaultOpticalDevice.class);
-
- // shared Port type handler map.
- // TODO Is there a use case, where we need to differentiate this map per Device?
- private static final Map<Class<? extends Port>, PortMapper<? extends Port>> MAPPERS
- = ImmutableMap.<Class<? extends Port>, PortMapper<? extends Port>>builder()
- .put(OchPort.class, new OchPortMapper())
- .put(OmsPort.class, new OmsPortMapper())
- .put(OduCltPort.class, new OduCltPortMapper())
- .put(OtuPort.class, new OtuPortMapper())
- // TODO add other optical port type here
- .build();
-
-
-
- // effectively final
- private Device delegate;
-
- // Default constructor required as a Behaviour.
- public DefaultOpticalDevice() {}
-
- @Override
- public Device delegate() {
- if (delegate == null) {
- // dirty work around.
- // wanted to pass delegate Device at construction,
- // but was not possible. A Behaviour requires no-arg constructor.
- checkState(data() != null, "DriverData must exist");
- DriverData data = data();
- DeviceService service = DefaultServiceDirectory.getService(DeviceService.class);
- delegate = checkNotNull(service.getDevice(data.deviceId()),
- "No Device found for %s", data.deviceId());
- }
- return delegate;
- }
-
- @Override
- public <T extends Port> boolean portIs(Port port, Class<T> portClass) {
-
- PortMapper<? extends Port> mapper = MAPPERS.get(portClass);
- if (mapper != null) {
- return mapper.is(port);
- }
- return false;
- }
-
- @Override
- public <T extends Port> Optional<T> portAs(Port port, Class<T> portClass) {
- PortMapper<? extends Port> mapper = MAPPERS.get(portClass);
- if (mapper != null) {
- return (Optional<T>) (mapper.as(port));
- }
- return Optional.empty();
- }
-
- @Override
- public Port port(Port port) {
- for (PortMapper<? extends Port> mapper : MAPPERS.values()) {
- if (mapper.is(port)) {
- return mapper.as(port).map(Port.class::cast).orElse(port);
- }
- }
- return port;
- }
-
- @Override
- public boolean equals(Object obj) {
- return delegate().equals(obj);
- }
-
- @Override
- public int hashCode() {
- return delegate().hashCode();
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("delegate", delegate)
- .toString();
- }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/OchPort.java b/core/api/src/main/java/org/onosproject/net/optical/OchPort.java
deleted file mode 100644
index 8d19889..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/OchPort.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.optical;
-
-import org.onosproject.net.OchSignal;
-import org.onosproject.net.OduSignalType;
-import org.onosproject.net.Port;
-
-import com.google.common.annotations.Beta;
-
-/**
- * OCh port (Optical Channel).
- * Also referred to as a line side port (L-port) or narrow band port.
- * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
- */
-@Beta
-public interface OchPort extends Port {
-
- /**
- * Returns ODU signal type.
- *
- * @return ODU signal type
- */
- public OduSignalType signalType();
-
- /**
- * Returns true if port is wavelength tunable.
- *
- * @return tunable wavelength capability
- */
- public boolean isTunable();
-
- /**
- * Returns OCh signal.
- *
- * @return OCh signal
- */
- public OchSignal lambda();
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/OduCltPort.java b/core/api/src/main/java/org/onosproject/net/optical/OduCltPort.java
deleted file mode 100644
index b4342f4..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/OduCltPort.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.net.optical;
-
-import org.onosproject.net.CltSignalType;
-import org.onosproject.net.Port;
-
-import com.google.common.annotations.Beta;
-
-/**
- * ODU client port (Optical channel Data Unit).
- * Also referred to as a T-port or wide band port.
- * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
- */
-@Beta
-public interface OduCltPort extends Port {
-
- /**
- * Returns ODU client signal type.
- *
- * @return ODU client signal type
- */
- CltSignalType signalType();
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/OmsPort.java b/core/api/src/main/java/org/onosproject/net/optical/OmsPort.java
deleted file mode 100644
index 898fce9..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/OmsPort.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.net.optical;
-
-import org.onlab.util.Frequency;
-import org.onosproject.net.Port;
-
-import com.google.common.annotations.Beta;
-
-/**
- * OMS port (Optical Multiplexing Section).
- * Also referred to as a WDM port or W-port.
- * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
- *
- * Assumes we only support fixed grid for now.
- */
-@Beta
-public interface OmsPort extends Port {
-
- /**
- * Returns the total number of channels on the port.
- *
- * @return total number of channels
- */
- default short totalChannels() {
- Frequency diff = maxFrequency().subtract(minFrequency());
- return (short) (diff.asHz() / grid().asHz() + 1);
- }
-
- /**
- * Returns the minimum frequency.
- *
- * @return minimum frequency
- */
- Frequency minFrequency();
-
- /**
- * Returns the maximum frequency.
- *
- * @return maximum frequency
- */
- Frequency maxFrequency();
-
- /**
- * Returns the grid spacing frequency.
- *
- * @return grid spacing frequency
- */
- Frequency grid();
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/OpticalDevice.java b/core/api/src/main/java/org/onosproject/net/optical/OpticalDevice.java
deleted file mode 100644
index a1498ab..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/OpticalDevice.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.optical;
-
-import java.util.Optional;
-
-import org.onosproject.net.Device;
-import org.onosproject.net.Port;
-import org.onosproject.net.driver.Behaviour;
-
-import com.google.common.annotations.Beta;
-
-
-// TODO consider more fine grained device type. e.g., Transponder, WSS, ROADM
-/**
- * Representation of a optical network infrastructure device.
- */
-@Beta
-public interface OpticalDevice extends Device, Behaviour {
-
- /**
- * Returns true if {@code port} is capable of being projected as the
- * specified class.
- *
- * @param port Port instance to test
- * @param portClass requested projection class
- * @param <T> type of Port
- * @return true if the requested projection is supported
- */
- <T extends Port> boolean portIs(Port port, Class<T> portClass);
-
- /**
- * Returns the specified projection of the {@code port} if such projection
- * is supported.
- *
- * @param port Port instance to project
- * @param portClass requested projection class
- * @param <T> type of Port
- * @return projection instance or empty if not supported.
- */
- <T extends Port> Optional<T> portAs(Port port, Class<T> portClass);
-
- /**
- * Returns most specific projection of the {@code port} or the {@code port}
- * itself.
- *
- * @param port Port instance
- * @return projection instance or {@code port} itself
- */
- Port port(Port port);
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/OtuPort.java b/core/api/src/main/java/org/onosproject/net/optical/OtuPort.java
deleted file mode 100644
index 15f284d..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/OtuPort.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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 gcd ~/Dooverning permissions and
- * limitations under the License.
- */
-package org.onosproject.net.optical;
-
-import org.onosproject.net.OtuSignalType;
-import org.onosproject.net.Port;
-
-import com.google.common.annotations.Beta;
-
-/**
- * OTU port (Optical channel Transport Unit).
- * <p>
- * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" and
- * Open Networking Foundation "Optical Transport Protocol Extensions Version 1.0".
- */
-@Beta
-public interface OtuPort extends Port {
-
- /**
- * Returns OTU signal type.
- *
- * @return OTU signal type
- */
- public OtuSignalType signalType();
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/OchPortHelper.java b/core/api/src/main/java/org/onosproject/net/optical/device/OchPortHelper.java
deleted file mode 100644
index 50dc98c..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/OchPortHelper.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.optical.device;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.io.IOException;
-import java.util.Optional;
-
-import org.onosproject.net.Annotations;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultAnnotations.Builder;
-import org.onosproject.net.OchSignal;
-import org.onosproject.net.OduSignalType;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.device.DefaultPortDescription;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.optical.OchPort;
-import org.onosproject.net.optical.impl.DefaultOchPort;
-import org.onosproject.net.optical.json.OchSignalCodec;
-import org.slf4j.Logger;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.annotations.Beta;
-
-/**
- * OCh port related helpers.
- */
-@Beta
-public final class OchPortHelper {
-
- private static final Logger log = getLogger(OchPortHelper.class);
-
- private static final ObjectMapper MAPPER = new ObjectMapper();
-
- // Annotation keys
- private static final String SIGNAL_TYPE = "signalType";
- private static final String TUNABLE = "tunable";
- private static final String LAMBDA = "lambda";
-
- /**
- * Creates OCh port DefaultPortDescription based on the supplied information.
- *
- * @param number port number
- * @param isEnabled port enabled state
- * @param signalType ODU signal type
- * @param isTunable tunable wavelength capability
- * @param lambda OCh signal
- * @return OCh port DefaultPortDescription with OCh annotations
- */
- public static PortDescription ochPortDescription(PortNumber number,
- boolean isEnabled,
- OduSignalType signalType,
- boolean isTunable,
- OchSignal lambda) {
- return ochPortDescription(number, isEnabled, signalType, isTunable, lambda, DefaultAnnotations.EMPTY);
- }
-
- /**
- * Creates OCh port DefaultPortDescription based on the supplied information.
- *
- * @param number port number
- * @param isEnabled port enabled state
- * @param signalType ODU signal type
- * @param isTunable tunable wavelength capability
- * @param lambda OCh signal
- * @param annotationsIn key/value annotations map
- * @return OCh port DefaultPortDescription with OCh annotations
- */
- public static PortDescription ochPortDescription(PortNumber number,
- boolean isEnabled,
- OduSignalType signalType,
- boolean isTunable,
- OchSignal lambda,
- SparseAnnotations annotationsIn) {
-
- Builder builder = DefaultAnnotations.builder();
- builder.putAll(annotationsIn);
-
- builder.set(TUNABLE, String.valueOf(isTunable));
- builder.set(LAMBDA, OchSignalCodec.encode(lambda).toString());
- builder.set(SIGNAL_TYPE, signalType.toString());
-
- DefaultAnnotations annotations = builder.build();
- long portSpeed = 0; // FIXME assign appropriate value
- return new DefaultPortDescription(number, isEnabled, Port.Type.OCH, portSpeed, annotations);
- }
-
- /**
- * Creates OCh port DefaultPortDescription based on the supplied information.
- *
- * @param base PortDescription to get basic information from
- * @param signalType ODU signal type
- * @param isTunable tunable wavelength capability
- * @param lambda OCh signal
- * @param annotations key/value annotations map
- * @return OCh port DefaultPortDescription with OCh annotations
- */
- public static PortDescription ochPortDescription(PortDescription base,
- OduSignalType signalType,
- boolean isTunable,
- OchSignal lambda,
- SparseAnnotations annotations) {
- return ochPortDescription(base.portNumber(), base.isEnabled(), signalType, isTunable, lambda, annotations);
- }
-
-
- public static Optional<OchPort> asOchPort(Port port) {
- if (port instanceof OchPort) {
- return Optional.of((OchPort) port);
- }
-
- try {
- Annotations an = port.annotations();
-
- OduSignalType signalType = Enum.valueOf(OduSignalType.class,
- an.value(SIGNAL_TYPE));
-
- boolean isTunable = Boolean.valueOf(an.value(TUNABLE));
-
- ObjectNode obj = (ObjectNode) MAPPER.readTree(an.value(LAMBDA));
- OchSignal lambda = OchSignalCodec.decode(obj);
-
- // Note: OCh specific annotations is not filtered-out here.
- // DefaultOchPort should filter them, if necessary.
- return Optional.of(new DefaultOchPort(port, signalType, isTunable, lambda));
-
- // TODO: it'll be better to verify each inputs properly
- // instead of catching all these Exceptions.
- } catch (IOException | NullPointerException
- | IllegalArgumentException | ClassCastException e) {
-
- log.warn("{} was not well-formed OCh port.", port, e);
- return Optional.empty();
- }
- }
-
- // not meant to be instantiated
- private OchPortHelper() {}
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/OduCltPortHelper.java b/core/api/src/main/java/org/onosproject/net/optical/device/OduCltPortHelper.java
deleted file mode 100644
index efda401..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/OduCltPortHelper.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.net.optical.device;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Optional;
-
-import org.onosproject.net.Annotations;
-import org.onosproject.net.CltSignalType;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.DefaultAnnotations.Builder;
-import org.onosproject.net.device.DefaultPortDescription;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.optical.OduCltPort;
-import org.onosproject.net.optical.impl.DefaultOduCltPort;
-import org.slf4j.Logger;
-
-import com.google.common.annotations.Beta;
-
-/**
- * ODU client port related helpers.
- */
-@Beta
-public final class OduCltPortHelper {
-
- private static final Logger log = getLogger(OduCltPortHelper.class);
-
- // Annotation keys
- /**
- * {@link CltSignalType} as String.
- */
- private static final String SIGNAL_TYPE = "signalType";
-
- /**
- * Creates ODU client port description based on the supplied information.
- *
- * @param number port number
- * @param isEnabled port enabled state
- * @param signalType ODU client signal type
- */
- public static PortDescription oduCltPortDescription(PortNumber number,
- boolean isEnabled,
- CltSignalType signalType) {
- return oduCltPortDescription(number, isEnabled, signalType, DefaultAnnotations.EMPTY);
- }
-
- /**
- * Creates ODU client port description based on the supplied information.
- *
- * @param number port number
- * @param isEnabled port enabled state
- * @param signalType ODU client signal type
- * @param annotations key/value annotations map
- */
- public static PortDescription oduCltPortDescription(PortNumber number,
- boolean isEnabled,
- CltSignalType signalType,
- SparseAnnotations annotations) {
- Builder builder = DefaultAnnotations.builder();
- builder.putAll(annotations);
-
- builder.set(SIGNAL_TYPE, signalType.toString());
-
- long portSpeed = signalType.bitRate();
- return new DefaultPortDescription(number,
- isEnabled,
- Port.Type.ODUCLT,
- portSpeed,
- builder.build());
- }
-
- /**
- * Creates ODU client port description based on the supplied information.
- *
- * @param base PortDescription to get basic information from
- * @param signalType ODU client signal type
- * @param annotations key/value annotations map
- */
- public static PortDescription oduCltPortDescription(PortDescription base,
- CltSignalType signalType,
- SparseAnnotations annotations) {
- return oduCltPortDescription(base.portNumber(), base.isEnabled(), signalType, annotations);
- }
-
- public static Optional<OduCltPort> asOduCltPort(Port port) {
- if (port instanceof OduCltPort) {
- return Optional.of((OduCltPort) port);
- }
-
- try {
- Annotations an = port.annotations();
-
- CltSignalType signalType = Enum.valueOf(CltSignalType.class,
- an.value(SIGNAL_TYPE));
-
-
- // Note: ODU specific annotations is not filtered-out here.
- // DefaultOduCltPort should filter them, if necessary.
- return Optional.of(new DefaultOduCltPort(port, signalType));
-
- } catch (NullPointerException | IllegalArgumentException e) {
-
- log.warn("{} was not well-formed OduClt port.", port, e);
- return Optional.empty();
- }
- }
-
- // not meant to be instantiated
- private OduCltPortHelper() {}
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/OmsPortHelper.java b/core/api/src/main/java/org/onosproject/net/optical/device/OmsPortHelper.java
deleted file mode 100644
index 2c99c53..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/OmsPortHelper.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.net.optical.device;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Optional;
-
-import org.onlab.util.Frequency;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.DefaultAnnotations.Builder;
-import org.onosproject.net.device.DefaultPortDescription;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.optical.OmsPort;
-import org.onosproject.net.optical.impl.DefaultOmsPort;
-import org.slf4j.Logger;
-
-import com.google.common.annotations.Beta;
-
-/**
- * OMS port related helpers.
- */
-@Beta
-public final class OmsPortHelper {
-
- private static final Logger log = getLogger(OmsPortHelper.class);
-
- // Annotation keys
- /**
- * minFrequency in Hz.
- */
- private static final String MIN_FREQ_HZ = "minFrequency";
- /**
- * maxFrequency in Hz.
- */
- private static final String MAX_FREQ_HZ = "maxFrequency";
- /**
- * grid in Hz.
- */
- private static final String GRID_HZ = "grid";
-
- /**
- * Creates OMS port description based on the supplied information.
- *
- * @param number port number
- * @param isEnabled port enabled state
- * @param minFrequency minimum frequency
- * @param maxFrequency maximum frequency
- * @param grid grid spacing frequency
- * @param annotations key/value annotations map
- */
- public static PortDescription omsPortDescription(PortNumber number,
- boolean isEnabled,
- Frequency minFrequency,
- Frequency maxFrequency,
- Frequency grid,
- SparseAnnotations annotations) {
-
- Builder builder = DefaultAnnotations.builder();
- builder.putAll(annotations);
-
- builder.set(MIN_FREQ_HZ, String.valueOf(minFrequency.asHz()));
- builder.set(MAX_FREQ_HZ, String.valueOf(maxFrequency.asHz()));
- builder.set(GRID_HZ, String.valueOf(grid.asHz()));
-
- long portSpeed = 0;
- return new DefaultPortDescription(number, isEnabled, Port.Type.OMS, portSpeed, builder.build());
- }
-
- /**
- * Creates OMS port description based on the supplied information.
- *
- * @param number port number
- * @param isEnabled port enabled state
- * @param minFrequency minimum frequency
- * @param maxFrequency maximum frequency
- * @param grid grid spacing frequency
- */
- public static PortDescription omsPortDescription(PortNumber number,
- boolean isEnabled,
- Frequency minFrequency,
- Frequency maxFrequency,
- Frequency grid) {
- return omsPortDescription(number, isEnabled, minFrequency, maxFrequency, grid, DefaultAnnotations.EMPTY);
- }
-
- /**
- * Creates OMS port description based on the supplied information.
- *
- * @param base PortDescription to get basic information from
- * @param minFrequency minimum frequency
- * @param maxFrequency maximum frequency
- * @param grid grid spacing frequency
- * @param annotations key/value annotations map
- */
- public static PortDescription omsPortDescription(PortDescription base,
- Frequency minFrequency,
- Frequency maxFrequency,
- Frequency grid,
- SparseAnnotations annotations) {
-
- return omsPortDescription(base.portNumber(), base.isEnabled(),
- minFrequency, maxFrequency, grid,
- annotations);
- }
-
- public static Optional<OmsPort> asOmsPort(Port port) {
- if (port instanceof OmsPort) {
- return Optional.of((OmsPort) port);
- }
-
- try {
- Annotations an = port.annotations();
-
- Frequency minFrequency = Frequency.ofHz(Long.parseLong(an.value(MIN_FREQ_HZ)));
- Frequency maxFrequency = Frequency.ofHz(Long.parseLong(an.value(MAX_FREQ_HZ)));
- Frequency grid = Frequency.ofHz(Long.parseLong(an.value(GRID_HZ)));
-
- return Optional.of(new DefaultOmsPort(port, minFrequency, maxFrequency, grid));
-
- } catch (NumberFormatException e) {
-
- log.warn("{} was not well-formed OMS port.", port, e);
- return Optional.empty();
- }
- }
-
- // not meant to be instantiated
- private OmsPortHelper() {}
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java b/core/api/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java
deleted file mode 100644
index da4da82..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.optical.device;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.optical.OpticalDevice;
-import org.onosproject.net.utils.ForwardingDeviceService;
-import org.slf4j.Logger;
-
-import com.google.common.annotations.Beta;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-import org.apache.commons.lang3.tuple.Pair;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Element;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-
-
-// TODO replace places using DeviceService expecting Optical specific ports.
-// with this
-
-/**
- * Decorator, which provides a DeviceService view, which returns
- * Ports in optical specific ports.
- */
-@Beta
-public class OpticalDeviceServiceView
- extends ForwardingDeviceService
- implements DeviceService {
-
- private static final Logger log = getLogger(OpticalDeviceServiceView.class);
-
- /**
- * DeviceListener to wrapped DeviceListener map.
- * <p>
- * {@literal original listener -> wrapped listener}
- */
- private final Map<DeviceListener, DeviceListener> wrapped = Maps.newIdentityHashMap();
-
- // May need a way to monitor Drivers loaded on ONOS and
- // invalidate this Cache if a driver was added/updated
- /**
- * Device to {@link OpticalDevice} map cache.
- */
- private final LoadingCache<Element, Optional<OpticalDevice>> optdev
- = CacheBuilder.newBuilder()
- .weakKeys() // == for Key comparison
- .maximumSize(100)
- .build(CacheLoader.from(elm -> {
- if (elm.is(OpticalDevice.class)) {
- return Optional.of(elm.as(OpticalDevice.class));
- } else {
- return Optional.empty();
- }
- }));
-
- // Not intended to be instantiated directly
- protected OpticalDeviceServiceView(DeviceService base) {
- super(base);
- }
-
- /**
- * Wraps the given DeviceService to provide a view,
- * which returns port as optical specific Port class.
- *
- * @param base {@link DeviceService} view to use as baseline.
- * @return Decorated view of {@code base}
- */
- public static OpticalDeviceServiceView opticalView(DeviceService base) {
- // TODO might make sense to track and assign an instance for each `base`
- return new OpticalDeviceServiceView(base);
- }
-
- /**
- * Transform Port instance on the event to Optical specific port, if it is well-formed.
- *
- * @param event original event to transform
- * @return transformed {@link DeviceEvent}
- */
- public DeviceEvent augment(DeviceEvent event) {
- final Port port = augment(event.port());
- if (port == event.port()) {
- // If the Port not changed, pass through
- return event;
- }
- return new DeviceEvent(event.type(), event.subject(), port, event.time());
- }
-
- /**
- * Transform Port instance to Optical specific port, if it is well-formed.
- *
- * @param port Port instance to translate
- * @return Optical specific port instance or original {@code port}.
- */
- public Port augment(Port port) {
- if (port == null) {
- return null;
- }
- return optdev.getUnchecked(port.element())
- .map(odev -> odev.port(port))
- .orElse(port);
- }
-
- @Override
- public void addListener(DeviceListener listener) {
- super.addListener(wrapped.computeIfAbsent(listener, OpticalDeviceListener::new));
- }
-
- @Override
- public void removeListener(DeviceListener listener) {
- DeviceListener wrappedListener = wrapped.remove(listener);
- if (wrappedListener != null) {
- super.removeListener(wrappedListener);
- }
- }
-
-
- @Override
- public List<Port> getPorts(DeviceId deviceId) {
- return Lists.transform(super.getPorts(deviceId),
- this::augment);
- }
-
- @Override
- public Port getPort(DeviceId deviceId, PortNumber portNumber) {
- return augment(super.getPort(deviceId, portNumber));
- }
-
-
- /**
- * DeviceListener, which translates generic Port to optical specific Port
- * before passing.
- */
- class OpticalDeviceListener implements DeviceListener {
-
- private final DeviceListener listener;
-
- // shallow cache to reuse transformed event in isRelevant and event call
- private Pair<DeviceEvent, DeviceEvent> cache;
-
- public OpticalDeviceListener(DeviceListener listener) {
- this.listener = listener;
- }
-
- private DeviceEvent opticalEvent(DeviceEvent event) {
-
- Pair<DeviceEvent, DeviceEvent> entry = cache;
- if (entry != null && entry.getLeft() == event) {
- return entry.getRight();
- }
-
- DeviceEvent opticalEvent = augment(event);
- cache = Pair.of(event, opticalEvent);
- return opticalEvent;
- }
-
- @Override
- public boolean isRelevant(DeviceEvent event) {
- return listener.isRelevant(opticalEvent(event));
- }
-
- @Override
- public void event(DeviceEvent event) {
- listener.event(opticalEvent(event));
- }
- }
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/OtuPortHelper.java b/core/api/src/main/java/org/onosproject/net/optical/device/OtuPortHelper.java
deleted file mode 100644
index aeac4f9..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/OtuPortHelper.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.net.optical.device;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Optional;
-
-import org.onosproject.net.Annotations;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.DefaultAnnotations.Builder;
-import org.onosproject.net.OtuSignalType;
-import org.onosproject.net.device.DefaultPortDescription;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.optical.OtuPort;
-import org.onosproject.net.optical.impl.DefaultOtuPort;
-import org.slf4j.Logger;
-
-import com.google.common.annotations.Beta;
-
-/**
- * OTU port related helpers.
- */
-@Beta
-public final class OtuPortHelper {
-
- private static final Logger log = getLogger(OtuPortHelper.class);
-
- // Annotation keys
- /**
- * {@link OtuSignalType} as String.
- */
- private static final String SIGNAL_TYPE = "signalType";
-
- /**
- * Creates OTU port description based on the supplied information.
- *
- * @param number port number
- * @param isEnabled port enabled state
- * @param signalType OTU client signal type
- */
- public static PortDescription otuPortDescription(PortNumber number,
- boolean isEnabled,
- OtuSignalType signalType) {
- return otuPortDescription(number, isEnabled, signalType, DefaultAnnotations.EMPTY);
- }
-
- /**
- * Creates OTU port description based on the supplied information.
- *
- * @param number port number
- * @param isEnabled port enabled state
- * @param signalType OTU client signal type
- * @param annotations key/value annotations map
- */
- public static PortDescription otuPortDescription(PortNumber number,
- boolean isEnabled,
- OtuSignalType signalType,
- SparseAnnotations annotations) {
- Builder builder = DefaultAnnotations.builder();
- builder.putAll(annotations);
-
- builder.set(SIGNAL_TYPE, signalType.toString());
-
- long portSpeed = 0; // TODO specify appropriate value?
- return new DefaultPortDescription(number,
- isEnabled,
- Port.Type.OTU,
- portSpeed,
- builder.build());
- }
-
- /**
- * Creates OTU port description based on the supplied information.
- *
- * @param base PortDescription to get basic information from
- * @param signalType OTU client signal type
- * @param annotations key/value annotations map
- */
- public static PortDescription otuPortDescription(PortDescription base,
- OtuSignalType signalType,
- SparseAnnotations annotations) {
- return otuPortDescription(base.portNumber(), base.isEnabled(), signalType, annotations);
- }
-
- public static Optional<OtuPort> asOtuPort(Port port) {
- if (port instanceof OtuPort) {
- return Optional.of((OtuPort) port);
- }
-
- try {
- Annotations an = port.annotations();
-
- OtuSignalType signalType = Enum.valueOf(OtuSignalType.class,
- an.value(SIGNAL_TYPE));
-
-
- // Note: OTU specific annotations is not filtered-out here.
- // DefaultOtuPort should filter them, if necessary.
- return Optional.of(new DefaultOtuPort(port, signalType));
-
- } catch (NullPointerException | IllegalArgumentException e) {
-
- log.warn("{} was not well-formed Otu port.", port, e);
- return Optional.empty();
- }
- }
-
-
- // not meant to be instantiated
- private OtuPortHelper() {}
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/device/package-info.java
deleted file mode 100644
index 20b6d33..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Optical device models.
- */
-package org.onosproject.net.optical.device;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/AbstractPortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/AbstractPortMapper.java
deleted file mode 100644
index 8162dd3..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/port/AbstractPortMapper.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.net.optical.device.port;
-
-import java.util.Optional;
-
-import org.onosproject.net.Port;
-
-import com.google.common.annotations.Beta;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-
-/**
- * PortMapper which caches mapped Port instance.
- */
-@Beta
-public abstract class AbstractPortMapper<P extends Port> implements PortMapper<P> {
-
- private final LoadingCache<Port, Optional<P>> cache
- = CacheBuilder.newBuilder()
- .weakKeys() // use == to compare keys
- .maximumSize(100)
- .build(CacheLoader.from(this::mapPort));
-
- /**
- * {@inheritDoc}
- *
- * <p>
- * Note: Subclasses should override and implement short-cut conditions
- * and call {@code super.is(port)}.
- */
- @Override
- public boolean is(Port port) {
- return as(port).isPresent();
- }
-
- /**
- * {@inheritDoc}
- *
- * <p>
- * Note: Subclasses should override and check if {@code port} is
- * already of type {@code P} and directly return {@code Optional.of((P) port)},
- * if not call {@code super.as(port)}.
- */
- @Override
- public Optional<P> as(Port port) {
- if (port == null) {
- return Optional.empty();
- }
- return cache.getUnchecked(port);
- }
-
- /**
- * Returns {@code port} mapped to {@code <P>}.
- *
- * @param port Port to map
- * @return {@code port} mapped to {@code <P>}
- */
- protected abstract Optional<P> mapPort(Port port);
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/IdentityMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/IdentityMapper.java
deleted file mode 100644
index 40c25af..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/port/IdentityMapper.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.net.optical.device.port;
-
-import java.util.Optional;
-
-import org.onosproject.net.Port;
-
-import com.google.common.annotations.Beta;
-
-/**
- * {@link PortMapper} which simply return given input.
- */
-@Beta
-public class IdentityMapper implements PortMapper<Port> {
-
- @Override
- public boolean is(Port port) {
- return true;
- }
-
- @Override
- public Optional<Port> as(Port port) {
- return Optional.of(port);
- }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/OchPortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/OchPortMapper.java
deleted file mode 100644
index badca9d..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/port/OchPortMapper.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.net.optical.device.port;
-
-import java.util.Optional;
-
-import org.onosproject.net.Port;
-import org.onosproject.net.optical.OchPort;
-import org.onosproject.net.optical.device.OchPortHelper;
-import org.onosproject.net.optical.impl.DefaultOchPort;
-
-import com.google.common.annotations.Beta;
-
-/**
- * {@link PortMapper} to handler {@link OchPort} translation.
- */
-@Beta
-public class OchPortMapper extends AbstractPortMapper<OchPort> {
-
- @Override
- public boolean is(Port port) {
- return port != null &&
- port.type() == Port.Type.OCH &&
- super.is(port);
- }
-
- @Override
- public Optional<OchPort> as(Port port) {
- if (port instanceof OchPort) {
- return Optional.of((OchPort) port);
- }
- return super.as(port);
- }
-
- @Override
- protected Optional<OchPort> mapPort(Port port) {
- if (port instanceof OchPort) {
- return Optional.of((OchPort) port);
- } else if (port instanceof org.onosproject.net.OchPort) {
- // TODO remove after deprecation of old OchPort is complete
-
- // translate to new OchPort
- org.onosproject.net.OchPort old = (org.onosproject.net.OchPort) port;
- return Optional.of(new DefaultOchPort(old,
- old.signalType(),
- old.isTunable(),
- old.lambda()));
- }
-
- return OchPortHelper.asOchPort(port);
- }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/OduCltPortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/OduCltPortMapper.java
deleted file mode 100644
index 6eeb631..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/port/OduCltPortMapper.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.net.optical.device.port;
-
-import java.util.Optional;
-
-import org.onosproject.net.Port;
-import org.onosproject.net.optical.OduCltPort;
-import org.onosproject.net.optical.device.OduCltPortHelper;
-import org.onosproject.net.optical.impl.DefaultOduCltPort;
-
-import com.google.common.annotations.Beta;
-
-/**
- * {@link PortMapper} to handler {@link OduCltPort} translation.
- */
-@Beta
-public class OduCltPortMapper extends AbstractPortMapper<OduCltPort> {
-
- @Override
- public boolean is(Port port) {
- return port != null &&
- port.type() == Port.Type.ODUCLT &&
- super.is(port);
- }
-
- @Override
- public Optional<OduCltPort> as(Port port) {
- if (port instanceof OduCltPort) {
- return Optional.of((OduCltPort) port);
- }
- return super.as(port);
- }
-
- @Override
- protected Optional<OduCltPort> mapPort(Port port) {
- if (port instanceof OduCltPort) {
- return Optional.of((OduCltPort) port);
- } else if (port instanceof org.onosproject.net.OduCltPort) {
- // TODO remove after deprecation of old OduCltPort is complete
-
- // translate to new OduCltPort
- org.onosproject.net.OduCltPort old = (org.onosproject.net.OduCltPort) port;
- return Optional.of(new DefaultOduCltPort(old,
- old.signalType()));
- }
-
- return OduCltPortHelper.asOduCltPort(port);
- }
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/OmsPortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/OmsPortMapper.java
deleted file mode 100644
index 70a8aa9..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/port/OmsPortMapper.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.net.optical.device.port;
-
-import java.util.Optional;
-
-import org.onosproject.net.Port;
-import org.onosproject.net.optical.OmsPort;
-import org.onosproject.net.optical.device.OmsPortHelper;
-import org.onosproject.net.optical.impl.DefaultOmsPort;
-
-import com.google.common.annotations.Beta;
-
-/**
- * {@link PortMapper} to handler {@link OmsPort} translation.
- */
-@Beta
-public class OmsPortMapper extends AbstractPortMapper<OmsPort> {
-
- @Override
- public boolean is(Port port) {
- return port != null &&
- port.type() == Port.Type.OMS &&
- super.is(port);
- }
-
- @Override
- public Optional<OmsPort> as(Port port) {
- if (port instanceof OmsPort) {
- return Optional.of((OmsPort) port);
- }
- return super.as(port);
- }
-
- @Override
- protected Optional<OmsPort> mapPort(Port port) {
- if (port instanceof OmsPort) {
- return Optional.of((OmsPort) port);
- } else if (port instanceof org.onosproject.net.OmsPort) {
- // TODO remove after deprecation of old OmsPort is complete
-
- // translate to new OmsPort
- org.onosproject.net.OmsPort old = (org.onosproject.net.OmsPort) port;
- return Optional.of(new DefaultOmsPort(old,
- old.minFrequency(),
- old.maxFrequency(),
- old.grid()));
- }
-
- return OmsPortHelper.asOmsPort(port);
- }
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/OtuPortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/OtuPortMapper.java
deleted file mode 100644
index c70033a..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/port/OtuPortMapper.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.net.optical.device.port;
-
-import java.util.Optional;
-
-import org.onosproject.net.Port;
-import org.onosproject.net.optical.OtuPort;
-import org.onosproject.net.optical.device.OtuPortHelper;
-import org.onosproject.net.optical.impl.DefaultOtuPort;
-
-import com.google.common.annotations.Beta;
-
-/**
- * {@link PortMapper} to handler {@link OtuPort} translation.
- */
-@Beta
-public class OtuPortMapper extends AbstractPortMapper<OtuPort> {
-
- @Override
- public boolean is(Port port) {
- return port != null &&
- port.type() == Port.Type.OTU &&
- super.is(port);
- }
-
- @Override
- public Optional<OtuPort> as(Port port) {
- if (port instanceof OtuPort) {
- return Optional.of((OtuPort) port);
- }
- return super.as(port);
- }
-
- @Override
- protected Optional<OtuPort> mapPort(Port port) {
- if (port instanceof OtuPort) {
- return Optional.of((OtuPort) port);
- } else if (port instanceof org.onosproject.net.OtuPort) {
- // TODO remove after deprecation of old OtuPort is complete
-
- // translate to new OtuPort
- org.onosproject.net.OtuPort old = (org.onosproject.net.OtuPort) port;
- return Optional.of(new DefaultOtuPort(old,
- old.signalType()));
- }
-
- return OtuPortHelper.asOtuPort(port);
- }
-
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/PortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/PortMapper.java
deleted file mode 100644
index 90da7ae..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/port/PortMapper.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.net.optical.device.port;
-
-import java.util.Optional;
-
-import org.onosproject.net.Port;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Abstraction of a class capable of translating generic-Port object
- * as another domain-specific Port of type {@code P}.
- *
- * @param <P> Port type to map generic Port to
- */
-@Beta
-public interface PortMapper<P extends Port> {
-
- /**
- * Returns true if this port is capable of being projected as {@code <P>}.
- */
- boolean is(Port port);
-
- /**
- * Returns {@code port} mapped to {@code <P>}.
- *
- * @param port Port to map
- * @return {@code port} mapped to {@code <P>}
- */
- Optional<P> as(Port port);
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/package-info.java
deleted file mode 100644
index 4b53003..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/device/port/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-/**
- * Optical device port related utilities.
- */
-package org.onosproject.net.optical.device.port;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java
deleted file mode 100644
index 593b021..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java
+++ /dev/null
@@ -1,145 +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.net.optical.impl;
-
-import org.onosproject.net.Annotations;
-import org.onosproject.net.OchSignal;
-import org.onosproject.net.OduSignalType;
-import org.onosproject.net.Port;
-import org.onosproject.net.optical.OchPort;
-import org.onosproject.net.utils.ForwardingPort;
-
-import com.google.common.annotations.Beta;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-/**
- * Implementation of OCh port (Optical Channel).
- * Also referred to as a line side port (L-port) or narrow band port.
- * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
- */
-@Beta
-public class DefaultOchPort extends ForwardingPort implements OchPort {
-
- // Note: try to avoid direct access to the field, use accessor.
- // We might want to lazily parse annotation in the future
- private final OduSignalType signalType;
- private final boolean isTunable;
- private final OchSignal lambda;
-
- /**
- * Creates an OCh port in the specified network element.
- *
- * @param base Port
- * @param signalType ODU signal type
- * @param isTunable tunable wavelength capability
- * @param lambda OCh signal
- */
- public DefaultOchPort(Port base,
- OduSignalType signalType,
- boolean isTunable,
- OchSignal lambda) {
- super(base);
- // TODO should this class be parsing annotation to instantiate signalType?
- this.signalType = checkNotNull(signalType);
- this.isTunable = isTunable;
- this.lambda = checkNotNull(lambda);
- }
-
- @Override
- public Type type() {
- return Type.OCH;
- }
-
- @Override
- public long portSpeed() {
- return signalType.bitRate();
- }
-
-
- @Override
- public Annotations annotations() {
- // FIXME Filter OCh annotations, after confirming that
- // it'll not result in information-loss
- return super.annotations();
- }
-
- /**
- * Returns ODU signal type.
- *
- * @return ODU signal type
- */
- @Override
- public OduSignalType signalType() {
- return signalType;
- }
-
- /**
- * Returns true if port is wavelength tunable.
- *
- * @return tunable wavelength capability
- */
- @Override
- public boolean isTunable() {
- return isTunable;
- }
-
- /**
- * Returns OCh signal.
- *
- * @return OCh signal
- */
- @Override
- public OchSignal lambda() {
- return lambda;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(),
- signalType(),
- isTunable(),
- lambda());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj != null && getClass() == obj.getClass()) {
- final DefaultOchPort that = (DefaultOchPort) obj;
- return super.toEqualsBuilder(that)
- .append(this.signalType(), that.signalType())
- .append(this.isTunable(), that.isTunable())
- .append(this.lambda(), that.lambda())
- .isEquals();
- }
- return false;
- }
-
- @Override
- public String toString() {
- return super.toStringHelper()
- .add("signalType", signalType())
- .add("isTunable", isTunable())
- .add("lambda", lambda())
- .toString();
- }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java
deleted file mode 100644
index 78a4266..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.net.optical.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-import org.onosproject.net.CltSignalType;
-import org.onosproject.net.Port;
-import org.onosproject.net.optical.OduCltPort;
-import org.onosproject.net.utils.ForwardingPort;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Implementation of ODU client port (Optical channel Data Unit).
- * Also referred to as a T-port or wide band port.
- * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
- */
-@Beta
-public class DefaultOduCltPort extends ForwardingPort implements OduCltPort {
-
- private final CltSignalType signalType;
-
- /**
- * Creates an ODU client port.
- *
- * @param delegate Port
- * @param signalType ODU client signal type
- */
- public DefaultOduCltPort(Port delegate, CltSignalType signalType) {
- super(delegate);
- this.signalType = checkNotNull(signalType);
- }
-
- @Override
- public Type type() {
- return Type.ODUCLT;
- }
-
- @Override
- public long portSpeed() {
- return signalType().bitRate();
- }
-
- @Override
- public CltSignalType signalType() {
- return signalType;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(),
- signalType());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj != null && getClass() == obj.getClass()) {
- final DefaultOduCltPort that = (DefaultOduCltPort) obj;
- return super.toEqualsBuilder(that)
- .append(this.signalType(), that.signalType())
- .isEquals();
- }
- return false;
- }
-
- @Override
- public String toString() {
- return super.toStringHelper()
- .add("signalType", signalType())
- .toString();
- }
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java
deleted file mode 100644
index eb2c426..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.net.optical.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-import org.onlab.util.Frequency;
-import org.onosproject.net.Port;
-import org.onosproject.net.optical.OmsPort;
-import org.onosproject.net.utils.ForwardingPort;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Implementation of OMS port (Optical Multiplexing Section).
- * Also referred to as a WDM port or W-port.
- * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
- *
- * Assumes we only support fixed grid for now.
- */
-@Beta
-public class DefaultOmsPort extends ForwardingPort implements OmsPort {
-
- private final Frequency minFrequency; // Minimum frequency
- private final Frequency maxFrequency; // Maximum frequency
- private final Frequency grid; // Grid spacing frequency
-
- /**
- * Creates an OMS port.
- *
- * @param delegate Port
- * @param minFrequency minimum frequency
- * @param maxFrequency maximum frequency
- * @param grid grid spacing frequency
- */
- public DefaultOmsPort(Port delegate, Frequency minFrequency, Frequency maxFrequency, Frequency grid) {
- super(delegate);
-
- this.minFrequency = checkNotNull(minFrequency);
- this.maxFrequency = checkNotNull(maxFrequency);
- this.grid = checkNotNull(grid);
- }
-
- @Override
- public Type type() {
- return Type.OMS;
- }
-
- @Override
- public long portSpeed() {
- return 0;
- }
-
- @Override
- public Frequency minFrequency() {
- return minFrequency;
- }
-
- @Override
- public Frequency maxFrequency() {
- return maxFrequency;
- }
-
- @Override
- public Frequency grid() {
- return grid;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(),
- minFrequency(),
- maxFrequency(),
- grid());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj != null && getClass() == obj.getClass()) {
- final DefaultOmsPort that = (DefaultOmsPort) obj;
- return super.toEqualsBuilder(that)
- .append(this.minFrequency(), that.minFrequency())
- .append(this.maxFrequency(), that.maxFrequency())
- .append(this.grid(), that.grid())
- .isEquals();
- }
- return false;
- }
-
- @Override
- public String toString() {
- return super.toStringHelper()
- .add("minFrequency", minFrequency())
- .add("maxFrequency", maxFrequency())
- .add("grid", grid())
- .toString();
- }
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java
deleted file mode 100644
index 2c038c8..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.net.optical.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-import org.onosproject.net.OtuSignalType;
-import org.onosproject.net.Port;
-import org.onosproject.net.optical.OtuPort;
-import org.onosproject.net.utils.ForwardingPort;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Implementation of OTU port (Optical channel Transport Unit).
- *
- */
-@Beta
-public class DefaultOtuPort extends ForwardingPort implements OtuPort {
-
- private final OtuSignalType signalType;
-
- /**
- * Creates an ODU client port.
- *
- * @param delegate Port
- * @param signalType OTU signal type
- */
- public DefaultOtuPort(Port delegate, OtuSignalType signalType) {
- super(delegate);
- this.signalType = checkNotNull(signalType);
- }
-
- @Override
- public Type type() {
- return Type.OTU;
- }
-
-// @Override
-// public long portSpeed() {
-// return signalType().bitRate();
-// }
-
- @Override
- public OtuSignalType signalType() {
- return signalType;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(),
- signalType());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj != null && getClass() == obj.getClass()) {
- final DefaultOtuPort that = (DefaultOtuPort) obj;
- return super.toEqualsBuilder(that)
- .append(this.signalType(), that.signalType())
- .isEquals();
- }
- return false;
- }
-
- @Override
- public String toString() {
- return super.toStringHelper()
- .add("signalType", signalType())
- .toString();
- }
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/impl/package-info.java
deleted file mode 100644
index 8542c62..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/impl/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Note: All classes in this package is expected to be instance local, and
-// are not expected to be serialized (by Kryo, etc.)
-/**
- * Implementation of Optical augmentation classes.
- */
-package org.onosproject.net.optical.impl;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/json/OchSignalCodec.java b/core/api/src/main/java/org/onosproject/net/optical/json/OchSignalCodec.java
deleted file mode 100644
index 0fba4fa..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/json/OchSignalCodec.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.optical.json;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import org.onosproject.net.ChannelSpacing;
-import org.onosproject.net.GridType;
-import org.onosproject.net.OchSignal;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.annotations.Beta;
-
-// TODO define common interface for JsonCodec for annotation?
-// unlike existing JsonCodec, this use-case requires that encode/decode is
-// reversible. (e.g., obj.equals(decode(encode(obj))))
-/**
- * JSON codec for OchSignal.
- */
-@Beta
-public abstract class OchSignalCodec {
-
- // TODO should probably use shared mapper across optical codecs.
- private static final ObjectMapper MAPPER = new ObjectMapper();
-
- /**
- * Creates an instance of {@link OchSignal} from JSON representation.
- *
- * @param obj JSON Object representing OchSignal
- * @return OchSignal
- * @throws IllegalArgumentException - if JSON object is ill-formed
- * @see OchSignalCodec#encode(OchSignal)
- */
- public static OchSignal decode(ObjectNode obj) {
- final GridType gridType;
- final ChannelSpacing channelSpacing;
- final int spacingMultiplier;
- final int slotGranularity;
-
- String s;
- s = obj.get("channelSpacing").textValue();
- checkArgument(s != null, "ill-formed channelSpacing");
- channelSpacing = Enum.valueOf(ChannelSpacing.class, s);
-
- s = obj.get("gridType").textValue();
- checkArgument(s != null, "ill-formed gridType");
- gridType = Enum.valueOf(GridType.class, s);
-
- JsonNode node;
- node = obj.get("spacingMultiplier");
- checkArgument(node.canConvertToInt(), "ill-formed spacingMultiplier");
- spacingMultiplier = node.asInt();
-
- node = obj.get("slotGranularity");
- checkArgument(node.canConvertToInt(), "ill-formed slotGranularity");
- slotGranularity = node.asInt();
-
- return new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity);
- }
-
- /**
- * Returns a JSON Object representation of this instance.
- *
- * @return JSON Object representing OchSignal
- */
- public static ObjectNode encode(OchSignal j) {
- ObjectNode obj = MAPPER.createObjectNode();
- obj.put("channelSpacing", j.channelSpacing().toString());
- obj.put("gridType", j.gridType().toString());
- obj.put("slotGranularity", j.slotGranularity());
- obj.put("spacingMultiplier", j.spacingMultiplier());
- return obj;
- }
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/json/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/json/package-info.java
deleted file mode 100644
index 93f2ed3..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/json/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * JSON related utilities.
- */
-package org.onosproject.net.optical.json;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/package-info.java
deleted file mode 100644
index fbb4d4e..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Note: this package sub-tree will be moved out from onos-api bundle soon.
-/**
- * Optical augmentation classes.
- */
-package org.onosproject.net.optical;
diff --git a/core/api/src/test/java/org/onosproject/net/optical/device/OmsPortHelperTest.java b/core/api/src/test/java/org/onosproject/net/optical/device/OmsPortHelperTest.java
deleted file mode 100644
index 6a309aa..0000000
--- a/core/api/src/test/java/org/onosproject/net/optical/device/OmsPortHelperTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.net.optical.device;
-
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-
-import java.util.Optional;
-
-import org.junit.Test;
-import org.onlab.packet.ChassisId;
-import org.onlab.util.Frequency;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.DefaultPort;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.optical.OmsPort;
-import org.onosproject.net.Device.Type;
-import org.onosproject.net.provider.ProviderId;
-
-/**
- * Tests for {@link OmsPortHelper}.
- */
-public class OmsPortHelperTest {
-
- private static final ProviderId PID = new ProviderId("test", "id");
- private static final DeviceId DID = DeviceId.deviceId("test:00123");
- private static final String MFC = "MFC";
- private static final String HW = "HW V";
- private static final String SW = "SW V";
- private static final String SER = "SER";
- private static final ChassisId CHS = new ChassisId(42);
- private static final Annotations DEV_ANON = DefaultAnnotations.EMPTY;
- private static final Device DEV = new DefaultDevice(PID, DID, Type.ROADM, MFC, HW, SW, SER, CHS, DEV_ANON);
-
-
- @Test
- public void testOmsPortDescriptionCanBeConvertedToOmsPort() {
- PortNumber pn = PortNumber.portNumber(4900);
-
- boolean isEnabled = true;
- String anKey = "Base";
- String anValue = "value";
- SparseAnnotations an = DefaultAnnotations.builder()
- .set(anKey, anValue)
- .build();
-
- Frequency minF = Frequency.ofGHz(3);
- Frequency maxF = Frequency.ofGHz(33);
- Frequency grid = Frequency.ofGHz(2);
-
- PortDescription portDescription = OmsPortHelper.omsPortDescription(pn, isEnabled, minF, maxF, grid, an);
- Port port = new DefaultPort(DEV,
- portDescription.portNumber(),
- portDescription.isEnabled(),
- portDescription.type(),
- portDescription.portSpeed(),
- portDescription.annotations());
-
- Optional<OmsPort> maybeOms = OmsPortHelper.asOmsPort(port);
- assertTrue(maybeOms.isPresent());
-
- OmsPort oms = maybeOms.get();
-
- assertThat(oms.isEnabled(), is(isEnabled));
- assertThat(oms.number(), is(pn));
- assertThat(oms.annotations().value(anKey), is(anValue));
-
- assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
- assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
-
- assertThat(oms.maxFrequency(), is(maxF));
- assertThat(oms.minFrequency(), is(minF));
- assertThat(oms.grid(), is(grid));
- assertThat("((33-3)/2)+1 = 16", oms.totalChannels(), is((short) 16));
- }
-
-}
diff --git a/core/api/src/test/java/org/onosproject/net/optical/impl/DefaultOmsPortTest.java b/core/api/src/test/java/org/onosproject/net/optical/impl/DefaultOmsPortTest.java
deleted file mode 100644
index a09d5ec..0000000
--- a/core/api/src/test/java/org/onosproject/net/optical/impl/DefaultOmsPortTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.net.optical.impl;
-
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-import static org.onosproject.net.PortNumber.portNumber;
-
-import org.junit.Test;
-import org.onlab.packet.ChassisId;
-import org.onlab.util.Frequency;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.DefaultPort;
-import org.onosproject.net.Device;
-import org.onosproject.net.Device.Type;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.optical.OmsPort;
-import org.onosproject.net.provider.ProviderId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Tests for {@link DefaultOmsPort}.
- */
-public class DefaultOmsPortTest {
-
- private static final ProviderId PID = new ProviderId("test", "id");
- private static final DeviceId DID = DeviceId.deviceId("test:00123");
- private static final String MFC = "MFC";
- private static final String HW = "HW V";
- private static final String SW = "SW V";
- private static final String SER = "SER";
- private static final ChassisId CHS = new ChassisId(42);
- private static final Annotations DEV_ANON = DefaultAnnotations.EMPTY;
- private static final Device DEV = new DefaultDevice(PID, DID, Type.ROADM, MFC, HW, SW, SER, CHS, DEV_ANON);
-
- @Test
- public void testEquality() {
- PortNumber pn = PortNumber.portNumber(4900);
- Annotations an = DefaultAnnotations.builder()
- .set("Base", "value")
- .build();
- Annotations an2 = DefaultAnnotations.builder()
- .set("Base", "value2")
- .build();
-
- Port base = new DefaultPort(DEV, pn, true, Port.Type.VIRTUAL, 2, an);
- Frequency minF = Frequency.ofGHz(3);
- Frequency maxF = Frequency.ofGHz(33);
- Frequency grid = Frequency.ofGHz(2);
-
- // reference OMS port
- OmsPort oms = new DefaultOmsPort(base, minF, maxF, grid);
-
- new EqualsTester()
- .addEqualityGroup(oms,
- // different base port type or portspeed is ignored
- new DefaultOmsPort(new DefaultPort(DEV, pn, true, an), minF, maxF, grid))
- // different port number
- .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, portNumber(1), true, an), minF, maxF, grid))
- // different isEnabled
- .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, pn, false, an), minF, maxF, grid))
- // different annotation
- .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, pn, true, an2), minF, maxF, grid))
- // different minFreq
- .addEqualityGroup(new DefaultOmsPort(base, Frequency.ofKHz(3), maxF, grid))
- // different maxFreq
- .addEqualityGroup(new DefaultOmsPort(base, minF, Frequency.ofKHz(33), grid))
- // different grid
- .addEqualityGroup(new DefaultOmsPort(base, minF, maxF, Frequency.ofKHz(2)))
- .testEquals();
-
- }
-
- @Test
- public void basicTests() {
- PortNumber pn = PortNumber.portNumber(4900);
- Annotations annotations = DefaultAnnotations.builder()
- .set("Base", "value")
- .build();
-
- boolean isEnabled = true;
- Port base = new DefaultPort(DEV, pn, isEnabled, Port.Type.VIRTUAL, 2, annotations);
- Frequency minFrequency = Frequency.ofGHz(3);
- Frequency maxFrequency = Frequency.ofGHz(33);
- Frequency grid = Frequency.ofGHz(2);
- OmsPort oms = new DefaultOmsPort(base, minFrequency, maxFrequency, grid);
-
- // basic attributes and annotations are inherited from base
- assertThat(oms.element(), is(DEV));
- assertThat(oms.isEnabled(), is(isEnabled));
- assertThat(oms.number(), is(pn));
- assertThat(oms.annotations(), is(annotations));
-
- assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
- assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
-
- assertThat(oms.maxFrequency(), is(maxFrequency));
- assertThat(oms.minFrequency(), is(minFrequency));
- assertThat(oms.grid(), is(grid));
- assertThat("((33-3)/2)+1 = 16", oms.totalChannels(), is((short) 16));
- }
-
-}
diff --git a/core/net/BUCK b/core/net/BUCK
index fa93865..25db0df 100644
--- a/core/net/BUCK
+++ b/core/net/BUCK
@@ -4,6 +4,8 @@
'//utils/rest:onlab-rest',
'//incubator/net:onos-incubator-net',
'//incubator/store:onos-incubator-store',
+ # TODO Remove after decoupling optical
+ '//apps/optical-model:onos-apps-optical-model',
]
TEST_DEPS = [
@@ -19,4 +21,4 @@
deps = COMPILE_DEPS,
test_deps = TEST_DEPS,
visibility = ['PUBLIC'],
-)
\ No newline at end of file
+)
diff --git a/core/net/pom.xml b/core/net/pom.xml
index 1d3650b..428ec4d 100644
--- a/core/net/pom.xml
+++ b/core/net/pom.xml
@@ -104,6 +104,16 @@
<artifactId>onos-incubator-api</artifactId>
</dependency>
+ <!-- TODO Remove after decoupling optical -->
+ <!-- - DeviceManager.InternalDeviceProviderService#ensureGeneric -->
+ <!-- - OpticalCompilers x4 -->
+ <!-- - OpticalPortOperator -->
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-optical-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>org.apache.karaf.features.core</artifactId>
diff --git a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
index 8e09e8e..23aba6a 100644
--- a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
@@ -569,6 +569,7 @@
case VIRTUAL:
return desc;
default:
+ // TODO: add plugin mechanism in order to decouple this
OpticalPortConfig opc = networkConfigService.getConfig(
new ConnectPoint(did, desc.portNumber()), OpticalPortConfig.class);
return OpticalPortOperator.combine(opc, desc);