summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShankaranarayanan Puzhavakath Narayanan <snarayanan@research.att.com>2018-08-31 17:39:04 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-31 17:39:04 +0000
commit2380d2c2a94be01b0609038d08bf8fcd1fc0c4e4 (patch)
tree9f531ac69172a04b49005901508de7519d2bc71a
parent2bbdae56050b30011561c0078ddf5c4b4b090a9f (diff)
parentb2793e27111a3867af736014530f1e8dec3f50b4 (diff)
Merge "fix the route issue in same domain"
-rw-r--r--osdf/optimizers/routeopt/simple_route_opt.py77
1 files changed, 73 insertions, 4 deletions
diff --git a/osdf/optimizers/routeopt/simple_route_opt.py b/osdf/optimizers/routeopt/simple_route_opt.py
index f7524d4..adf33e4 100644
--- a/osdf/optimizers/routeopt/simple_route_opt.py
+++ b/osdf/optimizers/routeopt/simple_route_opt.py
@@ -34,6 +34,17 @@ class RouteOpt:
"Real-Time": "true"
}
+ def isCrossONAPLink(self, logical_link):
+ """
+ This method checks if cross link is cross onap
+ :param logical_link:
+ :return:
+ """
+ for relationship in logical_link["logical-links"]["relationsihp-list"]["relationship"]:
+ if relationship["related-to"] == "p-interface":
+ if "external" in relationship["related-link"]:
+ return True
+ return False
def getRoute(self, request):
"""
@@ -42,21 +53,79 @@ class RouteOpt:
:return:
"""
- print(request["srcPort"])
- print(request["dstport"])
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
logical_links = self.get_logical_links()
+ # take the logical link where both the p-interface in same onap
+ if logical_links != None:
+ for logical_link in logical_links["results"]:
+ if not self.isCrossONAPLink(logical_link):
+
+ # link is in local ONAP
+ for relationship in logical_link["logical-links"]["relationsihp-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"]
+ }
+ ]
+ }
+
+
+
+ def get_pinterface(self, url):
"""
- TODO: Logic to be extended for the repose filling
+ This method returns details for p interface
+ :return: details of p interface
"""
+ aai_req_url = self.aai_host + url
+ response = requests.get(aai_req_url,
+ headers=self.aai_headers,
+ auth=HTTPBasicAuth("", ""))
+
+ if response.status_code == 200:
+ return response.json
+
-
def get_logical_links(self):
"""
This method returns list of all cross ONAP links