aboutsummaryrefslogtreecommitdiffstats
path: root/osdf/optimizers/routeopt/simple_route_opt.py
blob: 762ccea9c0cb16e26262a0c28f3b4c9d11538131 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -------------------------------------------------------------------------
#   Copyright (c) 2018 Huawei Intellectual Property
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
# -------------------------------------------------------------------------
#

import requests
from requests.auth import HTTPBasicAuth


class RouteOpt:

   """
   This values will need to deleted.. 
   only added for the debug purpose 
   """
    aai_host = "https:\\192.168.17.26:8443"
    aai_headers = {
        "X-TransactionId": "9999",
        "X-FromAppId": "OOF",
        "Content-Type": "applicatoin/json",
        "Real-Time": "true"
    }


    def getRoute(self, request):
        """
        This method checks 
        :param logical_link:
        :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"]

        ingress_p_interface = None
        egress_p_interface = None

        logical_links = self.get_logical_links()

            """
            TODO: Logic to be extended for the repose filling
            """

            
        def get_logical_links(self):
        """
                    This method returns list of all cross ONAP links
                    from /aai/v14/network/logical-links?operation-status="Up"
                    :return: logical-links[]
        """
        logical_link_url = "/aai/v14/network/logical-links?operation-status=\"Up\""
        aai_req_url = self.aai_host + logical_link_url

        response = requests.get(aai_req_url,
                     headers=self.aai_headers,
                     auth=HTTPBasicAuth("", ""))

        if response.status_code == 200:
            return response.json