X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=osdfapp.py;h=6ae84cc3a47a0efeab5e6ced57602ea92986541f;hb=20341f67d4cc4be4e048aa26840ec55b66341c3f;hp=bd5efa718efff1be51966a5b6df66c31c08007a9;hpb=0c5c12ce1b84a1a26362eac5c98d9eb47d8b0ec3;p=optf%2Fosdf.git 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):