summaryrefslogtreecommitdiffstats
path: root/osdfapp.py
diff options
context:
space:
mode:
authorseshukm <seshu.kumar.m@huawei.com>2018-09-01 21:51:44 +0800
committerSeshu Kumar M <seshu.kumar.m@huawei.com>2018-09-03 08:44:31 +0000
commit20341f67d4cc4be4e048aa26840ec55b66341c3f (patch)
treef948c40786b2e42e8cf2eb40f98496a717cc878a /osdfapp.py
parent0c5c12ce1b84a1a26362eac5c98d9eb47d8b0ec3 (diff)
Fix return message format
Change-Id: Ia52cf0675449fdabdaba33928daa0cbcd99df781 Issue-ID: OPTFRA-334 Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
Diffstat (limited to 'osdfapp.py')
-rwxr-xr-xosdfapp.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/osdfapp.py b/osdfapp.py
index bd5efa7..6ae84cc 100755
--- a/osdfapp.py
+++ b/osdfapp.py
@@ -125,15 +125,38 @@ def do_placement_opt():
@app.route("/api/oof/v1/route", methods=["POST"])
-@auth_basic.login_required
def do_route_calc():
- """Perform the basic route calculations and returnn the vpn-bindings
- TODO:Need to add the new class for the route in the API and model to provide this function
+ """
+ Perform the basic route calculations and returnn the vpn-bindings
"""
request_json = request.get_json()
audit_log.info("Calculate Route request received!")
- return RouteOpt.getRoute(request_json)
-
+ src_access_node_id = ""
+ dst_access_node_id = ""
+ try:
+ src_access_node_id = request_json["srcPort"]["src-access-node-id"]
+ audit_log.info( src_access_node_id )
+ dst_access_node_id = request_json["dstPort"]["dst-access-node-id"]
+ except Exception as ex:
+ error_log.error("Exception while retriving the src and dst node info")
+ # for the case of request_json for same domain, return the same node with destination update
+ if src_access_node_id == dst_access_node_id:
+ audit_log.info("src and dst are same")
+ data = '{'\
+ '"vpns":['\
+ '{'\
+ '"access-topology-id": "' + request_json["srcPort"]["src-access-topology-id"] + '",'\
+ '"access-client-id": "' + request_json["srcPort"]["src-access-client-id"] + '",'\
+ '"access-provider-id": "' + request_json["srcPort"]["src-access-provider-id"]+ '",'\
+ '"access-node-id": "' + request_json["srcPort"]["src-access-node-id"]+ '",'\
+ '"src-access-ltp-id": "' + request_json["srcPort"]["src-access-ltp-id"]+ '",'\
+ '"dst-access-ltp-id": "' + request_json["dstPort"]["dst-access-ltp-id"] +'"'\
+ '}'\
+ ']'\
+ '}'
+ return data
+ else:
+ return RouteOpt.getRoute(request_json)
@app.errorhandler(500)
def internal_failure(error):