blob: 2cfb3335ca8270db007813daa9602306579754fc [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 /**
Simon Huntbc30e682017-02-15 18:39:23 -080053 * Annotation key for UI location type of device/host
54 * (either 'geo' or 'grid').
55 */
56 public static final String LOC_TYPE = "locType";
57
58 /**
59 * Annotation key for latitude (e.g. latitude of device/host
60 * in a geo-layout).
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080061 */
62 public static final String LATITUDE = "latitude";
63
64 /**
Simon Huntbc30e682017-02-15 18:39:23 -080065 * Annotation key for longitude (e.g. longitude of device/host
66 * in a geo-layout).
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080067 */
68 public static final String LONGITUDE = "longitude";
69
70 /**
Simon Huntbc30e682017-02-15 18:39:23 -080071 * Annotation key for grid-Y (e.g. y-coordinate of device/host
72 * in a grid-layout).
73 */
74 public static final String GRID_Y = "gridY";
75
76 /**
77 * Annotation key for grid-X (e.g. x-coordinate of device/host
78 * in a grid-layout).
79 */
80 public static final String GRID_X = "gridX";
81
82 /**
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080083 * Annotation key for southbound protocol.
84 */
85 public static final String PROTOCOL = "protocol";
86
87 /**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070088 * Annotation key for the device driver name.
89 */
90 public static final String DRIVER = "driver";
91
92 /**
Thomas Vachuska57126fe2014-11-11 17:13:24 -080093 * Annotation key for durable links.
94 */
95 public static final String DURABLE = "durable";
96
97 /**
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -080098 * Annotation key for link metric; used by
99 * {@link org.onosproject.net.topology.MetricLinkWeight} function.
100 */
101 public static final String METRIC = "metric";
102
103 /**
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800104 * Annotation key for latency.
dingdamud3a0b212017-05-16 11:18:27 +0200105 * The value of this key is expected to be latency in nanosecond.
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800106 */
107 public static final String LATENCY = "latency";
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800108
109 /**
Toshio Koide4b6562b2014-11-13 17:20:47 -0800110 * Annotation key for bandwidth.
Sho SHIMIZU0ce220a2015-01-23 15:54:47 -0800111 * The value for this key is interpreted as Mbps.
Toshio Koide4b6562b2014-11-13 17:20:47 -0800112 */
113 public static final String BANDWIDTH = "bandwidth";
114
115 /**
116 * Annotation key for the number of optical waves.
117 */
118 public static final String OPTICAL_WAVES = "optical.waves";
119
120 /**
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700121 * Annotation key for the port name.
122 */
123 public static final String PORT_NAME = "portName";
124
Simon Huntab1305242015-05-06 18:07:13 -0700125 /**
fahadnaeemkhan71827242017-09-21 15:10:07 -0700126 * Annotation key for the optical channel receiving/in port (RX).
127 */
128 public static final String PORT_IN = "portIn";
129
130 /**
131 * Annotation key for the optical channel port transmitting/out port (TX).
132 */
133
134 public static final String PORT_OUT = "portOut";
135 /**
lishuai4ee42042015-11-30 17:19:21 +0800136 * Annotation key for the port mac.
137 */
138 public static final String PORT_MAC = "portMac";
139
140 /**
mskalac584bd92017-11-28 15:51:17 +0100141 * Annotation key for the admin state.
142 * The value of this key is expected to be "enabled" or "disabled"
143 *
144 */
145 public static final String ADMIN_STATE = "adminState";
146
147 /**
Simon Huntab1305242015-05-06 18:07:13 -0700148 * Annotation key for the router ID.
149 */
150 public static final String ROUTER_ID = "routerId";
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700151
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800152 /**
153 * Annotation key for the static lambda.
154 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700155 public static final String STATIC_LAMBDA = "staticLambda";
156
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800157 /**
158 * Annotation key for the static port.
159 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700160 public static final String STATIC_PORT = "staticPort";
161
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700162 /**
Ayaka Koshibe08911292015-08-05 15:07:08 -0700163 * Annotation key for device location.
164 */
165 public static final String RACK_ADDRESS = "rackAddress";
166
167 /**
168 * Annotation key for device owner.
169 */
170 public static final String OWNER = "owner";
171
172 /**
andreafe3308f2015-10-06 15:51:25 -0700173 * Annotation key for the channel id.
174 */
175 public static final String CHANNEL_ID = "channelId";
176
177 /**
178 * Annotation key for the management address.
179 */
180 public static final String MANAGEMENT_ADDRESS = "managementAddress";
181
182 /**
Brian Stanke9bf8d7c2016-02-11 10:17:23 -0500183 * Annotation key for the username.
184 */
185 public static final String USERNAME = "username";
186
187 /**
188 * Annotation key for the password.
189 */
190 public static final String PASSWORD = "password";
191
192 /**
Yuta HIGUCHI76609cd2016-09-16 15:25:13 -0700193 * Link annotation key to express that a Link
194 * is backed by underlying protection mechanism.
195 */
196 // value is undefined at the moment, only using key existence
197 public static final String PROTECTED = "protected";
198
199 /**
Michele Santuaric372c222017-01-12 09:41:25 +0100200 * Annotation key for REST server identifier.
201 */
202 public static final String REST_SERVER = "restServer";
203
204 /**
Himanshu Ranjan7c2ee3c2017-02-13 05:10:08 -0600205 * Annotation key for the sshkey.
206 */
207 public static final String SSHKEY = "sshkey";
208
209 /**
DongRyeol Chace65cc02018-07-23 15:02:28 +0900210 * Annotation key for the protocol layer.
211 */
212 public static final String LAYER = "layer";
213
214 /**
Aaron Dunlap239ea5c2020-02-26 12:10:31 -0600215 * Annotation key for jitter.
216 * The value of this key is expected to be jitter in seconds
217 */
218 public static final String JITTER = "jitter";
219
220 /**
221 * Annotation key for delay.
222 * The value of this key is expected to be delay in seconds
223 */
224 public static final String DELAY = "delay";
225
226 /**
227 * Annotation key for loss.
228 * The value of this key is expected to be loss in percentage.
229 */
230 public static final String LOSS = "loss";
231
232 /**
233 * Annotation key for availability.
234 * The value of this key is expected to be availability as a percentage
235 */
236 public static final String AVAILABILITY = "availability";
237
238 /**
239 * Annotation key for flapping.
240 * The value of this key is expected to be a subjective percentage for flapping
241 */
242 public static final String FLAPPING = "flapping";
243
244 /**
David Glantz0843f5d2020-03-05 21:23:10 -0600245 * Annotation key for identifying a metered link.
246 * The value of this key is expected to be a boolean for metered as true/false.
247 */
248 public static final String METERED = "metered";
249
250 /**
David Glantzde82ada2020-03-19 14:43:32 -0500251 * Annotation key for data usage on a metered link.
252 * The value of this key is expected to be a percentage of the data available within the plan.
253 */
254 public static final String METERED_USAGE = "meteredUsage";
255
256 /**
257 * Annotation key for identifying the tier ranking of a link. Links with a lower tier would be
258 * selected in the path over links with a higher tier.
259 * The value of this key is expected to be a number that represents the tier value.
260 */
261 public static final String TIER = "tier";
262
263 /**
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800264 * Returns the value annotated object for the specified annotation key.
265 * The annotated value is expected to be String that can be parsed as double.
Yuta HIGUCHIf1653a72018-01-31 14:24:25 -0800266 * If parsing fails, the returned value will be {@value #DEFAULT_VALUE}.
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800267 *
268 * @param annotated annotated object whose annotated value is obtained
andreafe3308f2015-10-06 15:51:25 -0700269 * @param key key of annotation
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800270 * @return double value of annotated object for the specified key
271 */
272 public static double getAnnotatedValue(Annotated annotated, String key) {
273 double value;
274 try {
275 value = Double.parseDouble(annotated.annotations().value(key));
276 } catch (NumberFormatException e) {
Simon Huntbc30e682017-02-15 18:39:23 -0800277 value = DEFAULT_VALUE;
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800278 }
279 return value;
280 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800281}