blob: 5af7f7a69148d5b1ff63885a9dfd8f73931873ce [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 /**
Carmelo Cascone0761cd32018-08-29 19:22:50 -070092 * 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 Vachuska57126fe2014-11-11 17:13:24 -0800102 * Annotation key for durable links.
103 */
104 public static final String DURABLE = "durable";
105
106 /**
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800107 * 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 SHIMIZUfe129db2014-11-11 14:24:51 -0800113 * Annotation key for latency.
dingdamud3a0b212017-05-16 11:18:27 +0200114 * The value of this key is expected to be latency in nanosecond.
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800115 */
116 public static final String LATENCY = "latency";
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800117
118 /**
Toshio Koide4b6562b2014-11-13 17:20:47 -0800119 * Annotation key for bandwidth.
Sho SHIMIZU0ce220a2015-01-23 15:54:47 -0800120 * The value for this key is interpreted as Mbps.
Toshio Koide4b6562b2014-11-13 17:20:47 -0800121 */
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 Vachuskab52a0142015-04-21 17:48:15 -0700130 * Annotation key for the port name.
131 */
132 public static final String PORT_NAME = "portName";
133
Simon Huntab1305242015-05-06 18:07:13 -0700134 /**
fahadnaeemkhan71827242017-09-21 15:10:07 -0700135 * 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 /**
lishuai4ee42042015-11-30 17:19:21 +0800145 * Annotation key for the port mac.
146 */
147 public static final String PORT_MAC = "portMac";
148
149 /**
mskalac584bd92017-11-28 15:51:17 +0100150 * 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 Huntab1305242015-05-06 18:07:13 -0700157 * Annotation key for the router ID.
158 */
159 public static final String ROUTER_ID = "routerId";
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700160
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800161 /**
162 * Annotation key for the static lambda.
163 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700164 public static final String STATIC_LAMBDA = "staticLambda";
165
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800166 /**
167 * Annotation key for the static port.
168 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700169 public static final String STATIC_PORT = "staticPort";
170
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700171 /**
Ayaka Koshibe08911292015-08-05 15:07:08 -0700172 * 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 /**
andreafe3308f2015-10-06 15:51:25 -0700182 * 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 Stanke9bf8d7c2016-02-11 10:17:23 -0500192 * 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 HIGUCHI76609cd2016-09-16 15:25:13 -0700202 * 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 Santuaric372c222017-01-12 09:41:25 +0100209 * Annotation key for REST server identifier.
210 */
211 public static final String REST_SERVER = "restServer";
212
213 /**
Himanshu Ranjan7c2ee3c2017-02-13 05:10:08 -0600214 * Annotation key for the sshkey.
215 */
216 public static final String SSHKEY = "sshkey";
217
218 /**
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800219 * Returns the value annotated object for the specified annotation key.
220 * The annotated value is expected to be String that can be parsed as double.
Yuta HIGUCHIf1653a72018-01-31 14:24:25 -0800221 * If parsing fails, the returned value will be {@value #DEFAULT_VALUE}.
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800222 *
223 * @param annotated annotated object whose annotated value is obtained
andreafe3308f2015-10-06 15:51:25 -0700224 * @param key key of annotation
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800225 * @return double value of annotated object for the specified key
226 */
227 public static double getAnnotatedValue(Annotated annotated, String key) {
228 double value;
229 try {
230 value = Double.parseDouble(annotated.annotations().value(key));
231 } catch (NumberFormatException e) {
Simon Huntbc30e682017-02-15 18:39:23 -0800232 value = DEFAULT_VALUE;
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800233 }
234 return value;
235 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800236}