blob: 4f81e929a74b3a9f84b90a3996fb4013f6f9a38d [file] [log] [blame]
Sho SHIMIZUfe129db2014-11-11 14:24:51 -08001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
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.
24 * </p>
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080025 */
26public final class AnnotationKeys {
27
28 // Prohibit instantiation
andreafe3308f2015-10-06 15:51:25 -070029 private AnnotationKeys() {
30 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080031
32 /**
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080033 * Annotation key for instance name.
Thomas Vachuska96d55b12015-05-11 08:52:03 -070034 *
35 * @deprecated since Cardinal
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080036 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070037 @Deprecated
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080038 public static final String NAME = "name";
39
40 /**
41 * Annotation key for instance type (e.g. host type).
Thomas Vachuska96d55b12015-05-11 08:52:03 -070042 *
43 * @deprecated since Cardinal
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080044 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070045 @Deprecated
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080046 public static final String TYPE = "type";
47
48 /**
49 * Annotation key for latitude (e.g. latitude of device).
Thomas Vachuska96d55b12015-05-11 08:52:03 -070050 *
51 * @deprecated since Cardinal
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080052 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070053 @Deprecated
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080054 public static final String LATITUDE = "latitude";
55
56 /**
57 * Annotation key for longitute (e.g. longitude of device).
Thomas Vachuska96d55b12015-05-11 08:52:03 -070058 *
59 * @deprecated since Cardinal
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080060 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070061 @Deprecated
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080062 public static final String LONGITUDE = "longitude";
63
64 /**
65 * Annotation key for southbound protocol.
66 */
67 public static final String PROTOCOL = "protocol";
68
69 /**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070070 * Annotation key for the device driver name.
Thomas Vachuska96d55b12015-05-11 08:52:03 -070071 *
72 * @deprecated since Cardinal
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070073 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070074 @Deprecated
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070075 public static final String DRIVER = "driver";
76
77 /**
Thomas Vachuska57126fe2014-11-11 17:13:24 -080078 * Annotation key for durable links.
79 */
80 public static final String DURABLE = "durable";
81
82 /**
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -080083 * Annotation key for link metric; used by
84 * {@link org.onosproject.net.topology.MetricLinkWeight} function.
85 */
86 public static final String METRIC = "metric";
87
88 /**
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080089 * Annotation key for latency.
Thomas Vachuska96d55b12015-05-11 08:52:03 -070090 *
91 * @deprecated since Cardinal
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080092 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070093 @Deprecated
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080094 public static final String LATENCY = "latency";
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -080095
96 /**
Toshio Koide4b6562b2014-11-13 17:20:47 -080097 * Annotation key for bandwidth.
Sho SHIMIZU0ce220a2015-01-23 15:54:47 -080098 * The value for this key is interpreted as Mbps.
Thomas Vachuska96d55b12015-05-11 08:52:03 -070099 *
100 * @deprecated since Cardinal
Toshio Koide4b6562b2014-11-13 17:20:47 -0800101 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700102 @Deprecated
Toshio Koide4b6562b2014-11-13 17:20:47 -0800103 public static final String BANDWIDTH = "bandwidth";
104
105 /**
106 * Annotation key for the number of optical waves.
107 */
108 public static final String OPTICAL_WAVES = "optical.waves";
109
110 /**
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700111 * Annotation key for the port name.
112 */
113 public static final String PORT_NAME = "portName";
114
Simon Huntab1305242015-05-06 18:07:13 -0700115 /**
116 * Annotation key for the router ID.
117 */
118 public static final String ROUTER_ID = "routerId";
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700119
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800120 /**
121 * Annotation key for the static lambda.
122 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700123 public static final String STATIC_LAMBDA = "staticLambda";
124
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800125 /**
126 * Annotation key for the static port.
127 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700128 public static final String STATIC_PORT = "staticPort";
129
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700130 /**
Ayaka Koshibe08911292015-08-05 15:07:08 -0700131 * Annotation key for device location.
132 */
133 public static final String RACK_ADDRESS = "rackAddress";
134
135 /**
136 * Annotation key for device owner.
137 */
138 public static final String OWNER = "owner";
139
140 /**
andreafe3308f2015-10-06 15:51:25 -0700141 * Annotation key for the channel id.
142 */
143 public static final String CHANNEL_ID = "channelId";
144
145 /**
146 * Annotation key for the management address.
147 */
148 public static final String MANAGEMENT_ADDRESS = "managementAddress";
149
150 /**
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800151 * Returns the value annotated object for the specified annotation key.
152 * The annotated value is expected to be String that can be parsed as double.
153 * If parsing fails, the returned value will be 1.0.
154 *
155 * @param annotated annotated object whose annotated value is obtained
andreafe3308f2015-10-06 15:51:25 -0700156 * @param key key of annotation
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800157 * @return double value of annotated object for the specified key
158 */
159 public static double getAnnotatedValue(Annotated annotated, String key) {
160 double value;
161 try {
162 value = Double.parseDouble(annotated.annotations().value(key));
163 } catch (NumberFormatException e) {
164 value = 1.0;
165 }
166 return value;
167 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800168}