Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net; |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * Collection of keys for annotation. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 20 | * <p> |
| 21 | * Number of the annotation keys have been deprecated as the use of annotations |
| 22 | * is being phased out and instead network configuration subsystem is being |
| 23 | * phased-in for majority of model meta-data. |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 24 | */ |
| 25 | public final class AnnotationKeys { |
| 26 | |
Simon Hunt | bc30e68 | 2017-02-15 18:39:23 -0800 | [diff] [blame] | 27 | private static final double DEFAULT_VALUE = 1.0; |
| 28 | |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 29 | // Prohibit instantiation |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame] | 30 | private AnnotationKeys() { |
| 31 | } |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 32 | |
| 33 | /** |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 34 | * Annotation key for instance name. |
| 35 | */ |
| 36 | public static final String NAME = "name"; |
| 37 | |
| 38 | /** |
| 39 | * Annotation key for instance type (e.g. host type). |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 40 | * |
| 41 | * @deprecated since Cardinal |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 42 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 43 | @Deprecated |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 44 | public static final String TYPE = "type"; |
| 45 | |
| 46 | /** |
Simon Hunt | 1e20dae | 2016-10-28 11:26:26 -0700 | [diff] [blame] | 47 | * Annotation key for UI type (the glyph ID for rendering). |
| 48 | */ |
| 49 | public static final String UI_TYPE = "uiType"; |
| 50 | |
| 51 | /** |
Simon Hunt | bc30e68 | 2017-02-15 18:39:23 -0800 | [diff] [blame] | 52 | * Annotation key for UI location type of device/host |
| 53 | * (either 'geo' or 'grid'). |
| 54 | */ |
| 55 | public static final String LOC_TYPE = "locType"; |
| 56 | |
| 57 | /** |
| 58 | * Annotation key for latitude (e.g. latitude of device/host |
| 59 | * in a geo-layout). |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 60 | */ |
| 61 | public static final String LATITUDE = "latitude"; |
| 62 | |
| 63 | /** |
Simon Hunt | bc30e68 | 2017-02-15 18:39:23 -0800 | [diff] [blame] | 64 | * Annotation key for longitude (e.g. longitude of device/host |
| 65 | * in a geo-layout). |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 66 | */ |
| 67 | public static final String LONGITUDE = "longitude"; |
| 68 | |
| 69 | /** |
Simon Hunt | bc30e68 | 2017-02-15 18:39:23 -0800 | [diff] [blame] | 70 | * Annotation key for grid-Y (e.g. y-coordinate of device/host |
| 71 | * in a grid-layout). |
| 72 | */ |
| 73 | public static final String GRID_Y = "gridY"; |
| 74 | |
| 75 | /** |
| 76 | * Annotation key for grid-X (e.g. x-coordinate of device/host |
| 77 | * in a grid-layout). |
| 78 | */ |
| 79 | public static final String GRID_X = "gridX"; |
| 80 | |
| 81 | /** |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 82 | * Annotation key for southbound protocol. |
| 83 | */ |
| 84 | public static final String PROTOCOL = "protocol"; |
| 85 | |
| 86 | /** |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 87 | * Annotation key for the device driver name. |
| 88 | */ |
| 89 | public static final String DRIVER = "driver"; |
| 90 | |
| 91 | /** |
Carmelo Cascone | 0761cd3 | 2018-08-29 19:22:50 -0700 | [diff] [blame] | 92 | * Annotation key for the device availability behavior. The value of this key |
| 93 | * is expected to be a boolean ({@code true} or {@code false}) and it is |
| 94 | * used to determine if the device can be marked online by the core when |
| 95 | * deemed appropriate (value is {@code false}, default behaviour if key is |
| 96 | * not present), or if marking online should be left to providers ({@code |
| 97 | * true}). |
| 98 | */ |
| 99 | public static final String PROVIDER_MARK_ONLINE = "providerMarkOnline"; |
| 100 | |
| 101 | /** |
Thomas Vachuska | 57126fe | 2014-11-11 17:13:24 -0800 | [diff] [blame] | 102 | * Annotation key for durable links. |
| 103 | */ |
| 104 | public static final String DURABLE = "durable"; |
| 105 | |
| 106 | /** |
Thomas Vachuska | 41fe1ec | 2015-12-03 23:17:02 -0800 | [diff] [blame] | 107 | * Annotation key for link metric; used by |
| 108 | * {@link org.onosproject.net.topology.MetricLinkWeight} function. |
| 109 | */ |
| 110 | public static final String METRIC = "metric"; |
| 111 | |
| 112 | /** |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 113 | * Annotation key for latency. |
dingdamu | d3a0b21 | 2017-05-16 11:18:27 +0200 | [diff] [blame] | 114 | * The value of this key is expected to be latency in nanosecond. |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 115 | */ |
| 116 | public static final String LATENCY = "latency"; |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 117 | |
| 118 | /** |
Toshio Koide | 4b6562b | 2014-11-13 17:20:47 -0800 | [diff] [blame] | 119 | * Annotation key for bandwidth. |
Sho SHIMIZU | 0ce220a | 2015-01-23 15:54:47 -0800 | [diff] [blame] | 120 | * The value for this key is interpreted as Mbps. |
Toshio Koide | 4b6562b | 2014-11-13 17:20:47 -0800 | [diff] [blame] | 121 | */ |
| 122 | public static final String BANDWIDTH = "bandwidth"; |
| 123 | |
| 124 | /** |
| 125 | * Annotation key for the number of optical waves. |
| 126 | */ |
| 127 | public static final String OPTICAL_WAVES = "optical.waves"; |
| 128 | |
| 129 | /** |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 130 | * Annotation key for the port name. |
| 131 | */ |
| 132 | public static final String PORT_NAME = "portName"; |
| 133 | |
Simon Hunt | ab130524 | 2015-05-06 18:07:13 -0700 | [diff] [blame] | 134 | /** |
fahadnaeemkhan | 7182724 | 2017-09-21 15:10:07 -0700 | [diff] [blame] | 135 | * Annotation key for the optical channel receiving/in port (RX). |
| 136 | */ |
| 137 | public static final String PORT_IN = "portIn"; |
| 138 | |
| 139 | /** |
| 140 | * Annotation key for the optical channel port transmitting/out port (TX). |
| 141 | */ |
| 142 | |
| 143 | public static final String PORT_OUT = "portOut"; |
| 144 | /** |
lishuai | 4ee4204 | 2015-11-30 17:19:21 +0800 | [diff] [blame] | 145 | * Annotation key for the port mac. |
| 146 | */ |
| 147 | public static final String PORT_MAC = "portMac"; |
| 148 | |
| 149 | /** |
mskala | c584bd9 | 2017-11-28 15:51:17 +0100 | [diff] [blame] | 150 | * Annotation key for the admin state. |
| 151 | * The value of this key is expected to be "enabled" or "disabled" |
| 152 | * |
| 153 | */ |
| 154 | public static final String ADMIN_STATE = "adminState"; |
| 155 | |
| 156 | /** |
Simon Hunt | ab130524 | 2015-05-06 18:07:13 -0700 | [diff] [blame] | 157 | * Annotation key for the router ID. |
| 158 | */ |
| 159 | public static final String ROUTER_ID = "routerId"; |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 160 | |
Thomas Vachuska | 41fe1ec | 2015-12-03 23:17:02 -0800 | [diff] [blame] | 161 | /** |
| 162 | * Annotation key for the static lambda. |
| 163 | */ |
Marc De Leenheer | 723f553 | 2015-06-03 20:16:17 -0700 | [diff] [blame] | 164 | public static final String STATIC_LAMBDA = "staticLambda"; |
| 165 | |
Thomas Vachuska | 41fe1ec | 2015-12-03 23:17:02 -0800 | [diff] [blame] | 166 | /** |
| 167 | * Annotation key for the static port. |
| 168 | */ |
Marc De Leenheer | 723f553 | 2015-06-03 20:16:17 -0700 | [diff] [blame] | 169 | public static final String STATIC_PORT = "staticPort"; |
| 170 | |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 171 | /** |
Ayaka Koshibe | 0891129 | 2015-08-05 15:07:08 -0700 | [diff] [blame] | 172 | * Annotation key for device location. |
| 173 | */ |
| 174 | public static final String RACK_ADDRESS = "rackAddress"; |
| 175 | |
| 176 | /** |
| 177 | * Annotation key for device owner. |
| 178 | */ |
| 179 | public static final String OWNER = "owner"; |
| 180 | |
| 181 | /** |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame] | 182 | * Annotation key for the channel id. |
| 183 | */ |
| 184 | public static final String CHANNEL_ID = "channelId"; |
| 185 | |
| 186 | /** |
| 187 | * Annotation key for the management address. |
| 188 | */ |
| 189 | public static final String MANAGEMENT_ADDRESS = "managementAddress"; |
| 190 | |
| 191 | /** |
Brian Stanke | 9bf8d7c | 2016-02-11 10:17:23 -0500 | [diff] [blame] | 192 | * Annotation key for the username. |
| 193 | */ |
| 194 | public static final String USERNAME = "username"; |
| 195 | |
| 196 | /** |
| 197 | * Annotation key for the password. |
| 198 | */ |
| 199 | public static final String PASSWORD = "password"; |
| 200 | |
| 201 | /** |
Yuta HIGUCHI | 76609cd | 2016-09-16 15:25:13 -0700 | [diff] [blame] | 202 | * Link annotation key to express that a Link |
| 203 | * is backed by underlying protection mechanism. |
| 204 | */ |
| 205 | // value is undefined at the moment, only using key existence |
| 206 | public static final String PROTECTED = "protected"; |
| 207 | |
| 208 | /** |
Michele Santuari | c372c22 | 2017-01-12 09:41:25 +0100 | [diff] [blame] | 209 | * Annotation key for REST server identifier. |
| 210 | */ |
| 211 | public static final String REST_SERVER = "restServer"; |
| 212 | |
| 213 | /** |
Himanshu Ranjan | 7c2ee3c | 2017-02-13 05:10:08 -0600 | [diff] [blame] | 214 | * Annotation key for the sshkey. |
| 215 | */ |
| 216 | public static final String SSHKEY = "sshkey"; |
| 217 | |
| 218 | /** |
DongRyeol Cha | ce65cc0 | 2018-07-23 15:02:28 +0900 | [diff] [blame] | 219 | * Annotation key for the protocol layer. |
| 220 | */ |
| 221 | public static final String LAYER = "layer"; |
| 222 | |
| 223 | /** |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 224 | * Returns the value annotated object for the specified annotation key. |
| 225 | * The annotated value is expected to be String that can be parsed as double. |
Yuta HIGUCHI | f1653a7 | 2018-01-31 14:24:25 -0800 | [diff] [blame] | 226 | * If parsing fails, the returned value will be {@value #DEFAULT_VALUE}. |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 227 | * |
| 228 | * @param annotated annotated object whose annotated value is obtained |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame] | 229 | * @param key key of annotation |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 230 | * @return double value of annotated object for the specified key |
| 231 | */ |
| 232 | public static double getAnnotatedValue(Annotated annotated, String key) { |
| 233 | double value; |
| 234 | try { |
| 235 | value = Double.parseDouble(annotated.annotations().value(key)); |
| 236 | } catch (NumberFormatException e) { |
Simon Hunt | bc30e68 | 2017-02-15 18:39:23 -0800 | [diff] [blame] | 237 | value = DEFAULT_VALUE; |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 238 | } |
| 239 | return value; |
| 240 | } |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 241 | } |