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 { |
Yuta HIGUCHI | 6ac8d18 | 2013-10-22 15:24:56 -0700 | [diff] [blame] | 12 | protected final static Logger log = LoggerFactory.getLogger(AutoPortFast.class); |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 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 | } |