blob: fe0ad870fd2fd94d9053ee74f9d650a18c18d1e1 [file] [log] [blame]
HIGUCHI Yutaea60e5f2013-06-12 11:10:21 -07001package net.onrc.onos.ofcontroller.bgproute;
pingping-line2a09ca2013-03-23 09:33:58 +08002
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
Yuta HIGUCHI6ac8d182013-10-22 15:24:56 -070013 protected final static Logger log = LoggerFactory
pingping-line2a09ca2013-03-23 09:33:58 +080014 .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}