blob: ff7aea6858bba0b154849e9abf2ec197c2b6a4e3 [file] [log] [blame]
pingping-line2a09ca2013-03-23 09:33:58 +08001package net.floodlightcontroller.bgproute;
2
3
4import org.restlet.resource.Post;
5import org.restlet.resource.Delete;
6import org.restlet.resource.ServerResource;
7import org.slf4j.Logger;
8import org.slf4j.LoggerFactory;
pingping-line2a09ca2013-03-23 09:33:58 +08009
10
11public class BgpRouteResourceSynch extends ServerResource {
12
13 protected static Logger log = LoggerFactory
14 .getLogger(BgpRouteResource.class);
15
16 @Post
17 public String store(String fmJson) {
18
19 IBgpRouteService bgpRoute = (IBgpRouteService)getContext().getAttributes().
20 get(IBgpRouteService.class.getCanonicalName());
21
22 String router_id = (String) getRequestAttributes().get("routerid");
23 String prefix = (String) getRequestAttributes().get("prefix");
24 String mask = (String) getRequestAttributes().get("mask");
25 String nexthop = (String) getRequestAttributes().get("nexthop");
26
27 try{
28
29 String BGPdRestIp = bgpRoute.getBGPdRestIp();
30
Jonathan Hart61ba9372013-05-19 20:10:29 -070031 //bgpdRestIp includes port number, such as 1.1.1.1:8080
pingping-line2a09ca2013-03-23 09:33:58 +080032 RestClient.post("http://"+BGPdRestIp+"/wm/bgp/"+router_id+"/"+prefix+"/"+mask+"/"+nexthop);
33 }catch(Exception e)
34 {e.printStackTrace();}
35
36 String reply = "";
37 reply = "[POST: " + prefix + "/" + mask + ":" + nexthop + "/synch]";
38 log.info(reply);
39
40 return reply + "\n";
41
42
43 }
44
45 @Delete
46 public String delete(String fmJson) {
47 IBgpRouteService bgpRoute = (IBgpRouteService)getContext().getAttributes().
48 get(IBgpRouteService.class.getCanonicalName());
49
50 String routerId = (String) getRequestAttributes().get("routerid");
51 String prefix = (String) getRequestAttributes().get("prefix");
52 String mask = (String) getRequestAttributes().get("mask");
53 String nextHop = (String) getRequestAttributes().get("nexthop");
54
55 String reply = "";
56 try{
57 String BGPdRestIp = bgpRoute.getBGPdRestIp();
58
59 RestClient.delete("http://"+BGPdRestIp+"/wm/bgp/"+routerId+"/"+prefix+"/"+mask+"/"+nextHop);
60
61 }catch(Exception e)
62 {e.printStackTrace();}
63
64 reply =reply + "[DELE: " + prefix + "/" + mask + ":" + nextHop + "/synch]";
65
66 log.info(reply);
67
68
69 return reply + "\n";
70 }
71}