Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 3 | * |
| 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net; |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * Collection of keys for annotation. |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 20 | * <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 SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 24 | */ |
| 25 | public final class AnnotationKeys { |
| 26 | |
| 27 | // Prohibit instantiation |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame] | 28 | private AnnotationKeys() { |
| 29 | } |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 30 | |
| 31 | /** |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 32 | * Annotation key for instance name. |
| 33 | */ |
| 34 | public static final String NAME = "name"; |
| 35 | |
| 36 | /** |
| 37 | * Annotation key for instance type (e.g. host type). |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 38 | * |
| 39 | * @deprecated since Cardinal |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 40 | */ |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 41 | @Deprecated |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 42 | public static final String TYPE = "type"; |
| 43 | |
| 44 | /** |
Simon Hunt | 1e20dae | 2016-10-28 11:26:26 -0700 | [diff] [blame] | 45 | * Annotation key for UI type (the glyph ID for rendering). |
| 46 | */ |
| 47 | public static final String UI_TYPE = "uiType"; |
| 48 | |
| 49 | /** |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 50 | * Annotation key for latitude (e.g. latitude of device). |
| 51 | */ |
| 52 | public static final String LATITUDE = "latitude"; |
| 53 | |
| 54 | /** |
Simon Hunt | 6a8cb4f | 2016-08-09 15:08:57 -0700 | [diff] [blame] | 55 | * Annotation key for longitude (e.g. longitude of device). |
Sho SHIMIZU | f5c3a2e | 2014-12-02 14:49:39 -0800 | [diff] [blame] | 56 | */ |
| 57 | public static final String LONGITUDE = "longitude"; |
| 58 | |
| 59 | /** |
| 60 | * Annotation key for southbound protocol. |
| 61 | */ |
| 62 | public static final String PROTOCOL = "protocol"; |
| 63 | |
| 64 | /** |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 65 | * Annotation key for the device driver name. |
| 66 | */ |
| 67 | public static final String DRIVER = "driver"; |
| 68 | |
| 69 | /** |
Thomas Vachuska | 57126fe | 2014-11-11 17:13:24 -0800 | [diff] [blame] | 70 | * Annotation key for durable links. |
| 71 | */ |
| 72 | public static final String DURABLE = "durable"; |
| 73 | |
| 74 | /** |
Thomas Vachuska | 41fe1ec | 2015-12-03 23:17:02 -0800 | [diff] [blame] | 75 | * Annotation key for link metric; used by |
| 76 | * {@link org.onosproject.net.topology.MetricLinkWeight} function. |
| 77 | */ |
| 78 | public static final String METRIC = "metric"; |
| 79 | |
| 80 | /** |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 81 | * Annotation key for latency. |
| 82 | */ |
| 83 | public static final String LATENCY = "latency"; |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 84 | |
| 85 | /** |
Toshio Koide | 4b6562b | 2014-11-13 17:20:47 -0800 | [diff] [blame] | 86 | * Annotation key for bandwidth. |
Sho SHIMIZU | 0ce220a | 2015-01-23 15:54:47 -0800 | [diff] [blame] | 87 | * The value for this key is interpreted as Mbps. |
Toshio Koide | 4b6562b | 2014-11-13 17:20:47 -0800 | [diff] [blame] | 88 | */ |
| 89 | public static final String BANDWIDTH = "bandwidth"; |
| 90 | |
| 91 | /** |
| 92 | * Annotation key for the number of optical waves. |
| 93 | */ |
| 94 | public static final String OPTICAL_WAVES = "optical.waves"; |
| 95 | |
| 96 | /** |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 97 | * Annotation key for the port name. |
| 98 | */ |
| 99 | public static final String PORT_NAME = "portName"; |
| 100 | |
Simon Hunt | ab130524 | 2015-05-06 18:07:13 -0700 | [diff] [blame] | 101 | /** |
lishuai | 4ee4204 | 2015-11-30 17:19:21 +0800 | [diff] [blame] | 102 | * Annotation key for the port mac. |
| 103 | */ |
| 104 | public static final String PORT_MAC = "portMac"; |
| 105 | |
| 106 | /** |
Simon Hunt | ab130524 | 2015-05-06 18:07:13 -0700 | [diff] [blame] | 107 | * Annotation key for the router ID. |
| 108 | */ |
| 109 | public static final String ROUTER_ID = "routerId"; |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 110 | |
Thomas Vachuska | 41fe1ec | 2015-12-03 23:17:02 -0800 | [diff] [blame] | 111 | /** |
| 112 | * Annotation key for the static lambda. |
| 113 | */ |
Marc De Leenheer | 723f553 | 2015-06-03 20:16:17 -0700 | [diff] [blame] | 114 | public static final String STATIC_LAMBDA = "staticLambda"; |
| 115 | |
Thomas Vachuska | 41fe1ec | 2015-12-03 23:17:02 -0800 | [diff] [blame] | 116 | /** |
| 117 | * Annotation key for the static port. |
| 118 | */ |
Marc De Leenheer | 723f553 | 2015-06-03 20:16:17 -0700 | [diff] [blame] | 119 | public static final String STATIC_PORT = "staticPort"; |
| 120 | |
Thomas Vachuska | b52a014 | 2015-04-21 17:48:15 -0700 | [diff] [blame] | 121 | /** |
Ayaka Koshibe | 0891129 | 2015-08-05 15:07:08 -0700 | [diff] [blame] | 122 | * Annotation key for device location. |
| 123 | */ |
| 124 | public static final String RACK_ADDRESS = "rackAddress"; |
| 125 | |
| 126 | /** |
| 127 | * Annotation key for device owner. |
| 128 | */ |
| 129 | public static final String OWNER = "owner"; |
| 130 | |
| 131 | /** |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame] | 132 | * Annotation key for the channel id. |
| 133 | */ |
| 134 | public static final String CHANNEL_ID = "channelId"; |
| 135 | |
| 136 | /** |
| 137 | * Annotation key for the management address. |
| 138 | */ |
| 139 | public static final String MANAGEMENT_ADDRESS = "managementAddress"; |
| 140 | |
| 141 | /** |
Brian Stanke | 9bf8d7c | 2016-02-11 10:17:23 -0500 | [diff] [blame] | 142 | * Annotation key for the username. |
| 143 | */ |
| 144 | public static final String USERNAME = "username"; |
| 145 | |
| 146 | /** |
| 147 | * Annotation key for the password. |
| 148 | */ |
| 149 | public static final String PASSWORD = "password"; |
| 150 | |
| 151 | /** |
Yuta HIGUCHI | 76609cd | 2016-09-16 15:25:13 -0700 | [diff] [blame] | 152 | * Link annotation key to express that a Link |
| 153 | * is backed by underlying protection mechanism. |
| 154 | */ |
| 155 | // value is undefined at the moment, only using key existence |
| 156 | public static final String PROTECTED = "protected"; |
| 157 | |
| 158 | /** |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 159 | * Returns the value annotated object for the specified annotation key. |
| 160 | * The annotated value is expected to be String that can be parsed as double. |
| 161 | * If parsing fails, the returned value will be 1.0. |
| 162 | * |
| 163 | * @param annotated annotated object whose annotated value is obtained |
andrea | fe3308f | 2015-10-06 15:51:25 -0700 | [diff] [blame] | 164 | * @param key key of annotation |
Sho SHIMIZU | 97a64cd | 2014-11-11 16:31:21 -0800 | [diff] [blame] | 165 | * @return double value of annotated object for the specified key |
| 166 | */ |
| 167 | public static double getAnnotatedValue(Annotated annotated, String key) { |
| 168 | double value; |
| 169 | try { |
| 170 | value = Double.parseDouble(annotated.annotations().value(key)); |
| 171 | } catch (NumberFormatException e) { |
| 172 | value = 1.0; |
| 173 | } |
| 174 | return value; |
| 175 | } |
Sho SHIMIZU | fe129db | 2014-11-11 14:24:51 -0800 | [diff] [blame] | 176 | } |