Skip to content
Snippets Groups Projects
Commit 3ac0fb59 authored by Randall Sharo's avatar Randall Sharo
Browse files

Changed DeviceResource to return a JSON object instead of simply returning a list.

Many REST ingest schemes (e.g. Graylog "JSON path from HTTP") expect servers to return well-formed JSON objects.  Floodlight is sometimes returning values that lack root objects.

Was:
   [ <list-of-device-objects>]

Now:
   { 'devices' : <list-of-device-objects> }
parent 0af050a2
No related branches found
No related tags found
No related merge requests found
/**
* Copyright 2012, Big Switch Networks, Inc.
* Copyright 2012, Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
......@@ -17,7 +17,9 @@
package net.floodlightcontroller.devicemanager.web;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import net.floodlightcontroller.devicemanager.IDevice;
import org.restlet.resource.Get;
......@@ -26,8 +28,14 @@ import org.restlet.resource.Get;
* Resource for querying and displaying devices that exist in the system
*/
public class DeviceResource extends AbstractDeviceResource {
@Get("json")
public Iterator<? extends IDevice> getDevices() {
return super.getDevices();
}
@Get("json")
public Map<String, Iterator<? extends IDevice>> getNamedDeviceList() {
Map<String, Iterator<? extends IDevice>> result = new HashMap<String, Iterator<? extends IDevice>>();
result.put("devices", getDevices());
return result;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment