blob: a22b7688f8760dec2be8ca84c20fb4594c9d6264 [file] [log] [blame]
Sho SHIMIZUfe129db2014-11-11 14:24:51 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
Sho SHIMIZUfe129db2014-11-11 14:24:51 -08003 *
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,
Aaron Dunlap239ea5c2020-02-26 12:10:31 -060012 *
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
Brian O'Connorabafb502014-12-02 22:26:20 -080017package org.onosproject.net;
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080018
19/**
20 * Collection of keys for annotation.
Thomas Vachuska96d55b12015-05-11 08:52:03 -070021 * <p>
22 * Number of the annotation keys have been deprecated as the use of annotations
23 * is being phased out and instead network configuration subsystem is being
24 * phased-in for majority of model meta-data.
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080025 */
26public final class AnnotationKeys {
27
Simon Huntbc30e682017-02-15 18:39:23 -080028 private static final double DEFAULT_VALUE = 1.0;
29
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080030 // Prohibit instantiation
andreafe3308f2015-10-06 15:51:25 -070031 private AnnotationKeys() {
32 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080033
34 /**
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080035 * Annotation key for instance name.
36 */
37 public static final String NAME = "name";
38
39 /**
40 * Annotation key for instance type (e.g. host type).
Thomas Vachuska96d55b12015-05-11 08:52:03 -070041 *
42 * @deprecated since Cardinal
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080043 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070044 @Deprecated
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080045 public static final String TYPE = "type";
46
47 /**
Simon Hunt1e20dae2016-10-28 11:26:26 -070048 * Annotation key for UI type (the glyph ID for rendering).
49 */
50 public static final String UI_TYPE = "uiType";
51
52 /**
Thomas Vachuskaf06f5d62021-03-10 14:24:47 -080053 * Annotation key for UI connection type (the style for host link rendering).
54 */
55 public static final String CONNECTION_TYPE = "connectionType";
56
57 /**
Simon Huntbc30e682017-02-15 18:39:23 -080058 * Annotation key for UI location type of device/host
59 * (either 'geo' or 'grid').
60 */
61 public static final String LOC_TYPE = "locType";
62
63 /**
64 * Annotation key for latitude (e.g. latitude of device/host
65 * in a geo-layout).
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080066 */
67 public static final String LATITUDE = "latitude";
68
69 /**
Simon Huntbc30e682017-02-15 18:39:23 -080070 * Annotation key for longitude (e.g. longitude of device/host
71 * in a geo-layout).
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080072 */
73 public static final String LONGITUDE = "longitude";
74
75 /**
Simon Huntbc30e682017-02-15 18:39:23 -080076 * Annotation key for grid-Y (e.g. y-coordinate of device/host
77 * in a grid-layout).
78 */
79 public static final String GRID_Y = "gridY";
80
81 /**
82 * Annotation key for grid-X (e.g. x-coordinate of device/host
83 * in a grid-layout).
84 */
85 public static final String GRID_X = "gridX";
86
87 /**
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080088 * Annotation key for southbound protocol.
89 */
90 public static final String PROTOCOL = "protocol";
91
92 /**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070093 * Annotation key for the device driver name.
94 */
95 public static final String DRIVER = "driver";
96
97 /**
Thomas Vachuska57126fe2014-11-11 17:13:24 -080098 * Annotation key for durable links.
99 */
100 public static final String DURABLE = "durable";
101
102 /**
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800103 * Annotation key for link metric; used by
104 * {@link org.onosproject.net.topology.MetricLinkWeight} function.
105 */
106 public static final String METRIC = "metric";
107
108 /**
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800109 * Annotation key for latency.
dingdamud3a0b212017-05-16 11:18:27 +0200110 * The value of this key is expected to be latency in nanosecond.
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800111 */
112 public static final String LATENCY = "latency";
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800113
114 /**
Toshio Koide4b6562b2014-11-13 17:20:47 -0800115 * Annotation key for bandwidth.
Sho SHIMIZU0ce220a2015-01-23 15:54:47 -0800116 * The value for this key is interpreted as Mbps.
Toshio Koide4b6562b2014-11-13 17:20:47 -0800117 */
118 public static final String BANDWIDTH = "bandwidth";
119
120 /**
121 * Annotation key for the number of optical waves.
122 */
123 public static final String OPTICAL_WAVES = "optical.waves";
124
125 /**
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700126 * Annotation key for the port name.
127 */
128 public static final String PORT_NAME = "portName";
129
Simon Huntab1305242015-05-06 18:07:13 -0700130 /**
fahadnaeemkhan71827242017-09-21 15:10:07 -0700131 * Annotation key for the optical channel receiving/in port (RX).
132 */
133 public static final String PORT_IN = "portIn";
134
135 /**
136 * Annotation key for the optical channel port transmitting/out port (TX).
137 */
138
139 public static final String PORT_OUT = "portOut";
140 /**
lishuai4ee42042015-11-30 17:19:21 +0800141 * Annotation key for the port mac.
142 */
143 public static final String PORT_MAC = "portMac";
144
145 /**
mskalac584bd92017-11-28 15:51:17 +0100146 * Annotation key for the admin state.
147 * The value of this key is expected to be "enabled" or "disabled"
148 *
149 */
150 public static final String ADMIN_STATE = "adminState";
151
152 /**
Simon Huntab1305242015-05-06 18:07:13 -0700153 * Annotation key for the router ID.
154 */
155 public static final String ROUTER_ID = "routerId";
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700156
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800157 /**
158 * Annotation key for the static lambda.
159 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700160 public static final String STATIC_LAMBDA = "staticLambda";
161
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800162 /**
163 * Annotation key for the static port.
164 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700165 public static final String STATIC_PORT = "staticPort";
166
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700167 /**
Ayaka Koshibe08911292015-08-05 15:07:08 -0700168 * Annotation key for device location.
169 */
170 public static final String RACK_ADDRESS = "rackAddress";
171
172 /**
173 * Annotation key for device owner.
174 */
175 public static final String OWNER = "owner";
176
177 /**
andreafe3308f2015-10-06 15:51:25 -0700178 * Annotation key for the channel id.
179 */
180 public static final String CHANNEL_ID = "channelId";
181
182 /**
183 * Annotation key for the management address.
184 */
185 public static final String MANAGEMENT_ADDRESS = "managementAddress";
186
187 /**
Brian Stanke9bf8d7c2016-02-11 10:17:23 -0500188 * Annotation key for the username.
189 */
190 public static final String USERNAME = "username";
191
192 /**
193 * Annotation key for the password.
194 */
195 public static final String PASSWORD = "password";
196
197 /**
Yuta HIGUCHI76609cd2016-09-16 15:25:13 -0700198 * Link annotation key to express that a Link
199 * is backed by underlying protection mechanism.
200 */
201 // value is undefined at the moment, only using key existence
202 public static final String PROTECTED = "protected";
203
204 /**
Michele Santuaric372c222017-01-12 09:41:25 +0100205 * Annotation key for REST server identifier.
206 */
207 public static final String REST_SERVER = "restServer";
208
209 /**
Himanshu Ranjan7c2ee3c2017-02-13 05:10:08 -0600210 * Annotation key for the sshkey.
211 */
212 public static final String SSHKEY = "sshkey";
213
214 /**
DongRyeol Chace65cc02018-07-23 15:02:28 +0900215 * Annotation key for the protocol layer.
216 */
217 public static final String LAYER = "layer";
218
219 /**
Aaron Dunlap239ea5c2020-02-26 12:10:31 -0600220 * Annotation key for jitter.
221 * The value of this key is expected to be jitter in seconds
222 */
223 public static final String JITTER = "jitter";
224
225 /**
226 * Annotation key for delay.
227 * The value of this key is expected to be delay in seconds
228 */
229 public static final String DELAY = "delay";
230
231 /**
232 * Annotation key for loss.
233 * The value of this key is expected to be loss in percentage.
234 */
235 public static final String LOSS = "loss";
236
237 /**
238 * Annotation key for availability.
239 * The value of this key is expected to be availability as a percentage
240 */
241 public static final String AVAILABILITY = "availability";
242
243 /**
244 * Annotation key for flapping.
245 * The value of this key is expected to be a subjective percentage for flapping
246 */
247 public static final String FLAPPING = "flapping";
248
249 /**
David Glantz0843f5d2020-03-05 21:23:10 -0600250 * Annotation key for identifying a metered link.
251 * The value of this key is expected to be a boolean for metered as true/false.
252 */
253 public static final String METERED = "metered";
254
255 /**
David Glantzde82ada2020-03-19 14:43:32 -0500256 * Annotation key for data usage on a metered link.
257 * The value of this key is expected to be a percentage of the data available within the plan.
258 */
259 public static final String METERED_USAGE = "meteredUsage";
260
261 /**
262 * Annotation key for identifying the tier ranking of a link. Links with a lower tier would be
263 * selected in the path over links with a higher tier.
264 * The value of this key is expected to be a number that represents the tier value.
265 */
266 public static final String TIER = "tier";
267
268 /**
Miguel Borges de Freitas5b32b592021-10-09 19:08:19 +0100269 * Annotation key for the datapath description.
270 * Provides a human readable description of a given datapath. Used, for instance, when an Openflow
271 * switch connects to the controller, in the response to the OFPMP_DESC request
272 */
273 public static final String DATAPATH_DESCRIPTION = "datapathDescription";
274
275 /**
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800276 * Returns the value annotated object for the specified annotation key.
277 * The annotated value is expected to be String that can be parsed as double.
Yuta HIGUCHIf1653a72018-01-31 14:24:25 -0800278 * If parsing fails, the returned value will be {@value #DEFAULT_VALUE}.
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800279 *
280 * @param annotated annotated object whose annotated value is obtained
andreafe3308f2015-10-06 15:51:25 -0700281 * @param key key of annotation
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800282 * @return double value of annotated object for the specified key
283 */
284 public static double getAnnotatedValue(Annotated annotated, String key) {
285 double value;
286 try {
287 value = Double.parseDouble(annotated.annotations().value(key));
288 } catch (NumberFormatException e) {
Simon Huntbc30e682017-02-15 18:39:23 -0800289 value = DEFAULT_VALUE;
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800290 }
291 return value;
292 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800293}