Yuta HIGUCHI | 8c6e194 | 2018-04-05 13:40:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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.odtn.behaviour; |
| 17 | |
Yuta HIGUCHI | e4702af | 2018-05-18 17:17:34 -0700 | [diff] [blame^] | 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | |
Yuta HIGUCHI | 8c6e194 | 2018-04-05 13:40:51 -0700 | [diff] [blame] | 20 | import java.util.List; |
| 21 | |
| 22 | import org.onosproject.net.device.DeviceDescriptionDiscovery; |
| 23 | import org.onosproject.net.device.PortDescription; |
| 24 | |
Yuta HIGUCHI | 44e3a61 | 2018-05-11 15:03:39 -0700 | [diff] [blame] | 25 | import com.google.common.annotations.Beta; |
| 26 | |
Yuta HIGUCHI | 8c6e194 | 2018-04-05 13:40:51 -0700 | [diff] [blame] | 27 | /** |
| 28 | * DeviceDescriptionDiscovery used in ODTN. |
| 29 | * |
Yuta HIGUCHI | e9df0c4 | 2018-05-07 16:24:42 -0700 | [diff] [blame] | 30 | * Just declaring certain Annotations will be required. |
Yuta HIGUCHI | 8c6e194 | 2018-04-05 13:40:51 -0700 | [diff] [blame] | 31 | */ |
Yuta HIGUCHI | 44e3a61 | 2018-05-11 15:03:39 -0700 | [diff] [blame] | 32 | @Beta |
Yuta HIGUCHI | 8c6e194 | 2018-04-05 13:40:51 -0700 | [diff] [blame] | 33 | public interface OdtnDeviceDescriptionDiscovery |
| 34 | extends DeviceDescriptionDiscovery { |
| 35 | |
| 36 | /** |
Yuta HIGUCHI | 44e3a61 | 2018-05-11 15:03:39 -0700 | [diff] [blame] | 37 | * Annotations key intended for a Port, which stores OpenConfig component name. |
Yuta HIGUCHI | e4702af | 2018-05-18 17:17:34 -0700 | [diff] [blame^] | 38 | * <p> |
| 39 | * Optional; only for purpose of debugging. |
Yuta HIGUCHI | 8c6e194 | 2018-04-05 13:40:51 -0700 | [diff] [blame] | 40 | */ |
| 41 | String OC_NAME = "oc-name"; |
| 42 | |
| 43 | /** |
Yuta HIGUCHI | 44e3a61 | 2018-05-11 15:03:39 -0700 | [diff] [blame] | 44 | * Annotations key intended for a Port, which stores OpenConfig component type. |
Yuta HIGUCHI | e4702af | 2018-05-18 17:17:34 -0700 | [diff] [blame^] | 45 | * <p> |
| 46 | * Optional; only for purpose of debugging. |
Yuta HIGUCHI | 8c6e194 | 2018-04-05 13:40:51 -0700 | [diff] [blame] | 47 | */ |
| 48 | String OC_TYPE = "oc-type"; |
| 49 | |
Yuta HIGUCHI | 44e3a61 | 2018-05-11 15:03:39 -0700 | [diff] [blame] | 50 | /** |
| 51 | * Annotations key intended for a Port, |
| 52 | * which stores string identifier used to |
Yuta HIGUCHI | 4b11fab | 2018-05-15 13:03:29 -0700 | [diff] [blame] | 53 | * logically group Ports corresponding to a transponder, etc. |
Yuta HIGUCHI | 44e3a61 | 2018-05-11 15:03:39 -0700 | [diff] [blame] | 54 | */ |
Yuta HIGUCHI | 4b11fab | 2018-05-15 13:03:29 -0700 | [diff] [blame] | 55 | String CONNECTION_ID = "odtn-connection-id"; |
Yuta HIGUCHI | 44e3a61 | 2018-05-11 15:03:39 -0700 | [diff] [blame] | 56 | |
Yuta HIGUCHI | e4702af | 2018-05-18 17:17:34 -0700 | [diff] [blame^] | 57 | /** |
| 58 | * Annotations key for a Port, |
| 59 | * which describes role of the port annotated. |
| 60 | * Value must be one of “client” or “line”. |
| 61 | * |
| 62 | * @see OdtnPortType |
| 63 | */ |
| 64 | String PORT_TYPE = "odtn-port-type"; |
| 65 | |
| 66 | enum OdtnPortType { |
| 67 | CLIENT("client"), |
| 68 | LINE("line"); |
| 69 | |
| 70 | private final String value; |
| 71 | |
| 72 | OdtnPortType(String value) { |
| 73 | this.value = value; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Returns the value to be used as Annotations value. |
| 78 | * @return value |
| 79 | */ |
| 80 | public String value() { |
| 81 | return value; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Returns the corresponding enum value from a string value. |
| 86 | * @param value to look up |
| 87 | * @return OdtnPortType |
| 88 | * |
| 89 | * @throws NullPointerException if {@code value} was null |
| 90 | * @throws IllegalArgumentException if non-OdtnPortValue was given |
| 91 | */ |
| 92 | public static OdtnPortType fromValue(String value) { |
| 93 | checkNotNull(value); |
| 94 | if (value.equalsIgnoreCase(CLIENT.value())) { |
| 95 | return CLIENT; |
| 96 | } else if (value.equalsIgnoreCase(LINE.value())) { |
| 97 | return LINE; |
| 98 | } else { |
| 99 | throw new IllegalArgumentException("Invalid value: " + value); |
| 100 | } |
| 101 | } |
| 102 | } |
Yuta HIGUCHI | 44e3a61 | 2018-05-11 15:03:39 -0700 | [diff] [blame] | 103 | |
| 104 | /** |
| 105 | * OpenConfig component property name to store, |
| 106 | * decimal integer index to be used when creating PortNumber. |
Yuta HIGUCHI | e4702af | 2018-05-18 17:17:34 -0700 | [diff] [blame^] | 107 | * <p> |
| 108 | * Optional if providing original implementation other than |
| 109 | * odtn-driver supplied driver. |
Yuta HIGUCHI | 44e3a61 | 2018-05-11 15:03:39 -0700 | [diff] [blame] | 110 | */ |
| 111 | String ONOS_PORT_INDEX = "onos-index"; |
| 112 | |
Yuta HIGUCHI | 8c6e194 | 2018-04-05 13:40:51 -0700 | [diff] [blame] | 113 | // overriding just to make checkstyle happy |
| 114 | @Override |
| 115 | List<PortDescription> discoverPortDetails(); |
| 116 | |
| 117 | } |