X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=smo-install%2Ftest%2Fpythonsdk%2Fsrc%2Foransdk%2Fsdnc%2Fsdnc.py;h=48de22c8a04d50065254fb7ffd0ef29d4069a6d2;hb=6c7e3c3c5e51182a891a2a21676f1cc2646ba484;hp=2353882cdc7146a129cc761a8cffae57786e876f;hpb=8b713ed09d061baacf624a533be3351e7dcb0500;p=it%2Fdep.git diff --git a/smo-install/test/pythonsdk/src/oransdk/sdnc/sdnc.py b/smo-install/test/pythonsdk/src/oransdk/sdnc/sdnc.py index 2353882c..48de22c8 100644 --- a/smo-install/test/pythonsdk/src/oransdk/sdnc/sdnc.py +++ b/smo-install/test/pythonsdk/src/oransdk/sdnc/sdnc.py @@ -1,16 +1,37 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# SPDX-License-Identifier: Apache-2.0 +### +# ============LICENSE_START======================================================= +# ORAN SMO PACKAGE - PYTHONSDK TESTS +# ================================================================================ +# Copyright (C) 2021-2022 AT&T Intellectual Property. All rights +# reserved. +# ================================================================================ +# 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. +# ============LICENSE_END============================================ +# =================================================================== +# +### """Onap Sdnc module.""" from typing import Dict -from oransdk.configuration import settings from onapsdk.sdnc.sdnc_element import SdncElement +from oransdk.configuration import settings class OranSdnc(SdncElement): """SDNC library.""" base_url = settings.SDNC_URL + header = {"Accept": "application/json", "Content-Type": "application/json"} @classmethod def get_status(cls) -> str: @@ -50,3 +71,29 @@ class OranSdnc(SdncElement): url, basic_auth=basic_auth) return status + + @classmethod + def get_devices(cls, device_node, basic_auth: Dict[str, str]) -> int: + """ + Get Devices on SDNC. + + Returns: + the status of the sdnc component + """ + url = f"{cls.base_url}/rests/data/network-topology:network-topology/topology=topology-netconf/node={device_node}" + status = cls.send_message('GET', 'Get status of Device connectivity', url, basic_auth=basic_auth) + return status.status_code + + @classmethod + def get_events(cls, basic_auth: Dict[str, str], device): + """ + Create device events in Sdnc. + + Args: + topic: the event to create, in json format + :param basic_auth: (Dict[str, str]) for example:{ 'username': 'bob', 'password': 'secret' } + :param device: + + """ + url = f"{cls.base_url}/rests/operations/data-provider:read-faultlog-list" + 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)