blob: 00efb4a8402e0f40ec2c324970b9c6974aef76ba [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
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.
34 */
35 public static final String NAME = "name";
36
37 /**
38 * Annotation key for instance type (e.g. host type).
Thomas Vachuska96d55b12015-05-11 08:52:03 -070039 *
40 * @deprecated since Cardinal
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080041 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070042 @Deprecated
Sho SHIMIZUf5c3a2e2014-12-02 14:49:39 -080043 public static final String TYPE = "type";
44
45 /**
46 * Annotation key for latitude (e.g. latitude of device).
47 */
48 public static final String LATITUDE = "latitude";
49
50 /**
51 * Annotation key for longitute (e.g. longitude of device).
52 */
53 public static final String LONGITUDE = "longitude";
54
55 /**
56 * Annotation key for southbound protocol.
57 */
58 public static final String PROTOCOL = "protocol";
59
60 /**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070061 * Annotation key for the device driver name.
62 */
63 public static final String DRIVER = "driver";
64
65 /**
Thomas Vachuska57126fe2014-11-11 17:13:24 -080066 * Annotation key for durable links.
67 */
68 public static final String DURABLE = "durable";
69
70 /**
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -080071 * Annotation key for link metric; used by
72 * {@link org.onosproject.net.topology.MetricLinkWeight} function.
73 */
74 public static final String METRIC = "metric";
75
76 /**
Sho SHIMIZUfe129db2014-11-11 14:24:51 -080077 * Annotation key for latency.
78 */
79 public static final String LATENCY = "latency";
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -080080
81 /**
Toshio Koide4b6562b2014-11-13 17:20:47 -080082 * Annotation key for bandwidth.
Sho SHIMIZU0ce220a2015-01-23 15:54:47 -080083 * The value for this key is interpreted as Mbps.
Toshio Koide4b6562b2014-11-13 17:20:47 -080084 */
85 public static final String BANDWIDTH = "bandwidth";
86
87 /**
88 * Annotation key for the number of optical waves.
89 */
90 public static final String OPTICAL_WAVES = "optical.waves";
91
92 /**
Thomas Vachuskab52a0142015-04-21 17:48:15 -070093 * Annotation key for the port name.
94 */
95 public static final String PORT_NAME = "portName";
96
Simon Huntab1305242015-05-06 18:07:13 -070097 /**
lishuai4ee42042015-11-30 17:19:21 +080098 * Annotation key for the port mac.
99 */
100 public static final String PORT_MAC = "portMac";
101
102 /**
Simon Huntab1305242015-05-06 18:07:13 -0700103 * Annotation key for the router ID.
104 */
105 public static final String ROUTER_ID = "routerId";
Thomas Vachuskab52a0142015-04-21 17:48:15 -0700106
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800107 /**
108 * Annotation key for the static lambda.
109 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700110 public static final String STATIC_LAMBDA = "staticLambda";
111
Thomas Vachuska41fe1ec2015-12-03 23:17:02 -0800112 /**
113 * Annotation key for the static port.
114 */
Marc De Leenheer723f5532015-06-03 20:16:17 -0700115 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 /**
andreafe3308f2015-10-06 15:51:25 -0700128 * Annotation key for the channel id.
129 */
130 public static final String CHANNEL_ID = "channelId";
131
132 /**
133 * Annotation key for the management address.
134 */
135 public static final String MANAGEMENT_ADDRESS = "managementAddress";
136
137 /**
Brian Stanke9bf8d7c2016-02-11 10:17:23 -0500138 * Annotation key for the username.
139 */
140 public static final String USERNAME = "username";
141
142 /**
143 * Annotation key for the password.
144 */
145 public static final String PASSWORD = "password";
146
147 /**
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800148 * Returns the value annotated object for the specified annotation key.
149 * The annotated value is expected to be String that can be parsed as double.
150 * If parsing fails, the returned value will be 1.0.
151 *
152 * @param annotated annotated object whose annotated value is obtained
andreafe3308f2015-10-06 15:51:25 -0700153 * @param key key of annotation
Sho SHIMIZU97a64cd2014-11-11 16:31:21 -0800154 * @return double value of annotated object for the specified key
155 */
156 public static double getAnnotatedValue(Annotated annotated, String key) {
157 double value;
158 try {
159 value = Double.parseDouble(annotated.annotations().value(key));
160 } catch (NumberFormatException e) {
161 value = 1.0;
162 }
163 return value;
164 }
Sho SHIMIZUfe129db2014-11-11 14:24:51 -0800165}