Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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 | */ |
| 16 | package org.onosproject.ui.impl; |
| 17 | |
| 18 | import com.fasterxml.jackson.databind.JsonNode; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 19 | import com.fasterxml.jackson.databind.node.ArrayNode; |
| 20 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 21 | import org.onlab.osgi.ServiceDirectory; |
| 22 | import org.onlab.packet.IpAddress; |
| 23 | import org.onosproject.cluster.ClusterEvent; |
| 24 | import org.onosproject.cluster.ClusterService; |
| 25 | import org.onosproject.cluster.ControllerNode; |
| 26 | import org.onosproject.cluster.NodeId; |
| 27 | import org.onosproject.core.CoreService; |
Thomas Vachuska | f0397b5 | 2015-05-29 13:50:17 -0700 | [diff] [blame] | 28 | import org.onosproject.incubator.net.PortStatisticsService; |
cheng fan | 35dc0f2 | 2015-06-10 06:02:47 +0800 | [diff] [blame] | 29 | import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; |
| 30 | import org.onosproject.incubator.net.tunnel.Tunnel; |
| 31 | import org.onosproject.incubator.net.tunnel.TunnelService; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 32 | import org.onosproject.mastership.MastershipService; |
| 33 | import org.onosproject.net.Annotated; |
| 34 | import org.onosproject.net.AnnotationKeys; |
| 35 | import org.onosproject.net.Annotations; |
| 36 | import org.onosproject.net.ConnectPoint; |
| 37 | import org.onosproject.net.DefaultEdgeLink; |
| 38 | import org.onosproject.net.Device; |
| 39 | import org.onosproject.net.DeviceId; |
| 40 | import org.onosproject.net.EdgeLink; |
| 41 | import org.onosproject.net.Host; |
| 42 | import org.onosproject.net.HostId; |
| 43 | import org.onosproject.net.HostLocation; |
| 44 | import org.onosproject.net.Link; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 45 | import org.onosproject.net.PortNumber; |
| 46 | import org.onosproject.net.device.DeviceEvent; |
| 47 | import org.onosproject.net.device.DeviceService; |
| 48 | import org.onosproject.net.flow.FlowEntry; |
| 49 | import org.onosproject.net.flow.FlowRuleService; |
| 50 | import org.onosproject.net.flow.TrafficTreatment; |
| 51 | import org.onosproject.net.flow.instructions.Instruction; |
| 52 | import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; |
| 53 | import org.onosproject.net.host.HostEvent; |
| 54 | import org.onosproject.net.host.HostService; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 55 | import org.onosproject.net.intent.IntentService; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 56 | import org.onosproject.net.link.LinkEvent; |
| 57 | import org.onosproject.net.link.LinkService; |
| 58 | import org.onosproject.net.provider.ProviderId; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 59 | import org.onosproject.net.statistic.StatisticService; |
| 60 | import org.onosproject.net.topology.Topology; |
| 61 | import org.onosproject.net.topology.TopologyService; |
Simon Hunt | d2747a0 | 2015-04-30 22:41:16 -0700 | [diff] [blame] | 62 | import org.onosproject.ui.JsonUtils; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 63 | import org.onosproject.ui.UiConnection; |
Simon Hunt | a0ddb02 | 2015-05-01 09:53:01 -0700 | [diff] [blame] | 64 | import org.onosproject.ui.UiMessageHandler; |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 65 | import org.onosproject.ui.impl.topo.ServicesBundle; |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 66 | import org.onosproject.ui.topo.ButtonId; |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 67 | import org.onosproject.ui.topo.DeviceHighlight; |
| 68 | import org.onosproject.ui.topo.Highlights; |
| 69 | import org.onosproject.ui.topo.HostHighlight; |
| 70 | import org.onosproject.ui.topo.LinkHighlight; |
Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame] | 71 | import org.onosproject.ui.topo.PropertyPanel; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 72 | import org.slf4j.Logger; |
| 73 | import org.slf4j.LoggerFactory; |
| 74 | |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 75 | import java.util.ArrayList; |
| 76 | import java.util.Collection; |
| 77 | import java.util.Collections; |
| 78 | import java.util.HashMap; |
| 79 | import java.util.HashSet; |
| 80 | import java.util.Iterator; |
| 81 | import java.util.List; |
| 82 | import java.util.Map; |
| 83 | import java.util.Set; |
| 84 | import java.util.concurrent.ConcurrentHashMap; |
| 85 | |
| 86 | import static com.google.common.base.Preconditions.checkNotNull; |
| 87 | import static com.google.common.base.Strings.isNullOrEmpty; |
| 88 | import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_ADDED; |
| 89 | import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_REMOVED; |
| 90 | import static org.onosproject.cluster.ControllerNode.State.ACTIVE; |
Thomas Vachuska | 204cb6c | 2015-06-04 00:03:06 -0700 | [diff] [blame] | 91 | import static org.onosproject.net.DefaultEdgeLink.createEdgeLink; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 92 | import static org.onosproject.net.PortNumber.portNumber; |
| 93 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED; |
| 94 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_REMOVED; |
| 95 | import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; |
| 96 | import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED; |
| 97 | import static org.onosproject.net.link.LinkEvent.Type.LINK_ADDED; |
| 98 | import static org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED; |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 99 | import static org.onosproject.ui.impl.topo.TopoUtils.compactLinkString; |
Simon Hunt | 3a0598f | 2015-08-04 19:59:04 -0700 | [diff] [blame] | 100 | import static org.onosproject.ui.topo.TopoConstants.CoreButtons; |
| 101 | import static org.onosproject.ui.topo.TopoConstants.Properties; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 102 | |
| 103 | /** |
| 104 | * Facility for creating messages bound for the topology viewer. |
| 105 | */ |
Simon Hunt | a0ddb02 | 2015-05-01 09:53:01 -0700 | [diff] [blame] | 106 | public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 107 | |
Simon Hunt | d2747a0 | 2015-04-30 22:41:16 -0700 | [diff] [blame] | 108 | protected static final Logger log = |
| 109 | LoggerFactory.getLogger(TopologyViewMessageHandlerBase.class); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 110 | |
Simon Hunt | d2747a0 | 2015-04-30 22:41:16 -0700 | [diff] [blame] | 111 | private static final ProviderId PID = |
| 112 | new ProviderId("core", "org.onosproject.core", true); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 113 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 114 | protected static final String SHOW_HIGHLIGHTS = "showHighlights"; |
Thomas Vachuska | f0397b5 | 2015-05-29 13:50:17 -0700 | [diff] [blame] | 115 | |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 116 | protected ServiceDirectory directory; |
| 117 | protected ClusterService clusterService; |
| 118 | protected DeviceService deviceService; |
| 119 | protected LinkService linkService; |
| 120 | protected HostService hostService; |
| 121 | protected MastershipService mastershipService; |
| 122 | protected IntentService intentService; |
| 123 | protected FlowRuleService flowService; |
Thomas Vachuska | f0397b5 | 2015-05-29 13:50:17 -0700 | [diff] [blame] | 124 | protected StatisticService flowStatsService; |
| 125 | protected PortStatisticsService portStatsService; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 126 | protected TopologyService topologyService; |
cheng fan | 35dc0f2 | 2015-06-10 06:02:47 +0800 | [diff] [blame] | 127 | protected TunnelService tunnelService; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 128 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 129 | protected ServicesBundle servicesBundle; |
Thomas Vachuska | f0397b5 | 2015-05-29 13:50:17 -0700 | [diff] [blame] | 130 | |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 131 | private String version; |
| 132 | |
| 133 | // TODO: extract into an external & durable state; good enough for now and demo |
| 134 | private static Map<String, ObjectNode> metaUi = new ConcurrentHashMap<>(); |
| 135 | |
| 136 | /** |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 137 | * Returns read-only view of the meta-ui information. |
| 138 | * |
| 139 | * @return map of id to meta-ui mementos |
| 140 | */ |
| 141 | static Map<String, ObjectNode> getMetaUi() { |
| 142 | return Collections.unmodifiableMap(metaUi); |
| 143 | } |
| 144 | |
| 145 | @Override |
| 146 | public void init(UiConnection connection, ServiceDirectory directory) { |
| 147 | super.init(connection, directory); |
| 148 | this.directory = checkNotNull(directory, "Directory cannot be null"); |
| 149 | clusterService = directory.get(ClusterService.class); |
| 150 | deviceService = directory.get(DeviceService.class); |
| 151 | linkService = directory.get(LinkService.class); |
| 152 | hostService = directory.get(HostService.class); |
| 153 | mastershipService = directory.get(MastershipService.class); |
| 154 | intentService = directory.get(IntentService.class); |
| 155 | flowService = directory.get(FlowRuleService.class); |
Thomas Vachuska | f0397b5 | 2015-05-29 13:50:17 -0700 | [diff] [blame] | 156 | flowStatsService = directory.get(StatisticService.class); |
| 157 | portStatsService = directory.get(PortStatisticsService.class); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 158 | topologyService = directory.get(TopologyService.class); |
cheng fan | 35dc0f2 | 2015-06-10 06:02:47 +0800 | [diff] [blame] | 159 | tunnelService = directory.get(TunnelService.class); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 160 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 161 | servicesBundle = new ServicesBundle(intentService, deviceService, |
| 162 | hostService, linkService, |
| 163 | flowService, |
| 164 | flowStatsService, portStatsService); |
| 165 | |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 166 | String ver = directory.get(CoreService.class).version().toString(); |
| 167 | version = ver.replace(".SNAPSHOT", "*").replaceFirst("~.*$", ""); |
| 168 | } |
| 169 | |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 170 | // Returns the specified set of IP addresses as a string. |
| 171 | private String ip(Set<IpAddress> ipAddresses) { |
| 172 | Iterator<IpAddress> it = ipAddresses.iterator(); |
| 173 | return it.hasNext() ? it.next().toString() : "unknown"; |
| 174 | } |
| 175 | |
| 176 | // Produces JSON structure from annotations. |
| 177 | private JsonNode props(Annotations annotations) { |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 178 | ObjectNode props = objectNode(); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 179 | if (annotations != null) { |
| 180 | for (String key : annotations.keys()) { |
| 181 | props.put(key, annotations.value(key)); |
| 182 | } |
| 183 | } |
| 184 | return props; |
| 185 | } |
| 186 | |
| 187 | // Produces an informational log message event bound to the client. |
| 188 | protected ObjectNode info(long id, String message) { |
| 189 | return message("info", id, message); |
| 190 | } |
| 191 | |
| 192 | // Produces a warning log message event bound to the client. |
| 193 | protected ObjectNode warning(long id, String message) { |
| 194 | return message("warning", id, message); |
| 195 | } |
| 196 | |
| 197 | // Produces an error log message event bound to the client. |
| 198 | protected ObjectNode error(long id, String message) { |
| 199 | return message("error", id, message); |
| 200 | } |
| 201 | |
| 202 | // Produces a log message event bound to the client. |
| 203 | private ObjectNode message(String severity, long id, String message) { |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 204 | ObjectNode payload = objectNode() |
Simon Hunt | d2747a0 | 2015-04-30 22:41:16 -0700 | [diff] [blame] | 205 | .put("severity", severity) |
| 206 | .put("message", message); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 207 | |
Simon Hunt | d2747a0 | 2015-04-30 22:41:16 -0700 | [diff] [blame] | 208 | return JsonUtils.envelope("message", id, payload); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 211 | // Produces a cluster instance message to the client. |
| 212 | protected ObjectNode instanceMessage(ClusterEvent event, String messageType) { |
| 213 | ControllerNode node = event.subject(); |
| 214 | int switchCount = mastershipService.getDevicesOf(node.id()).size(); |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 215 | ObjectNode payload = objectNode() |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 216 | .put("id", node.id().toString()) |
| 217 | .put("ip", node.ip().toString()) |
| 218 | .put("online", clusterService.getState(node.id()) == ACTIVE) |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 219 | .put("uiAttached", node.equals(clusterService.getLocalNode())) |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 220 | .put("switches", switchCount); |
| 221 | |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 222 | ArrayNode labels = arrayNode(); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 223 | labels.add(node.id().toString()); |
| 224 | labels.add(node.ip().toString()); |
| 225 | |
| 226 | // Add labels, props and stuff the payload into envelope. |
| 227 | payload.set("labels", labels); |
| 228 | addMetaUi(node.id().toString(), payload); |
| 229 | |
| 230 | String type = messageType != null ? messageType : |
| 231 | ((event.type() == INSTANCE_ADDED) ? "addInstance" : |
| 232 | ((event.type() == INSTANCE_REMOVED ? "removeInstance" : |
| 233 | "addInstance"))); |
Simon Hunt | d2747a0 | 2015-04-30 22:41:16 -0700 | [diff] [blame] | 234 | return JsonUtils.envelope(type, 0, payload); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | // Produces a device event message to the client. |
| 238 | protected ObjectNode deviceMessage(DeviceEvent event) { |
| 239 | Device device = event.subject(); |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 240 | ObjectNode payload = objectNode() |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 241 | .put("id", device.id().toString()) |
| 242 | .put("type", device.type().toString().toLowerCase()) |
| 243 | .put("online", deviceService.isAvailable(device.id())) |
| 244 | .put("master", master(device.id())); |
| 245 | |
| 246 | // Generate labels: id, chassis id, no-label, optional-name |
| 247 | String name = device.annotations().value(AnnotationKeys.NAME); |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 248 | ArrayNode labels = arrayNode(); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 249 | labels.add(""); |
| 250 | labels.add(isNullOrEmpty(name) ? device.id().toString() : name); |
| 251 | labels.add(device.id().toString()); |
| 252 | |
| 253 | // Add labels, props and stuff the payload into envelope. |
| 254 | payload.set("labels", labels); |
| 255 | payload.set("props", props(device.annotations())); |
| 256 | addGeoLocation(device, payload); |
| 257 | addMetaUi(device.id().toString(), payload); |
| 258 | |
| 259 | String type = (event.type() == DEVICE_ADDED) ? "addDevice" : |
| 260 | ((event.type() == DEVICE_REMOVED) ? "removeDevice" : "updateDevice"); |
Simon Hunt | d2747a0 | 2015-04-30 22:41:16 -0700 | [diff] [blame] | 261 | return JsonUtils.envelope(type, 0, payload); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | // Produces a link event message to the client. |
| 265 | protected ObjectNode linkMessage(LinkEvent event) { |
| 266 | Link link = event.subject(); |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 267 | ObjectNode payload = objectNode() |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 268 | .put("id", compactLinkString(link)) |
| 269 | .put("type", link.type().toString().toLowerCase()) |
| 270 | .put("online", link.state() == Link.State.ACTIVE) |
| 271 | .put("linkWidth", 1.2) |
| 272 | .put("src", link.src().deviceId().toString()) |
| 273 | .put("srcPort", link.src().port().toString()) |
| 274 | .put("dst", link.dst().deviceId().toString()) |
| 275 | .put("dstPort", link.dst().port().toString()); |
| 276 | String type = (event.type() == LINK_ADDED) ? "addLink" : |
| 277 | ((event.type() == LINK_REMOVED) ? "removeLink" : "updateLink"); |
Simon Hunt | d2747a0 | 2015-04-30 22:41:16 -0700 | [diff] [blame] | 278 | return JsonUtils.envelope(type, 0, payload); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | // Produces a host event message to the client. |
| 282 | protected ObjectNode hostMessage(HostEvent event) { |
| 283 | Host host = event.subject(); |
| 284 | String hostType = host.annotations().value(AnnotationKeys.TYPE); |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 285 | ObjectNode payload = objectNode() |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 286 | .put("id", host.id().toString()) |
| 287 | .put("type", isNullOrEmpty(hostType) ? "endstation" : hostType) |
| 288 | .put("ingress", compactLinkString(edgeLink(host, true))) |
| 289 | .put("egress", compactLinkString(edgeLink(host, false))); |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 290 | payload.set("cp", hostConnect(host.location())); |
| 291 | payload.set("labels", labels(ip(host.ipAddresses()), |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 292 | host.mac().toString())); |
| 293 | payload.set("props", props(host.annotations())); |
| 294 | addGeoLocation(host, payload); |
| 295 | addMetaUi(host.id().toString(), payload); |
| 296 | |
| 297 | String type = (event.type() == HOST_ADDED) ? "addHost" : |
| 298 | ((event.type() == HOST_REMOVED) ? "removeHost" : "updateHost"); |
Simon Hunt | d2747a0 | 2015-04-30 22:41:16 -0700 | [diff] [blame] | 299 | return JsonUtils.envelope(type, 0, payload); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | // Encodes the specified host location into a JSON object. |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 303 | private ObjectNode hostConnect(HostLocation location) { |
| 304 | return objectNode() |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 305 | .put("device", location.deviceId().toString()) |
| 306 | .put("port", location.port().toLong()); |
| 307 | } |
| 308 | |
| 309 | // Encodes the specified list of labels a JSON array. |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 310 | private ArrayNode labels(String... labels) { |
| 311 | ArrayNode json = arrayNode(); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 312 | for (String label : labels) { |
| 313 | json.add(label); |
| 314 | } |
| 315 | return json; |
| 316 | } |
| 317 | |
| 318 | // Returns the name of the master node for the specified device id. |
| 319 | private String master(DeviceId deviceId) { |
| 320 | NodeId master = mastershipService.getMasterFor(deviceId); |
| 321 | return master != null ? master.toString() : ""; |
| 322 | } |
| 323 | |
| 324 | // Generates an edge link from the specified host location. |
| 325 | private EdgeLink edgeLink(Host host, boolean ingress) { |
| 326 | return new DefaultEdgeLink(PID, new ConnectPoint(host.id(), portNumber(0)), |
| 327 | host.location(), ingress); |
| 328 | } |
| 329 | |
| 330 | // Adds meta UI information for the specified object. |
| 331 | private void addMetaUi(String id, ObjectNode payload) { |
| 332 | ObjectNode meta = metaUi.get(id); |
| 333 | if (meta != null) { |
| 334 | payload.set("metaUi", meta); |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | // Adds a geo location JSON to the specified payload object. |
| 339 | private void addGeoLocation(Annotated annotated, ObjectNode payload) { |
| 340 | Annotations annotations = annotated.annotations(); |
| 341 | if (annotations == null) { |
| 342 | return; |
| 343 | } |
| 344 | |
| 345 | String slat = annotations.value(AnnotationKeys.LATITUDE); |
| 346 | String slng = annotations.value(AnnotationKeys.LONGITUDE); |
| 347 | try { |
| 348 | if (slat != null && slng != null && !slat.isEmpty() && !slng.isEmpty()) { |
| 349 | double lat = Double.parseDouble(slat); |
| 350 | double lng = Double.parseDouble(slng); |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 351 | ObjectNode loc = objectNode() |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 352 | .put("type", "latlng").put("lat", lat).put("lng", lng); |
| 353 | payload.set("location", loc); |
| 354 | } |
| 355 | } catch (NumberFormatException e) { |
| 356 | log.warn("Invalid geo data latitude={}; longiture={}", slat, slng); |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | // Updates meta UI information for the specified object. |
Simon Hunt | d2747a0 | 2015-04-30 22:41:16 -0700 | [diff] [blame] | 361 | protected void updateMetaUi(ObjectNode payload) { |
| 362 | metaUi.put(JsonUtils.string(payload, "id"), |
| 363 | JsonUtils.node(payload, "memento")); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 364 | } |
| 365 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 366 | |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 367 | // ----------------------------------------------------------------------- |
| 368 | // Create models of the data to return, that overlays can adjust / augment |
| 369 | |
| 370 | // Returns property panel model for summary response. |
Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame] | 371 | protected PropertyPanel summmaryMessage(long sid) { |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 372 | Topology topology = topologyService.currentTopology(); |
Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame] | 373 | |
Simon Hunt | 00a27ff | 2015-07-28 18:53:40 -0700 | [diff] [blame] | 374 | return new PropertyPanel("ONOS Summary", "node") |
Simon Hunt | fb94011 | 2015-07-29 18:36:35 -0700 | [diff] [blame] | 375 | .addProp(Properties.DEVICES, topology.deviceCount()) |
| 376 | .addProp(Properties.LINKS, topology.linkCount()) |
| 377 | .addProp(Properties.HOSTS, hostService.getHostCount()) |
| 378 | .addProp(Properties.TOPOLOGY_SSCS, topology.clusterCount()) |
Simon Hunt | 00a27ff | 2015-07-28 18:53:40 -0700 | [diff] [blame] | 379 | .addSeparator() |
Simon Hunt | fb94011 | 2015-07-29 18:36:35 -0700 | [diff] [blame] | 380 | .addProp(Properties.INTENTS, intentService.getIntentCount()) |
| 381 | .addProp(Properties.TUNNELS, tunnelService.tunnelCount()) |
| 382 | .addProp(Properties.FLOWS, flowService.getFlowRuleCount()) |
| 383 | .addProp(Properties.VERSION, version); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 384 | } |
| 385 | |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 386 | // Returns property panel model for device details response. |
| 387 | protected PropertyPanel deviceDetails(DeviceId deviceId, long sid) { |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 388 | Device device = deviceService.getDevice(deviceId); |
| 389 | Annotations annot = device.annotations(); |
| 390 | String name = annot.value(AnnotationKeys.NAME); |
| 391 | int portCount = deviceService.getPorts(deviceId).size(); |
| 392 | int flowCount = getFlowCount(deviceId); |
cheng fan | 35dc0f2 | 2015-06-10 06:02:47 +0800 | [diff] [blame] | 393 | int tunnelCount = getTunnelCount(deviceId); |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 394 | |
| 395 | String title = isNullOrEmpty(name) ? deviceId.toString() : name; |
| 396 | String typeId = device.type().toString().toLowerCase(); |
| 397 | |
| 398 | PropertyPanel pp = new PropertyPanel(title, typeId) |
Simon Hunt | fb94011 | 2015-07-29 18:36:35 -0700 | [diff] [blame] | 399 | .id(deviceId.toString()) |
Simon Hunt | 3a0598f | 2015-08-04 19:59:04 -0700 | [diff] [blame] | 400 | |
Simon Hunt | fb94011 | 2015-07-29 18:36:35 -0700 | [diff] [blame] | 401 | .addProp(Properties.URI, deviceId.toString()) |
| 402 | .addProp(Properties.VENDOR, device.manufacturer()) |
| 403 | .addProp(Properties.HW_VERSION, device.hwVersion()) |
| 404 | .addProp(Properties.SW_VERSION, device.swVersion()) |
| 405 | .addProp(Properties.SERIAL_NUMBER, device.serialNumber()) |
| 406 | .addProp(Properties.PROTOCOL, annot.value(AnnotationKeys.PROTOCOL)) |
| 407 | .addSeparator() |
Simon Hunt | 3a0598f | 2015-08-04 19:59:04 -0700 | [diff] [blame] | 408 | |
Simon Hunt | fb94011 | 2015-07-29 18:36:35 -0700 | [diff] [blame] | 409 | .addProp(Properties.LATITUDE, annot.value(AnnotationKeys.LATITUDE)) |
| 410 | .addProp(Properties.LONGITUDE, annot.value(AnnotationKeys.LONGITUDE)) |
| 411 | .addSeparator() |
Simon Hunt | 3a0598f | 2015-08-04 19:59:04 -0700 | [diff] [blame] | 412 | |
Simon Hunt | fb94011 | 2015-07-29 18:36:35 -0700 | [diff] [blame] | 413 | .addProp(Properties.PORTS, portCount) |
| 414 | .addProp(Properties.FLOWS, flowCount) |
Simon Hunt | 3a0598f | 2015-08-04 19:59:04 -0700 | [diff] [blame] | 415 | .addProp(Properties.TUNNELS, tunnelCount) |
Simon Hunt | 00a27ff | 2015-07-28 18:53:40 -0700 | [diff] [blame] | 416 | |
Simon Hunt | 3a0598f | 2015-08-04 19:59:04 -0700 | [diff] [blame] | 417 | .addButton(CoreButtons.SHOW_DEVICE_VIEW) |
| 418 | .addButton(CoreButtons.SHOW_FLOW_VIEW) |
| 419 | .addButton(CoreButtons.SHOW_PORT_VIEW) |
| 420 | .addButton(CoreButtons.SHOW_GROUP_VIEW); |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 421 | |
| 422 | return pp; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | protected int getFlowCount(DeviceId deviceId) { |
| 426 | int count = 0; |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 427 | for (FlowEntry flowEntry : flowService.getFlowEntries(deviceId)) { |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 428 | count++; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 429 | } |
| 430 | return count; |
| 431 | } |
| 432 | |
cheng fan | 35dc0f2 | 2015-06-10 06:02:47 +0800 | [diff] [blame] | 433 | protected int getTunnelCount(DeviceId deviceId) { |
| 434 | int count = 0; |
| 435 | Collection<Tunnel> tunnels = tunnelService.queryAllTunnels(); |
| 436 | for (Tunnel tunnel : tunnels) { |
| 437 | OpticalTunnelEndPoint src = (OpticalTunnelEndPoint) tunnel.src(); |
| 438 | OpticalTunnelEndPoint dst = (OpticalTunnelEndPoint) tunnel.dst(); |
| 439 | DeviceId srcDevice = (DeviceId) src.elementId().get(); |
| 440 | DeviceId dstDevice = (DeviceId) dst.elementId().get(); |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 441 | if (srcDevice.toString().equals(deviceId.toString()) || |
| 442 | dstDevice.toString().equals(deviceId.toString())) { |
cheng fan | 35dc0f2 | 2015-06-10 06:02:47 +0800 | [diff] [blame] | 443 | count++; |
| 444 | } |
| 445 | } |
| 446 | return count; |
| 447 | } |
| 448 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 449 | // Counts all flow entries that egress on the links of the given device. |
| 450 | private Map<Link, Integer> getLinkFlowCounts(DeviceId deviceId) { |
| 451 | // get the flows for the device |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 452 | List<FlowEntry> entries = new ArrayList<>(); |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 453 | for (FlowEntry flowEntry : flowService.getFlowEntries(deviceId)) { |
| 454 | entries.add(flowEntry); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 455 | } |
| 456 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 457 | // get egress links from device, and include edge links |
| 458 | Set<Link> links = new HashSet<>(linkService.getDeviceEgressLinks(deviceId)); |
| 459 | Set<Host> hosts = hostService.getConnectedHosts(deviceId); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 460 | if (hosts != null) { |
| 461 | for (Host host : hosts) { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 462 | links.add(createEdgeLink(host, false)); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 463 | } |
| 464 | } |
| 465 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 466 | // compile flow counts per link |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 467 | Map<Link, Integer> counts = new HashMap<>(); |
| 468 | for (Link link : links) { |
| 469 | counts.put(link, getEgressFlows(link, entries)); |
| 470 | } |
| 471 | return counts; |
| 472 | } |
| 473 | |
| 474 | // Counts all entries that egress on the link source port. |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 475 | private int getEgressFlows(Link link, List<FlowEntry> entries) { |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 476 | int count = 0; |
| 477 | PortNumber out = link.src().port(); |
| 478 | for (FlowEntry entry : entries) { |
| 479 | TrafficTreatment treatment = entry.treatment(); |
Ray Milkey | 4250735 | 2015-03-20 15:16:10 -0700 | [diff] [blame] | 480 | for (Instruction instruction : treatment.allInstructions()) { |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 481 | if (instruction.type() == Instruction.Type.OUTPUT && |
| 482 | ((OutputInstruction) instruction).port().equals(out)) { |
| 483 | count++; |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | return count; |
| 488 | } |
| 489 | |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 490 | // Returns host details response. |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 491 | protected PropertyPanel hostDetails(HostId hostId, long sid) { |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 492 | Host host = hostService.getHost(hostId); |
| 493 | Annotations annot = host.annotations(); |
| 494 | String type = annot.value(AnnotationKeys.TYPE); |
| 495 | String name = annot.value(AnnotationKeys.NAME); |
| 496 | String vlan = host.vlan().toString(); |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 497 | |
| 498 | String title = isNullOrEmpty(name) ? hostId.toString() : name; |
| 499 | String typeId = isNullOrEmpty(type) ? "endstation" : type; |
| 500 | |
| 501 | PropertyPanel pp = new PropertyPanel(title, typeId) |
Simon Hunt | fb94011 | 2015-07-29 18:36:35 -0700 | [diff] [blame] | 502 | .id(hostId.toString()) |
| 503 | .addProp(Properties.MAC, host.mac()) |
| 504 | .addProp(Properties.IP, host.ipAddresses(), "[\\[\\]]") |
| 505 | .addProp(Properties.VLAN, vlan.equals("-1") ? "none" : vlan) |
| 506 | .addSeparator() |
| 507 | .addProp(Properties.LATITUDE, annot.value(AnnotationKeys.LATITUDE)) |
| 508 | .addProp(Properties.LONGITUDE, annot.value(AnnotationKeys.LONGITUDE)); |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 509 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 510 | // Potentially add button descriptors here |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 511 | return pp; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 515 | // ---------------------------------------------------------------------- |
| 516 | |
| 517 | /** |
| 518 | * Transforms the given highlights model into a JSON message payload. |
| 519 | * |
| 520 | * @param highlights the model to transform |
| 521 | * @return JSON payload |
| 522 | */ |
| 523 | protected ObjectNode json(Highlights highlights) { |
Simon Hunt | da58088 | 2015-05-12 20:58:18 -0700 | [diff] [blame] | 524 | ObjectNode payload = objectNode(); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 525 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 526 | ArrayNode devices = arrayNode(); |
| 527 | ArrayNode hosts = arrayNode(); |
| 528 | ArrayNode links = arrayNode(); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 529 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 530 | payload.set("devices", devices); |
| 531 | payload.set("hosts", hosts); |
| 532 | payload.set("links", links); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 533 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 534 | highlights.devices().forEach(dh -> devices.add(json(dh))); |
| 535 | highlights.hosts().forEach(hh -> hosts.add(json(hh))); |
| 536 | jsonifyLinks(links, highlights.links()); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 537 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 538 | return payload; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 539 | } |
| 540 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 541 | private void jsonifyLinks(ArrayNode links, Set<LinkHighlight> hilites) { |
| 542 | // a little more complicated than devices or hosts, since we are |
| 543 | // grouping the link highlights by CSS classes |
Thomas Vachuska | 204cb6c | 2015-06-04 00:03:06 -0700 | [diff] [blame] | 544 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 545 | // TODO: refactor this method (including client side) to use new format |
| 546 | // as a more compact representation of the data... |
| 547 | // * links: |
| 548 | // * "primary animated": |
| 549 | // * "link01" -> "label" |
| 550 | // * "link02" -> "label" |
| 551 | // * "secondary": |
| 552 | // * "link04" -> "label" |
| 553 | // * "link05" -> "" |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 554 | |
| 555 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 556 | Map<String, List<String>> linkIdMap = new HashMap<>(); |
| 557 | Map<String, List<String>> linkLabelMap = new HashMap<>(); |
| 558 | List<String> ids; |
| 559 | List<String> labels; |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 560 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 561 | for (LinkHighlight lh : hilites) { |
| 562 | String cls = lh.cssClasses(); |
| 563 | ids = linkIdMap.get(cls); |
| 564 | labels = linkLabelMap.get(cls); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 565 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 566 | if (ids == null) { // labels will be null also |
| 567 | ids = new ArrayList<>(); |
| 568 | linkIdMap.put(cls, ids); |
| 569 | labels = new ArrayList<>(); |
| 570 | linkLabelMap.put(cls, labels); |
Simon Hunt | 80170a7 | 2015-06-10 19:49:57 -0700 | [diff] [blame] | 571 | } |
| 572 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 573 | ids.add(lh.elementId()); |
| 574 | labels.add(lh.label()); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 575 | } |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 576 | |
| 577 | for (String cls : linkIdMap.keySet()) { |
| 578 | ObjectNode group = objectNode(); |
| 579 | links.add(group); |
| 580 | |
| 581 | group.put("class", cls); |
| 582 | |
| 583 | ArrayNode lnks = arrayNode(); |
| 584 | ArrayNode labs = arrayNode(); |
| 585 | group.set("links", lnks); |
| 586 | group.set("labels", labs); |
| 587 | |
| 588 | linkIdMap.get(cls).forEach(lnks::add); |
| 589 | linkLabelMap.get(cls).forEach(labs::add); |
| 590 | } |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 591 | } |
| 592 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame^] | 593 | |
| 594 | protected ObjectNode json(DeviceHighlight dh) { |
| 595 | // TODO: implement this once we know what a device highlight looks like |
| 596 | return objectNode(); |
| 597 | } |
| 598 | |
| 599 | protected ObjectNode json(HostHighlight hh) { |
| 600 | // TODO: implement this once we know what a host highlight looks like |
| 601 | return objectNode(); |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 602 | } |
| 603 | |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 604 | // translates the property panel into JSON, for returning to the client |
Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame] | 605 | protected ObjectNode json(PropertyPanel pp) { |
| 606 | ObjectNode result = objectNode() |
Simon Hunt | b745ca6 | 2015-07-28 15:37:11 -0700 | [diff] [blame] | 607 | .put("title", pp.title()) |
| 608 | .put("type", pp.typeId()) |
| 609 | .put("id", pp.id()); |
| 610 | |
Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame] | 611 | ObjectNode pnode = objectNode(); |
| 612 | ArrayNode porder = arrayNode(); |
| 613 | for (PropertyPanel.Prop p : pp.properties()) { |
| 614 | porder.add(p.key()); |
| 615 | pnode.put(p.key(), p.value()); |
| 616 | } |
| 617 | result.set("propOrder", porder); |
| 618 | result.set("props", pnode); |
Simon Hunt | fb94011 | 2015-07-29 18:36:35 -0700 | [diff] [blame] | 619 | |
| 620 | ArrayNode buttons = arrayNode(); |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 621 | for (ButtonId b : pp.buttons()) { |
| 622 | buttons.add(b.id()); |
Simon Hunt | fb94011 | 2015-07-29 18:36:35 -0700 | [diff] [blame] | 623 | } |
| 624 | result.set("buttons", buttons); |
Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame] | 625 | return result; |
| 626 | } |
| 627 | |
Thomas Vachuska | 329af53 | 2015-03-10 02:08:33 -0700 | [diff] [blame] | 628 | } |