summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--osdf/optimizers/routeopt/simple_route_opt.py65
-rwxr-xr-xosdfapp.py33
2 files changed, 54 insertions, 44 deletions
diff --git a/osdf/optimizers/routeopt/simple_route_opt.py b/osdf/optimizers/routeopt/simple_route_opt.py
index 9560996..d1cf13f 100644
--- a/osdf/optimizers/routeopt/simple_route_opt.py
+++ b/osdf/optimizers/routeopt/simple_route_opt.py
@@ -42,9 +42,9 @@ class RouteOpt:
:param logical_link:
:return:
"""
- for relationship in logical_link["logical-links"]["relationsihp-list"]["relationship"]:
+ for relationship in logical_link["logical-links"]["relationship-list"]["relationship"]:
if relationship["related-to"] == "p-interface":
- if "external" in relationship["related-link"]:
+ if "ext-aai-network" in relationship["related-link"]:
return True
return False
@@ -58,20 +58,6 @@ class RouteOpt:
src_access_node_id = request["srcPort"]["src-access-node-id"]
dst_access_node_id = request["dstPort"]["dst-access-node-id"]
- # for the case of request for same domain, return the same node with destination update
- if src_access_node_id == dst_access_node_id:
- return {
- [
- {
- "access-topology-id": request["srcPort"]["src-access-topology-id"],
- "access-client-id": request["srcPort"]["access-client-id"],
- "access-provider-id": request["srcPort"]["access-provider-id"],
- "access-node-id": request["srcPort"]["access-node-id"],
- "src-access-ltp-id": request["srcPort"]["src-access-ltp-id"],
- "dst-access-ltp-id": request["dstPort"]["dst-access-ltp-id"]
- }
- ]
- }
ingress_p_interface = None
egress_p_interface = None
@@ -84,33 +70,34 @@ class RouteOpt:
if not self.isCrossONAPLink(logical_link):
# link is in local ONAP
- for relationship in logical_link["logical-links"]["relationsihp-list"]["relationship"]:
+ for relationship in logical_link["logical-links"]["relationship-list"]["relationship"]:
if relationship["related-to"] == "p-interface":
if src_access_node_id in relationship["related-link"]:
ingress_p_interface = relationship["related-link"].split("/")[-1]
if dst_access_node_id in relationship["related-link"]:
egress_p_interface = relationship["related-link"].split("/")[-1]
- return {
- [
- {
- "access-topology-id": request["srcPort"]["src-access-topology-id"],
- "access-client-id": request["srcPort"]["access-client-id"],
- "access-provider-id": request["srcPort"]["access-provider-id"],
- "access-node-id": request["srcPort"]["access-node-id"],
- "src-access-ltp-id": request["srcPort"]["src-access-ltp-id"],
- "dst-access-ltp-id": ingress_p_interface
- },
- {
- "access-topology-id": request["dstPort"]["access-topology-id"],
- "access-client-id": request["dstPort"]["access-client-id"],
- "access-provider-id": request["dstPort"]["access-provider-id"],
- "access-node-id": request["dstPort"]["access-node-id"],
- "src-access-ltp-id": egress_p_interface,
- "dst-access-ltp-id": request["dstPort"]["dst-access-ltp-id"]
- }
- ]
- }
+ data = '{'\
+ '"vpns":['\
+ '{'\
+ '"access-topology-id": "' + request["srcPort"]["src-access-topology-id"] + '",'\
+ '"access-client-id": "' + request["srcPort"]["src-access-client-id"] + '",'\
+ '"access-provider-id": "' + request["srcPort"]["src-access-provider-id"]+ '",'\
+ '"access-node-id": "' + request["srcPort"]["src-access-node-id"]+ '",'\
+ '"src-access-ltp-id": "' + request["srcPort"]["src-access-ltp-id"]+ '",'\
+ '"dst-access-ltp-id": "' + ingress_p_interface +'"'\
+ '},'\
+ '{' \
+ '"access-topology-id": "' + request["dstPort"]["dst-access-topology-id"] + '",' \
+ '"access-topology-id": "' + request["dstPort"]["dst-access-topology-id"]+ '",' \
+ '"access-provider-id": "' + request["dstPort"]["dst-access-provider-id"]+ '",' \
+ '"access-node-id": "' + request["dstPort"]["dst-access-node-id"]+ '",' \
+ '"src-access-ltp-id": "' + egress_p_interface + '",' \
+ '"dst-access-ltp-id": "' + request["dstPort"]["dst-access-ltp-id"] + '"' \
+ '}'\
+ ']'\
+ '}'
+ return data
@@ -125,7 +112,7 @@ class RouteOpt:
auth=HTTPBasicAuth("", ""))
if response.status_code == 200:
- return response.json
+ return response.json()
def get_logical_links(self):
@@ -142,4 +129,4 @@ class RouteOpt:
auth=HTTPBasicAuth("", ""))
if response.status_code == 200:
- return response.json
+ return response.json() \ No newline at end of file
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):