Committed by
Yuta HIGUCHI
ONOS-4417 Remove OtuPort out of core.
Change-Id: Ibc72ee617b238005585f0bcd873b9123e48ee7fc
Showing
15 changed files
with
413 additions
and
18 deletions
| ... | @@ -25,7 +25,6 @@ import org.apache.karaf.shell.commands.Option; | ... | @@ -25,7 +25,6 @@ import org.apache.karaf.shell.commands.Option; |
| 25 | import org.onlab.util.Frequency; | 25 | import org.onlab.util.Frequency; |
| 26 | import org.onosproject.utils.Comparators; | 26 | import org.onosproject.utils.Comparators; |
| 27 | import org.onosproject.net.Device; | 27 | import org.onosproject.net.Device; |
| 28 | -import org.onosproject.net.OtuPort; | ||
| 29 | import org.onosproject.net.Port; | 28 | import org.onosproject.net.Port; |
| 30 | import org.onosproject.net.PortNumber; | 29 | import org.onosproject.net.PortNumber; |
| 31 | import org.onosproject.net.device.DeviceService; | 30 | import org.onosproject.net.device.DeviceService; |
| ... | @@ -33,6 +32,8 @@ import org.onosproject.net.optical.OchPort; | ... | @@ -33,6 +32,8 @@ import org.onosproject.net.optical.OchPort; |
| 33 | import org.onosproject.net.optical.OduCltPort; | 32 | import org.onosproject.net.optical.OduCltPort; |
| 34 | import org.onosproject.net.optical.OmsPort; | 33 | import org.onosproject.net.optical.OmsPort; |
| 35 | import org.onosproject.net.optical.OpticalDevice; | 34 | import org.onosproject.net.optical.OpticalDevice; |
| 35 | +import org.onosproject.net.optical.OtuPort; | ||
| 36 | + | ||
| 36 | import java.util.ArrayList; | 37 | import java.util.ArrayList; |
| 37 | import java.util.Collections; | 38 | import java.util.Collections; |
| 38 | import java.util.List; | 39 | import java.util.List; |
| ... | @@ -227,9 +228,21 @@ public class DevicePortsListCommand extends DevicesListCommand { | ... | @@ -227,9 +228,21 @@ public class DevicePortsListCommand extends DevicesListCommand { |
| 227 | print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); | 228 | print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); |
| 228 | break; | 229 | break; |
| 229 | case OTU: | 230 | case OTU: |
| 231 | + if (port instanceof org.onosproject.net.OtuPort) { | ||
| 232 | + org.onosproject.net.OtuPort otu = (org.onosproject.net.OtuPort) port; | ||
| 233 | + print("WARN: OtuPort in old model"); | ||
| 234 | + print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, | ||
| 235 | + otu.signalType().toString(), annotations); | ||
| 236 | + break; | ||
| 237 | + } | ||
| 238 | + if (port instanceof OtuPort) { | ||
| 230 | print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, | 239 | print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, |
| 231 | ((OtuPort) port).signalType().toString(), annotations); | 240 | ((OtuPort) port).signalType().toString(), annotations); |
| 232 | break; | 241 | break; |
| 242 | + } | ||
| 243 | + print("WARN: OtuPort but not on OpticalDevice or ill-formed"); | ||
| 244 | + print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); | ||
| 245 | + break; | ||
| 233 | default: | 246 | default: |
| 234 | print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); | 247 | print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); |
| 235 | break; | 248 | break; | ... | ... |
| ... | @@ -21,8 +21,10 @@ import static com.google.common.base.MoreObjects.toStringHelper; | ... | @@ -21,8 +21,10 @@ import static com.google.common.base.MoreObjects.toStringHelper; |
| 21 | 21 | ||
| 22 | /** | 22 | /** |
| 23 | * Implementation of OTU port (Optical channel Transport Unit). | 23 | * Implementation of OTU port (Optical channel Transport Unit). |
| 24 | + * | ||
| 25 | + * @deprecated in Goldeneye (1.6.0) | ||
| 24 | */ | 26 | */ |
| 25 | - | 27 | +@Deprecated |
| 26 | public class OtuPort extends DefaultPort { | 28 | public class OtuPort extends DefaultPort { |
| 27 | 29 | ||
| 28 | private final OtuSignalType signalType; | 30 | private final OtuSignalType signalType; | ... | ... |
| ... | @@ -24,7 +24,10 @@ import org.onosproject.net.SparseAnnotations; | ... | @@ -24,7 +24,10 @@ import org.onosproject.net.SparseAnnotations; |
| 24 | 24 | ||
| 25 | /** | 25 | /** |
| 26 | * Default implementation of immutable OTU port description. | 26 | * Default implementation of immutable OTU port description. |
| 27 | + * | ||
| 28 | + * @deprecated in Goldeneye (1.6.0) | ||
| 27 | */ | 29 | */ |
| 30 | +@Deprecated | ||
| 28 | public class OtuPortDescription extends DefaultPortDescription { | 31 | public class OtuPortDescription extends DefaultPortDescription { |
| 29 | 32 | ||
| 30 | private final OtuSignalType signalType; | 33 | private final OtuSignalType signalType; | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language gcd ~/Dooverning permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.net.optical; | ||
| 17 | + | ||
| 18 | +import org.onosproject.net.OtuSignalType; | ||
| 19 | +import org.onosproject.net.Port; | ||
| 20 | + | ||
| 21 | +import com.google.common.annotations.Beta; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * OTU port (Optical channel Transport Unit). | ||
| 25 | + * <p> | ||
| 26 | + * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" and | ||
| 27 | + * Open Networking Foundation "Optical Transport Protocol Extensions Version 1.0". | ||
| 28 | + */ | ||
| 29 | +@Beta | ||
| 30 | +public interface OtuPort extends Port { | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * Returns OTU signal type. | ||
| 34 | + * | ||
| 35 | + * @return OTU signal type | ||
| 36 | + */ | ||
| 37 | + public OtuSignalType signalType(); | ||
| 38 | + | ||
| 39 | +} |
| ... | @@ -31,9 +31,11 @@ import org.onosproject.net.optical.OchPort; | ... | @@ -31,9 +31,11 @@ import org.onosproject.net.optical.OchPort; |
| 31 | import org.onosproject.net.optical.OduCltPort; | 31 | import org.onosproject.net.optical.OduCltPort; |
| 32 | import org.onosproject.net.optical.OmsPort; | 32 | import org.onosproject.net.optical.OmsPort; |
| 33 | import org.onosproject.net.optical.OpticalDevice; | 33 | import org.onosproject.net.optical.OpticalDevice; |
| 34 | +import org.onosproject.net.optical.OtuPort; | ||
| 34 | import org.onosproject.net.optical.device.port.OchPortMapper; | 35 | import org.onosproject.net.optical.device.port.OchPortMapper; |
| 35 | import org.onosproject.net.optical.device.port.OduCltPortMapper; | 36 | import org.onosproject.net.optical.device.port.OduCltPortMapper; |
| 36 | import org.onosproject.net.optical.device.port.OmsPortMapper; | 37 | import org.onosproject.net.optical.device.port.OmsPortMapper; |
| 38 | +import org.onosproject.net.optical.device.port.OtuPortMapper; | ||
| 37 | import org.onosproject.net.optical.device.port.PortMapper; | 39 | import org.onosproject.net.optical.device.port.PortMapper; |
| 38 | import org.onosproject.net.optical.utils.ForwardingDevice; | 40 | import org.onosproject.net.optical.utils.ForwardingDevice; |
| 39 | import org.slf4j.Logger; | 41 | import org.slf4j.Logger; |
| ... | @@ -66,6 +68,7 @@ public class DefaultOpticalDevice | ... | @@ -66,6 +68,7 @@ public class DefaultOpticalDevice |
| 66 | .put(OchPort.class, new OchPortMapper()) | 68 | .put(OchPort.class, new OchPortMapper()) |
| 67 | .put(OmsPort.class, new OmsPortMapper()) | 69 | .put(OmsPort.class, new OmsPortMapper()) |
| 68 | .put(OduCltPort.class, new OduCltPortMapper()) | 70 | .put(OduCltPort.class, new OduCltPortMapper()) |
| 71 | + .put(OtuPort.class, new OtuPortMapper()) | ||
| 69 | // TODO add other optical port type here | 72 | // TODO add other optical port type here |
| 70 | .build(); | 73 | .build(); |
| 71 | 74 | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.net.optical.device; | ||
| 17 | + | ||
| 18 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 19 | + | ||
| 20 | +import java.util.Optional; | ||
| 21 | + | ||
| 22 | +import org.onosproject.net.Annotations; | ||
| 23 | +import org.onosproject.net.DefaultAnnotations; | ||
| 24 | +import org.onosproject.net.Port; | ||
| 25 | +import org.onosproject.net.PortNumber; | ||
| 26 | +import org.onosproject.net.SparseAnnotations; | ||
| 27 | +import org.onosproject.net.DefaultAnnotations.Builder; | ||
| 28 | +import org.onosproject.net.OtuSignalType; | ||
| 29 | +import org.onosproject.net.device.DefaultPortDescription; | ||
| 30 | +import org.onosproject.net.device.PortDescription; | ||
| 31 | +import org.onosproject.net.optical.OtuPort; | ||
| 32 | +import org.onosproject.net.optical.impl.DefaultOtuPort; | ||
| 33 | +import org.slf4j.Logger; | ||
| 34 | + | ||
| 35 | +import com.google.common.annotations.Beta; | ||
| 36 | + | ||
| 37 | +/** | ||
| 38 | + * OTU port related helpers. | ||
| 39 | + */ | ||
| 40 | +@Beta | ||
| 41 | +public final class OtuPortHelper { | ||
| 42 | + | ||
| 43 | + private static final Logger log = getLogger(OtuPortHelper.class); | ||
| 44 | + | ||
| 45 | + // Annotation keys | ||
| 46 | + /** | ||
| 47 | + * {@link OtuSignalType} as String. | ||
| 48 | + */ | ||
| 49 | + private static final String SIGNAL_TYPE = "signalType"; | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * Creates OTU port description based on the supplied information. | ||
| 53 | + * | ||
| 54 | + * @param number port number | ||
| 55 | + * @param isEnabled port enabled state | ||
| 56 | + * @param signalType OTU client signal type | ||
| 57 | + */ | ||
| 58 | + public static PortDescription otuPortDescription(PortNumber number, | ||
| 59 | + boolean isEnabled, | ||
| 60 | + OtuSignalType signalType) { | ||
| 61 | + return otuPortDescription(number, isEnabled, signalType, DefaultAnnotations.EMPTY); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * Creates OTU port description based on the supplied information. | ||
| 66 | + * | ||
| 67 | + * @param number port number | ||
| 68 | + * @param isEnabled port enabled state | ||
| 69 | + * @param signalType OTU client signal type | ||
| 70 | + * @param annotations key/value annotations map | ||
| 71 | + */ | ||
| 72 | + public static PortDescription otuPortDescription(PortNumber number, | ||
| 73 | + boolean isEnabled, | ||
| 74 | + OtuSignalType signalType, | ||
| 75 | + SparseAnnotations annotations) { | ||
| 76 | + Builder builder = DefaultAnnotations.builder(); | ||
| 77 | + builder.putAll(annotations); | ||
| 78 | + | ||
| 79 | + builder.set(SIGNAL_TYPE, signalType.toString()); | ||
| 80 | + | ||
| 81 | + long portSpeed = 0; // TODO specify appropriate value? | ||
| 82 | + return new DefaultPortDescription(number, | ||
| 83 | + isEnabled, | ||
| 84 | + Port.Type.OTU, | ||
| 85 | + portSpeed, | ||
| 86 | + builder.build()); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + /** | ||
| 90 | + * Creates OTU port description based on the supplied information. | ||
| 91 | + * | ||
| 92 | + * @param base PortDescription to get basic information from | ||
| 93 | + * @param signalType OTU client signal type | ||
| 94 | + * @param annotations key/value annotations map | ||
| 95 | + */ | ||
| 96 | + public static PortDescription otuPortDescription(PortDescription base, | ||
| 97 | + OtuSignalType signalType, | ||
| 98 | + SparseAnnotations annotations) { | ||
| 99 | + return otuPortDescription(base.portNumber(), base.isEnabled(), signalType, annotations); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + public static Optional<OtuPort> asOtuPort(Port port) { | ||
| 103 | + if (port instanceof OtuPort) { | ||
| 104 | + return Optional.of((OtuPort) port); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + try { | ||
| 108 | + Annotations an = port.annotations(); | ||
| 109 | + | ||
| 110 | + OtuSignalType signalType = Enum.valueOf(OtuSignalType.class, | ||
| 111 | + an.value(SIGNAL_TYPE)); | ||
| 112 | + | ||
| 113 | + | ||
| 114 | + // Note: OTU specific annotations is not filtered-out here. | ||
| 115 | + // DefaultOtuPort should filter them, if necessary. | ||
| 116 | + return Optional.of(new DefaultOtuPort(port, signalType)); | ||
| 117 | + | ||
| 118 | + } catch (NullPointerException | IllegalArgumentException e) { | ||
| 119 | + | ||
| 120 | + log.warn("{} was not well-formed Otu port.", port, e); | ||
| 121 | + return Optional.empty(); | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + | ||
| 126 | + // not meant to be instantiated | ||
| 127 | + private OtuPortHelper() {} | ||
| 128 | + | ||
| 129 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.net.optical.device.port; | ||
| 17 | + | ||
| 18 | +import java.util.Optional; | ||
| 19 | + | ||
| 20 | +import org.onosproject.net.Port; | ||
| 21 | +import org.onosproject.net.optical.OtuPort; | ||
| 22 | +import org.onosproject.net.optical.device.OtuPortHelper; | ||
| 23 | +import org.onosproject.net.optical.impl.DefaultOtuPort; | ||
| 24 | + | ||
| 25 | +import com.google.common.annotations.Beta; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * {@link PortMapper} to handler {@link OtuPort} translation. | ||
| 29 | + */ | ||
| 30 | +@Beta | ||
| 31 | +public class OtuPortMapper extends AbstractPortMapper<OtuPort> { | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public boolean is(Port port) { | ||
| 35 | + return port != null && | ||
| 36 | + port.type() == Port.Type.OTU && | ||
| 37 | + super.is(port); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @Override | ||
| 41 | + public Optional<OtuPort> as(Port port) { | ||
| 42 | + if (port instanceof OtuPort) { | ||
| 43 | + return Optional.of((OtuPort) port); | ||
| 44 | + } | ||
| 45 | + return super.as(port); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + protected Optional<OtuPort> mapPort(Port port) { | ||
| 50 | + if (port instanceof OtuPort) { | ||
| 51 | + return Optional.of((OtuPort) port); | ||
| 52 | + } else if (port instanceof org.onosproject.net.OtuPort) { | ||
| 53 | + // TODO remove after deprecation of old OtuPort is complete | ||
| 54 | + | ||
| 55 | + // translate to new OtuPort | ||
| 56 | + org.onosproject.net.OtuPort old = (org.onosproject.net.OtuPort) port; | ||
| 57 | + return Optional.of(new DefaultOtuPort(old, | ||
| 58 | + old.signalType())); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + return OtuPortHelper.asOtuPort(port); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + | ||
| 65 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.net.optical.impl; | ||
| 17 | + | ||
| 18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 19 | + | ||
| 20 | +import java.util.Objects; | ||
| 21 | + | ||
| 22 | +import org.onosproject.net.OtuSignalType; | ||
| 23 | +import org.onosproject.net.Port; | ||
| 24 | +import org.onosproject.net.optical.OtuPort; | ||
| 25 | +import org.onosproject.net.optical.utils.ForwardingPort; | ||
| 26 | + | ||
| 27 | +import com.google.common.annotations.Beta; | ||
| 28 | + | ||
| 29 | +/** | ||
| 30 | + * Implementation of OTU port (Optical channel Transport Unit). | ||
| 31 | + * | ||
| 32 | + */ | ||
| 33 | +@Beta | ||
| 34 | +public class DefaultOtuPort extends ForwardingPort implements OtuPort { | ||
| 35 | + | ||
| 36 | + private final OtuSignalType signalType; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * Creates an ODU client port. | ||
| 40 | + * | ||
| 41 | + * @param delegate Port | ||
| 42 | + * @param signalType OTU signal type | ||
| 43 | + */ | ||
| 44 | + public DefaultOtuPort(Port delegate, OtuSignalType signalType) { | ||
| 45 | + super(delegate); | ||
| 46 | + this.signalType = checkNotNull(signalType); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @Override | ||
| 50 | + public Type type() { | ||
| 51 | + return Type.OTU; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | +// @Override | ||
| 55 | +// public long portSpeed() { | ||
| 56 | +// return signalType().bitRate(); | ||
| 57 | +// } | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + public OtuSignalType signalType() { | ||
| 61 | + return signalType; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public int hashCode() { | ||
| 66 | + return Objects.hash(super.hashCode(), | ||
| 67 | + signalType()); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public boolean equals(Object obj) { | ||
| 72 | + if (this == obj) { | ||
| 73 | + return true; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + if (obj != null && getClass() == obj.getClass()) { | ||
| 77 | + final DefaultOtuPort that = (DefaultOtuPort) obj; | ||
| 78 | + return super.toEqualsBuilder(that) | ||
| 79 | + .append(this.signalType(), that.signalType()) | ||
| 80 | + .isEquals(); | ||
| 81 | + } | ||
| 82 | + return false; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @Override | ||
| 86 | + public String toString() { | ||
| 87 | + return super.toStringHelper() | ||
| 88 | + .add("signalType", signalType()) | ||
| 89 | + .toString(); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | +} |
| ... | @@ -18,6 +18,7 @@ package org.onosproject.net.device.impl; | ... | @@ -18,6 +18,7 @@ package org.onosproject.net.device.impl; |
| 18 | import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | 18 | import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; |
| 19 | import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; | 19 | import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; |
| 20 | import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription; | 20 | import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription; |
| 21 | +import static org.onosproject.net.optical.device.OtuPortHelper.otuPortDescription; | ||
| 21 | import static org.slf4j.LoggerFactory.getLogger; | 22 | import static org.slf4j.LoggerFactory.getLogger; |
| 22 | import static com.google.common.base.Preconditions.checkNotNull; | 23 | import static com.google.common.base.Preconditions.checkNotNull; |
| 23 | 24 | ||
| ... | @@ -25,7 +26,6 @@ import org.onosproject.net.config.ConfigOperator; | ... | @@ -25,7 +26,6 @@ import org.onosproject.net.config.ConfigOperator; |
| 25 | import org.onosproject.net.config.basics.OpticalPortConfig; | 26 | import org.onosproject.net.config.basics.OpticalPortConfig; |
| 26 | import org.onosproject.net.AnnotationKeys; | 27 | import org.onosproject.net.AnnotationKeys; |
| 27 | import org.onosproject.net.DefaultAnnotations; | 28 | import org.onosproject.net.DefaultAnnotations; |
| 28 | -import org.onosproject.net.OtuPort; | ||
| 29 | import org.onosproject.net.Port; | 29 | import org.onosproject.net.Port; |
| 30 | import org.onosproject.net.PortNumber; | 30 | import org.onosproject.net.PortNumber; |
| 31 | import org.onosproject.net.SparseAnnotations; | 31 | import org.onosproject.net.SparseAnnotations; |
| ... | @@ -39,6 +39,7 @@ import org.onosproject.net.optical.OchPort; | ... | @@ -39,6 +39,7 @@ import org.onosproject.net.optical.OchPort; |
| 39 | import org.onosproject.net.optical.OduCltPort; | 39 | import org.onosproject.net.optical.OduCltPort; |
| 40 | import org.onosproject.net.optical.OmsPort; | 40 | import org.onosproject.net.optical.OmsPort; |
| 41 | import org.onosproject.net.optical.OpticalDevice; | 41 | import org.onosproject.net.optical.OpticalDevice; |
| 42 | +import org.onosproject.net.optical.OtuPort; | ||
| 42 | import org.slf4j.Logger; | 43 | import org.slf4j.Logger; |
| 43 | 44 | ||
| 44 | /** | 45 | /** |
| ... | @@ -135,8 +136,12 @@ public final class OpticalPortOperator implements ConfigOperator { | ... | @@ -135,8 +136,12 @@ public final class OpticalPortOperator implements ConfigOperator { |
| 135 | return new DefaultPortDescription(port, descr.isEnabled(), descr.type(), | 136 | return new DefaultPortDescription(port, descr.isEnabled(), descr.type(), |
| 136 | descr.portSpeed(), sa); | 137 | descr.portSpeed(), sa); |
| 137 | case OTU: | 138 | case OTU: |
| 139 | + if (descr instanceof OtuPortDescription) { | ||
| 140 | + // TODO This block can go away once deprecation is complete. | ||
| 138 | OtuPortDescription otu = (OtuPortDescription) descr; | 141 | OtuPortDescription otu = (OtuPortDescription) descr; |
| 139 | - return new OtuPortDescription(port, otu.isEnabled(), otu.signalType(), sa); | 142 | + return otuPortDescription(port, otu.isEnabled(), otu.signalType(), sa); |
| 143 | + } | ||
| 144 | + return descr; | ||
| 140 | default: | 145 | default: |
| 141 | log.warn("Unsupported optical port type {} - can't update", descr.type()); | 146 | log.warn("Unsupported optical port type {} - can't update", descr.type()); |
| 142 | return descr; | 147 | return descr; |
| ... | @@ -242,8 +247,19 @@ public final class OpticalPortOperator implements ConfigOperator { | ... | @@ -242,8 +247,19 @@ public final class OpticalPortOperator implements ConfigOperator { |
| 242 | } | 247 | } |
| 243 | return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an); | 248 | return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an); |
| 244 | case OTU: | 249 | case OTU: |
| 250 | + if (port instanceof org.onosproject.net.OtuPort) { | ||
| 251 | + // remove if-block once deprecation is complete | ||
| 252 | + org.onosproject.net.OtuPort otu = (org.onosproject.net.OtuPort) port; | ||
| 253 | + return otuPortDescription(ptn, isup, otu.signalType(), an); | ||
| 254 | + } | ||
| 255 | + if (port.element().is(OpticalDevice.class)) { | ||
| 256 | + OpticalDevice optDevice = port.element().as(OpticalDevice.class); | ||
| 257 | + if (optDevice.portIs(port, OtuPort.class)) { | ||
| 245 | OtuPort otu = (OtuPort) port; | 258 | OtuPort otu = (OtuPort) port; |
| 246 | - return new OtuPortDescription(ptn, isup, otu.signalType(), an); | 259 | + return otuPortDescription(ptn, isup, otu.signalType(), an); |
| 260 | + } | ||
| 261 | + } | ||
| 262 | + return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an); | ||
| 247 | default: | 263 | default: |
| 248 | return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an); | 264 | return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an); |
| 249 | } | 265 | } | ... | ... |
| ... | @@ -30,7 +30,6 @@ import org.onosproject.net.LinkKey; | ... | @@ -30,7 +30,6 @@ import org.onosproject.net.LinkKey; |
| 30 | import org.onosproject.net.OduSignalId; | 30 | import org.onosproject.net.OduSignalId; |
| 31 | import org.onosproject.net.OduSignalType; | 31 | import org.onosproject.net.OduSignalType; |
| 32 | import org.onosproject.net.OduSignalUtils; | 32 | import org.onosproject.net.OduSignalUtils; |
| 33 | -import org.onosproject.net.OtuPort; | ||
| 34 | import org.onosproject.net.Path; | 33 | import org.onosproject.net.Path; |
| 35 | import org.onosproject.net.Port; | 34 | import org.onosproject.net.Port; |
| 36 | import org.onosproject.net.TributarySlot; | 35 | import org.onosproject.net.TributarySlot; |
| ... | @@ -50,6 +49,7 @@ import org.onosproject.net.intent.IntentExtensionService; | ... | @@ -50,6 +49,7 @@ import org.onosproject.net.intent.IntentExtensionService; |
| 50 | import org.onosproject.net.intent.OpticalOduIntent; | 49 | import org.onosproject.net.intent.OpticalOduIntent; |
| 51 | import org.onosproject.net.intent.impl.IntentCompilationException; | 50 | import org.onosproject.net.intent.impl.IntentCompilationException; |
| 52 | import org.onosproject.net.optical.OduCltPort; | 51 | import org.onosproject.net.optical.OduCltPort; |
| 52 | +import org.onosproject.net.optical.OtuPort; | ||
| 53 | import org.onosproject.net.resource.Resource; | 53 | import org.onosproject.net.resource.Resource; |
| 54 | import org.onosproject.net.resource.ResourceService; | 54 | import org.onosproject.net.resource.ResourceService; |
| 55 | import org.onosproject.net.resource.ResourceAllocation; | 55 | import org.onosproject.net.resource.ResourceAllocation; | ... | ... |
| ... | @@ -38,7 +38,6 @@ import org.onosproject.net.Link; | ... | @@ -38,7 +38,6 @@ import org.onosproject.net.Link; |
| 38 | import org.onosproject.net.OduSignalId; | 38 | import org.onosproject.net.OduSignalId; |
| 39 | import org.onosproject.net.OduSignalType; | 39 | import org.onosproject.net.OduSignalType; |
| 40 | import org.onosproject.net.OduSignalUtils; | 40 | import org.onosproject.net.OduSignalUtils; |
| 41 | -import org.onosproject.net.OtuPort; | ||
| 42 | import org.onosproject.net.OtuSignalType; | 41 | import org.onosproject.net.OtuSignalType; |
| 43 | import org.onosproject.net.Path; | 42 | import org.onosproject.net.Path; |
| 44 | import org.onosproject.net.Port; | 43 | import org.onosproject.net.Port; |
| ... | @@ -58,7 +57,9 @@ import org.onosproject.net.intent.Key; | ... | @@ -58,7 +57,9 @@ import org.onosproject.net.intent.Key; |
| 58 | import org.onosproject.net.intent.MockIdGenerator; | 57 | import org.onosproject.net.intent.MockIdGenerator; |
| 59 | import org.onosproject.net.intent.OpticalOduIntent; | 58 | import org.onosproject.net.intent.OpticalOduIntent; |
| 60 | import org.onosproject.net.optical.OduCltPort; | 59 | import org.onosproject.net.optical.OduCltPort; |
| 60 | +import org.onosproject.net.optical.OtuPort; | ||
| 61 | import org.onosproject.net.optical.impl.DefaultOduCltPort; | 61 | import org.onosproject.net.optical.impl.DefaultOduCltPort; |
| 62 | +import org.onosproject.net.optical.impl.DefaultOtuPort; | ||
| 62 | import org.onosproject.net.provider.ProviderId; | 63 | import org.onosproject.net.provider.ProviderId; |
| 63 | import org.onosproject.net.topology.LinkWeight; | 64 | import org.onosproject.net.topology.LinkWeight; |
| 64 | import org.onosproject.net.topology.Topology; | 65 | import org.onosproject.net.topology.Topology; |
| ... | @@ -129,13 +130,17 @@ public class OpticalOduIntentCompilerTest { | ... | @@ -129,13 +130,17 @@ public class OpticalOduIntentCompilerTest { |
| 129 | 130 | ||
| 130 | // Otu ports with signalType=ODU2 | 131 | // Otu ports with signalType=ODU2 |
| 131 | private static final OtuPort D1P2 = | 132 | private static final OtuPort D1P2 = |
| 132 | - new OtuPort(device1, PortNumber.portNumber(2), true, OtuSignalType.OTU2, annotations2); | 133 | + new DefaultOtuPort(new DefaultPort(device1, PortNumber.portNumber(2), true, annotations2), |
| 134 | + OtuSignalType.OTU2); | ||
| 133 | private static final OtuPort D2P1 = | 135 | private static final OtuPort D2P1 = |
| 134 | - new OtuPort(device2, PortNumber.portNumber(1), true, OtuSignalType.OTU2, annotations2); | 136 | + new DefaultOtuPort(new DefaultPort(device2, PortNumber.portNumber(1), true, annotations2), |
| 137 | + OtuSignalType.OTU2); | ||
| 135 | private static final OtuPort D2P2 = | 138 | private static final OtuPort D2P2 = |
| 136 | - new OtuPort(device2, PortNumber.portNumber(2), true, OtuSignalType.OTU2, annotations2); | 139 | + new DefaultOtuPort(new DefaultPort(device2, PortNumber.portNumber(2), true, annotations2), |
| 140 | + OtuSignalType.OTU2); | ||
| 137 | private static final OtuPort D3P1 = | 141 | private static final OtuPort D3P1 = |
| 138 | - new OtuPort(device3, PortNumber.portNumber(1), true, OtuSignalType.OTU2, annotations2); | 142 | + new DefaultOtuPort(new DefaultPort(device3, PortNumber.portNumber(1), true, annotations2), |
| 143 | + OtuSignalType.OTU2); | ||
| 139 | 144 | ||
| 140 | // OduClt ports with signalType=10GBE | 145 | // OduClt ports with signalType=10GBE |
| 141 | private static final OduCltPort D1P3 = | 146 | private static final OduCltPort D1P3 = | ... | ... |
| ... | @@ -20,6 +20,7 @@ import static org.onosproject.net.DefaultAnnotations.union; | ... | @@ -20,6 +20,7 @@ import static org.onosproject.net.DefaultAnnotations.union; |
| 20 | import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | 20 | import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; |
| 21 | import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; | 21 | import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; |
| 22 | import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription; | 22 | import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription; |
| 23 | +import static org.onosproject.net.optical.device.OtuPortHelper.otuPortDescription; | ||
| 23 | 24 | ||
| 24 | import java.util.Collections; | 25 | import java.util.Collections; |
| 25 | import java.util.Map; | 26 | import java.util.Map; |
| ... | @@ -157,11 +158,19 @@ class DeviceDescriptions { | ... | @@ -157,11 +158,19 @@ class DeviceDescriptions { |
| 157 | } | 158 | } |
| 158 | break; | 159 | break; |
| 159 | case OTU: | 160 | case OTU: |
| 161 | + if (newDesc.value() instanceof OtuPortDescription) { | ||
| 162 | + // remove if-block after deprecation is complete | ||
| 160 | OtuPortDescription otuDesc = (OtuPortDescription) (newDesc.value()); | 163 | OtuPortDescription otuDesc = (OtuPortDescription) (newDesc.value()); |
| 161 | newOne = new Timestamped<>( | 164 | newOne = new Timestamped<>( |
| 162 | - new OtuPortDescription( | 165 | + otuPortDescription( |
| 163 | otuDesc, otuDesc.signalType(), merged), | 166 | otuDesc, otuDesc.signalType(), merged), |
| 164 | newDesc.timestamp()); | 167 | newDesc.timestamp()); |
| 168 | + } else { | ||
| 169 | + // same as default case | ||
| 170 | + newOne = new Timestamped<>( | ||
| 171 | + new DefaultPortDescription(newDesc.value(), merged), | ||
| 172 | + newDesc.timestamp()); | ||
| 173 | + } | ||
| 165 | break; | 174 | break; |
| 166 | default: | 175 | default: |
| 167 | newOne = new Timestamped<>( | 176 | newOne = new Timestamped<>( | ... | ... |
| ... | @@ -1116,8 +1116,14 @@ public class GossipDeviceStore | ... | @@ -1116,8 +1116,14 @@ public class GossipDeviceStore |
| 1116 | return new DefaultPort(device, number, isEnabled, description.type(), | 1116 | return new DefaultPort(device, number, isEnabled, description.type(), |
| 1117 | description.portSpeed(), annotations); | 1117 | description.portSpeed(), annotations); |
| 1118 | case OTU: | 1118 | case OTU: |
| 1119 | + if (description instanceof OtuPortDescription) { | ||
| 1120 | + // remove if-block once deprecation is complete | ||
| 1119 | OtuPortDescription otuDesc = (OtuPortDescription) description; | 1121 | OtuPortDescription otuDesc = (OtuPortDescription) description; |
| 1120 | return new OtuPort(device, number, isEnabled, otuDesc.signalType(), annotations); | 1122 | return new OtuPort(device, number, isEnabled, otuDesc.signalType(), annotations); |
| 1123 | + } | ||
| 1124 | + // same as default | ||
| 1125 | + return new DefaultPort(device, number, isEnabled, description.type(), | ||
| 1126 | + description.portSpeed(), annotations); | ||
| 1121 | default: | 1127 | default: |
| 1122 | return new DefaultPort(device, number, isEnabled, description.type(), | 1128 | return new DefaultPort(device, number, isEnabled, description.type(), |
| 1123 | description.portSpeed(), annotations); | 1129 | description.portSpeed(), annotations); | ... | ... |
| ... | @@ -17,7 +17,6 @@ package org.onosproject.driver.query; | ... | @@ -17,7 +17,6 @@ package org.onosproject.driver.query; |
| 17 | 17 | ||
| 18 | import org.onlab.util.GuavaCollectors; | 18 | import org.onlab.util.GuavaCollectors; |
| 19 | import org.onosproject.net.OduSignalType; | 19 | import org.onosproject.net.OduSignalType; |
| 20 | -import org.onosproject.net.OtuPort; | ||
| 21 | import org.onosproject.net.OtuSignalType; | 20 | import org.onosproject.net.OtuSignalType; |
| 22 | import org.onosproject.net.Port; | 21 | import org.onosproject.net.Port; |
| 23 | import org.onosproject.net.PortNumber; | 22 | import org.onosproject.net.PortNumber; |
| ... | @@ -25,6 +24,7 @@ import org.onosproject.net.TributarySlot; | ... | @@ -25,6 +24,7 @@ import org.onosproject.net.TributarySlot; |
| 25 | import org.onosproject.net.device.DeviceService; | 24 | import org.onosproject.net.device.DeviceService; |
| 26 | import org.onosproject.net.driver.AbstractHandlerBehaviour; | 25 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 27 | import org.onosproject.net.optical.OchPort; | 26 | import org.onosproject.net.optical.OchPort; |
| 27 | +import org.onosproject.net.optical.OtuPort; | ||
| 28 | import org.onosproject.net.behaviour.TributarySlotQuery; | 28 | import org.onosproject.net.behaviour.TributarySlotQuery; |
| 29 | import org.slf4j.Logger; | 29 | import org.slf4j.Logger; |
| 30 | import org.slf4j.LoggerFactory; | 30 | import org.slf4j.LoggerFactory; |
| ... | @@ -70,7 +70,7 @@ public class DefaultTributarySlotQuery extends AbstractHandlerBehaviour implemen | ... | @@ -70,7 +70,7 @@ public class DefaultTributarySlotQuery extends AbstractHandlerBehaviour implemen |
| 70 | case OCH: | 70 | case OCH: |
| 71 | return queryOchTributarySlots(p); | 71 | return queryOchTributarySlots(p); |
| 72 | case OTU: | 72 | case OTU: |
| 73 | - return queryOtuTributarySlots((OtuPort) p); | 73 | + return queryOtuTributarySlots(p); |
| 74 | default: | 74 | default: |
| 75 | return Collections.emptySet(); | 75 | return Collections.emptySet(); |
| 76 | } | 76 | } |
| ... | @@ -102,8 +102,21 @@ public class DefaultTributarySlotQuery extends AbstractHandlerBehaviour implemen | ... | @@ -102,8 +102,21 @@ public class DefaultTributarySlotQuery extends AbstractHandlerBehaviour implemen |
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | - private Set<TributarySlot> queryOtuTributarySlots(OtuPort otuPort) { | 105 | + private Set<TributarySlot> queryOtuTributarySlots(Port otuPort) { |
| 106 | - OtuSignalType signalType = otuPort.signalType(); | 106 | + OtuSignalType signalType = null; |
| 107 | + if (otuPort instanceof org.onosproject.net.OtuPort) { | ||
| 108 | + // remove once deprecation of old OtuPort model is done | ||
| 109 | + signalType = ((org.onosproject.net.OtuPort) otuPort).signalType(); | ||
| 110 | + } | ||
| 111 | + if (otuPort instanceof OtuPort) { | ||
| 112 | + signalType = ((OtuPort) otuPort).signalType(); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + if (signalType == null) { | ||
| 116 | + log.warn("{} was not an OtuPort", otuPort); | ||
| 117 | + return Collections.emptySet(); | ||
| 118 | + } | ||
| 119 | + | ||
| 107 | switch (signalType) { | 120 | switch (signalType) { |
| 108 | case OTU2: | 121 | case OTU2: |
| 109 | return ENTIRE_ODU2_TRIBUTARY_SLOTS; | 122 | return ENTIRE_ODU2_TRIBUTARY_SLOTS; | ... | ... |
| ... | @@ -24,6 +24,7 @@ import static org.onosproject.net.Port.Type.FIBER; | ... | @@ -24,6 +24,7 @@ import static org.onosproject.net.Port.Type.FIBER; |
| 24 | import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | 24 | import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; |
| 25 | import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; | 25 | import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; |
| 26 | import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription; | 26 | import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription; |
| 27 | +import static org.onosproject.net.optical.device.OtuPortHelper.otuPortDescription; | ||
| 27 | import static org.onosproject.openflow.controller.Dpid.dpid; | 28 | import static org.onosproject.openflow.controller.Dpid.dpid; |
| 28 | import static org.onosproject.openflow.controller.Dpid.uri; | 29 | import static org.onosproject.openflow.controller.Dpid.uri; |
| 29 | import static org.slf4j.LoggerFactory.getLogger; | 30 | import static org.slf4j.LoggerFactory.getLogger; |
| ... | @@ -68,7 +69,6 @@ import org.onosproject.net.device.DeviceDescription; | ... | @@ -68,7 +69,6 @@ import org.onosproject.net.device.DeviceDescription; |
| 68 | import org.onosproject.net.device.DeviceProvider; | 69 | import org.onosproject.net.device.DeviceProvider; |
| 69 | import org.onosproject.net.device.DeviceProviderRegistry; | 70 | import org.onosproject.net.device.DeviceProviderRegistry; |
| 70 | import org.onosproject.net.device.DeviceProviderService; | 71 | import org.onosproject.net.device.DeviceProviderService; |
| 71 | -import org.onosproject.net.device.OtuPortDescription; | ||
| 72 | import org.onosproject.net.device.PortDescription; | 72 | import org.onosproject.net.device.PortDescription; |
| 73 | import org.onosproject.net.device.PortStatistics; | 73 | import org.onosproject.net.device.PortStatistics; |
| 74 | import org.onosproject.net.provider.AbstractProvider; | 74 | import org.onosproject.net.provider.AbstractProvider; |
| ... | @@ -624,7 +624,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -624,7 +624,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
| 624 | OtuSignalType otuSignalType = | 624 | OtuSignalType otuSignalType = |
| 625 | ((sigType == OFPortOpticalTransportSignalType.OTU2) ? OtuSignalType.OTU2 : | 625 | ((sigType == OFPortOpticalTransportSignalType.OTU2) ? OtuSignalType.OTU2 : |
| 626 | OtuSignalType.OTU4); | 626 | OtuSignalType.OTU4); |
| 627 | - portDes = new OtuPortDescription(portNo, enabled, otuSignalType, annotations); | 627 | + portDes = otuPortDescription(portNo, enabled, otuSignalType, annotations); |
| 628 | break; | 628 | break; |
| 629 | default: | 629 | default: |
| 630 | break; | 630 | break; | ... | ... |
-
Please register or login to post a comment