3 # ============LICENSE_START=======================================================
4 # ORAN SMO PACKAGE - PYTHONSDK TESTS
5 # ================================================================================
6 # Copyright (C) 2021-2022 AT&T Intellectual Property. All rights
8 # ================================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END============================================
21 # ===================================================================
24 """Onap Sdnc module."""
26 from typing import Dict
27 from onapsdk.sdnc.sdnc_element import SdncElement
28 from oransdk.configuration import settings
30 class OranSdnc(SdncElement):
33 base_url = settings.SDNC_URL
34 header = {"Accept": "application/json", "Content-Type": "application/json"}
37 def get_status(cls) -> str:
39 Get status of SDNC component.
42 the status of the SDNC component
45 url = f"{cls.base_url}/apidoc/explorer/"
46 status = cls.send_message('GET',
47 'Get status of SDNC component',
52 def get_odu_oru_status(cls,
55 basic_auth: Dict[str, str]) -> dict:
57 Get status of SDNC component.
60 basic_auth: (Dict[str, str]) for example:{ 'username': 'bob', 'password': 'secret' }
63 the status of the SDNC component
66 url = f"{cls.base_url}/rests/data/network-topology:network-topology/"\
67 + f"topology=topology-netconf/node={odu_node}/yang-ext:mount/"\
68 + f"o-ran-sc-du-hello-world:network-function/du-to-ru-connection={oru_node}"
69 status = cls.send_message_json('GET',
70 'Get status of Odu Oru connectivity',
72 basic_auth=basic_auth)
76 def get_devices(cls, device_node, basic_auth: Dict[str, str]) -> int:
81 the status of the sdnc component
83 url = f"{cls.base_url}/rests/data/network-topology:network-topology/topology=topology-netconf/node={device_node}"
84 status = cls.send_message('GET', 'Get status of Device connectivity', url, basic_auth=basic_auth)
85 return status.status_code
88 def get_events(cls, basic_auth: Dict[str, str], device):
90 Create device events in Sdnc.
93 topic: the event to create, in json format
94 :param basic_auth: (Dict[str, str]) for example:{ 'username': 'bob', 'password': 'secret' }
98 url = f"{cls.base_url}/rests/operations/data-provider:read-faultlog-list"
99 return cls.send_message('POST', 'Get SDNC events', url, data='{"input": {"filter": [ {"property": "node-id", "filtervalue": "' + device + '"}],"sortorder": [{"property": "timestamp","sortorder": "descending"}],"pagination": {"size": 10,"page": 1}}}', basic_auth=basic_auth)