blob: da93417563cd8113217e817b44d2c73e735cc82a [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,
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net;
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080017
18/**
19 * Collection of keys for annotation.
Thomas Vachuska96d55b12015-05-11 08:52:03 -070020 * <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 SHIMIZUfe129db2014-11-11 14:24:51 -080024 */
25public final class AnnotationKeys {
26
Simon Huntbc30e682017-02-15 18:39:23 -080027 private static final double DEFAULT_VALUE = 1.0;
28
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080029 // Prohibit instantiation
andreafe3308f2015-10-06 15:51:25 -070030 private AnnotationKeys() {
31 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080032
33 /**
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080034 * 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 Vachuska96d55b12015-05-11 08:52:03 -070040 *
41 * @deprecated since Cardinal
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080042 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070043 @Deprecated
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080044 public static final String TYPE = "type";
45
46 /**
Simon Hunt1e20dae2016-10-28 11:26:26 -070047 * Annotation key for UI type (the glyph ID for rendering).
48 */
49 public static final String UI_TYPE = "uiType";
50
51 /**
Simon Huntbc30e682017-02-15 18:39:23 -080052 * 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 SHIMIZUf5c3a2e2014-12-02 14:49:39 -080060 */
61 public static final String LATITUDE = "latitude";
62
63 /**
Simon Huntbc30e682017-02-15 18:39:23 -080064 * Annotation key for longitude (e.g. longitude of device/host
65 * in a geo-layout).
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080066 */
67 public static final String LONGITUDE = "longitude";
68
69 /**
Simon Huntbc30e682017-02-15 18:39:23 -080070 * 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 SHIMIZUf5c3a2e2014-12-02 14:49:39 -080082 * Annotation key for southbound protocol.
83 */
84 public static final String PROTOCOL = "protocol";
85
86 /**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070087 * Annotation key for the device driver name.
88 */
89 public static final String DRIVER = "driver";
90
91 /**
Thomas Vachuska57126fe2014-11-11 17:13:24 -080092 * Annotation key for durable links.
93 */
94 public static final String DURABLE = "durable";
95
96 /**
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -080097 * Annotation key for link metric; used by
98 * {@link org.onosproject.net.topology.MetricLinkWeight} function.
99 */
100 public static final String METRIC = "metric";
101
102 /**
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800103 * Annotation key for latency.
dingdamud3a0b212017-05-16 11:18:27 +0200104 * The value of this key is expected to be latency in nanosecond.
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800105 */
106 public static final String LATENCY = "latency";
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800107
108 /**
Toshio Koide4b6562b2014-11-13 17:20:47 -0800109 * Annotation key for bandwidth.
Sho SHIMIZU0ce220a2015-01-23 15:54:47 -0800110 * The value for this key is interpreted as Mbps.
Toshio Koide4b6562b2014-11-13 17:20:47 -0800111 */
112 public static final String BANDWIDTH = "bandwidth";
113
114 /**
115 * Annotation key for the number of optical waves.
116 */
117 public static final String OPTICAL_WAVES = "optical.waves";
118
119 /**
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700120 * Annotation key for the port name.
121 */
122 public static final String PORT_NAME = "portName";
123
Simon Huntab1305242015-05-06 18:07:13 -0700124 /**
fahadnaeemkhan71827242017-09-21 15:10:07 -0700125 * Annotation key for the optical channel receiving/in port (RX).
126 */
127 public static final String PORT_IN = "portIn";
128
129 /**
130 * Annotation key for the optical channel port transmitting/out port (TX).
131 */
132
133 public static final String PORT_OUT = "portOut";
134 /**
lishuai4ee42042015-11-30 17:19:21 +0800135 * Annotation key for the port mac.
136 */
137 public static final String PORT_MAC = "portMac";
138
139 /**
Simon Huntab1305242015-05-06 18:07:13 -0700140 * Annotation key for the router ID.
141 */
142 public static final String ROUTER_ID = "routerId";
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700143
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800144 /**
145 * Annotation key for the static lambda.
146 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700147 public static final String STATIC_LAMBDA = "staticLambda";
148
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800149 /**
150 * Annotation key for the static port.
151 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700152 public static final String STATIC_PORT = "staticPort";
153
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700154 /**
Ayaka Koshibe08911292015-08-05 15:07:08 -0700155 * Annotation key for device location.
156 */
157 public static final String RACK_ADDRESS = "rackAddress";
158
159 /**
160 * Annotation key for device owner.
161 */
162 public static final String OWNER = "owner";
163
164 /**
andreafe3308f2015-10-06 15:51:25 -0700165 * Annotation key for the channel id.
166 */
167 public static final String CHANNEL_ID = "channelId";
168
169 /**
170 * Annotation key for the management address.
171 */
172 public static final String MANAGEMENT_ADDRESS = "managementAddress";
173
174 /**
Brian Stanke9bf8d7c2016-02-11 10:17:23 -0500175 * Annotation key for the username.
176 */
177 public static final String USERNAME = "username";
178
179 /**
180 * Annotation key for the password.
181 */
182 public static final String PASSWORD = "password";
183
184 /**
Yuta HIGUCHI76609cd2016-09-16 15:25:13 -0700185 * Link annotation key to express that a Link
186 * is backed by underlying protection mechanism.
187 */
188 // value is undefined at the moment, only using key existence
189 public static final String PROTECTED = "protected";
190
191 /**
Michele Santuaric372c222017-01-12 09:41:25 +0100192 * Annotation key for REST server identifier.
193 */
194 public static final String REST_SERVER = "restServer";
195
196 /**
Himanshu Ranjan7c2ee3c2017-02-13 05:10:08 -0600197 * Annotation key for the sshkey.
198 */
199 public static final String SSHKEY = "sshkey";
200
201 /**
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800202 * Returns the value annotated object for the specified annotation key.
203 * The annotated value is expected to be String that can be parsed as double.
Simon Huntbc30e682017-02-15 18:39:23 -0800204 * If parsing fails, the returned value will be {@value DEFAULT_VALUE}.
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800205 *
206 * @param annotated annotated object whose annotated value is obtained
andreafe3308f2015-10-06 15:51:25 -0700207 * @param key key of annotation
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800208 * @return double value of annotated object for the specified key
209 */
210 public static double getAnnotatedValue(Annotated annotated, String key) {
211 double value;
212 try {
213 value = Double.parseDouble(annotated.annotations().value(key));
214 } catch (NumberFormatException e) {
Simon Huntbc30e682017-02-15 18:39:23 -0800215 value = DEFAULT_VALUE;
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800216 }
217 return value;
218 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800219}