HIGUCHI Yuta | a56fbde | 2013-06-17 14:26:05 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.linkdiscovery.web; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 2 | |
HIGUCHI Yuta | a56fbde | 2013-06-17 14:26:05 -0700 | [diff] [blame] | 3 | import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryService; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 4 | |
| 5 | import org.restlet.data.Status; |
| 6 | import org.restlet.resource.Get; |
| 7 | import org.restlet.resource.ServerResource; |
| 8 | import org.slf4j.Logger; |
| 9 | import org.slf4j.LoggerFactory; |
| 10 | |
| 11 | public class AutoPortFast extends ServerResource { |
| 12 | protected static Logger log = LoggerFactory.getLogger(AutoPortFast.class); |
| 13 | |
| 14 | @Get("json") |
| 15 | public String retrieve() { |
| 16 | ILinkDiscoveryService linkDiscovery; |
| 17 | linkDiscovery = (ILinkDiscoveryService)getContext().getAttributes(). |
| 18 | get(ILinkDiscoveryService.class.getCanonicalName()); |
| 19 | |
| 20 | String param = ((String)getRequestAttributes().get("state")).toLowerCase(); |
| 21 | if (param.equals("enable") || param.equals("true")) { |
| 22 | linkDiscovery.setAutoPortFastFeature(true); |
| 23 | } else if (param.equals("disable") || param.equals("false")) { |
| 24 | linkDiscovery.setAutoPortFastFeature(false); |
| 25 | } |
| 26 | setStatus(Status.SUCCESS_OK, "OK"); |
| 27 | if (linkDiscovery.isAutoPortFastFeature()) |
| 28 | return "enabled"; |
| 29 | else return "disabled"; |
| 30 | } |
| 31 | } |