Committed by
Gerrit Code Review
[ONOS-4513] decouple optical-model from CLI
- core/cli is now optical-model clean - Add command for pretty printing optical-ports Change-Id: I2926ef6d52971d1a7f6642dfe4098d7ed2422363
Showing
28 changed files
with
432 additions
and
158 deletions
| ... | @@ -59,6 +59,17 @@ | ... | @@ -59,6 +59,17 @@ |
| 59 | 59 | ||
| 60 | <dependency> | 60 | <dependency> |
| 61 | <groupId>org.onosproject</groupId> | 61 | <groupId>org.onosproject</groupId> |
| 62 | + <artifactId>onos-cli</artifactId> | ||
| 63 | + <version>${project.version}</version> | ||
| 64 | + </dependency> | ||
| 65 | + | ||
| 66 | + <dependency> | ||
| 67 | + <groupId>org.apache.karaf.shell</groupId> | ||
| 68 | + <artifactId>org.apache.karaf.shell.console</artifactId> | ||
| 69 | + </dependency> | ||
| 70 | + | ||
| 71 | + <dependency> | ||
| 72 | + <groupId>org.onosproject</groupId> | ||
| 62 | <artifactId>onlab-junit</artifactId> | 73 | <artifactId>onlab-junit</artifactId> |
| 63 | <scope>test</scope> | 74 | <scope>test</scope> |
| 64 | </dependency> | 75 | </dependency> | ... | ... |
| ... | @@ -17,8 +17,6 @@ package org.onosproject.net.optical; | ... | @@ -17,8 +17,6 @@ package org.onosproject.net.optical; |
| 17 | 17 | ||
| 18 | import org.onosproject.net.OchSignal; | 18 | import org.onosproject.net.OchSignal; |
| 19 | import org.onosproject.net.OduSignalType; | 19 | import org.onosproject.net.OduSignalType; |
| 20 | -import org.onosproject.net.Port; | ||
| 21 | - | ||
| 22 | import com.google.common.annotations.Beta; | 20 | import com.google.common.annotations.Beta; |
| 23 | 21 | ||
| 24 | /** | 22 | /** |
| ... | @@ -27,7 +25,7 @@ import com.google.common.annotations.Beta; | ... | @@ -27,7 +25,7 @@ import com.google.common.annotations.Beta; |
| 27 | * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" | 25 | * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" |
| 28 | */ | 26 | */ |
| 29 | @Beta | 27 | @Beta |
| 30 | -public interface OchPort extends Port { | 28 | +public interface OchPort extends ProjectedPort { |
| 31 | 29 | ||
| 32 | /** | 30 | /** |
| 33 | * Returns ODU signal type. | 31 | * Returns ODU signal type. | ... | ... |
| ... | @@ -16,8 +16,6 @@ | ... | @@ -16,8 +16,6 @@ |
| 16 | package org.onosproject.net.optical; | 16 | package org.onosproject.net.optical; |
| 17 | 17 | ||
| 18 | import org.onosproject.net.CltSignalType; | 18 | import org.onosproject.net.CltSignalType; |
| 19 | -import org.onosproject.net.Port; | ||
| 20 | - | ||
| 21 | import com.google.common.annotations.Beta; | 19 | import com.google.common.annotations.Beta; |
| 22 | 20 | ||
| 23 | /** | 21 | /** |
| ... | @@ -26,7 +24,7 @@ import com.google.common.annotations.Beta; | ... | @@ -26,7 +24,7 @@ import com.google.common.annotations.Beta; |
| 26 | * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" | 24 | * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" |
| 27 | */ | 25 | */ |
| 28 | @Beta | 26 | @Beta |
| 29 | -public interface OduCltPort extends Port { | 27 | +public interface OduCltPort extends ProjectedPort { |
| 30 | 28 | ||
| 31 | /** | 29 | /** |
| 32 | * Returns ODU client signal type. | 30 | * Returns ODU client signal type. | ... | ... |
| ... | @@ -16,8 +16,6 @@ | ... | @@ -16,8 +16,6 @@ |
| 16 | package org.onosproject.net.optical; | 16 | package org.onosproject.net.optical; |
| 17 | 17 | ||
| 18 | import org.onlab.util.Frequency; | 18 | import org.onlab.util.Frequency; |
| 19 | -import org.onosproject.net.Port; | ||
| 20 | - | ||
| 21 | import com.google.common.annotations.Beta; | 19 | import com.google.common.annotations.Beta; |
| 22 | 20 | ||
| 23 | /** | 21 | /** |
| ... | @@ -28,7 +26,7 @@ import com.google.common.annotations.Beta; | ... | @@ -28,7 +26,7 @@ import com.google.common.annotations.Beta; |
| 28 | * Assumes we only support fixed grid for now. | 26 | * Assumes we only support fixed grid for now. |
| 29 | */ | 27 | */ |
| 30 | @Beta | 28 | @Beta |
| 31 | -public interface OmsPort extends Port { | 29 | +public interface OmsPort extends ProjectedPort { |
| 32 | 30 | ||
| 33 | /** | 31 | /** |
| 34 | * Returns the total number of channels on the port. | 32 | * Returns the total number of channels on the port. | ... | ... |
| ... | @@ -16,8 +16,6 @@ | ... | @@ -16,8 +16,6 @@ |
| 16 | package org.onosproject.net.optical; | 16 | package org.onosproject.net.optical; |
| 17 | 17 | ||
| 18 | import org.onosproject.net.OtuSignalType; | 18 | import org.onosproject.net.OtuSignalType; |
| 19 | -import org.onosproject.net.Port; | ||
| 20 | - | ||
| 21 | import com.google.common.annotations.Beta; | 19 | import com.google.common.annotations.Beta; |
| 22 | 20 | ||
| 23 | /** | 21 | /** |
| ... | @@ -27,7 +25,7 @@ import com.google.common.annotations.Beta; | ... | @@ -27,7 +25,7 @@ import com.google.common.annotations.Beta; |
| 27 | * Open Networking Foundation "Optical Transport Protocol Extensions Version 1.0". | 25 | * Open Networking Foundation "Optical Transport Protocol Extensions Version 1.0". |
| 28 | */ | 26 | */ |
| 29 | @Beta | 27 | @Beta |
| 30 | -public interface OtuPort extends Port { | 28 | +public interface OtuPort extends ProjectedPort { |
| 31 | 29 | ||
| 32 | /** | 30 | /** |
| 33 | * Returns OTU signal type. | 31 | * Returns OTU signal type. | ... | ... |
| 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.onosproject.net.Annotations; | ||
| 19 | +import org.onosproject.net.Port; | ||
| 20 | + | ||
| 21 | +import com.google.common.annotations.Beta; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * Abstraction of a network port. | ||
| 25 | + */ | ||
| 26 | +@Beta | ||
| 27 | +public interface ProjectedPort extends Port { | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Returns the key/value annotations, not used by projection. | ||
| 31 | + * | ||
| 32 | + * @return key/value annotations | ||
| 33 | + */ | ||
| 34 | + Annotations unhandledAnnotations(); | ||
| 35 | + | ||
| 36 | +} |
| ... | @@ -13,11 +13,14 @@ | ... | @@ -13,11 +13,14 @@ |
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package org.onosproject.cli.net; | 16 | +package org.onosproject.net.optical.cli; |
| 17 | 17 | ||
| 18 | import org.apache.karaf.shell.commands.Argument; | 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; | 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.apache.karaf.shell.commands.Option; | 20 | import org.apache.karaf.shell.commands.Option; |
| 21 | +import org.onosproject.cli.app.AllApplicationNamesCompleter; | ||
| 22 | +import org.onosproject.cli.net.ConnectPointCompleter; | ||
| 23 | +import org.onosproject.cli.net.ConnectivityIntentCommand; | ||
| 21 | import org.onosproject.net.CltSignalType; | 24 | import org.onosproject.net.CltSignalType; |
| 22 | import org.onosproject.net.ConnectPoint; | 25 | import org.onosproject.net.ConnectPoint; |
| 23 | import org.onosproject.net.Device; | 26 | import org.onosproject.net.Device; |
| ... | @@ -45,6 +48,14 @@ import static org.onosproject.net.optical.device.OpticalDeviceServiceView.optica | ... | @@ -45,6 +48,14 @@ import static org.onosproject.net.optical.device.OpticalDeviceServiceView.optica |
| 45 | description = "Installs optical connectivity intent") | 48 | description = "Installs optical connectivity intent") |
| 46 | public class AddOpticalIntentCommand extends ConnectivityIntentCommand { | 49 | public class AddOpticalIntentCommand extends ConnectivityIntentCommand { |
| 47 | 50 | ||
| 51 | + // OSGi workaround | ||
| 52 | + @SuppressWarnings("unused") | ||
| 53 | + private ConnectPointCompleter cpCompleter; | ||
| 54 | + | ||
| 55 | + // OSGi workaround | ||
| 56 | + @SuppressWarnings("unused") | ||
| 57 | + private AllApplicationNamesCompleter appCompleter; | ||
| 58 | + | ||
| 48 | @Argument(index = 0, name = "ingressDevice", | 59 | @Argument(index = 0, name = "ingressDevice", |
| 49 | description = "Ingress Device/Port Description", | 60 | description = "Ingress Device/Port Description", |
| 50 | required = true, multiValued = false) | 61 | required = true, multiValued = false) | ... | ... |
apps/optical-model/src/main/java/org/onosproject/net/optical/cli/OpticalPortsListCommand.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2014-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.cli; | ||
| 17 | + | ||
| 18 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 19 | +import org.apache.karaf.shell.commands.Command; | ||
| 20 | +import org.onlab.util.Frequency; | ||
| 21 | +import org.onosproject.cli.net.DevicePortsListCommand; | ||
| 22 | +import org.onosproject.net.Device; | ||
| 23 | +import org.onosproject.net.Port; | ||
| 24 | +import org.onosproject.net.Port.Type; | ||
| 25 | +import org.onosproject.net.device.DeviceService; | ||
| 26 | +import org.onosproject.net.optical.OchPort; | ||
| 27 | +import org.onosproject.net.optical.OduCltPort; | ||
| 28 | +import org.onosproject.net.optical.OmsPort; | ||
| 29 | +import org.onosproject.net.optical.OtuPort; | ||
| 30 | + | ||
| 31 | +import java.util.ArrayList; | ||
| 32 | +import java.util.EnumSet; | ||
| 33 | +import java.util.List; | ||
| 34 | + | ||
| 35 | +import static org.onosproject.net.DeviceId.deviceId; | ||
| 36 | +import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView; | ||
| 37 | + | ||
| 38 | +/** | ||
| 39 | + * Lists all ports or all ports of a device. | ||
| 40 | + */ | ||
| 41 | +@Command(scope = "onos", name = "optical-ports", | ||
| 42 | + description = "Lists all optical ports or all optical ports of a device") | ||
| 43 | +public class OpticalPortsListCommand extends DevicePortsListCommand { | ||
| 44 | + | ||
| 45 | + private static final String FMT = " port=%s, state=%s, type=%s, speed=%s %s"; | ||
| 46 | + private static final String FMT_OCH = " port=%s, state=%s, type=%s, signalType=%s, isTunable=%s %s"; | ||
| 47 | + private static final String FMT_ODUCLT_OTU = " port=%s, state=%s, type=%s, signalType=%s %s"; | ||
| 48 | + private static final String FMT_OMS = " port=%s, state=%s, type=%s, freqs=%s / %s / %s GHz, totalChannels=%s %s"; | ||
| 49 | + | ||
| 50 | + private static final EnumSet<Port.Type> OPTICAL = EnumSet.of(Type.OCH, Type.ODUCLT, Type.OMS, Type.OTU); | ||
| 51 | + | ||
| 52 | + @Override | ||
| 53 | + protected void execute() { | ||
| 54 | + DeviceService service = opticalView(get(DeviceService.class)); | ||
| 55 | + if (uri == null) { | ||
| 56 | + if (outputJson()) { | ||
| 57 | + print("%s", jsonPorts(service, getSortedDevices(service))); | ||
| 58 | + } else { | ||
| 59 | + for (Device device : getSortedDevices(service)) { | ||
| 60 | + printDevice(service, device); | ||
| 61 | + printPorts(service, device); | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + } else { | ||
| 66 | + Device device = service.getDevice(deviceId(uri)); | ||
| 67 | + if (device == null) { | ||
| 68 | + error("No such device %s", uri); | ||
| 69 | + } else if (outputJson()) { | ||
| 70 | + print("%s", jsonPorts(service, new ObjectMapper(), device)); | ||
| 71 | + } else { | ||
| 72 | + printDevice(service, device); | ||
| 73 | + printPorts(service, device); | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + // Determines if a port should be included in output. | ||
| 79 | + @Override | ||
| 80 | + protected boolean isIncluded(Port port) { | ||
| 81 | + return OPTICAL.contains(port.type()) && | ||
| 82 | + super.isIncluded(port); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @Override | ||
| 86 | + protected void printPorts(DeviceService service, Device device) { | ||
| 87 | + List<Port> ports = new ArrayList<>(service.getPorts(device.id())); | ||
| 88 | + ports.sort((p1, p2) -> | ||
| 89 | + Long.signum(p1.number().toLong() - p2.number().toLong()) | ||
| 90 | + ); | ||
| 91 | + for (Port port : ports) { | ||
| 92 | + if (!isIncluded(port)) { | ||
| 93 | + continue; | ||
| 94 | + } | ||
| 95 | + String portName = port.number().toString(); | ||
| 96 | + String portIsEnabled = port.isEnabled() ? "enabled" : "disabled"; | ||
| 97 | + String portType = port.type().toString().toLowerCase(); | ||
| 98 | + switch (port.type()) { | ||
| 99 | + case OCH: | ||
| 100 | + if (port instanceof OchPort) { | ||
| 101 | + OchPort och = (OchPort) port; | ||
| 102 | + print(FMT_OCH, portName, portIsEnabled, portType, | ||
| 103 | + och.signalType().toString(), | ||
| 104 | + och.isTunable() ? "yes" : "no", | ||
| 105 | + annotations(och.unhandledAnnotations())); | ||
| 106 | + break; | ||
| 107 | + } | ||
| 108 | + print("WARN: OchPort but not on OpticalDevice or ill-formed"); | ||
| 109 | + print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations())); | ||
| 110 | + break; | ||
| 111 | + case ODUCLT: | ||
| 112 | + if (port instanceof OduCltPort) { | ||
| 113 | + OduCltPort oduCltPort = (OduCltPort) port; | ||
| 114 | + print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, | ||
| 115 | + oduCltPort.signalType().toString(), | ||
| 116 | + annotations(oduCltPort.unhandledAnnotations())); | ||
| 117 | + break; | ||
| 118 | + } | ||
| 119 | + print("WARN: OduCltPort but not on OpticalDevice or ill-formed"); | ||
| 120 | + print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations())); | ||
| 121 | + break; | ||
| 122 | + case OMS: | ||
| 123 | + if (port instanceof OmsPort) { | ||
| 124 | + OmsPort oms = (OmsPort) port; | ||
| 125 | + print(FMT_OMS, portName, portIsEnabled, portType, | ||
| 126 | + oms.minFrequency().asHz() / Frequency.ofGHz(1).asHz(), | ||
| 127 | + oms.maxFrequency().asHz() / Frequency.ofGHz(1).asHz(), | ||
| 128 | + oms.grid().asHz() / Frequency.ofGHz(1).asHz(), | ||
| 129 | + oms.totalChannels(), | ||
| 130 | + annotations(oms.unhandledAnnotations())); | ||
| 131 | + break; | ||
| 132 | + } | ||
| 133 | + print("WARN: OmsPort but not on OpticalDevice or ill-formed"); | ||
| 134 | + print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations())); | ||
| 135 | + break; | ||
| 136 | + case OTU: | ||
| 137 | + if (port instanceof OtuPort) { | ||
| 138 | + OtuPort otuPort = (OtuPort) port; | ||
| 139 | + print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, | ||
| 140 | + otuPort.signalType().toString(), | ||
| 141 | + annotations(otuPort.unhandledAnnotations())); | ||
| 142 | + break; | ||
| 143 | + } | ||
| 144 | + print("WARN: OtuPort but not on OpticalDevice or ill-formed"); | ||
| 145 | + print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations())); | ||
| 146 | + break; | ||
| 147 | + default: | ||
| 148 | + // do not print non-optical ports | ||
| 149 | + break; | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
| 5 | + * use this file except in compliance with the License. You may obtain a copy of | ||
| 6 | + * 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, WITHOUT | ||
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| 13 | + * License for the specific language governing permissions and limitations under | ||
| 14 | + * the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Console command-line for interacting with the | ||
| 19 | + * optical network model & services. | ||
| 20 | + */ | ||
| 21 | +package org.onosproject.net.optical.cli; |
apps/optical-model/src/main/java/org/onosproject/net/optical/device/FilteredAnnotation.java
0 → 100644
| 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 com.google.common.base.Preconditions.checkNotNull; | ||
| 19 | + | ||
| 20 | +import java.util.HashMap; | ||
| 21 | +import java.util.Map; | ||
| 22 | +import java.util.Set; | ||
| 23 | + | ||
| 24 | +import org.onosproject.net.Annotations; | ||
| 25 | + | ||
| 26 | +import com.google.common.annotations.Beta; | ||
| 27 | +import com.google.common.collect.ImmutableSet; | ||
| 28 | +import com.google.common.collect.Sets; | ||
| 29 | + | ||
| 30 | +/** | ||
| 31 | + * Filtered {@link Annotations} view. | ||
| 32 | + */ | ||
| 33 | +@Beta | ||
| 34 | +public class FilteredAnnotation implements Annotations { | ||
| 35 | + | ||
| 36 | + private final Annotations delegate; | ||
| 37 | + private final Set<String> filtered; | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * Creates filtered {@link Annotations} view based on {@code delegate}. | ||
| 41 | + * | ||
| 42 | + * @param delegate input {@link Annotations} | ||
| 43 | + * @param keys to filter-out | ||
| 44 | + */ | ||
| 45 | + public FilteredAnnotation(Annotations delegate, Set<String> keys) { | ||
| 46 | + this.delegate = checkNotNull(delegate); | ||
| 47 | + this.filtered = ImmutableSet.copyOf(keys); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public String value(String key) { | ||
| 52 | + if (filtered.contains(key)) { | ||
| 53 | + return null; | ||
| 54 | + } | ||
| 55 | + return delegate.value(key); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public Set<String> keys() { | ||
| 60 | + return Sets.difference(delegate.keys(), filtered); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + public String toString() { | ||
| 65 | + Map<String, String> mapView = new HashMap<>(); | ||
| 66 | + keys().forEach(key -> mapView.put(key, delegate.value(key))); | ||
| 67 | + return mapView.toString(); | ||
| 68 | + } | ||
| 69 | +} |
| ... | @@ -38,6 +38,7 @@ import org.slf4j.Logger; | ... | @@ -38,6 +38,7 @@ import org.slf4j.Logger; |
| 38 | import com.fasterxml.jackson.databind.ObjectMapper; | 38 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 39 | import com.fasterxml.jackson.databind.node.ObjectNode; | 39 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 40 | import com.google.common.annotations.Beta; | 40 | import com.google.common.annotations.Beta; |
| 41 | +import com.google.common.collect.ImmutableSet; | ||
| 41 | 42 | ||
| 42 | /** | 43 | /** |
| 43 | * OCh port related helpers. | 44 | * OCh port related helpers. |
| ... | @@ -151,6 +152,16 @@ public final class OchPortHelper { | ... | @@ -151,6 +152,16 @@ public final class OchPortHelper { |
| 151 | } | 152 | } |
| 152 | } | 153 | } |
| 153 | 154 | ||
| 155 | + /** | ||
| 156 | + * Returns {@link Annotations} not used by the port type projection. | ||
| 157 | + * | ||
| 158 | + * @param input {@link Annotations} | ||
| 159 | + * @return filtered view of given {@link Annotations} | ||
| 160 | + */ | ||
| 161 | + public static Annotations stripHandledAnnotations(Annotations input) { | ||
| 162 | + return new FilteredAnnotation(input, ImmutableSet.of(SIGNAL_TYPE, TUNABLE, LAMBDA)); | ||
| 163 | + } | ||
| 164 | + | ||
| 154 | // not meant to be instantiated | 165 | // not meant to be instantiated |
| 155 | private OchPortHelper() {} | 166 | private OchPortHelper() {} |
| 156 | } | 167 | } | ... | ... |
| ... | @@ -33,6 +33,7 @@ import org.onosproject.net.optical.impl.DefaultOduCltPort; | ... | @@ -33,6 +33,7 @@ import org.onosproject.net.optical.impl.DefaultOduCltPort; |
| 33 | import org.slf4j.Logger; | 33 | import org.slf4j.Logger; |
| 34 | 34 | ||
| 35 | import com.google.common.annotations.Beta; | 35 | import com.google.common.annotations.Beta; |
| 36 | +import com.google.common.collect.ImmutableSet; | ||
| 36 | 37 | ||
| 37 | /** | 38 | /** |
| 38 | * ODU client port related helpers. | 39 | * ODU client port related helpers. |
| ... | @@ -122,6 +123,16 @@ public final class OduCltPortHelper { | ... | @@ -122,6 +123,16 @@ public final class OduCltPortHelper { |
| 122 | } | 123 | } |
| 123 | } | 124 | } |
| 124 | 125 | ||
| 126 | + /** | ||
| 127 | + * Returns {@link Annotations} not used by the port type projection. | ||
| 128 | + * | ||
| 129 | + * @param input {@link Annotations} | ||
| 130 | + * @return filtered view of given {@link Annotations} | ||
| 131 | + */ | ||
| 132 | + public static Annotations stripHandledAnnotations(Annotations input) { | ||
| 133 | + return new FilteredAnnotation(input, ImmutableSet.of(SIGNAL_TYPE)); | ||
| 134 | + } | ||
| 135 | + | ||
| 125 | // not meant to be instantiated | 136 | // not meant to be instantiated |
| 126 | private OduCltPortHelper() {} | 137 | private OduCltPortHelper() {} |
| 127 | } | 138 | } | ... | ... |
| ... | @@ -33,6 +33,7 @@ import org.onosproject.net.optical.impl.DefaultOmsPort; | ... | @@ -33,6 +33,7 @@ import org.onosproject.net.optical.impl.DefaultOmsPort; |
| 33 | import org.slf4j.Logger; | 33 | import org.slf4j.Logger; |
| 34 | 34 | ||
| 35 | import com.google.common.annotations.Beta; | 35 | import com.google.common.annotations.Beta; |
| 36 | +import com.google.common.collect.ImmutableSet; | ||
| 36 | 37 | ||
| 37 | /** | 38 | /** |
| 38 | * OMS port related helpers. | 39 | * OMS port related helpers. |
| ... | @@ -142,6 +143,16 @@ public final class OmsPortHelper { | ... | @@ -142,6 +143,16 @@ public final class OmsPortHelper { |
| 142 | } | 143 | } |
| 143 | } | 144 | } |
| 144 | 145 | ||
| 146 | + /** | ||
| 147 | + * Returns {@link Annotations} not used by the port type projection. | ||
| 148 | + * | ||
| 149 | + * @param input {@link Annotations} | ||
| 150 | + * @return filtered view of given {@link Annotations} | ||
| 151 | + */ | ||
| 152 | + public static Annotations stripHandledAnnotations(Annotations input) { | ||
| 153 | + return new FilteredAnnotation(input, ImmutableSet.of(MIN_FREQ_HZ, MAX_FREQ_HZ, GRID_HZ)); | ||
| 154 | + } | ||
| 155 | + | ||
| 145 | // not meant to be instantiated | 156 | // not meant to be instantiated |
| 146 | private OmsPortHelper() {} | 157 | private OmsPortHelper() {} |
| 147 | } | 158 | } | ... | ... |
| ... | @@ -33,6 +33,7 @@ import org.onosproject.net.optical.impl.DefaultOtuPort; | ... | @@ -33,6 +33,7 @@ import org.onosproject.net.optical.impl.DefaultOtuPort; |
| 33 | import org.slf4j.Logger; | 33 | import org.slf4j.Logger; |
| 34 | 34 | ||
| 35 | import com.google.common.annotations.Beta; | 35 | import com.google.common.annotations.Beta; |
| 36 | +import com.google.common.collect.ImmutableSet; | ||
| 36 | 37 | ||
| 37 | /** | 38 | /** |
| 38 | * OTU port related helpers. | 39 | * OTU port related helpers. |
| ... | @@ -122,6 +123,15 @@ public final class OtuPortHelper { | ... | @@ -122,6 +123,15 @@ public final class OtuPortHelper { |
| 122 | } | 123 | } |
| 123 | } | 124 | } |
| 124 | 125 | ||
| 126 | + /** | ||
| 127 | + * Returns {@link Annotations} not used by the port type projection. | ||
| 128 | + * | ||
| 129 | + * @param input {@link Annotations} | ||
| 130 | + * @return filtered view of given {@link Annotations} | ||
| 131 | + */ | ||
| 132 | + public static Annotations stripHandledAnnotations(Annotations input) { | ||
| 133 | + return new FilteredAnnotation(input, ImmutableSet.of(SIGNAL_TYPE)); | ||
| 134 | + } | ||
| 125 | 135 | ||
| 126 | // not meant to be instantiated | 136 | // not meant to be instantiated |
| 127 | private OtuPortHelper() {} | 137 | private OtuPortHelper() {} | ... | ... |
| ... | @@ -25,6 +25,7 @@ import org.onosproject.net.utils.ForwardingPort; | ... | @@ -25,6 +25,7 @@ import org.onosproject.net.utils.ForwardingPort; |
| 25 | import com.google.common.annotations.Beta; | 25 | import com.google.common.annotations.Beta; |
| 26 | 26 | ||
| 27 | import static com.google.common.base.Preconditions.checkNotNull; | 27 | import static com.google.common.base.Preconditions.checkNotNull; |
| 28 | +import static org.onosproject.net.optical.device.OchPortHelper.stripHandledAnnotations; | ||
| 28 | 29 | ||
| 29 | import java.util.Objects; | 30 | import java.util.Objects; |
| 30 | 31 | ||
| ... | @@ -71,12 +72,9 @@ public class DefaultOchPort extends ForwardingPort implements OchPort { | ... | @@ -71,12 +72,9 @@ public class DefaultOchPort extends ForwardingPort implements OchPort { |
| 71 | return signalType.bitRate(); | 72 | return signalType.bitRate(); |
| 72 | } | 73 | } |
| 73 | 74 | ||
| 74 | - | ||
| 75 | @Override | 75 | @Override |
| 76 | - public Annotations annotations() { | 76 | + public Annotations unhandledAnnotations() { |
| 77 | - // FIXME Filter OCh annotations, after confirming that | 77 | + return stripHandledAnnotations(super.annotations()); |
| 78 | - // it'll not result in information-loss | ||
| 79 | - return super.annotations(); | ||
| 80 | } | 78 | } |
| 81 | 79 | ||
| 82 | /** | 80 | /** |
| ... | @@ -140,6 +138,7 @@ public class DefaultOchPort extends ForwardingPort implements OchPort { | ... | @@ -140,6 +138,7 @@ public class DefaultOchPort extends ForwardingPort implements OchPort { |
| 140 | .add("signalType", signalType()) | 138 | .add("signalType", signalType()) |
| 141 | .add("isTunable", isTunable()) | 139 | .add("isTunable", isTunable()) |
| 142 | .add("lambda", lambda()) | 140 | .add("lambda", lambda()) |
| 141 | + .add("annotations", unhandledAnnotations()) | ||
| 143 | .toString(); | 142 | .toString(); |
| 144 | } | 143 | } |
| 145 | } | 144 | } | ... | ... |
| ... | @@ -16,9 +16,11 @@ | ... | @@ -16,9 +16,11 @@ |
| 16 | package org.onosproject.net.optical.impl; | 16 | package org.onosproject.net.optical.impl; |
| 17 | 17 | ||
| 18 | import static com.google.common.base.Preconditions.checkNotNull; | 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | +import static org.onosproject.net.optical.device.OduCltPortHelper.stripHandledAnnotations; | ||
| 19 | 20 | ||
| 20 | import java.util.Objects; | 21 | import java.util.Objects; |
| 21 | 22 | ||
| 23 | +import org.onosproject.net.Annotations; | ||
| 22 | import org.onosproject.net.CltSignalType; | 24 | import org.onosproject.net.CltSignalType; |
| 23 | import org.onosproject.net.Port; | 25 | import org.onosproject.net.Port; |
| 24 | import org.onosproject.net.optical.OduCltPort; | 26 | import org.onosproject.net.optical.OduCltPort; |
| ... | @@ -58,6 +60,11 @@ public class DefaultOduCltPort extends ForwardingPort implements OduCltPort { | ... | @@ -58,6 +60,11 @@ public class DefaultOduCltPort extends ForwardingPort implements OduCltPort { |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | @Override | 62 | @Override |
| 63 | + public Annotations unhandledAnnotations() { | ||
| 64 | + return stripHandledAnnotations(super.annotations()); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @Override | ||
| 61 | public CltSignalType signalType() { | 68 | public CltSignalType signalType() { |
| 62 | return signalType; | 69 | return signalType; |
| 63 | } | 70 | } |
| ... | @@ -87,6 +94,7 @@ public class DefaultOduCltPort extends ForwardingPort implements OduCltPort { | ... | @@ -87,6 +94,7 @@ public class DefaultOduCltPort extends ForwardingPort implements OduCltPort { |
| 87 | public String toString() { | 94 | public String toString() { |
| 88 | return super.toStringHelper() | 95 | return super.toStringHelper() |
| 89 | .add("signalType", signalType()) | 96 | .add("signalType", signalType()) |
| 97 | + .add("annotations", unhandledAnnotations()) | ||
| 90 | .toString(); | 98 | .toString(); |
| 91 | } | 99 | } |
| 92 | 100 | ... | ... |
| ... | @@ -16,10 +16,12 @@ | ... | @@ -16,10 +16,12 @@ |
| 16 | package org.onosproject.net.optical.impl; | 16 | package org.onosproject.net.optical.impl; |
| 17 | 17 | ||
| 18 | import static com.google.common.base.Preconditions.checkNotNull; | 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | +import static org.onosproject.net.optical.device.OmsPortHelper.stripHandledAnnotations; | ||
| 19 | 20 | ||
| 20 | import java.util.Objects; | 21 | import java.util.Objects; |
| 21 | 22 | ||
| 22 | import org.onlab.util.Frequency; | 23 | import org.onlab.util.Frequency; |
| 24 | +import org.onosproject.net.Annotations; | ||
| 23 | import org.onosproject.net.Port; | 25 | import org.onosproject.net.Port; |
| 24 | import org.onosproject.net.optical.OmsPort; | 26 | import org.onosproject.net.optical.OmsPort; |
| 25 | import org.onosproject.net.utils.ForwardingPort; | 27 | import org.onosproject.net.utils.ForwardingPort; |
| ... | @@ -67,6 +69,12 @@ public class DefaultOmsPort extends ForwardingPort implements OmsPort { | ... | @@ -67,6 +69,12 @@ public class DefaultOmsPort extends ForwardingPort implements OmsPort { |
| 67 | } | 69 | } |
| 68 | 70 | ||
| 69 | @Override | 71 | @Override |
| 72 | + public Annotations unhandledAnnotations() { | ||
| 73 | + return stripHandledAnnotations(super.annotations()); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + | ||
| 77 | + @Override | ||
| 70 | public Frequency minFrequency() { | 78 | public Frequency minFrequency() { |
| 71 | return minFrequency; | 79 | return minFrequency; |
| 72 | } | 80 | } |
| ... | @@ -112,6 +120,7 @@ public class DefaultOmsPort extends ForwardingPort implements OmsPort { | ... | @@ -112,6 +120,7 @@ public class DefaultOmsPort extends ForwardingPort implements OmsPort { |
| 112 | .add("minFrequency", minFrequency()) | 120 | .add("minFrequency", minFrequency()) |
| 113 | .add("maxFrequency", maxFrequency()) | 121 | .add("maxFrequency", maxFrequency()) |
| 114 | .add("grid", grid()) | 122 | .add("grid", grid()) |
| 123 | + .add("annotations", unhandledAnnotations()) | ||
| 115 | .toString(); | 124 | .toString(); |
| 116 | } | 125 | } |
| 117 | 126 | ... | ... |
| ... | @@ -16,9 +16,11 @@ | ... | @@ -16,9 +16,11 @@ |
| 16 | package org.onosproject.net.optical.impl; | 16 | package org.onosproject.net.optical.impl; |
| 17 | 17 | ||
| 18 | import static com.google.common.base.Preconditions.checkNotNull; | 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | +import static org.onosproject.net.optical.device.OtuPortHelper.stripHandledAnnotations; | ||
| 19 | 20 | ||
| 20 | import java.util.Objects; | 21 | import java.util.Objects; |
| 21 | 22 | ||
| 23 | +import org.onosproject.net.Annotations; | ||
| 22 | import org.onosproject.net.OtuSignalType; | 24 | import org.onosproject.net.OtuSignalType; |
| 23 | import org.onosproject.net.Port; | 25 | import org.onosproject.net.Port; |
| 24 | import org.onosproject.net.optical.OtuPort; | 26 | import org.onosproject.net.optical.OtuPort; |
| ... | @@ -57,6 +59,11 @@ public class DefaultOtuPort extends ForwardingPort implements OtuPort { | ... | @@ -57,6 +59,11 @@ public class DefaultOtuPort extends ForwardingPort implements OtuPort { |
| 57 | // } | 59 | // } |
| 58 | 60 | ||
| 59 | @Override | 61 | @Override |
| 62 | + public Annotations unhandledAnnotations() { | ||
| 63 | + return stripHandledAnnotations(super.annotations()); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Override | ||
| 60 | public OtuSignalType signalType() { | 67 | public OtuSignalType signalType() { |
| 61 | return signalType; | 68 | return signalType; |
| 62 | } | 69 | } |
| ... | @@ -86,6 +93,7 @@ public class DefaultOtuPort extends ForwardingPort implements OtuPort { | ... | @@ -86,6 +93,7 @@ public class DefaultOtuPort extends ForwardingPort implements OtuPort { |
| 86 | public String toString() { | 93 | public String toString() { |
| 87 | return super.toStringHelper() | 94 | return super.toStringHelper() |
| 88 | .add("signalType", signalType()) | 95 | .add("signalType", signalType()) |
| 96 | + .add("annotations", unhandledAnnotations()) | ||
| 89 | .toString(); | 97 | .toString(); |
| 90 | } | 98 | } |
| 91 | 99 | ... | ... |
| 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 | +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> | ||
| 17 | + | ||
| 18 | + <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> | ||
| 19 | + <command> | ||
| 20 | + <action class="org.onosproject.net.optical.cli.AddOpticalIntentCommand"/> | ||
| 21 | + <completers> | ||
| 22 | + <ref component-id="connectPointCompleter"/> | ||
| 23 | + <ref component-id="connectPointCompleter"/> | ||
| 24 | + </completers> | ||
| 25 | + <optional-completers> | ||
| 26 | + <entry key="-a" value-ref="allAppNameCompleter"/> | ||
| 27 | + </optional-completers> | ||
| 28 | + </command> | ||
| 29 | + <command> | ||
| 30 | + <action class="org.onosproject.net.optical.cli.OpticalPortsListCommand"/> | ||
| 31 | + <completers> | ||
| 32 | + <ref component-id="deviceIdCompleter"/> | ||
| 33 | + </completers> | ||
| 34 | + </command> | ||
| 35 | + </command-bundle> | ||
| 36 | + | ||
| 37 | + <bean id="connectPointCompleter" class="org.onosproject.cli.net.ConnectPointCompleter"/> | ||
| 38 | + <bean id="allAppNameCompleter" class="org.onosproject.cli.app.AllApplicationNamesCompleter"/> | ||
| 39 | + <bean id="deviceIdCompleter" class="org.onosproject.cli.net.DeviceIdCompleter"/> | ||
| 40 | + | ||
| 41 | +</blueprint> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -5,8 +5,6 @@ COMPILE_DEPS = [ | ... | @@ -5,8 +5,6 @@ COMPILE_DEPS = [ |
| 5 | '//incubator/net:onos-incubator-net', | 5 | '//incubator/net:onos-incubator-net', |
| 6 | '//utils/rest:onlab-rest', | 6 | '//utils/rest:onlab-rest', |
| 7 | '//core/common:onos-core-common', | 7 | '//core/common:onos-core-common', |
| 8 | - # TODO Remove after decoupling optical | ||
| 9 | - '//apps/optical-model:onos-apps-optical-model', | ||
| 10 | ] | 8 | ] |
| 11 | 9 | ||
| 12 | osgi_jar ( | 10 | osgi_jar ( | ... | ... |
| ... | @@ -49,13 +49,6 @@ | ... | @@ -49,13 +49,6 @@ |
| 49 | <artifactId>onos-core-common</artifactId> | 49 | <artifactId>onos-core-common</artifactId> |
| 50 | </dependency> | 50 | </dependency> |
| 51 | 51 | ||
| 52 | - <!-- TODO Remove after decoupling optical --> | ||
| 53 | - <dependency> | ||
| 54 | - <groupId>org.onosproject</groupId> | ||
| 55 | - <artifactId>onos-optical-model</artifactId> | ||
| 56 | - <version>${project.version}</version> | ||
| 57 | - </dependency> | ||
| 58 | - | ||
| 59 | <dependency> | 52 | <dependency> |
| 60 | <groupId>com.fasterxml.jackson.core</groupId> | 53 | <groupId>com.fasterxml.jackson.core</groupId> |
| 61 | <artifactId>jackson-databind</artifactId> | 54 | <artifactId>jackson-databind</artifactId> | ... | ... |
| ... | @@ -22,24 +22,15 @@ import com.fasterxml.jackson.databind.node.ObjectNode; | ... | @@ -22,24 +22,15 @@ import com.fasterxml.jackson.databind.node.ObjectNode; |
| 22 | import org.apache.karaf.shell.commands.Argument; | 22 | import org.apache.karaf.shell.commands.Argument; |
| 23 | import org.apache.karaf.shell.commands.Command; | 23 | import org.apache.karaf.shell.commands.Command; |
| 24 | import org.apache.karaf.shell.commands.Option; | 24 | import org.apache.karaf.shell.commands.Option; |
| 25 | -import org.onlab.util.Frequency; | ||
| 26 | import org.onosproject.utils.Comparators; | 25 | import org.onosproject.utils.Comparators; |
| 27 | import org.onosproject.net.Device; | 26 | import org.onosproject.net.Device; |
| 28 | import org.onosproject.net.Port; | 27 | import org.onosproject.net.Port; |
| 29 | -import org.onosproject.net.PortNumber; | ||
| 30 | import org.onosproject.net.device.DeviceService; | 28 | import org.onosproject.net.device.DeviceService; |
| 31 | -import org.onosproject.net.optical.OchPort; | ||
| 32 | -import org.onosproject.net.optical.OduCltPort; | ||
| 33 | -import org.onosproject.net.optical.OmsPort; | ||
| 34 | -import org.onosproject.net.optical.OpticalDevice; | ||
| 35 | -import org.onosproject.net.optical.OtuPort; | ||
| 36 | - | ||
| 37 | import java.util.ArrayList; | 29 | import java.util.ArrayList; |
| 38 | import java.util.Collections; | 30 | import java.util.Collections; |
| 39 | import java.util.List; | 31 | import java.util.List; |
| 40 | 32 | ||
| 41 | import static org.onosproject.net.DeviceId.deviceId; | 33 | import static org.onosproject.net.DeviceId.deviceId; |
| 42 | -import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView; | ||
| 43 | 34 | ||
| 44 | /** | 35 | /** |
| 45 | * Lists all ports or all ports of a device. | 36 | * Lists all ports or all ports of a device. |
| ... | @@ -49,9 +40,6 @@ import static org.onosproject.net.optical.device.OpticalDeviceServiceView.optica | ... | @@ -49,9 +40,6 @@ import static org.onosproject.net.optical.device.OpticalDeviceServiceView.optica |
| 49 | public class DevicePortsListCommand extends DevicesListCommand { | 40 | public class DevicePortsListCommand extends DevicesListCommand { |
| 50 | 41 | ||
| 51 | private static final String FMT = " port=%s, state=%s, type=%s, speed=%s %s"; | 42 | private static final String FMT = " port=%s, state=%s, type=%s, speed=%s %s"; |
| 52 | - private static final String FMT_OCH = " port=%s, state=%s, type=%s, signalType=%s, isTunable=%s %s"; | ||
| 53 | - private static final String FMT_ODUCLT_OTU = " port=%s, state=%s, type=%s, signalType=%s %s"; | ||
| 54 | - private static final String FMT_OMS = " port=%s, state=%s, type=%s, Freqs= %s / %s / %s GHz, totalChannels=%s %s"; | ||
| 55 | 43 | ||
| 56 | @Option(name = "-e", aliases = "--enabled", description = "Show only enabled ports", | 44 | @Option(name = "-e", aliases = "--enabled", description = "Show only enabled ports", |
| 57 | required = false, multiValued = false) | 45 | required = false, multiValued = false) |
| ... | @@ -63,17 +51,18 @@ public class DevicePortsListCommand extends DevicesListCommand { | ... | @@ -63,17 +51,18 @@ public class DevicePortsListCommand extends DevicesListCommand { |
| 63 | 51 | ||
| 64 | @Argument(index = 0, name = "uri", description = "Device ID", | 52 | @Argument(index = 0, name = "uri", description = "Device ID", |
| 65 | required = false, multiValued = false) | 53 | required = false, multiValued = false) |
| 66 | - String uri = null; | 54 | + protected String uri = null; |
| 67 | 55 | ||
| 68 | @Override | 56 | @Override |
| 69 | protected void execute() { | 57 | protected void execute() { |
| 70 | - DeviceService service = opticalView(get(DeviceService.class)); | 58 | + DeviceService service = get(DeviceService.class); |
| 71 | if (uri == null) { | 59 | if (uri == null) { |
| 72 | if (outputJson()) { | 60 | if (outputJson()) { |
| 73 | print("%s", jsonPorts(service, getSortedDevices(service))); | 61 | print("%s", jsonPorts(service, getSortedDevices(service))); |
| 74 | } else { | 62 | } else { |
| 75 | for (Device device : getSortedDevices(service)) { | 63 | for (Device device : getSortedDevices(service)) { |
| 76 | printDevice(service, device); | 64 | printDevice(service, device); |
| 65 | + printPorts(service, device); | ||
| 77 | } | 66 | } |
| 78 | } | 67 | } |
| 79 | 68 | ||
| ... | @@ -85,6 +74,7 @@ public class DevicePortsListCommand extends DevicesListCommand { | ... | @@ -85,6 +74,7 @@ public class DevicePortsListCommand extends DevicesListCommand { |
| 85 | print("%s", jsonPorts(service, new ObjectMapper(), device)); | 74 | print("%s", jsonPorts(service, new ObjectMapper(), device)); |
| 86 | } else { | 75 | } else { |
| 87 | printDevice(service, device); | 76 | printDevice(service, device); |
| 77 | + printPorts(service, device); | ||
| 88 | } | 78 | } |
| 89 | } | 79 | } |
| 90 | } | 80 | } |
| ... | @@ -119,7 +109,7 @@ public class DevicePortsListCommand extends DevicesListCommand { | ... | @@ -119,7 +109,7 @@ public class DevicePortsListCommand extends DevicesListCommand { |
| 119 | for (Port port : service.getPorts(device.id())) { | 109 | for (Port port : service.getPorts(device.id())) { |
| 120 | if (isIncluded(port)) { | 110 | if (isIncluded(port)) { |
| 121 | ports.add(mapper.createObjectNode() | 111 | ports.add(mapper.createObjectNode() |
| 122 | - .put("port", portName(port.number())) | 112 | + .put("port", port.number().toString()) |
| 123 | .put("isEnabled", port.isEnabled()) | 113 | .put("isEnabled", port.isEnabled()) |
| 124 | .put("type", port.type().toString().toLowerCase()) | 114 | .put("type", port.type().toString().toLowerCase()) |
| 125 | .put("portSpeed", port.portSpeed()) | 115 | .put("portSpeed", port.portSpeed()) |
| ... | @@ -131,122 +121,24 @@ public class DevicePortsListCommand extends DevicesListCommand { | ... | @@ -131,122 +121,24 @@ public class DevicePortsListCommand extends DevicesListCommand { |
| 131 | return result; | 121 | return result; |
| 132 | } | 122 | } |
| 133 | 123 | ||
| 134 | - private String portName(PortNumber port) { | ||
| 135 | - return port.equals(PortNumber.LOCAL) ? "local" : port.toString(); | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | // Determines if a port should be included in output. | 124 | // Determines if a port should be included in output. |
| 139 | - private boolean isIncluded(Port port) { | 125 | + protected boolean isIncluded(Port port) { |
| 140 | return enabled && port.isEnabled() || disabled && !port.isEnabled() || | 126 | return enabled && port.isEnabled() || disabled && !port.isEnabled() || |
| 141 | !enabled && !disabled; | 127 | !enabled && !disabled; |
| 142 | } | 128 | } |
| 143 | 129 | ||
| 144 | - @Override | 130 | + protected void printPorts(DeviceService service, Device device) { |
| 145 | - protected void printDevice(DeviceService service, Device device) { | ||
| 146 | - super.printDevice(service, device); | ||
| 147 | List<Port> ports = new ArrayList<>(service.getPorts(device.id())); | 131 | List<Port> ports = new ArrayList<>(service.getPorts(device.id())); |
| 148 | Collections.sort(ports, Comparators.PORT_COMPARATOR); | 132 | Collections.sort(ports, Comparators.PORT_COMPARATOR); |
| 149 | for (Port port : ports) { | 133 | for (Port port : ports) { |
| 150 | if (!isIncluded(port)) { | 134 | if (!isIncluded(port)) { |
| 151 | continue; | 135 | continue; |
| 152 | } | 136 | } |
| 153 | - String portName = portName(port.number()); | 137 | + String portName = port.number().toString(); |
| 154 | Object portIsEnabled = port.isEnabled() ? "enabled" : "disabled"; | 138 | Object portIsEnabled = port.isEnabled() ? "enabled" : "disabled"; |
| 155 | String portType = port.type().toString().toLowerCase(); | 139 | String portType = port.type().toString().toLowerCase(); |
| 156 | String annotations = annotations(port.annotations()); | 140 | String annotations = annotations(port.annotations()); |
| 157 | - switch (port.type()) { | 141 | + print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); |
| 158 | - case OCH: | ||
| 159 | - if (port instanceof org.onosproject.net.OchPort) { | ||
| 160 | - // old OchPort model | ||
| 161 | - org.onosproject.net.OchPort oPort = (org.onosproject.net.OchPort) port; | ||
| 162 | - print("WARN: OchPort in old model"); | ||
| 163 | - print(FMT_OCH, portName, portIsEnabled, portType, | ||
| 164 | - oPort.signalType().toString(), | ||
| 165 | - oPort.isTunable() ? "yes" : "no", annotations); | ||
| 166 | - break; | ||
| 167 | - } | ||
| 168 | - if (port instanceof OchPort) { | ||
| 169 | - OchPort och = (OchPort) port; | ||
| 170 | - print(FMT_OCH, portName, portIsEnabled, portType, | ||
| 171 | - och.signalType().toString(), | ||
| 172 | - och.isTunable() ? "yes" : "no", annotations); | ||
| 173 | - break; | ||
| 174 | - } else if (port.element().is(OpticalDevice.class)) { | ||
| 175 | - // Note: should never reach here, but | ||
| 176 | - // leaving it here as an example to | ||
| 177 | - // manually translate to specific port. | ||
| 178 | - OpticalDevice optDevice = port.element().as(OpticalDevice.class); | ||
| 179 | - if (optDevice.portIs(port, OchPort.class)) { | ||
| 180 | - OchPort och = optDevice.portAs(port, OchPort.class).get(); | ||
| 181 | - print(FMT_OCH, portName, portIsEnabled, portType, | ||
| 182 | - och.signalType().toString(), | ||
| 183 | - och.isTunable() ? "yes" : "no", annotations); | ||
| 184 | - break; | ||
| 185 | - } | ||
| 186 | - } | ||
| 187 | - print("WARN: OchPort but not on OpticalDevice or ill-formed"); | ||
| 188 | - print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); | ||
| 189 | - break; | ||
| 190 | - case ODUCLT: | ||
| 191 | - if (port instanceof org.onosproject.net.OduCltPort) { | ||
| 192 | - // old OduCltPort model | ||
| 193 | - org.onosproject.net.OduCltPort oPort = (org.onosproject.net.OduCltPort) port; | ||
| 194 | - print("WARN: OduCltPort in old model"); | ||
| 195 | - print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, | ||
| 196 | - oPort.signalType().toString(), annotations); | ||
| 197 | - break; | ||
| 198 | - } | ||
| 199 | - if (port instanceof OduCltPort) { | ||
| 200 | - print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, | ||
| 201 | - ((OduCltPort) port).signalType().toString(), annotations); | ||
| 202 | - break; | ||
| 203 | - } | ||
| 204 | - print("WARN: OduCltPort but not on OpticalDevice or ill-formed"); | ||
| 205 | - print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); | ||
| 206 | - break; | ||
| 207 | - case OMS: | ||
| 208 | - if (port instanceof org.onosproject.net.OmsPort) { | ||
| 209 | - org.onosproject.net.OmsPort oms = (org.onosproject.net.OmsPort) port; | ||
| 210 | - print("WARN: OmsPort in old model"); | ||
| 211 | - print(FMT_OMS, portName, portIsEnabled, portType, | ||
| 212 | - oms.minFrequency().asHz() / Frequency.ofGHz(1).asHz(), | ||
| 213 | - oms.maxFrequency().asHz() / Frequency.ofGHz(1).asHz(), | ||
| 214 | - oms.grid().asHz() / Frequency.ofGHz(1).asHz(), | ||
| 215 | - oms.totalChannels(), annotations); | ||
| 216 | - break; | ||
| 217 | - } | ||
| 218 | - if (port instanceof OmsPort) { | ||
| 219 | - OmsPort oms = (OmsPort) port; | ||
| 220 | - print(FMT_OMS, portName, portIsEnabled, portType, | ||
| 221 | - oms.minFrequency().asHz() / Frequency.ofGHz(1).asHz(), | ||
| 222 | - oms.maxFrequency().asHz() / Frequency.ofGHz(1).asHz(), | ||
| 223 | - oms.grid().asHz() / Frequency.ofGHz(1).asHz(), | ||
| 224 | - oms.totalChannels(), annotations); | ||
| 225 | - break; | ||
| 226 | - } | ||
| 227 | - print("WARN: OmsPort but not on OpticalDevice or ill-formed"); | ||
| 228 | - print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); | ||
| 229 | - break; | ||
| 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) { | ||
| 239 | - print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, | ||
| 240 | - ((OtuPort) port).signalType().toString(), annotations); | ||
| 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; | ||
| 246 | - default: | ||
| 247 | - print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); | ||
| 248 | - break; | ||
| 249 | - } | ||
| 250 | } | 142 | } |
| 251 | } | 143 | } |
| 252 | } | 144 | } | ... | ... |
| ... | @@ -292,16 +292,6 @@ | ... | @@ -292,16 +292,6 @@ |
| 292 | </optional-completers> | 292 | </optional-completers> |
| 293 | </command> | 293 | </command> |
| 294 | <command> | 294 | <command> |
| 295 | - <action class="org.onosproject.cli.net.AddOpticalIntentCommand"/> | ||
| 296 | - <completers> | ||
| 297 | - <ref component-id="connectPointCompleter"/> | ||
| 298 | - <ref component-id="connectPointCompleter"/> | ||
| 299 | - </completers> | ||
| 300 | - <optional-completers> | ||
| 301 | - <entry key="-a" value-ref="allAppNameCompleter"/> | ||
| 302 | - </optional-completers> | ||
| 303 | - </command> | ||
| 304 | - <command> | ||
| 305 | <action class="org.onosproject.cli.net.GetStatisticsCommand"/> | 295 | <action class="org.onosproject.cli.net.GetStatisticsCommand"/> |
| 306 | <completers> | 296 | <completers> |
| 307 | <ref component-id="connectPointCompleter"/> | 297 | <ref component-id="connectPointCompleter"/> | ... | ... |
| ... | @@ -128,8 +128,6 @@ osgi_feature ( | ... | @@ -128,8 +128,6 @@ osgi_feature ( |
| 128 | required_features = ['onos-api'], | 128 | required_features = ['onos-api'], |
| 129 | included_bundles = [ | 129 | included_bundles = [ |
| 130 | '//cli:onos-cli', | 130 | '//cli:onos-cli', |
| 131 | - # TODO Remove after decoupling optical | ||
| 132 | - '//apps/optical-model:onos-apps-optical-model', | ||
| 133 | ] | 131 | ] |
| 134 | ) | 132 | ) |
| 135 | 133 | ... | ... |
| ... | @@ -142,8 +142,6 @@ | ... | @@ -142,8 +142,6 @@ |
| 142 | description="ONOS admin command console components"> | 142 | description="ONOS admin command console components"> |
| 143 | <feature>onos-api</feature> | 143 | <feature>onos-api</feature> |
| 144 | <bundle>mvn:org.onosproject/onos-cli/@ONOS-VERSION</bundle> | 144 | <bundle>mvn:org.onosproject/onos-cli/@ONOS-VERSION</bundle> |
| 145 | - <!-- TODO Remove after decoupling optical --> | ||
| 146 | - <bundle>mvn:org.onosproject/onos-optical-model/@ONOS-VERSION</bundle> | ||
| 147 | </feature> | 145 | </feature> |
| 148 | 146 | ||
| 149 | <feature name="onos-security" version="@FEATURE-VERSION" | 147 | <feature name="onos-security" version="@FEATURE-VERSION" | ... | ... |
| ... | @@ -33,6 +33,7 @@ | ... | @@ -33,6 +33,7 @@ |
| 33 | <onos.app.title>OpenFlow Meta App</onos.app.title> | 33 | <onos.app.title>OpenFlow Meta App</onos.app.title> |
| 34 | <onos.app.category>Provider</onos.app.category> | 34 | <onos.app.category>Provider</onos.app.category> |
| 35 | <onos.app.requires> | 35 | <onos.app.requires> |
| 36 | + org.onosproject.optical-model, | ||
| 36 | org.onosproject.openflow-base, | 37 | org.onosproject.openflow-base, |
| 37 | org.onosproject.hostprovider, | 38 | org.onosproject.hostprovider, |
| 38 | org.onosproject.lldpprovider | 39 | org.onosproject.lldpprovider | ... | ... |
-
Please register or login to post a comment