New route optimiser file added for the timebeing
[optf/osdf.git] / osdf / optimizers / routeopt / simple_route_opt.py
1 # -------------------------------------------------------------------------
2 #   Copyright (c) 2018 Huawei Intellectual Property
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #   Unless required by applicable law or agreed to in writing, software
11 #   distributed under the License is distributed on an "AS IS" BASIS,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #   limitations under the License.
15 #
16 # -------------------------------------------------------------------------
17 #
18
19 import requests
20 from requests.auth import HTTPBasicAuth
21
22
23 class RouteOpt:
24
25    """
26    This values will need to deleted.. 
27    only added for the debug purpose 
28    """
29     aai_host = "https:\\192.168.17.26:8443"
30     aai_headers = {
31         "X-TransactionId": "9999",
32         "X-FromAppId": "OOF",
33         "Content-Type": "applicatoin/json",
34         "Real-Time": "true"
35     }
36
37
38     def getRoute(self, request):
39         """
40         This method checks 
41         :param logical_link:
42         :return:
43         """
44
45         print(request["srcPort"])
46         print(request["dstport"])
47         src_access_node_id = request["srcPort"]["src-access-node-id"]
48         dst_access_node_id = request["dstPort"]["dst-access-node-id"]
49
50         ingress_p_interface = None
51         egress_p_interface = None
52
53         logical_links = self.get_logical_links()
54
55             """
56             TODO: Logic to be extended for the repose filling
57             """
58
59             
60         def get_logical_links(self):
61         """
62                     This method returns list of all cross ONAP links
63                     from /aai/v14/network/logical-links?operation-status="Up"
64                     :return: logical-links[]
65         """
66         logical_link_url = "/aai/v14/network/logical-links?operation-status=\"Up\""
67         aai_req_url = self.aai_host + logical_link_url
68
69         response = requests.get(aai_req_url,
70                      headers=self.aai_headers,
71                      auth=HTTPBasicAuth("", ""))
72
73         if response.status_code == 200:
74             return response.json