Yuta HIGUCHI | 69ef9dd | 2017-03-10 16:01:11 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-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.driver.optical.config; |
| 17 | |
| 18 | import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription; |
| 19 | |
| 20 | import java.util.List; |
| 21 | import java.util.stream.Collectors; |
| 22 | import java.util.stream.LongStream; |
| 23 | |
| 24 | import org.onlab.packet.ChassisId; |
| 25 | import org.onlab.util.Frequency; |
| 26 | import org.onlab.util.Spectrum; |
| 27 | import org.onosproject.net.Device.Type; |
| 28 | import org.onosproject.net.DefaultAnnotations; |
| 29 | import org.onosproject.net.PortNumber; |
| 30 | import org.onosproject.net.SparseAnnotations; |
| 31 | import org.onosproject.net.device.DefaultDeviceDescription; |
| 32 | import org.onosproject.net.device.DeviceDescription; |
| 33 | import org.onosproject.net.device.DeviceDescriptionDiscovery; |
| 34 | import org.onosproject.net.device.PortDescription; |
| 35 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 36 | |
| 37 | /** |
| 38 | * DeviceDescriptionDiscovery for Polatis. |
| 39 | */ |
| 40 | public class PolatisDeviceDiscovery |
| 41 | extends AbstractHandlerBehaviour |
| 42 | implements DeviceDescriptionDiscovery { |
| 43 | |
| 44 | |
| 45 | @Override |
| 46 | public DeviceDescription discoverDeviceDetails() { |
| 47 | Type type = Type.FIBER_SWITCH; |
| 48 | String manufacturer = "Polatis"; |
| 49 | String hwVersion = "N-VST-48x48-HU1-DMHNV-805"; |
| 50 | String swVersion = "6.6.1.7"; |
| 51 | String serialNumber = "1503"; |
| 52 | ChassisId chassis = new ChassisId(); |
| 53 | boolean defaultAvailable = true; |
| 54 | SparseAnnotations annotations = DefaultAnnotations.builder().build(); |
| 55 | return new DefaultDeviceDescription(this.data().deviceId().uri(), |
| 56 | type, |
| 57 | manufacturer, |
| 58 | hwVersion, |
| 59 | swVersion, |
| 60 | serialNumber, |
| 61 | chassis, |
| 62 | defaultAvailable, |
| 63 | annotations); |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public List<PortDescription> discoverPortDetails() { |
| 68 | SparseAnnotations ingress = DefaultAnnotations.builder() |
| 69 | .set("port-type", "INGRESS_PORT") |
| 70 | .build(); |
| 71 | SparseAnnotations egress = DefaultAnnotations.builder() |
| 72 | .set("port-type", "EGRESS_PORT") |
| 73 | .build(); |
| 74 | return LongStream.rangeClosed(1, 96) |
| 75 | .mapToObj(n -> omsPortDescription(PortNumber.portNumber(n), |
| 76 | true, |
| 77 | Spectrum.U_BAND_MIN, |
| 78 | Spectrum.O_BAND_MAX, |
| 79 | Frequency.ofGHz(100), |
| 80 | (n <= 48) ? ingress : egress) |
| 81 | ) |
| 82 | .collect(Collectors.toList()); |
| 83 | } |
| 84 | |
| 85 | } |