summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorseshukm <seshu.kumar.m@huawei.com>2018-08-31 20:51:05 +0800
committerSeshu Kumar M <seshu.kumar.m@huawei.com>2018-08-31 13:07:35 +0000
commitb2793e27111a3867af736014530f1e8dec3f50b4 (patch)
treef7c387d0c5b031440f5cd6d67f71fae064683e21
parente245dcdb2419299dc2388f66acb5c93f4df69b5c (diff)
fix the route issue in same domain
Issue-ID: OPTFRA-333 Change-Id: Ic77f71d3abdab8244bdae85a11856aea24543a54 Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
-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