blob: 4235ed1e2868fa85ad5e8c4901d74036f975c630 [file] [log] [blame]
Sho SHIMIZUfe129db2014-11-11 14:24:51 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present 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
yjimmyy646aa022016-07-05 12:09:50 -070018import com.google.common.annotations.Beta;
19
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080020/**
21 * Collection of keys for annotation.
Thomas Vachuska96d55b12015-05-11 08:52:03 -070022 * <p>
23 * Number of the annotation keys have been deprecated as the use of annotations
24 * is being phased out and instead network configuration subsystem is being
25 * phased-in for majority of model meta-data.
26 * </p>
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080027 */
28public final class AnnotationKeys {
29
30 // 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 /**
48 * Annotation key for latitude (e.g. latitude of device).
49 */
50 public static final String LATITUDE = "latitude";
51
52 /**
53 * Annotation key for longitute (e.g. longitude of device).
54 */
55 public static final String LONGITUDE = "longitude";
56
57 /**
58 * Annotation key for southbound protocol.
59 */
60 public static final String PROTOCOL = "protocol";
61
62 /**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070063 * Annotation key for the device driver name.
64 */
65 public static final String DRIVER = "driver";
66
67 /**
Thomas Vachuska57126fe2014-11-11 17:13:24 -080068 * Annotation key for durable links.
69 */
70 public static final String DURABLE = "durable";
71
72 /**
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -080073 * Annotation key for link metric; used by
74 * {@link org.onosproject.net.topology.MetricLinkWeight} function.
75 */
76 public static final String METRIC = "metric";
77
78 /**
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080079 * Annotation key for latency.
80 */
81 public static final String LATENCY = "latency";
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -080082
83 /**
Toshio Koide4b6562b2014-11-13 17:20:47 -080084 * Annotation key for bandwidth.
Sho SHIMIZU0ce220a2015-01-23 15:54:47 -080085 * The value for this key is interpreted as Mbps.
Toshio Koide4b6562b2014-11-13 17:20:47 -080086 */
87 public static final String BANDWIDTH = "bandwidth";
88
89 /**
90 * Annotation key for the number of optical waves.
91 */
92 public static final String OPTICAL_WAVES = "optical.waves";
93
94 /**
Thomas Vachuskab52a0142015-04-21 17:48:15 -070095 * Annotation key for the port name.
96 */
97 public static final String PORT_NAME = "portName";
98
Simon Huntab1305242015-05-06 18:07:13 -070099 /**
lishuai4ee42042015-11-30 17:19:21 +0800100 * Annotation key for the port mac.
101 */
102 public static final String PORT_MAC = "portMac";
103
104 /**
Simon Huntab1305242015-05-06 18:07:13 -0700105 * Annotation key for the router ID.
106 */
107 public static final String ROUTER_ID = "routerId";
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700108
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800109 /**
110 * Annotation key for the static lambda.
111 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700112 public static final String STATIC_LAMBDA = "staticLambda";
113
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800114 /**
yjimmyy646aa022016-07-05 12:09:50 -0700115 * Annotation key for optical port's target power.
116 */
117 @Beta
118 public static final String TARGET_POWER = "targetPower";
119
120 /**
121 * Annotation key for optical port's current power.
122 */
123 @Beta
124 public static final String CURRENT_POWER = "currentPower";
125
126 /**
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800127 * Annotation key for the static port.
128 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700129 public static final String STATIC_PORT = "staticPort";
130
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700131 /**
Ayaka Koshibe08911292015-08-05 15:07:08 -0700132 * Annotation key for device location.
133 */
134 public static final String RACK_ADDRESS = "rackAddress";
135
136 /**
137 * Annotation key for device owner.
138 */
139 public static final String OWNER = "owner";
140
141 /**
andreafe3308f2015-10-06 15:51:25 -0700142 * Annotation key for the channel id.
143 */
144 public static final String CHANNEL_ID = "channelId";
145
146 /**
147 * Annotation key for the management address.
148 */
149 public static final String MANAGEMENT_ADDRESS = "managementAddress";
150
151 /**
Brian Stanke9bf8d7c2016-02-11 10:17:23 -0500152 * Annotation key for the username.
153 */
154 public static final String USERNAME = "username";
155
156 /**
157 * Annotation key for the password.
158 */
159 public static final String PASSWORD = "password";
160
161 /**
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800162 * Returns the value annotated object for the specified annotation key.
163 * The annotated value is expected to be String that can be parsed as double.
164 * If parsing fails, the returned value will be 1.0.
165 *
166 * @param annotated annotated object whose annotated value is obtained
andreafe3308f2015-10-06 15:51:25 -0700167 * @param key key of annotation
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800168 * @return double value of annotated object for the specified key
169 */
170 public static double getAnnotatedValue(Annotated annotated, String key) {
171 double value;
172 try {
173 value = Double.parseDouble(annotated.annotations().value(key));
174 } catch (NumberFormatException e) {
175 value = 1.0;
176 }
177 return value;
178 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800179}