REST plug in for Tunnel CLI commands
diff --git a/cli/cli/c_actions.py b/cli/cli/c_actions.py
index 00582cf..4e01de3 100755
--- a/cli/cli/c_actions.py
+++ b/cli/cli/c_actions.py
@@ -97,11 +97,19 @@
if tunnel_dict:
url_str = ""
entries = tunnel_dict[tunnel_id]
- for entry in entries:
- url_str = url_str + "/node/" + entry
- print url_str
+ url_str = "http://%s/rest/v1/tunnel/" % (sdnsh.controller)
+ obj_data = {}
+ obj_data['tunnel-id']=tunnel_id
+ obj_data['tunnel-path']=entries
+ data = sdnsh.store.rest_post_request(url_str,obj_data)
+ # LOOK! successful stuff should be returned in json too.
+ if data != "saved":
+ result = json.loads(data)
+ return result
else:
print "empty command"
+ #Clear the transit information
+ tunnel_dict = {}
def write_fields(obj_type, obj_id, data):
diff --git a/cli/sdncon/rest/views.py b/cli/sdncon/rest/views.py
index e7ba572..f8c616b 100755
--- a/cli/sdncon/rest/views.py
+++ b/cli/sdncon/rest/views.py
@@ -2133,4 +2133,19 @@
jsondict['description'] = str(result['out']).strip()
return HttpResponse(simplejson.dumps(jsondict), JSON_CONTENT_TYPE)
+
+@safe_rest_view
+def do_sdnplatform_tunnel_config(request):
+ if request.method != 'PUT':
+ raise RestInvalidMethodException()
+
+ url = controller_url('onos', 'segmentrouting', 'tunnel')
+ post_data = request.raw_post_data
+ put_request = urllib2.Request(url, post_data)
+ put_request.get_method = lambda: 'POST'
+ put_request.add_header('Content-Type', 'application/json')
+ response = urllib2.urlopen(put_request)
+ response_text = response.read()
+ response = HttpResponse(response_text, JSON_CONTENT_TYPE)
+ return response
diff --git a/cli/sdncon/urls.py b/cli/sdncon/urls.py
index 329dc7d..4237d17 100755
--- a/cli/sdncon/urls.py
+++ b/cli/sdncon/urls.py
@@ -167,6 +167,9 @@
# REST APIs for controller summary statistics
(r'^rest/v1/controller/summary$', 'sdncon.rest.views.do_sdnplatform_controller_summary'),
+
+ # REST APIs for tunnel
+ (r'^rest/v1/tunnel/?$', 'sdncon.rest.views.do_sdnplatform_tunnel_config'),
)