blob: 4949bc40a439a0243758455ab46711862193ad34 [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
29 private AnnotationKeys() {}
30
31 /**
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080032 * Annotation key for instance name.
Thomas Vachuska96d55b12015-05-11 08:52:03 -070033 *
34 * @deprecated since Cardinal
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080035 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070036 @Deprecated
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080037 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 /**
48 * Annotation key for latitude (e.g. latitude of device).
Thomas Vachuska96d55b12015-05-11 08:52:03 -070049 *
50 * @deprecated since Cardinal
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080051 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070052 @Deprecated
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080053 public static final String LATITUDE = "latitude";
54
55 /**
56 * Annotation key for longitute (e.g. longitude of device).
Thomas Vachuska96d55b12015-05-11 08:52:03 -070057 *
58 * @deprecated since Cardinal
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080059 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070060 @Deprecated
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080061 public static final String LONGITUDE = "longitude";
62
63 /**
64 * Annotation key for southbound protocol.
65 */
66 public static final String PROTOCOL = "protocol";
67
68 /**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070069 * Annotation key for the device driver name.
Thomas Vachuska96d55b12015-05-11 08:52:03 -070070 *
71 * @deprecated since Cardinal
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070072 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070073 @Deprecated
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070074 public static final String DRIVER = "driver";
75
76 /**
Thomas Vachuska57126fe2014-11-11 17:13:24 -080077 * Annotation key for durable links.
78 */
79 public static final String DURABLE = "durable";
80
81 /**
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080082 * Annotation key for latency.
Thomas Vachuska96d55b12015-05-11 08:52:03 -070083 *
84 * @deprecated since Cardinal
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080085 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070086 @Deprecated
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080087 public static final String LATENCY = "latency";
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -080088
89 /**
Toshio Koide4b6562b2014-11-13 17:20:47 -080090 * Annotation key for bandwidth.
Sho SHIMIZU0ce220a2015-01-23 15:54:47 -080091 * The value for this key is interpreted as Mbps.
Thomas Vachuska96d55b12015-05-11 08:52:03 -070092 *
93 * @deprecated since Cardinal
Toshio Koide4b6562b2014-11-13 17:20:47 -080094 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070095 @Deprecated
Toshio Koide4b6562b2014-11-13 17:20:47 -080096 public static final String BANDWIDTH = "bandwidth";
97
98 /**
99 * Annotation key for the number of optical waves.
100 */
101 public static final String OPTICAL_WAVES = "optical.waves";
102
103 /**
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700104 * Annotation key for the port name.
105 */
106 public static final String PORT_NAME = "portName";
107
Simon Huntab1305242015-05-06 18:07:13 -0700108 /**
109 * Annotation key for the router ID.
110 */
111 public static final String ROUTER_ID = "routerId";
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700112
Marc De Leenheer723f5532015-06-03 20:16:17 -0700113 public static final String STATIC_LAMBDA = "staticLambda";
114
115 public static final String STATIC_PORT = "staticPort";
116
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700117 /**
Ayaka Koshibe08911292015-08-05 15:07:08 -0700118 * Annotation key for device location.
119 */
120 public static final String RACK_ADDRESS = "rackAddress";
121
122 /**
123 * Annotation key for device owner.
124 */
125 public static final String OWNER = "owner";
126
127 /**
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800128 * Returns the value annotated object for the specified annotation key.
129 * The annotated value is expected to be String that can be parsed as double.
130 * If parsing fails, the returned value will be 1.0.
131 *
132 * @param annotated annotated object whose annotated value is obtained
133 * @param key key of annotation
134 * @return double value of annotated object for the specified key
135 */
136 public static double getAnnotatedValue(Annotated annotated, String key) {
137 double value;
138 try {
139 value = Double.parseDouble(annotated.annotations().value(key));
140 } catch (NumberFormatException e) {
141 value = 1.0;
142 }
143 return value;
144 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800145}