HIGUCHI Yuta
Committed by Yuta HIGUCHI

ONOS-4415 Remove OmsPort out of core.

Change-Id: Ic796c4e715789ba18f350f28e29db04dd537822f
Showing 21 changed files with 724 additions and 35 deletions
...@@ -26,12 +26,12 @@ import org.onlab.util.Frequency; ...@@ -26,12 +26,12 @@ 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.OduCltPort; 28 import org.onosproject.net.OduCltPort;
29 -import org.onosproject.net.OmsPort;
30 import org.onosproject.net.OtuPort; 29 import org.onosproject.net.OtuPort;
31 import org.onosproject.net.Port; 30 import org.onosproject.net.Port;
32 import org.onosproject.net.PortNumber; 31 import org.onosproject.net.PortNumber;
33 import org.onosproject.net.device.DeviceService; 32 import org.onosproject.net.device.DeviceService;
34 import org.onosproject.net.optical.OchPort; 33 import org.onosproject.net.optical.OchPort;
34 +import org.onosproject.net.optical.OmsPort;
35 import org.onosproject.net.optical.OpticalDevice; 35 import org.onosproject.net.optical.OpticalDevice;
36 import java.util.ArrayList; 36 import java.util.ArrayList;
37 import java.util.Collections; 37 import java.util.Collections;
...@@ -191,11 +191,27 @@ public class DevicePortsListCommand extends DevicesListCommand { ...@@ -191,11 +191,27 @@ public class DevicePortsListCommand extends DevicesListCommand {
191 ((OduCltPort) port).signalType().toString(), annotations); 191 ((OduCltPort) port).signalType().toString(), annotations);
192 break; 192 break;
193 case OMS: 193 case OMS:
194 + if (port instanceof org.onosproject.net.OmsPort) {
195 + org.onosproject.net.OmsPort oms = (org.onosproject.net.OmsPort) port;
196 + print("WARN: OmsPort in old model");
194 print(FMT_OMS, portName, portIsEnabled, portType, 197 print(FMT_OMS, portName, portIsEnabled, portType,
195 - ((OmsPort) port).minFrequency().asHz() / Frequency.ofGHz(1).asHz(), 198 + oms.minFrequency().asHz() / Frequency.ofGHz(1).asHz(),
196 - ((OmsPort) port).maxFrequency().asHz() / Frequency.ofGHz(1).asHz(), 199 + oms.maxFrequency().asHz() / Frequency.ofGHz(1).asHz(),
197 - ((OmsPort) port).grid().asHz() / Frequency.ofGHz(1).asHz(), 200 + oms.grid().asHz() / Frequency.ofGHz(1).asHz(),
198 - ((OmsPort) port).totalChannels(), annotations); 201 + oms.totalChannels(), annotations);
202 + break;
203 + }
204 + if (port instanceof OmsPort) {
205 + OmsPort oms = (OmsPort) port;
206 + print(FMT_OMS, portName, portIsEnabled, portType,
207 + oms.minFrequency().asHz() / Frequency.ofGHz(1).asHz(),
208 + oms.maxFrequency().asHz() / Frequency.ofGHz(1).asHz(),
209 + oms.grid().asHz() / Frequency.ofGHz(1).asHz(),
210 + oms.totalChannels(), annotations);
211 + break;
212 + }
213 + print("WARN: OmsPort but not on OpticalDevice or ill-formed");
214 + print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations);
199 break; 215 break;
200 case OTU: 216 case OTU:
201 print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, 217 print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType,
......
...@@ -28,7 +28,10 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -28,7 +28,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
28 * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" 28 * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
29 * 29 *
30 * Assumes we only support fixed grid for now. 30 * Assumes we only support fixed grid for now.
31 + *
32 + * @deprecated in Goldeneye (1.6.0)
31 */ 33 */
34 +@Deprecated
32 public class OmsPort extends DefaultPort { 35 public class OmsPort extends DefaultPort {
33 36
34 private final Frequency minFrequency; // Minimum frequency 37 private final Frequency minFrequency; // Minimum frequency
......
...@@ -23,7 +23,10 @@ import org.onosproject.net.SparseAnnotations; ...@@ -23,7 +23,10 @@ import org.onosproject.net.SparseAnnotations;
23 23
24 /** 24 /**
25 * Default implementation of immutable OMS port description. 25 * Default implementation of immutable OMS port description.
26 + *
27 + * @deprecated in Goldeneye (1.6.0)
26 */ 28 */
29 +@Deprecated
27 public class OmsPortDescription extends DefaultPortDescription { 30 public class OmsPortDescription extends DefaultPortDescription {
28 31
29 private final Frequency minFrequency; 32 private final Frequency minFrequency;
...@@ -39,7 +42,10 @@ public class OmsPortDescription extends DefaultPortDescription { ...@@ -39,7 +42,10 @@ public class OmsPortDescription extends DefaultPortDescription {
39 * @param maxFrequency maximum frequency 42 * @param maxFrequency maximum frequency
40 * @param grid grid spacing frequency 43 * @param grid grid spacing frequency
41 * @param annotations optional key/value annotations map 44 * @param annotations optional key/value annotations map
45 + *
46 + * @deprecated in Goldeneye (1.6.0)
42 */ 47 */
48 + @Deprecated
43 public OmsPortDescription(PortNumber number, boolean isEnabled, Frequency minFrequency, Frequency maxFrequency, 49 public OmsPortDescription(PortNumber number, boolean isEnabled, Frequency minFrequency, Frequency maxFrequency,
44 Frequency grid, SparseAnnotations... annotations) { 50 Frequency grid, SparseAnnotations... annotations) {
45 super(number, isEnabled, Port.Type.OMS, 0, annotations); 51 super(number, isEnabled, Port.Type.OMS, 0, annotations);
...@@ -56,7 +62,10 @@ public class OmsPortDescription extends DefaultPortDescription { ...@@ -56,7 +62,10 @@ public class OmsPortDescription extends DefaultPortDescription {
56 * @param maxFrequency maximum frequency 62 * @param maxFrequency maximum frequency
57 * @param grid grid spacing frequency 63 * @param grid grid spacing frequency
58 * @param annotations optional key/value annotations map 64 * @param annotations optional key/value annotations map
65 + *
66 + * @deprecated in Goldeneye (1.6.0)
59 */ 67 */
68 + @Deprecated
60 public OmsPortDescription(PortDescription base, Frequency minFrequency, Frequency maxFrequency, 69 public OmsPortDescription(PortDescription base, Frequency minFrequency, Frequency maxFrequency,
61 Frequency grid, SparseAnnotations annotations) { 70 Frequency grid, SparseAnnotations annotations) {
62 super(base, annotations); 71 super(base, annotations);
......
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;
17 +
18 +import org.onlab.util.Frequency;
19 +import org.onosproject.net.Port;
20 +
21 +import com.google.common.annotations.Beta;
22 +
23 +/**
24 + * OMS port (Optical Multiplexing Section).
25 + * Also referred to as a WDM port or W-port.
26 + * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
27 + *
28 + * Assumes we only support fixed grid for now.
29 + */
30 +@Beta
31 +public interface OmsPort extends Port {
32 +
33 + /**
34 + * Returns the total number of channels on the port.
35 + *
36 + * @return total number of channels
37 + */
38 + default short totalChannels() {
39 + Frequency diff = maxFrequency().subtract(minFrequency());
40 + return (short) (diff.asHz() / grid().asHz());
41 + }
42 +
43 + /**
44 + * Returns the minimum frequency.
45 + *
46 + * @return minimum frequency
47 + */
48 + Frequency minFrequency();
49 +
50 + /**
51 + * Returns the maximum frequency.
52 + *
53 + * @return maximum frequency
54 + */
55 + Frequency maxFrequency();
56 +
57 + /**
58 + * Returns the grid spacing frequency.
59 + *
60 + * @return grid spacing frequency
61 + */
62 + Frequency grid();
63 +
64 +}
...@@ -28,8 +28,10 @@ import org.onosproject.net.device.DeviceService; ...@@ -28,8 +28,10 @@ import org.onosproject.net.device.DeviceService;
28 import org.onosproject.net.driver.AbstractBehaviour; 28 import org.onosproject.net.driver.AbstractBehaviour;
29 import org.onosproject.net.driver.DriverData; 29 import org.onosproject.net.driver.DriverData;
30 import org.onosproject.net.optical.OchPort; 30 import org.onosproject.net.optical.OchPort;
31 +import org.onosproject.net.optical.OmsPort;
31 import org.onosproject.net.optical.OpticalDevice; 32 import org.onosproject.net.optical.OpticalDevice;
32 import org.onosproject.net.optical.device.port.OchPortMapper; 33 import org.onosproject.net.optical.device.port.OchPortMapper;
34 +import org.onosproject.net.optical.device.port.OmsPortMapper;
33 import org.onosproject.net.optical.device.port.PortMapper; 35 import org.onosproject.net.optical.device.port.PortMapper;
34 import org.onosproject.net.optical.utils.ForwardingDevice; 36 import org.onosproject.net.optical.utils.ForwardingDevice;
35 import org.slf4j.Logger; 37 import org.slf4j.Logger;
...@@ -60,6 +62,7 @@ public class DefaultOpticalDevice ...@@ -60,6 +62,7 @@ public class DefaultOpticalDevice
60 private static final Map<Class<? extends Port>, PortMapper<? extends Port>> MAPPERS 62 private static final Map<Class<? extends Port>, PortMapper<? extends Port>> MAPPERS
61 = ImmutableMap.<Class<? extends Port>, PortMapper<? extends Port>>builder() 63 = ImmutableMap.<Class<? extends Port>, PortMapper<? extends Port>>builder()
62 .put(OchPort.class, new OchPortMapper()) 64 .put(OchPort.class, new OchPortMapper())
65 + .put(OmsPort.class, new OmsPortMapper())
63 // TODO add other optical port type here 66 // TODO add other optical port type here
64 .build(); 67 .build();
65 68
......
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.onlab.util.Frequency;
23 +import org.onosproject.net.Annotations;
24 +import org.onosproject.net.DefaultAnnotations;
25 +import org.onosproject.net.Port;
26 +import org.onosproject.net.PortNumber;
27 +import org.onosproject.net.SparseAnnotations;
28 +import org.onosproject.net.DefaultAnnotations.Builder;
29 +import org.onosproject.net.device.DefaultPortDescription;
30 +import org.onosproject.net.device.PortDescription;
31 +import org.onosproject.net.optical.OmsPort;
32 +import org.onosproject.net.optical.impl.DefaultOmsPort;
33 +import org.slf4j.Logger;
34 +
35 +import com.google.common.annotations.Beta;
36 +
37 +/**
38 + * OMS port related helpers.
39 + */
40 +@Beta
41 +public final class OmsPortHelper {
42 +
43 + private static final Logger log = getLogger(OmsPortHelper.class);
44 +
45 + // Annotation keys
46 + /**
47 + * minFrequency in Hz.
48 + */
49 + private static final String MIN_FREQ_HZ = "minFrequency";
50 + /**
51 + * maxFrequency in Hz.
52 + */
53 + private static final String MAX_FREQ_HZ = "maxFrequency";
54 + /**
55 + * grid in Hz.
56 + */
57 + private static final String GRID_HZ = "grid";
58 +
59 + /**
60 + * Creates OMS port description based on the supplied information.
61 + *
62 + * @param number port number
63 + * @param isEnabled port enabled state
64 + * @param minFrequency minimum frequency
65 + * @param maxFrequency maximum frequency
66 + * @param grid grid spacing frequency
67 + * @param annotations key/value annotations map
68 + */
69 + public static PortDescription omsPortDescription(PortNumber number,
70 + boolean isEnabled,
71 + Frequency minFrequency,
72 + Frequency maxFrequency,
73 + Frequency grid,
74 + SparseAnnotations annotations) {
75 +
76 + Builder builder = DefaultAnnotations.builder();
77 + builder.putAll(annotations);
78 +
79 + builder.set(MIN_FREQ_HZ, String.valueOf(minFrequency.asHz()));
80 + builder.set(MAX_FREQ_HZ, String.valueOf(maxFrequency.asHz()));
81 + builder.set(GRID_HZ, String.valueOf(grid.asHz()));
82 +
83 + long portSpeed = 0;
84 + return new DefaultPortDescription(number, isEnabled, Port.Type.OMS, portSpeed, builder.build());
85 + }
86 +
87 + /**
88 + * Creates OMS port description based on the supplied information.
89 + *
90 + * @param number port number
91 + * @param isEnabled port enabled state
92 + * @param minFrequency minimum frequency
93 + * @param maxFrequency maximum frequency
94 + * @param grid grid spacing frequency
95 + */
96 + public static PortDescription omsPortDescription(PortNumber number,
97 + boolean isEnabled,
98 + Frequency minFrequency,
99 + Frequency maxFrequency,
100 + Frequency grid) {
101 + return omsPortDescription(number, isEnabled, minFrequency, maxFrequency, grid, DefaultAnnotations.EMPTY);
102 + }
103 +
104 + /**
105 + * Creates OMS port description based on the supplied information.
106 + *
107 + * @param base PortDescription to get basic information from
108 + * @param minFrequency minimum frequency
109 + * @param maxFrequency maximum frequency
110 + * @param grid grid spacing frequency
111 + * @param annotations key/value annotations map
112 + */
113 + public static PortDescription omsPortDescription(PortDescription base,
114 + Frequency minFrequency,
115 + Frequency maxFrequency,
116 + Frequency grid,
117 + SparseAnnotations annotations) {
118 +
119 + return omsPortDescription(base.portNumber(), base.isEnabled(),
120 + minFrequency, maxFrequency, grid,
121 + annotations);
122 + }
123 +
124 + public static Optional<OmsPort> asOmsPort(Port port) {
125 + if (port instanceof OmsPort) {
126 + return Optional.of((OmsPort) port);
127 + }
128 +
129 + try {
130 + Annotations an = port.annotations();
131 +
132 + Frequency minFrequency = Frequency.ofHz(Long.parseLong(an.value(MIN_FREQ_HZ)));
133 + Frequency maxFrequency = Frequency.ofHz(Long.parseLong(an.value(MAX_FREQ_HZ)));
134 + Frequency grid = Frequency.ofHz(Long.parseLong(an.value(GRID_HZ)));
135 +
136 + return Optional.of(new DefaultOmsPort(port, minFrequency, maxFrequency, grid));
137 +
138 + } catch (NumberFormatException e) {
139 +
140 + log.warn("{} was not well-formed OMS port.", port, e);
141 + return Optional.empty();
142 + }
143 + }
144 +
145 + // not meant to be instantiated
146 + private OmsPortHelper() {}
147 +}
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.OmsPort;
22 +import org.onosproject.net.optical.device.OmsPortHelper;
23 +import org.onosproject.net.optical.impl.DefaultOmsPort;
24 +
25 +import com.google.common.annotations.Beta;
26 +
27 +/**
28 + * {@link PortMapper} to handler {@link OmsPort} translation.
29 + */
30 +@Beta
31 +public class OmsPortMapper extends AbstractPortMapper<OmsPort> {
32 +
33 + @Override
34 + public boolean is(Port port) {
35 + return port != null &&
36 + port.type() == Port.Type.OMS &&
37 + super.is(port);
38 + }
39 +
40 + @Override
41 + public Optional<OmsPort> as(Port port) {
42 + if (port instanceof OmsPort) {
43 + return Optional.of((OmsPort) port);
44 + }
45 + return super.as(port);
46 + }
47 +
48 + @Override
49 + protected Optional<OmsPort> mapPort(Port port) {
50 + if (port instanceof OmsPort) {
51 + return Optional.of((OmsPort) port);
52 + } else if (port instanceof org.onosproject.net.OmsPort) {
53 + // TODO remove after deprecation of old OmsPort is complete
54 +
55 + // translate to new OmsPort
56 + org.onosproject.net.OmsPort old = (org.onosproject.net.OmsPort) port;
57 + return Optional.of(new DefaultOmsPort(old,
58 + old.minFrequency(),
59 + old.maxFrequency(),
60 + old.grid()));
61 + }
62 +
63 + return OmsPortHelper.asOmsPort(port);
64 + }
65 +
66 +}
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.onlab.util.Frequency;
23 +import org.onosproject.net.Port;
24 +import org.onosproject.net.optical.OmsPort;
25 +import org.onosproject.net.optical.utils.ForwardingPort;
26 +
27 +import com.google.common.annotations.Beta;
28 +
29 +/**
30 + * Implementation of OMS port (Optical Multiplexing Section).
31 + * Also referred to as a WDM port or W-port.
32 + * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
33 + *
34 + * Assumes we only support fixed grid for now.
35 + */
36 +@Beta
37 +public class DefaultOmsPort extends ForwardingPort implements OmsPort {
38 +
39 + private final Frequency minFrequency; // Minimum frequency
40 + private final Frequency maxFrequency; // Maximum frequency
41 + private final Frequency grid; // Grid spacing frequency
42 +
43 + /**
44 + * Creates an OMS port.
45 + *
46 + * @param delegate Port
47 + * @param minFrequency minimum frequency
48 + * @param maxFrequency maximum frequency
49 + * @param grid grid spacing frequency
50 + */
51 + public DefaultOmsPort(Port delegate, Frequency minFrequency, Frequency maxFrequency, Frequency grid) {
52 + super(delegate);
53 +
54 + this.minFrequency = checkNotNull(minFrequency);
55 + this.maxFrequency = checkNotNull(maxFrequency);
56 + this.grid = checkNotNull(grid);
57 + }
58 +
59 + @Override
60 + public Type type() {
61 + return Type.OMS;
62 + }
63 +
64 + @Override
65 + public long portSpeed() {
66 + return 0;
67 + }
68 +
69 + @Override
70 + public Frequency minFrequency() {
71 + return minFrequency;
72 + }
73 +
74 + @Override
75 + public Frequency maxFrequency() {
76 + return maxFrequency;
77 + }
78 +
79 + @Override
80 + public Frequency grid() {
81 + return grid;
82 + }
83 +
84 + @Override
85 + public int hashCode() {
86 + return Objects.hash(super.hashCode(),
87 + minFrequency(),
88 + maxFrequency(),
89 + grid());
90 + }
91 +
92 + @Override
93 + public boolean equals(Object obj) {
94 + if (this == obj) {
95 + return true;
96 + }
97 +
98 + if (obj != null && getClass() == obj.getClass()) {
99 + final DefaultOmsPort that = (DefaultOmsPort) obj;
100 + return super.toEqualsBuilder(that)
101 + .append(this.minFrequency(), that.minFrequency())
102 + .append(this.maxFrequency(), that.maxFrequency())
103 + .append(this.grid(), that.grid())
104 + .isEquals();
105 + }
106 + return false;
107 + }
108 +
109 + @Override
110 + public String toString() {
111 + return super.toStringHelper()
112 + .add("minFrequency", minFrequency())
113 + .add("maxFrequency", maxFrequency())
114 + .add("grid", grid())
115 + .toString();
116 + }
117 +
118 +}
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.hamcrest.Matchers.*;
19 +import static org.junit.Assert.*;
20 +
21 +import java.util.Optional;
22 +
23 +import org.junit.Test;
24 +import org.onlab.packet.ChassisId;
25 +import org.onlab.util.Frequency;
26 +import org.onosproject.net.Annotations;
27 +import org.onosproject.net.DefaultAnnotations;
28 +import org.onosproject.net.DefaultDevice;
29 +import org.onosproject.net.DefaultPort;
30 +import org.onosproject.net.Device;
31 +import org.onosproject.net.DeviceId;
32 +import org.onosproject.net.Port;
33 +import org.onosproject.net.PortNumber;
34 +import org.onosproject.net.SparseAnnotations;
35 +import org.onosproject.net.device.PortDescription;
36 +import org.onosproject.net.optical.OmsPort;
37 +import org.onosproject.net.Device.Type;
38 +import org.onosproject.net.provider.ProviderId;
39 +
40 +/**
41 + * Tests for {@link OmsPortHelper}.
42 + */
43 +public class OmsPortHelperTest {
44 +
45 + private static final ProviderId PID = new ProviderId("test", "id");
46 + private static final DeviceId DID = DeviceId.deviceId("test:00123");
47 + private static final String MFC = "MFC";
48 + private static final String HW = "HW V";
49 + private static final String SW = "SW V";
50 + private static final String SER = "SER";
51 + private static final ChassisId CHS = new ChassisId(42);
52 + private static final Annotations DEV_ANON = DefaultAnnotations.EMPTY;
53 + private static final Device DEV = new DefaultDevice(PID, DID, Type.ROADM, MFC, HW, SW, SER, CHS, DEV_ANON);
54 +
55 +
56 + @Test
57 + public void testOmsPortDescriptionCanBeConvertedToOmsPort() {
58 + PortNumber pn = PortNumber.portNumber(4900);
59 +
60 + boolean isEnabled = true;
61 + String anKey = "Base";
62 + String anValue = "value";
63 + SparseAnnotations an = DefaultAnnotations.builder()
64 + .set(anKey, anValue)
65 + .build();
66 +
67 + Frequency minF = Frequency.ofGHz(3);
68 + Frequency maxF = Frequency.ofGHz(33);
69 + Frequency grid = Frequency.ofGHz(2);
70 +
71 + PortDescription portDescription = OmsPortHelper.omsPortDescription(pn, isEnabled, minF, maxF, grid, an);
72 + Port port = new DefaultPort(DEV,
73 + portDescription.portNumber(),
74 + portDescription.isEnabled(),
75 + portDescription.type(),
76 + portDescription.portSpeed(),
77 + portDescription.annotations());
78 +
79 + Optional<OmsPort> maybeOms = OmsPortHelper.asOmsPort(port);
80 + assertTrue(maybeOms.isPresent());
81 +
82 + OmsPort oms = maybeOms.get();
83 +
84 + assertThat(oms.isEnabled(), is(isEnabled));
85 + assertThat(oms.number(), is(pn));
86 + assertThat(oms.annotations().value(anKey), is(anValue));
87 +
88 + assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
89 + assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
90 +
91 + assertThat(oms.maxFrequency(), is(maxF));
92 + assertThat(oms.minFrequency(), is(minF));
93 + assertThat(oms.grid(), is(grid));
94 + assertThat("(33-3)/2 = 15", oms.totalChannels(), is((short) 15));
95 + }
96 +
97 +}
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 org.hamcrest.Matchers.*;
19 +import static org.junit.Assert.*;
20 +import static org.onosproject.net.PortNumber.portNumber;
21 +
22 +import org.junit.Test;
23 +import org.onlab.packet.ChassisId;
24 +import org.onlab.util.Frequency;
25 +import org.onosproject.net.Annotations;
26 +import org.onosproject.net.DefaultAnnotations;
27 +import org.onosproject.net.DefaultDevice;
28 +import org.onosproject.net.DefaultPort;
29 +import org.onosproject.net.Device;
30 +import org.onosproject.net.Device.Type;
31 +import org.onosproject.net.DeviceId;
32 +import org.onosproject.net.Port;
33 +import org.onosproject.net.PortNumber;
34 +import org.onosproject.net.optical.OmsPort;
35 +import org.onosproject.net.provider.ProviderId;
36 +
37 +import com.google.common.testing.EqualsTester;
38 +
39 +/**
40 + * Tests for {@link DefaultOmsPort}.
41 + */
42 +public class DefaultOmsPortTest {
43 +
44 + private static final ProviderId PID = new ProviderId("test", "id");
45 + private static final DeviceId DID = DeviceId.deviceId("test:00123");
46 + private static final String MFC = "MFC";
47 + private static final String HW = "HW V";
48 + private static final String SW = "SW V";
49 + private static final String SER = "SER";
50 + private static final ChassisId CHS = new ChassisId(42);
51 + private static final Annotations DEV_ANON = DefaultAnnotations.EMPTY;
52 + private static final Device DEV = new DefaultDevice(PID, DID, Type.ROADM, MFC, HW, SW, SER, CHS, DEV_ANON);
53 +
54 + @Test
55 + public void testEquality() {
56 + PortNumber pn = PortNumber.portNumber(4900);
57 + Annotations an = DefaultAnnotations.builder()
58 + .set("Base", "value")
59 + .build();
60 + Annotations an2 = DefaultAnnotations.builder()
61 + .set("Base", "value2")
62 + .build();
63 +
64 + Port base = new DefaultPort(DEV, pn, true, Port.Type.VIRTUAL, 2, an);
65 + Frequency minF = Frequency.ofGHz(3);
66 + Frequency maxF = Frequency.ofGHz(33);
67 + Frequency grid = Frequency.ofGHz(2);
68 +
69 + // reference OMS port
70 + OmsPort oms = new DefaultOmsPort(base, minF, maxF, grid);
71 +
72 + new EqualsTester()
73 + .addEqualityGroup(oms,
74 + // different base port type or portspeed is ignored
75 + new DefaultOmsPort(new DefaultPort(DEV, pn, true, an), minF, maxF, grid))
76 + // different port number
77 + .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, portNumber(1), true, an), minF, maxF, grid))
78 + // different isEnabled
79 + .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, pn, false, an), minF, maxF, grid))
80 + // different annotation
81 + .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, pn, true, an2), minF, maxF, grid))
82 + // different minFreq
83 + .addEqualityGroup(new DefaultOmsPort(base, Frequency.ofKHz(3), maxF, grid))
84 + // different maxFreq
85 + .addEqualityGroup(new DefaultOmsPort(base, minF, Frequency.ofKHz(33), grid))
86 + // different grid
87 + .addEqualityGroup(new DefaultOmsPort(base, minF, maxF, Frequency.ofKHz(2)))
88 + .testEquals();
89 +
90 + }
91 +
92 + @Test
93 + public void basicTests() {
94 + PortNumber pn = PortNumber.portNumber(4900);
95 + Annotations annotations = DefaultAnnotations.builder()
96 + .set("Base", "value")
97 + .build();
98 +
99 + boolean isEnabled = true;
100 + Port base = new DefaultPort(DEV, pn, isEnabled, Port.Type.VIRTUAL, 2, annotations);
101 + Frequency minFrequency = Frequency.ofGHz(3);
102 + Frequency maxFrequency = Frequency.ofGHz(33);
103 + Frequency grid = Frequency.ofGHz(2);
104 + OmsPort oms = new DefaultOmsPort(base, minFrequency, maxFrequency, grid);
105 +
106 + // basic attributes and annotations are inherited from base
107 + assertThat(oms.element(), is(DEV));
108 + assertThat(oms.isEnabled(), is(isEnabled));
109 + assertThat(oms.number(), is(pn));
110 + assertThat(oms.annotations(), is(annotations));
111 +
112 + assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
113 + assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
114 +
115 + assertThat(oms.maxFrequency(), is(maxFrequency));
116 + assertThat(oms.minFrequency(), is(minFrequency));
117 + assertThat(oms.grid(), is(grid));
118 + assertThat("(33-3)/2 = 15", oms.totalChannels(), is((short) 15));
119 + }
120 +
121 +}
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 package org.onosproject.net.device.impl; 16 package org.onosproject.net.device.impl;
17 17
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.OmsPortHelper.omsPortDescription;
19 import static org.slf4j.LoggerFactory.getLogger; 20 import static org.slf4j.LoggerFactory.getLogger;
20 import static com.google.common.base.Preconditions.checkNotNull; 21 import static com.google.common.base.Preconditions.checkNotNull;
21 22
...@@ -25,7 +26,6 @@ import org.onosproject.net.AnnotationKeys; ...@@ -25,7 +26,6 @@ import org.onosproject.net.AnnotationKeys;
25 import org.onosproject.net.DefaultAnnotations; 26 import org.onosproject.net.DefaultAnnotations;
26 import org.onosproject.net.OtuPort; 27 import org.onosproject.net.OtuPort;
27 import org.onosproject.net.OduCltPort; 28 import org.onosproject.net.OduCltPort;
28 -import org.onosproject.net.OmsPort;
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;
...@@ -36,6 +36,7 @@ import org.onosproject.net.device.OmsPortDescription; ...@@ -36,6 +36,7 @@ import org.onosproject.net.device.OmsPortDescription;
36 import org.onosproject.net.device.OtuPortDescription; 36 import org.onosproject.net.device.OtuPortDescription;
37 import org.onosproject.net.device.PortDescription; 37 import org.onosproject.net.device.PortDescription;
38 import org.onosproject.net.optical.OchPort; 38 import org.onosproject.net.optical.OchPort;
39 +import org.onosproject.net.optical.OmsPort;
39 import org.onosproject.net.optical.OpticalDevice; 40 import org.onosproject.net.optical.OpticalDevice;
40 import org.slf4j.Logger; 41 import org.slf4j.Logger;
41 42
...@@ -103,9 +104,13 @@ public final class OpticalPortOperator implements ConfigOperator { ...@@ -103,9 +104,13 @@ public final class OpticalPortOperator implements ConfigOperator {
103 PortNumber port, SparseAnnotations sa, PortDescription descr) { 104 PortNumber port, SparseAnnotations sa, PortDescription descr) {
104 switch (descr.type()) { 105 switch (descr.type()) {
105 case OMS: 106 case OMS:
107 + if (descr instanceof OmsPortDescription) {
108 + // TODO This block can go away once deprecation is complete.
106 OmsPortDescription oms = (OmsPortDescription) descr; 109 OmsPortDescription oms = (OmsPortDescription) descr;
107 - return new OmsPortDescription(port, oms.isEnabled(), oms.minFrequency(), 110 + return omsPortDescription(port, oms.isEnabled(), oms.minFrequency(),
108 oms.maxFrequency(), oms.grid(), sa); 111 oms.maxFrequency(), oms.grid(), sa);
112 + }
113 + return descr;
109 case OCH: 114 case OCH:
110 // We might need to update lambda below with STATIC_LAMBDA. 115 // We might need to update lambda below with STATIC_LAMBDA.
111 if (descr instanceof OchPortDescription) { 116 if (descr instanceof OchPortDescription) {
...@@ -185,9 +190,21 @@ public final class OpticalPortOperator implements ConfigOperator { ...@@ -185,9 +190,21 @@ public final class OpticalPortOperator implements ConfigOperator {
185 final SparseAnnotations an = (SparseAnnotations) port.annotations(); 190 final SparseAnnotations an = (SparseAnnotations) port.annotations();
186 switch (port.type()) { 191 switch (port.type()) {
187 case OMS: 192 case OMS:
188 - OmsPort oms = (OmsPort) port; 193 + if (port instanceof org.onosproject.net.OmsPort) {
189 - return new OmsPortDescription(ptn, isup, oms.minFrequency(), 194 + // remove if-block once deprecation is complete
195 + org.onosproject.net.OmsPort oms = (org.onosproject.net.OmsPort) port;
196 + return omsPortDescription(ptn, isup, oms.minFrequency(),
197 + oms.maxFrequency(), oms.grid(), an);
198 + }
199 + if (port.element().is(OpticalDevice.class)) {
200 + OpticalDevice optDevice = port.element().as(OpticalDevice.class);
201 + if (optDevice.portIs(port, OmsPort.class)) {
202 + OmsPort oms = optDevice.portAs(port, OmsPort.class).get();
203 + return omsPortDescription(ptn, isup, oms.minFrequency(),
190 oms.maxFrequency(), oms.grid(), an); 204 oms.maxFrequency(), oms.grid(), an);
205 + }
206 + }
207 + return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an);
191 case OCH: 208 case OCH:
192 if (port instanceof org.onosproject.net.OchPort) { 209 if (port instanceof org.onosproject.net.OchPort) {
193 // remove if-block once old OchPort deprecation is complete 210 // remove if-block once old OchPort deprecation is complete
......
...@@ -18,6 +18,7 @@ package org.onosproject.store.device.impl; ...@@ -18,6 +18,7 @@ package org.onosproject.store.device.impl;
18 import static com.google.common.base.Preconditions.checkNotNull; 18 import static com.google.common.base.Preconditions.checkNotNull;
19 import static org.onosproject.net.DefaultAnnotations.union; 19 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.OmsPortHelper.omsPortDescription;
21 22
22 import java.util.Collections; 23 import java.util.Collections;
23 import java.util.Map; 24 import java.util.Map;
...@@ -105,11 +106,21 @@ class DeviceDescriptions { ...@@ -105,11 +106,21 @@ class DeviceDescriptions {
105 newOne = null; 106 newOne = null;
106 switch (newDesc.value().type()) { 107 switch (newDesc.value().type()) {
107 case OMS: 108 case OMS:
109 + if (newDesc.value() instanceof OmsPortDescription) {
110 + // remove if-block after deprecation is complete
108 OmsPortDescription omsDesc = (OmsPortDescription) (newDesc.value()); 111 OmsPortDescription omsDesc = (OmsPortDescription) (newDesc.value());
109 newOne = new Timestamped<>( 112 newOne = new Timestamped<>(
110 - new OmsPortDescription( 113 + omsPortDescription(omsDesc,
111 - omsDesc, omsDesc.minFrequency(), omsDesc.maxFrequency(), omsDesc.grid(), merged), 114 + omsDesc.minFrequency(),
115 + omsDesc.maxFrequency(),
116 + omsDesc.grid(), merged),
112 newDesc.timestamp()); 117 newDesc.timestamp());
118 + } else {
119 + // same as default case
120 + newOne = new Timestamped<>(
121 + new DefaultPortDescription(newDesc.value(), merged),
122 + newDesc.timestamp());
123 + }
113 break; 124 break;
114 case OCH: 125 case OCH:
115 if (newDesc.value() instanceof OchPortDescription) { 126 if (newDesc.value() instanceof OchPortDescription) {
......
...@@ -530,9 +530,15 @@ public class ECDeviceStore ...@@ -530,9 +530,15 @@ public class ECDeviceStore
530 // FIXME this switch need to go away once all ports are done. 530 // FIXME this switch need to go away once all ports are done.
531 switch (description.type()) { 531 switch (description.type()) {
532 case OMS: 532 case OMS:
533 + if (description instanceof OmsPortDescription) {
534 + // remove if-block once deprecation is complete
533 OmsPortDescription omsDesc = (OmsPortDescription) description; 535 OmsPortDescription omsDesc = (OmsPortDescription) description;
534 return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(), 536 return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(),
535 omsDesc.maxFrequency(), omsDesc.grid(), annotations); 537 omsDesc.maxFrequency(), omsDesc.grid(), annotations);
538 + }
539 + // same as default
540 + return new DefaultPort(device, number, isEnabled, description.type(),
541 + description.portSpeed(), annotations);
536 case OCH: 542 case OCH:
537 if (description instanceof OchPortDescription) { 543 if (description instanceof OchPortDescription) {
538 // remove if-block once Och deprecation is complete 544 // remove if-block once Och deprecation is complete
......
...@@ -1088,9 +1088,15 @@ public class GossipDeviceStore ...@@ -1088,9 +1088,15 @@ public class GossipDeviceStore
1088 // FIXME this switch need to go away once all ports are done. 1088 // FIXME this switch need to go away once all ports are done.
1089 switch (description.type()) { 1089 switch (description.type()) {
1090 case OMS: 1090 case OMS:
1091 + if (description instanceof OmsPortDescription) {
1092 + // remove if-block once deprecation is complete
1091 OmsPortDescription omsDesc = (OmsPortDescription) description; 1093 OmsPortDescription omsDesc = (OmsPortDescription) description;
1092 return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(), 1094 return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(),
1093 omsDesc.maxFrequency(), omsDesc.grid(), annotations); 1095 omsDesc.maxFrequency(), omsDesc.grid(), annotations);
1096 + }
1097 + // same as default
1098 + return new DefaultPort(device, number, isEnabled, description.type(),
1099 + description.portSpeed(), annotations);
1094 case OCH: 1100 case OCH:
1095 if (description instanceof OchPortDescription) { 1101 if (description instanceof OchPortDescription) {
1096 // remove if-block once Och deprecation is complete 1102 // remove if-block once Och deprecation is complete
......
...@@ -55,13 +55,6 @@ ...@@ -55,13 +55,6 @@
55 <extensions>true</extensions> 55 <extensions>true</extensions>
56 <configuration> 56 <configuration>
57 <niceManifest>true</niceManifest> 57 <niceManifest>true</niceManifest>
58 - <instructions>
59 - <!-- TODO this can be removed once optical package
60 - has been separated out from the default drivers -->
61 - <Import-Package>
62 - *,org.onosproject.net.optical.device
63 - </Import-Package>
64 - </instructions>
65 </configuration> 58 </configuration>
66 </plugin> 59 </plugin>
67 </plugins> 60 </plugins>
......
...@@ -17,12 +17,14 @@ package org.onosproject.driver.query; ...@@ -17,12 +17,14 @@ package org.onosproject.driver.query;
17 17
18 import org.onosproject.net.ChannelSpacing; 18 import org.onosproject.net.ChannelSpacing;
19 import org.onosproject.net.OchSignal; 19 import org.onosproject.net.OchSignal;
20 -import org.onosproject.net.OmsPort;
21 import org.onosproject.net.Port; 20 import org.onosproject.net.Port;
22 import org.onosproject.net.PortNumber; 21 import org.onosproject.net.PortNumber;
23 import org.onosproject.net.behaviour.LambdaQuery; 22 import org.onosproject.net.behaviour.LambdaQuery;
24 import org.onosproject.net.device.DeviceService; 23 import org.onosproject.net.device.DeviceService;
25 import org.onosproject.net.driver.AbstractHandlerBehaviour; 24 import org.onosproject.net.driver.AbstractHandlerBehaviour;
25 +import org.onosproject.net.optical.OmsPort;
26 +
27 +import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
26 28
27 import java.util.Collections; 29 import java.util.Collections;
28 import java.util.Set; 30 import java.util.Set;
...@@ -46,7 +48,7 @@ public class OFOpticalSwitch13LambdaQuery extends AbstractHandlerBehaviour imple ...@@ -46,7 +48,7 @@ public class OFOpticalSwitch13LambdaQuery extends AbstractHandlerBehaviour imple
46 48
47 @Override 49 @Override
48 public Set<OchSignal> queryLambdas(PortNumber port) { 50 public Set<OchSignal> queryLambdas(PortNumber port) {
49 - DeviceService deviceService = this.handler().get(DeviceService.class); 51 + DeviceService deviceService = opticalView(this.handler().get(DeviceService.class));
50 Port p = deviceService.getPort(this.data().deviceId(), port); 52 Port p = deviceService.getPort(this.data().deviceId(), port);
51 53
52 // Only OMS ports expose lambda resources 54 // Only OMS ports expose lambda resources
......
...@@ -18,6 +18,8 @@ package org.onosproject.drivers.lumentum; ...@@ -18,6 +18,8 @@ package org.onosproject.drivers.lumentum;
18 18
19 import org.apache.felix.scr.annotations.Component; 19 import org.apache.felix.scr.annotations.Component;
20 import org.onosproject.net.driver.AbstractDriverLoader; 20 import org.onosproject.net.driver.AbstractDriverLoader;
21 +import org.onosproject.net.optical.OpticalDevice;
22 +import org.onosproject.net.optical.device.DefaultOpticalDevice;
21 23
22 /** 24 /**
23 * Loader for Lumentum device drivers from specific xml. 25 * Loader for Lumentum device drivers from specific xml.
...@@ -25,6 +27,12 @@ import org.onosproject.net.driver.AbstractDriverLoader; ...@@ -25,6 +27,12 @@ import org.onosproject.net.driver.AbstractDriverLoader;
25 @Component(immediate = true) 27 @Component(immediate = true)
26 public class LumentumDriversLoader extends AbstractDriverLoader { 28 public class LumentumDriversLoader extends AbstractDriverLoader {
27 29
30 + // OSGI: help bundle plugin discover runtime package dependency.
31 + @SuppressWarnings("unused")
32 + private OpticalDevice optical;
33 + @SuppressWarnings("unused")
34 + private DefaultOpticalDevice driver;
35 +
28 public LumentumDriversLoader() { 36 public LumentumDriversLoader() {
29 super("/lumentum-drivers.xml"); 37 super("/lumentum-drivers.xml");
30 } 38 }
......
...@@ -27,7 +27,6 @@ import org.onosproject.net.device.DefaultDeviceDescription; ...@@ -27,7 +27,6 @@ import org.onosproject.net.device.DefaultDeviceDescription;
27 import org.onosproject.net.device.DeviceDescription; 27 import org.onosproject.net.device.DeviceDescription;
28 import org.onosproject.net.device.DeviceDescriptionDiscovery; 28 import org.onosproject.net.device.DeviceDescriptionDiscovery;
29 import org.onosproject.net.device.DeviceService; 29 import org.onosproject.net.device.DeviceService;
30 -import org.onosproject.net.device.OmsPortDescription;
31 import org.onosproject.net.device.PortDescription; 30 import org.onosproject.net.device.PortDescription;
32 import org.onosproject.net.driver.AbstractHandlerBehaviour; 31 import org.onosproject.net.driver.AbstractHandlerBehaviour;
33 import org.slf4j.Logger; 32 import org.slf4j.Logger;
...@@ -40,6 +39,7 @@ import java.util.Collections; ...@@ -40,6 +39,7 @@ import java.util.Collections;
40 import java.util.List; 39 import java.util.List;
41 40
42 import static com.google.common.base.Preconditions.checkNotNull; 41 import static com.google.common.base.Preconditions.checkNotNull;
42 +import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription;
43 import static org.slf4j.LoggerFactory.getLogger; 43 import static org.slf4j.LoggerFactory.getLogger;
44 44
45 /** 45 /**
...@@ -97,7 +97,7 @@ public class LumentumRoadmDeviceDescription extends AbstractHandlerBehaviour imp ...@@ -97,7 +97,7 @@ public class LumentumRoadmDeviceDescription extends AbstractHandlerBehaviour imp
97 SparseAnnotations ann = DefaultAnnotations.builder() 97 SparseAnnotations ann = DefaultAnnotations.builder()
98 .set(AnnotationKeys.PORT_NAME, portDirection + "-" + portNumber) 98 .set(AnnotationKeys.PORT_NAME, portDirection + "-" + portNumber)
99 .build(); 99 .build();
100 - PortDescription p = new OmsPortDescription( 100 + PortDescription p = omsPortDescription(
101 PortNumber.portNumber(ports.size() + 1), 101 PortNumber.portNumber(ports.size() + 1),
102 true, 102 true,
103 LumentumSnmpDevice.START_CENTER_FREQ, 103 LumentumSnmpDevice.START_CENTER_FREQ,
...@@ -115,7 +115,7 @@ public class LumentumRoadmDeviceDescription extends AbstractHandlerBehaviour imp ...@@ -115,7 +115,7 @@ public class LumentumRoadmDeviceDescription extends AbstractHandlerBehaviour imp
115 SparseAnnotations annLineIn = DefaultAnnotations.builder() 115 SparseAnnotations annLineIn = DefaultAnnotations.builder()
116 .set(AnnotationKeys.PORT_NAME, "LINE IN") 116 .set(AnnotationKeys.PORT_NAME, "LINE IN")
117 .build(); 117 .build();
118 - ports.add(new OmsPortDescription( 118 + ports.add(omsPortDescription(
119 PortNumber.portNumber(ports.size() + 1), 119 PortNumber.portNumber(ports.size() + 1),
120 true, 120 true,
121 LumentumSnmpDevice.START_CENTER_FREQ, 121 LumentumSnmpDevice.START_CENTER_FREQ,
...@@ -127,7 +127,7 @@ public class LumentumRoadmDeviceDescription extends AbstractHandlerBehaviour imp ...@@ -127,7 +127,7 @@ public class LumentumRoadmDeviceDescription extends AbstractHandlerBehaviour imp
127 SparseAnnotations annLineOut = DefaultAnnotations.builder() 127 SparseAnnotations annLineOut = DefaultAnnotations.builder()
128 .set(AnnotationKeys.PORT_NAME, "LINE OUT") 128 .set(AnnotationKeys.PORT_NAME, "LINE OUT")
129 .build(); 129 .build();
130 - ports.add(new OmsPortDescription( 130 + ports.add(omsPortDescription(
131 PortNumber.portNumber(ports.size() + 1), 131 PortNumber.portNumber(ports.size() + 1),
132 true, 132 true,
133 LumentumSnmpDevice.START_CENTER_FREQ, 133 LumentumSnmpDevice.START_CENTER_FREQ,
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
24 impl="org.onosproject.drivers.lumentum.LumentumFlowRuleProgrammable"/> 24 impl="org.onosproject.drivers.lumentum.LumentumFlowRuleProgrammable"/>
25 <behaviour api="org.onosproject.incubator.net.faultmanagement.alarm.AlarmConsumer" 25 <behaviour api="org.onosproject.incubator.net.faultmanagement.alarm.AlarmConsumer"
26 impl="org.onosproject.drivers.lumentum.LumentumAlarmConsumer"/> 26 impl="org.onosproject.drivers.lumentum.LumentumAlarmConsumer"/>
27 + <behaviour api="org.onosproject.net.optical.OpticalDevice"
28 + impl="org.onosproject.net.optical.device.DefaultOpticalDevice"/>
27 </driver> 29 </driver>
28 </drivers> 30 </drivers>
29 31
......
...@@ -22,6 +22,7 @@ import static org.onosproject.net.DeviceId.deviceId; ...@@ -22,6 +22,7 @@ import static org.onosproject.net.DeviceId.deviceId;
22 import static org.onosproject.net.Port.Type.COPPER; 22 import static org.onosproject.net.Port.Type.COPPER;
23 import static org.onosproject.net.Port.Type.FIBER; 23 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.OmsPortHelper.omsPortDescription;
25 import static org.onosproject.openflow.controller.Dpid.dpid; 26 import static org.onosproject.openflow.controller.Dpid.dpid;
26 import static org.onosproject.openflow.controller.Dpid.uri; 27 import static org.onosproject.openflow.controller.Dpid.uri;
27 import static org.slf4j.LoggerFactory.getLogger; 28 import static org.slf4j.LoggerFactory.getLogger;
...@@ -67,7 +68,6 @@ import org.onosproject.net.device.DeviceProvider; ...@@ -67,7 +68,6 @@ import org.onosproject.net.device.DeviceProvider;
67 import org.onosproject.net.device.DeviceProviderRegistry; 68 import org.onosproject.net.device.DeviceProviderRegistry;
68 import org.onosproject.net.device.DeviceProviderService; 69 import org.onosproject.net.device.DeviceProviderService;
69 import org.onosproject.net.device.OduCltPortDescription; 70 import org.onosproject.net.device.OduCltPortDescription;
70 -import org.onosproject.net.device.OmsPortDescription;
71 import org.onosproject.net.device.OtuPortDescription; 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;
...@@ -582,7 +582,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr ...@@ -582,7 +582,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
582 PortDescription portDes = null; 582 PortDescription portDes = null;
583 switch (sigType) { 583 switch (sigType) {
584 case OMSN: 584 case OMSN:
585 - portDes = new OmsPortDescription(portNo, enabled, 585 + portDes = omsPortDescription(portNo, enabled,
586 FREQ191_7, FREQ191_7.add(FREQ4_4), FREQ50, annotations); 586 FREQ191_7, FREQ191_7.add(FREQ4_4), FREQ50, annotations);
587 break; 587 break;
588 case OCH: 588 case OCH:
...@@ -703,7 +703,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr ...@@ -703,7 +703,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
703 case 2: // OMS port 703 case 2: // OMS port
704 // Assume complete optical spectrum and 50 GHz grid 704 // Assume complete optical spectrum and 50 GHz grid
705 // LINC-OE is only supported optical OF device for now 705 // LINC-OE is only supported optical OF device for now
706 - return new OmsPortDescription(portNo, enabled, 706 + return omsPortDescription(portNo, enabled,
707 Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations); 707 Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations);
708 case 5: // OCH port 708 case 5: // OCH port
709 OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4); 709 OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4);
...@@ -742,7 +742,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr ...@@ -742,7 +742,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
742 742
743 // S160 data sheet 743 // S160 data sheet
744 // Wavelength range: 1260 - 1630 nm, grid is irrelevant for this type of switch 744 // Wavelength range: 1260 - 1630 nm, grid is irrelevant for this type of switch
745 - return new OmsPortDescription(portNo, enabled, 745 + return omsPortDescription(portNo, enabled,
746 Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(100), annotations); 746 Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(100), annotations);
747 } 747 }
748 748
......
...@@ -41,7 +41,6 @@ import org.onosproject.net.MastershipRole; ...@@ -41,7 +41,6 @@ import org.onosproject.net.MastershipRole;
41 import org.onosproject.net.OchSignal; 41 import org.onosproject.net.OchSignal;
42 import org.onosproject.net.OduCltPort; 42 import org.onosproject.net.OduCltPort;
43 import org.onosproject.net.OduSignalType; 43 import org.onosproject.net.OduSignalType;
44 -import org.onosproject.net.OmsPort;
45 import org.onosproject.net.Port; 44 import org.onosproject.net.Port;
46 import org.onosproject.net.PortNumber; 45 import org.onosproject.net.PortNumber;
47 import org.onosproject.net.SparseAnnotations; 46 import org.onosproject.net.SparseAnnotations;
...@@ -55,7 +54,6 @@ import org.onosproject.net.device.DeviceProviderRegistry; ...@@ -55,7 +54,6 @@ import org.onosproject.net.device.DeviceProviderRegistry;
55 import org.onosproject.net.device.DeviceProviderService; 54 import org.onosproject.net.device.DeviceProviderService;
56 import org.onosproject.net.device.DeviceService; 55 import org.onosproject.net.device.DeviceService;
57 import org.onosproject.net.device.OduCltPortDescription; 56 import org.onosproject.net.device.OduCltPortDescription;
58 -import org.onosproject.net.device.OmsPortDescription;
59 import org.onosproject.net.device.PortDescription; 57 import org.onosproject.net.device.PortDescription;
60 import org.onosproject.net.host.DefaultHostDescription; 58 import org.onosproject.net.host.DefaultHostDescription;
61 import org.onosproject.net.host.HostProvider; 59 import org.onosproject.net.host.HostProvider;
...@@ -66,6 +64,7 @@ import org.onosproject.net.link.LinkProvider; ...@@ -66,6 +64,7 @@ import org.onosproject.net.link.LinkProvider;
66 import org.onosproject.net.link.LinkProviderRegistry; 64 import org.onosproject.net.link.LinkProviderRegistry;
67 import org.onosproject.net.link.LinkProviderService; 65 import org.onosproject.net.link.LinkProviderService;
68 import org.onosproject.net.optical.OchPort; 66 import org.onosproject.net.optical.OchPort;
67 +import org.onosproject.net.optical.OmsPort;
69 import org.onosproject.net.provider.ProviderId; 68 import org.onosproject.net.provider.ProviderId;
70 import org.slf4j.Logger; 69 import org.slf4j.Logger;
71 import org.slf4j.LoggerFactory; 70 import org.slf4j.LoggerFactory;
...@@ -88,6 +87,7 @@ import static org.onosproject.net.PortNumber.portNumber; ...@@ -88,6 +87,7 @@ import static org.onosproject.net.PortNumber.portNumber;
88 import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED; 87 import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED;
89 import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED; 88 import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED;
90 import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; 89 import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription;
90 +import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription;
91 import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView; 91 import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
92 92
93 /** 93 /**
...@@ -259,7 +259,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { ...@@ -259,7 +259,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
259 case FIBER: 259 case FIBER:
260 // Currently, assume OMS when FIBER. Provide sane defaults. 260 // Currently, assume OMS when FIBER. Provide sane defaults.
261 annotations = annotations(node.get("annotations")); 261 annotations = annotations(node.get("annotations"));
262 - return new OmsPortDescription(port, node.path("enabled").asBoolean(true), 262 + return omsPortDescription(port, node.path("enabled").asBoolean(true),
263 Spectrum.CENTER_FREQUENCY, Spectrum.CENTER_FREQUENCY.add(TOTAL), 263 Spectrum.CENTER_FREQUENCY, Spectrum.CENTER_FREQUENCY.add(TOTAL),
264 Frequency.ofGHz(100), annotations); 264 Frequency.ofGHz(100), annotations);
265 case ODUCLT: 265 case ODUCLT:
...@@ -276,7 +276,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { ...@@ -276,7 +276,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
276 case OMS: 276 case OMS:
277 annotations = annotations(node.get("annotations")); 277 annotations = annotations(node.get("annotations"));
278 OmsPort omsPort = (OmsPort) deviceService.getPort(deviceId, port); 278 OmsPort omsPort = (OmsPort) deviceService.getPort(deviceId, port);
279 - return new OmsPortDescription(port, node.path("enabled").asBoolean(true), 279 + return omsPortDescription(port, node.path("enabled").asBoolean(true),
280 omsPort.minFrequency(), omsPort.maxFrequency(), omsPort.grid(), annotations); 280 omsPort.minFrequency(), omsPort.maxFrequency(), omsPort.grid(), annotations);
281 default: 281 default:
282 log.warn("{}: Unsupported Port Type"); 282 log.warn("{}: Unsupported Port Type");
...@@ -398,8 +398,8 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { ...@@ -398,8 +398,8 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
398 Frequency min = Spectrum.CENTER_FREQUENCY.add(grid); 398 Frequency min = Spectrum.CENTER_FREQUENCY.add(grid);
399 Frequency max = Spectrum.CENTER_FREQUENCY.add(grid.multiply(numChls)); 399 Frequency max = Spectrum.CENTER_FREQUENCY.add(grid.multiply(numChls));
400 400
401 - PortDescription srcPortDesc = new OmsPortDescription(srcCp.port(), true, min, max, grid); 401 + PortDescription srcPortDesc = omsPortDescription(srcCp.port(), true, min, max, grid);
402 - PortDescription dstPortDesc = new OmsPortDescription(dstCp.port(), true, min, max, grid); 402 + PortDescription dstPortDesc = omsPortDescription(dstCp.port(), true, min, max, grid);
403 descriptions.put(srcCp, srcPortDesc); 403 descriptions.put(srcCp, srcPortDesc);
404 descriptions.put(dstCp, dstPortDesc); 404 descriptions.put(dstCp, dstPortDesc);
405 deviceProviderService.portStatusChanged(srcCp.deviceId(), srcPortDesc); 405 deviceProviderService.portStatusChanged(srcCp.deviceId(), srcPortDesc);
...@@ -479,7 +479,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { ...@@ -479,7 +479,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
479 switch (p.type()) { 479 switch (p.type()) {
480 case OMS: 480 case OMS:
481 OmsPort op = (OmsPort) p; 481 OmsPort op = (OmsPort) p;
482 - return new OmsPortDescription( 482 + return omsPortDescription(
483 op.number(), op.isEnabled(), op.minFrequency(), op.maxFrequency(), op.grid()); 483 op.number(), op.isEnabled(), op.minFrequency(), op.maxFrequency(), op.grid());
484 case OCH: 484 case OCH:
485 OchPort ochp = (OchPort) p; 485 OchPort ochp = (OchPort) p;
......