From 01bd3bc1e98aa20ab8947a7da989213329314a8c Mon Sep 17 00:00:00 2001 From: "selvi.j" Date: Fri, 28 Apr 2023 06:47:48 +0000 Subject: [PATCH 01/16] Coverity-CWE 295: Improper Certificate Validation Added fix for CWE 295: Improper Certificate Validation (SSL certificate validation disabled) Change-Id: Ibdf84e00a79d42c695a25ce96e13c515e85b11f2 Signed-off-by: selvi.j --- osm_nbi/tests/send_kafka.py | 64 -------------------- osm_nbi/tests/upload.py | 117 ------------------------------------ 2 files changed, 181 deletions(-) delete mode 100755 osm_nbi/tests/send_kafka.py delete mode 100755 osm_nbi/tests/upload.py diff --git a/osm_nbi/tests/send_kafka.py b/osm_nbi/tests/send_kafka.py deleted file mode 100755 index d066d14..0000000 --- a/osm_nbi/tests/send_kafka.py +++ /dev/null @@ -1,64 +0,0 @@ -#! /usr/bin/python3 -# -*- coding: utf-8 -*- - -# 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 sys -import requests -import yaml -from os import getenv - -__author__ = "Alfonso Tierno, alfonso.tiernosepulveda@telefonica.com" -__date__ = "$2019-05-31$" -__version__ = "0.1" -version_date = "May 2019" - - -def usage(): - print("Usage: ", sys.argv[0], "topic key message") - print(" Sends a kafka message using URL test of NBI") - print(" host is defined by env OSMNBI_HOST (localhost by default)") - print(" port is defined by env OSMNBI_PORT (9999 by default)") - return - - -if __name__ == "__main__": - try: - if "--help" in sys.argv: - usage() - exit(0) - - if len(sys.argv) != 4: - print( - "missing parameters. Type --help for more information", file=sys.stderr - ) - exit(1) - - topic, key, message = sys.argv[1:] - host = getenv("OSMNBI_HOST", "localhost") - port = getenv("OSMNBI_PORT", "9999") - url = "https://{host}:{port}/osm/test/message/{topic}".format( - host=host, port=port, topic=topic - ) - print(url) - data = {key: message} - - r = requests.post(url, data=yaml.safe_dump(data), verify=False) - if r.status_code not in (200, 201, 202, 204): - print("Received code={}, content='{}'".format(r.status_code, r.text)) - exit(1) - print("{} -> {}: {}".format(topic, key, message)) - - except Exception: - raise diff --git a/osm_nbi/tests/upload.py b/osm_nbi/tests/upload.py deleted file mode 100755 index dfd7302..0000000 --- a/osm_nbi/tests/upload.py +++ /dev/null @@ -1,117 +0,0 @@ -#! /usr/bin/python3 -# -*- coding: utf-8 -*- - -# 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 getopt -import sys -import requests -from os.path import getsize, basename -from hashlib import md5 - -__author__ = "Alfonso Tierno, alfonso.tiernosepulveda@telefonica.com" -__date__ = "$2018-01-01$" -__version__ = "0.1" -version_date = "Jan 2018" - - -def usage(): - print("Usage: ", sys.argv[0], "[options]") - print(" --version: prints current version") - print(" -f|--file FILE: file to be sent") - print(" -h|--help: shows this help") - print(" -u|--url URL: complete server URL") - print(" -s|--chunk-size SIZE: size of chunks, by default 1000") - print(" -t|--token TOKEN: Authorizaton token, previously obtained from server") - print(" -v|--verbose print debug information, can be used several times") - return - - -if __name__ == "__main__": - try: - # load parameters and configuration - opts, args = getopt.getopt( - sys.argv[1:], - "hvu:s:f:t:", - ["url=", "help", "version", "verbose", "file=", "chunk-size=", "token="], - ) - url = None - chunk_size = 500 - pkg_file = None - verbose = 0 - token = None - - for o, a in opts: - if o == "--version": - print("upload version " + __version__ + " " + version_date) - sys.exit() - elif o in ("-v", "--verbose"): - verbose += 1 - elif o in ("-h", "--help"): - usage() - sys.exit() - elif o in ("-u", "--url"): - url = a - elif o in ("-s", "--chunk-size"): - chunk_size = int(a) - elif o in ("-f", "--file"): - pkg_file = a - elif o in ("-t", "--token"): - token = a - else: - assert False, "Unhandled option" - total_size = getsize(pkg_file) - index = 0 - transaction_id = None - file_md5 = md5() - with open(pkg_file, "rb") as f: - headers = { - "Content-type": "application/gzip", - "Content-Filename": basename(pkg_file), - "Accept": "application/json", - } - if token: - headers["Authorization"] = token - while index < total_size: - chunk_data = f.read(chunk_size) - file_md5.update(chunk_data) - # payload = {"file_name": pkg_file, "chunk_data": base64.b64encode(chunk_data).decode("utf-8"), - # "chunk_size": chunk_size} - if transaction_id: - headers["Transaction-Id"] = transaction_id - if index + len(chunk_data) == total_size: - headers["Content-File-MD5"] = file_md5.hexdigest() - # payload["id"] = transaction_id - headers["Content-range"] = "bytes {}-{}/{}".format( - index, index + len(chunk_data) - 1, total_size - ) - # refers to rfc2616: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html - if verbose: - print("TX chunk Headers: {}".format(headers)) - r = requests.post(url, data=chunk_data, headers=headers, verify=False) - if r.status_code not in (200, 201): - print("Got {}: {}".format(r.status_code, r.text)) - exit(1) - if verbose > 1: - print("RX {}: {}".format(r.status_code, r.text)) - response = r.json() - if not transaction_id: - transaction_id = response["id"] - index += len(chunk_data) - if verbose <= 1: - print("RX {}: {}".format(r.status_code, r.text)) - if "id" in response: - print("---\nid: {}".format(response["id"])) - except Exception: - raise -- 2.17.1 From 79276b21b9c1b57a16cb3d000ae2c1dc055d3f46 Mon Sep 17 00:00:00 2001 From: Mark Beierl Date: Fri, 21 Jul 2023 17:13:33 +0000 Subject: [PATCH 02/16] Update version of PyYAML Change-Id: I9672c4cfc5e1aa3abcb67ee328fab299068c141c Signed-off-by: Mark Beierl --- requirements-dev.txt | 2 +- requirements.in | 2 +- requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 8bbb75d..8e77feb 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -65,7 +65,7 @@ pymongo==4.3.3 # via # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master # motor -pyyaml==5.4.1 +pyyaml==6.0.1 # via # -r https://osm.etsi.org/gitweb/?p=osm/IM.git;a=blob_plain;f=requirements.txt;hb=master # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master diff --git a/requirements.in b/requirements.in index 3cb40db..9096b53 100644 --- a/requirements.in +++ b/requirements.in @@ -16,6 +16,6 @@ CherryPy>=18.1.2 deepdiff jsonschema>=3.2.0 python-keystoneclient -pyyaml==5.4.1 +pyyaml>6 requests tacacs_plus diff --git a/requirements.txt b/requirements.txt index 7de03f8..caa587d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -136,7 +136,7 @@ pytz==2023.3 # oslo-serialization # oslo-utils # tempora -pyyaml==5.4.1 +pyyaml==6.0.1 # via # -r requirements.in # oslo-config -- 2.17.1 From d7debb9afcbfe0fb1c112ea0834458753ffe34b1 Mon Sep 17 00:00:00 2001 From: gatici Date: Mon, 31 Jul 2023 14:37:32 +0300 Subject: [PATCH 03/16] Fix flake8 error caused by using type instead of isinstance Change-Id: Iccbf5a3a61e7b1c76c8e4e062fd8c24a09a39314 Signed-off-by: gatici --- osm_nbi/descriptor_topics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osm_nbi/descriptor_topics.py b/osm_nbi/descriptor_topics.py index d986963..9695866 100644 --- a/osm_nbi/descriptor_topics.py +++ b/osm_nbi/descriptor_topics.py @@ -681,7 +681,7 @@ class DescriptorTopic(BaseTopic): # to preserve current expected behaviour if "userDefinedData" in indata: data = indata.pop("userDefinedData") - if type(data) == dict: + if isinstance(data, dict): indata["_admin"]["userDefinedData"] = data else: raise EngineException( @@ -1524,7 +1524,7 @@ class NsdTopic(DescriptorTopic): # to preserve current expected behaviour if "userDefinedData" in indata: data = indata.pop("userDefinedData") - if type(data) == dict: + if isinstance(data, dict): indata["_admin"]["userDefinedData"] = data else: raise EngineException( -- 2.17.1 From f6574e3ca504b3f0bd98d3ccdc51830418d80ed8 Mon Sep 17 00:00:00 2001 From: Luis Vega Date: Tue, 11 Jul 2023 18:47:22 +0000 Subject: [PATCH 04/16] feature: helm charts repos with certs Change-Id: I34a6c02a7777081f851f5e9507db45dca6b1cef9 Signed-off-by: Luis Vega --- osm_nbi/validation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py index 4dafed5..518f1be 100644 --- a/osm_nbi/validation.py +++ b/osm_nbi/validation.py @@ -930,6 +930,9 @@ k8srepo_properties = { "description": description_schema, "type": k8srepo_types, "url": description_schema, + "cacert": long_description_schema, + "user": string_schema, + "password": passwd_schema, } k8srepo_new_schema = { "title": "k8scluster creation input schema", -- 2.17.1 From 514b546acfeedf03541574394f934e06335f16ee Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Wed, 6 Sep 2023 10:34:02 +0200 Subject: [PATCH 05/16] Fix pip requirements to update pyangbind version to 0.8.3.post1 Change-Id: Ia278a01b8797a353b8d89f5ca31c9e3073e40f2c Signed-off-by: garciadeblas --- requirements-dev.txt | 22 +++++------- requirements-test.in | 1 - requirements-test.txt | 12 +++---- requirements.txt | 83 ++++++++++++++++++++++++++----------------- tox.ini | 6 ++-- 5 files changed, 68 insertions(+), 56 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 8e77feb..fcf058d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -14,19 +14,15 @@ # limitations under the License. -aiokafka==0.8.0 +aiokafka==0.8.1 # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master -async-timeout==4.0.2 +async-timeout==4.0.3 # via # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master # aiokafka -bitarray==2.7.3 - # via - # -r https://osm.etsi.org/gitweb/?p=osm/IM.git;a=blob_plain;f=requirements.txt;hb=master - # pyangbind dataclasses==0.6 # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master -dnspython==2.3.0 +dnspython==2.4.2 # via # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master # pymongo @@ -38,12 +34,12 @@ kafka-python==2.0.2 # via # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master # aiokafka -lxml==4.9.2 +lxml==4.9.3 # via # -r https://osm.etsi.org/gitweb/?p=osm/IM.git;a=blob_plain;f=requirements.txt;hb=master # pyang # pyangbind -motor==3.1.2 +motor==3.3.1 # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master osm-common @ git+https://osm.etsi.org/gerrit/osm/common.git@master # via -r requirements-dev.in @@ -57,11 +53,11 @@ pyang==2.5.3 # via # -r https://osm.etsi.org/gitweb/?p=osm/IM.git;a=blob_plain;f=requirements.txt;hb=master # pyangbind -pyangbind==0.8.1 +pyangbind==0.8.3.post1 # via -r https://osm.etsi.org/gitweb/?p=osm/IM.git;a=blob_plain;f=requirements.txt;hb=master -pycryptodome==3.17 +pycryptodome==3.18.0 # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master -pymongo==4.3.3 +pymongo==4.5.0 # via # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master # motor @@ -69,7 +65,7 @@ pyyaml==6.0.1 # via # -r https://osm.etsi.org/gitweb/?p=osm/IM.git;a=blob_plain;f=requirements.txt;hb=master # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master -regex==2023.5.5 +regex==2023.8.8 # via # -r https://osm.etsi.org/gitweb/?p=osm/IM.git;a=blob_plain;f=requirements.txt;hb=master # pyangbind diff --git a/requirements-test.in b/requirements-test.in index 8c0f408..5d6739a 100644 --- a/requirements-test.in +++ b/requirements-test.in @@ -16,4 +16,3 @@ asynctest coverage deepdiff nose2 -#pyang diff --git a/requirements-test.txt b/requirements-test.txt index c81781d..e82586f 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -14,25 +14,25 @@ # limitations under the License. -aiohttp==3.8.4 +aiohttp==3.8.5 # via aioresponses aioresponses==0.7.4 # via -r requirements-test.in aiosignal==1.3.1 # via aiohttp -async-timeout==4.0.2 +async-timeout==4.0.3 # via aiohttp asynctest==0.13.0 # via -r requirements-test.in attrs==23.1.0 # via aiohttp -charset-normalizer==3.1.0 +charset-normalizer==3.2.0 # via aiohttp -coverage==7.2.5 +coverage==7.3.0 # via -r requirements-test.in -deepdiff==6.3.0 +deepdiff==6.4.1 # via -r requirements-test.in -frozenlist==1.3.3 +frozenlist==1.4.0 # via # aiohttp # aiosignal diff --git a/requirements.txt b/requirements.txt index caa587d..5f914cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,27 +14,30 @@ # limitations under the License. -aiohttp==3.8.4 +aiohttp==3.8.5 # via -r requirements.in aiosignal==1.3.1 # via aiohttp -async-timeout==4.0.2 +annotated-types==0.5.0 + # via pydantic +async-timeout==4.0.3 # via aiohttp attrs==23.1.0 # via # aiohttp # jsonschema + # referencing autocommand==2.2.2 # via jaraco-text cefevent==0.5.4 # via -r requirements.in -certifi==2023.5.7 +certifi==2023.7.22 # via requests -charset-normalizer==3.1.0 +charset-normalizer==3.2.0 # via # aiohttp # requests -cheroot==9.0.0 +cheroot==10.0.0 # via cherrypy cherrypy==18.8.0 # via -r requirements.in @@ -43,9 +46,9 @@ debtcollector==2.5.0 # oslo-config # oslo-utils # python-keystoneclient -deepdiff==6.3.0 +deepdiff==6.4.1 # via -r requirements.in -frozenlist==1.3.3 +frozenlist==1.4.0 # via # aiohttp # aiosignal @@ -53,28 +56,30 @@ idna==3.4 # via # requests # yarl -inflect==6.0.4 +inflect==7.0.0 # via jaraco-text -iso8601==1.1.0 +iso8601==2.0.0 # via # keystoneauth1 # oslo-utils -jaraco-collections==4.1.0 +jaraco-collections==4.3.0 # via cherrypy jaraco-context==4.3.0 # via jaraco-text -jaraco-functools==3.6.0 +jaraco-functools==3.9.0 # via # cheroot # jaraco-text # tempora jaraco-text==3.11.1 # via jaraco-collections -jsonschema==4.17.3 +jsonschema==4.19.0 # via -r requirements.in -keystoneauth1==5.1.2 +jsonschema-specifications==2023.7.1 + # via jsonschema +keystoneauth1==5.3.0 # via python-keystoneclient -more-itertools==9.1.0 +more-itertools==10.1.0 # via # cheroot # cherrypy @@ -96,16 +101,16 @@ ordered-set==4.1.0 # via deepdiff os-service-types==1.7.0 # via keystoneauth1 -oslo-config==9.1.1 +oslo-config==9.2.0 # via python-keystoneclient -oslo-i18n==6.0.0 +oslo-i18n==6.1.0 # via # oslo-config # oslo-utils # python-keystoneclient -oslo-serialization==5.1.1 +oslo-serialization==5.2.0 # via python-keystoneclient -oslo-utils==6.1.0 +oslo-utils==6.2.1 # via # oslo-serialization # python-keystoneclient @@ -121,17 +126,17 @@ pbr==5.11.1 # oslo-serialization # python-keystoneclient # stevedore -portend==3.1.0 +portend==3.2.0 # via cherrypy -pydantic==1.10.7 +pydantic==2.3.0 # via inflect -pyparsing==3.0.9 +pydantic-core==2.6.3 + # via pydantic +pyparsing==3.1.1 # via oslo-utils -pyrsistent==0.19.3 - # via jsonschema python-keystoneclient==5.1.0 # via -r requirements.in -pytz==2023.3 +pytz==2023.3.post1 # via # oslo-serialization # oslo-utils @@ -140,7 +145,11 @@ pyyaml==6.0.1 # via # -r requirements.in # oslo-config -requests==2.30.0 +referencing==0.30.2 + # via + # jsonschema + # jsonschema-specifications +requests==2.31.0 # via # -r requirements.in # keystoneauth1 @@ -148,24 +157,34 @@ requests==2.30.0 # python-keystoneclient rfc3986==2.0.0 # via oslo-config +rpds-py==0.10.2 + # via + # jsonschema + # referencing six==1.16.0 # via - # cheroot - # keystoneauth1 # python-keystoneclient # tacacs-plus -stevedore==5.0.0 +stevedore==5.1.0 # via # keystoneauth1 # oslo-config # python-keystoneclient tacacs-plus==2.6 # via -r requirements.in -tempora==5.2.2 +tempora==5.5.0 # via portend -typing-extensions==4.5.0 - # via pydantic -urllib3==2.0.2 +typing-extensions==4.7.1 + # via + # inflect + # jaraco-functools + # pydantic + # pydantic-core +tzdata==2023.3 + # via + # oslo-serialization + # oslo-utils +urllib3==2.0.4 # via requests wrapt==1.15.0 # via debtcollector diff --git a/tox.ini b/tox.ini index 4c8fd06..6521ae0 100644 --- a/tox.ini +++ b/tox.ini @@ -42,11 +42,9 @@ deps = {[testenv]deps} -r{toxinidir}/requirements-dev.txt -r{toxinidir}/requirements-test.txt commands = - sh -c "patch {toxworkdir}/cover/lib/python3.10/site-packages/pyangbind/lib/yangtypes.py < pyangbind.patch" sh -c 'rm -f nosetests.xml' coverage erase nose2 -C --coverage osm_nbi -s osm_nbi/tests - sh -c "patch -R {toxworkdir}/cover/lib/python3.10/site-packages/pyangbind/lib/yangtypes.py < pyangbind.patch" coverage report --omit='*tests*' coverage html -d ./cover --omit='*tests*' coverage xml -o coverage.xml --omit=*tests* @@ -83,7 +81,7 @@ commands = ####################################################################################### [testenv:pip-compile] -deps = pip-tools==6.6.2 +deps = pip-tools==6.13.0 skip_install = true allowlist_externals = bash [ @@ -91,7 +89,7 @@ commands = - bash -c "for file in requirements*.in ; do \ UNSAFE="" ; \ if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \ - pip-compile -rU --no-header $UNSAFE $file ;\ + pip-compile --resolver=backtracking -rU --no-header $UNSAFE $file ;\ out=`echo $file | sed 's/.in/.txt/'` ; \ sed -i -e '1 e head -16 tox.ini' $out ;\ done" -- 2.17.1 From 5cdcb80a5a968efc0f21c358974200c0f7bf75c5 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 28 Sep 2023 23:50:52 +0200 Subject: [PATCH 06/16] Update pip requirements to pass stage2 and stage3 in all modules Change-Id: I50582481c2aa5359c749dd7246e55aaa270dee57 Signed-off-by: garciadeblas --- requirements-dev.txt | 2 +- requirements-test.txt | 4 ++-- requirements.txt | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index fcf058d..0bf9737 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -55,7 +55,7 @@ pyang==2.5.3 # pyangbind pyangbind==0.8.3.post1 # via -r https://osm.etsi.org/gitweb/?p=osm/IM.git;a=blob_plain;f=requirements.txt;hb=master -pycryptodome==3.18.0 +pycryptodome==3.19.0 # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master pymongo==4.5.0 # via diff --git a/requirements-test.txt b/requirements-test.txt index e82586f..1abfb13 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -28,9 +28,9 @@ attrs==23.1.0 # via aiohttp charset-normalizer==3.2.0 # via aiohttp -coverage==7.3.0 +coverage==7.3.1 # via -r requirements-test.in -deepdiff==6.4.1 +deepdiff==6.5.0 # via -r requirements-test.in frozenlist==1.4.0 # via diff --git a/requirements.txt b/requirements.txt index 5f914cd..cc7328f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -46,7 +46,7 @@ debtcollector==2.5.0 # oslo-config # oslo-utils # python-keystoneclient -deepdiff==6.4.1 +deepdiff==6.5.0 # via -r requirements.in frozenlist==1.4.0 # via @@ -73,7 +73,7 @@ jaraco-functools==3.9.0 # tempora jaraco-text==3.11.1 # via jaraco-collections -jsonschema==4.19.0 +jsonschema==4.19.1 # via -r requirements.in jsonschema-specifications==2023.7.1 # via jsonschema @@ -85,13 +85,13 @@ more-itertools==10.1.0 # cherrypy # jaraco-functools # jaraco-text -msgpack==1.0.5 +msgpack==1.0.7 # via oslo-serialization multidict==6.0.4 # via # aiohttp # yarl -netaddr==0.8.0 +netaddr==0.9.0 # via # oslo-config # oslo-utils @@ -128,13 +128,13 @@ pbr==5.11.1 # stevedore portend==3.2.0 # via cherrypy -pydantic==2.3.0 +pydantic==2.4.2 # via inflect -pydantic-core==2.6.3 +pydantic-core==2.10.1 # via pydantic pyparsing==3.1.1 # via oslo-utils -python-keystoneclient==5.1.0 +python-keystoneclient==5.2.0 # via -r requirements.in pytz==2023.3.post1 # via @@ -157,7 +157,7 @@ requests==2.31.0 # python-keystoneclient rfc3986==2.0.0 # via oslo-config -rpds-py==0.10.2 +rpds-py==0.10.3 # via # jsonschema # referencing @@ -174,7 +174,7 @@ tacacs-plus==2.6 # via -r requirements.in tempora==5.5.0 # via portend -typing-extensions==4.7.1 +typing-extensions==4.8.0 # via # inflect # jaraco-functools @@ -184,7 +184,7 @@ tzdata==2023.3 # via # oslo-serialization # oslo-utils -urllib3==2.0.4 +urllib3==2.0.5 # via requests wrapt==1.15.0 # via debtcollector -- 2.17.1 From aef96f52934604c227b30d994c26e1771df20bf0 Mon Sep 17 00:00:00 2001 From: Luis Vega Date: Thu, 23 Nov 2023 20:29:29 +0000 Subject: [PATCH 07/16] Feature 11002: Deprecate helmv2 Change-Id: I77fb144d533f58ff927bda9382dbc6cba0f0dbd6 Signed-off-by: Luis Vega --- osm_nbi/validation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py index 518f1be..4226fd6 100644 --- a/osm_nbi/validation.py +++ b/osm_nbi/validation.py @@ -815,7 +815,6 @@ k8scluster_deploy_method_schema = { "title": "Deployment methods for K8s cluster", "type": "object", "properties": { - "helm-chart": {"type": "boolean"}, "juju-bundle": {"type": "boolean"}, "helm-chart-v3": {"type": "boolean"}, }, -- 2.17.1 From 0a1efeda7d6f21e7c5291ac617a6403853697949 Mon Sep 17 00:00:00 2001 From: Luis Vega Date: Tue, 28 Nov 2023 16:44:30 +0000 Subject: [PATCH 08/16] Feature 11002: Deprecate helmv2 Fixes I77fb144d533f58ff927bda9382dbc6cba0f0dbd6 Change-Id: Ieaef4f4d2d50ac28db45fb447e6656f79e38771a Signed-off-by: Luis Vega --- osm_nbi/validation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py index 4226fd6..1bf597c 100644 --- a/osm_nbi/validation.py +++ b/osm_nbi/validation.py @@ -819,7 +819,7 @@ k8scluster_deploy_method_schema = { "helm-chart-v3": {"type": "boolean"}, }, "additionalProperties": False, - "minProperties": 3, + "minProperties": 2, } k8scluster_nets_schema = { "title": "k8scluster nets input schema", -- 2.17.1 From 84a60df053d2e3f902e7e58d5f5a5db46789683e Mon Sep 17 00:00:00 2001 From: Gabriel Cuba Date: Mon, 30 Oct 2023 14:01:54 -0500 Subject: [PATCH 09/16] Feature 10996: Adds nslcmop_cancel to nbi.py and instance_topics.py Change-Id: I1094c7537377ad31ed38012c4e49d8a3f31b274b Signed-off-by: Gabriel Cuba --- osm_nbi/engine.py | 20 ++++++++++++++++++++ osm_nbi/instance_topics.py | 37 +++++++++++++++++++++++++++++++++++++ osm_nbi/nbi.py | 13 ++++++++++++- osm_nbi/validation.py | 17 +++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) diff --git a/osm_nbi/engine.py b/osm_nbi/engine.py index 9b17402..c4c8eb2 100644 --- a/osm_nbi/engine.py +++ b/osm_nbi/engine.py @@ -380,6 +380,26 @@ class Engine(object): with self.write_lock: return self.map_topic[topic].edit(session, _id, indata, kwargs) + def cancel_item( + self, rollback, session, topic, indata=None, kwargs=None, headers=None + ): + """ + Cancels an item + :param rollback: list to append created items at database in case a rollback must to be done + :param session: contains the used login username and working project, force to avoid checkins, public + :param topic: it can be: users, projects, vim_accounts, sdns, nsrs, nsds, vnfds + :param indata: data to be inserted + :param kwargs: used to override the indata descriptor + :param headers: http request headers + :return: _id: identity of the inserted data. + """ + if topic not in self.map_topic: + raise EngineException( + "Unknown topic {}!!!".format(topic), HTTPStatus.INTERNAL_SERVER_ERROR + ) + with self.write_lock: + self.map_topic[topic].cancel(rollback, session, indata, kwargs, headers) + def upgrade_db(self, current_version, target_version): if target_version not in self.map_target_version_to_int.keys(): raise EngineException( diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index 6072267..8488a93 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -31,6 +31,7 @@ from osm_nbi.validation import ( nsi_instantiate, ns_migrate, ns_verticalscale, + nslcmop_cancel, ) from osm_nbi.base_topic import ( BaseTopic, @@ -1202,6 +1203,7 @@ class NsLcmOpTopic(BaseTopic): "terminate": ns_terminate, "migrate": ns_migrate, "verticalscale": ns_verticalscale, + "cancel": nslcmop_cancel, } def __init__(self, db, fs, msg, auth): @@ -2370,6 +2372,41 @@ class NsLcmOpTopic(BaseTopic): # except DbException as e: # raise EngineException("Cannot get ns_instance '{}': {}".format(e), HTTPStatus.NOT_FOUND) + def cancel(self, rollback, session, indata=None, kwargs=None, headers=None): + validate_input(indata, self.operation_schema["cancel"]) + # Override descriptor with query string kwargs + self._update_input_with_kwargs(indata, kwargs, yaml_format=True) + nsLcmOpOccId = indata["nsLcmOpOccId"] + cancelMode = indata["cancelMode"] + # get nslcmop from nsLcmOpOccId + _filter = BaseTopic._get_project_filter(session) + _filter["_id"] = nsLcmOpOccId + nslcmop = self.db.get_one("nslcmops", _filter) + # Fail is this is not an ongoing nslcmop + if nslcmop.get("operationState") not in [ + "STARTING", + "PROCESSING", + "ROLLING_BACK", + ]: + raise EngineException( + "Operation is not in STARTING, PROCESSING or ROLLING_BACK state", + http_code=HTTPStatus.CONFLICT, + ) + nsInstanceId = nslcmop["nsInstanceId"] + update_dict = { + "isCancelPending": True, + "cancelMode": cancelMode, + } + self.db.set_one( + "nslcmops", q_filter=_filter, update_dict=update_dict, fail_on_empty=False + ) + data = { + "_id": nsLcmOpOccId, + "nsInstanceId": nsInstanceId, + "cancelMode": cancelMode, + } + self.msg.write("nslcmops", "cancel", data) + def delete(self, session, _id, dry_run=False, not_send_msg=None): raise EngineException( "Method delete called directly", HTTPStatus.INTERNAL_SERVER_ERROR diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index 46fd8cc..9aff857 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -92,7 +92,7 @@ URL: /osm GET POST heal O5 /ns_lcm_op_occs 5 5 / 5 5 5 - TO BE COMPLETED 5 5 + cancel 05 /vnf_instances (also vnfrs for compatibility) O / O /subscriptions 5 5 @@ -475,6 +475,10 @@ valid_url_methods = { "": { "METHODS": ("GET",), "ROLE_PERMISSION": "ns_instances:opps:id:", + "cancel": { + "METHODS": ("POST",), + "ROLE_PERMISSION": "ns_instances:opps:cancel:", + }, }, }, "vnfrs": { @@ -1670,6 +1674,13 @@ class Server(object): ) outdata = {"id": _id} cherrypy.response.status = HTTPStatus.ACCEPTED.value + elif topic == "ns_lcm_op_occs" and item == "cancel": + indata["nsLcmOpOccId"] = _id + self.engine.cancel_item( + rollback, engine_session, "nslcmops", indata, None + ) + self._set_location_header(main_topic, version, topic, _id) + cherrypy.response.status = HTTPStatus.ACCEPTED.value else: _id, op_id = self.engine.new_item( rollback, diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py index 1bf597c..bfea112 100644 --- a/osm_nbi/validation.py +++ b/osm_nbi/validation.py @@ -641,6 +641,23 @@ ns_verticalscale = { "additionalProperties": False, } +nslcmop_cancel = { + "title": "Cancel nslcmop input schema", + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "nsLcmOpOccId": id_schema, + "cancelMode": { + "enum": [ + "GRACEFUL", + "FORCEFUL", + ] + }, + }, + "required": ["cancelMode"], + "additionalProperties": False, +} + schema_version = {"type": "string", "enum": ["1.0"]} schema_type = {"type": "string"} vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]} -- 2.17.1 From 592e293bdaa0a3784a46b898cdf68b59a7785527 Mon Sep 17 00:00:00 2001 From: Rahul Kumar Date: Thu, 2 Nov 2023 13:19:32 +0000 Subject: [PATCH 10/16] Feature 10999: Dual-Stack IP Support for VNFs in SOL003 VNFM Interface Change-Id: Ifb36f670036b805478ba4e1564a72f43ca1b41d7 Signed-off-by: Rahul Kumar --- osm_nbi/osm_vnfm/vnf_instances.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osm_nbi/osm_vnfm/vnf_instances.py b/osm_nbi/osm_vnfm/vnf_instances.py index d65f1e0..c9d05ac 100644 --- a/osm_nbi/osm_vnfm/vnf_instances.py +++ b/osm_nbi/osm_vnfm/vnf_instances.py @@ -192,6 +192,11 @@ class NewVnfInstance(BaseMethod): } ], } + vnf_profile = vnf_content["vnf-profile"][0] + virtual_link_connectivity = vnf_profile["virtual-link-connectivity"][0] + constituent_cpd_id = virtual_link_connectivity["constituent-cpd-id"][0] + if "ip-address" in indata["additionalParams"]: + constituent_cpd_id["ip-address"] = indata["additionalParams"]["ip-address"] new_nsd["nsd"]["nsd"][0] = { "description": indata["vnfInstanceDescription"], "designer": "OSM", -- 2.17.1 From f354389ef8f0dd9768d63753336e83d6f6a9bc8c Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Fri, 20 Oct 2023 11:53:51 +0200 Subject: [PATCH 11/16] Feature 10997: add oci flag as new property in k8s repos Change-Id: Ie111db3cd71894454da8c7e96b3c1faf3cd2077a Signed-off-by: garciadeblas --- osm_nbi/validation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py index bfea112..620272f 100644 --- a/osm_nbi/validation.py +++ b/osm_nbi/validation.py @@ -949,6 +949,7 @@ k8srepo_properties = { "cacert": long_description_schema, "user": string_schema, "password": passwd_schema, + "oci": bool_schema, } k8srepo_new_schema = { "title": "k8scluster creation input schema", -- 2.17.1 From 646773d46821cc2a5461423021e87034a5aa86e9 Mon Sep 17 00:00:00 2001 From: Gabriel Cuba Date: Mon, 20 Nov 2023 01:43:05 -0500 Subject: [PATCH 12/16] Fixes validation of helm charts to include URLs Change-Id: Ifc01ff100aaa22bc1dfeada849b41fe1824e4c7f Signed-off-by: Gabriel Cuba --- osm_nbi/descriptor_topics.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osm_nbi/descriptor_topics.py b/osm_nbi/descriptor_topics.py index 9695866..98a41d1 100644 --- a/osm_nbi/descriptor_topics.py +++ b/osm_nbi/descriptor_topics.py @@ -31,6 +31,7 @@ from time import time from uuid import uuid4 from re import fullmatch from zipfile import ZipFile +from urllib.parse import urlparse from osm_nbi.validation import ( ValidationError, pdu_new_schema, @@ -858,12 +859,18 @@ class VnfdTopic(DescriptorTopic): @staticmethod def validate_helm_chart(indata): + def is_url(url): + result = urlparse(url) + return all([result.scheme, result.netloc]) + kdus = indata.get("kdu", []) for kdu in kdus: helm_chart_value = kdu.get("helm-chart") if not helm_chart_value: continue - if not valid_helm_chart_re.match(helm_chart_value): + if not ( + valid_helm_chart_re.match(helm_chart_value) or is_url(helm_chart_value) + ): raise EngineException( "helm-chart '{}' is not valid".format(helm_chart_value), http_code=HTTPStatus.UNPROCESSABLE_ENTITY, -- 2.17.1 From 828f3f29a221f4415e0962e63a491462c1b02370 Mon Sep 17 00:00:00 2001 From: "selvi.j" Date: Tue, 16 May 2023 05:43:48 +0000 Subject: [PATCH 13/16] Feature 10980: Service Function Chaining Change-Id: Ib0e34f152fa5b0f601fffe67b91882f5cc2fc11c Signed-off-by: sritharan Signed-off-by: selvi.j --- osm_nbi/descriptor_topics.py | 41 ++++++++++++++ osm_nbi/instance_topics.py | 12 ++++ osm_nbi/tests/test_descriptor_topics.py | 56 +++++++++++++++++++ osm_nbi/tests/test_pkg_descriptors.py | 74 +++++++++++++++++++++++++ 4 files changed, 183 insertions(+) diff --git a/osm_nbi/descriptor_topics.py b/osm_nbi/descriptor_topics.py index 98a41d1..b165b76 100644 --- a/osm_nbi/descriptor_topics.py +++ b/osm_nbi/descriptor_topics.py @@ -1467,6 +1467,8 @@ class NsdTopic(DescriptorTopic): # TODO validata that if contains cloud-init-file or charms, have artifacts _admin.storage."pkg-dir" is not none for vld in get_iterable(indata.get("virtual-link-desc")): self.validate_vld_mgmt_network_with_virtual_link_protocol_data(vld, indata) + for fg in get_iterable(indata.get("vnffgd")): + self.validate_vnffgd_data(fg, indata) self.validate_vnf_profiles_vnfd_id(indata) @@ -1488,6 +1490,45 @@ class NsdTopic(DescriptorTopic): http_code=HTTPStatus.UNPROCESSABLE_ENTITY, ) + @staticmethod + def validate_vnffgd_data(fg, indata): + position_list = [] + all_vnf_ids = set(get_iterable(fg.get("vnf-profile-id"))) + for fgposition in get_iterable(fg.get("nfp-position-element")): + position_list.append(fgposition["id"]) + + for nfpd in get_iterable(fg.get("nfpd")): + nfp_position = [] + for position in get_iterable(nfpd.get("position-desc-id")): + nfp_position = position.get("nfp-position-element-id") + if position == "nfp-position-element-id": + nfp_position = position.get("nfp-position-element-id") + if nfp_position[0] not in position_list: + raise EngineException( + "Error at vnffgd nfpd[id='{}']:nfp-position-element-id='{}' " + "does not match any nfp-position-element".format( + nfpd["id"], nfp_position[0] + ), + http_code=HTTPStatus.UNPROCESSABLE_ENTITY, + ) + + for cp in get_iterable(position.get("cp-profile-id")): + for cpe in get_iterable(cp.get("constituent-profile-elements")): + constituent_base_element_id = cpe.get( + "constituent-base-element-id" + ) + if ( + constituent_base_element_id + and constituent_base_element_id not in all_vnf_ids + ): + raise EngineException( + "Error at vnffgd constituent_profile[id='{}']:vnfd-id='{}' " + "does not match any constituent-base-element-id".format( + cpe["id"], constituent_base_element_id + ), + http_code=HTTPStatus.UNPROCESSABLE_ENTITY, + ) + @staticmethod def validate_vnf_profiles_vnfd_id(indata): all_vnfd_ids = set(get_iterable(indata.get("vnfd-id"))) diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index 8488a93..695a8f8 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -562,6 +562,7 @@ class NsrTopic(BaseTopic): "image": [], "affinity-or-anti-affinity-group": [], "shared-volumes": [], + "vnffgd": [], } if "revision" in nsd["_admin"]: nsr_descriptor["revision"] = nsd["_admin"]["revision"] @@ -641,6 +642,17 @@ class NsrTopic(BaseTopic): ) vld["name"] = vld["id"] nsr_descriptor["vld"] = nsr_vld + if nsd.get("vnffgd"): + vnffgd = nsd.get("vnffgd") + for vnffg in vnffgd: + info = {} + for k, v in vnffg.items(): + if k == "id": + info.update({k: v}) + if k == "nfpd": + info.update({k: v}) + nsr_descriptor["vnffgd"].append(info) + return nsr_descriptor def _get_affinity_or_anti_affinity_group_data_from_vnfd( diff --git a/osm_nbi/tests/test_descriptor_topics.py b/osm_nbi/tests/test_descriptor_topics.py index dcde0a5..f6d4001 100755 --- a/osm_nbi/tests/test_descriptor_topics.py +++ b/osm_nbi/tests/test_descriptor_topics.py @@ -32,6 +32,7 @@ from osm_nbi.tests.test_pkg_descriptors import ( db_nsds_text, vnfd_exploit_text, vnfd_exploit_fixed_text, + db_sfc_nsds_text, ) from osm_nbi.descriptor_topics import VnfdTopic, NsdTopic from osm_nbi.engine import EngineException @@ -2197,6 +2198,61 @@ class Test_NsdTopic(TestCase): "Wrong exception text", ) + def test_validate_vnffgd_descriptor_on_valid_descriptor(self): + indata = yaml.safe_load(db_sfc_nsds_text)[0] + vnffgd = indata.get("vnffgd") + fg = vnffgd[0] + self.topic.validate_vnffgd_data(fg, indata) + + def test_validate_vnffgd_descriptor_not_matching_nfp_position_element(self): + indata = yaml.safe_load(db_sfc_nsds_text)[0] + vnffgd = indata.get("vnffgd") + fg = vnffgd[0] + nfpd = fg.get("nfpd")[0] + with self.assertRaises(EngineException) as e: + fg.update({"nfp-position-element": [{"id": "test1"}]}) + self.topic.validate_vnffgd_data(fg, indata) + self.assertEqual( + e.exception.http_code, + HTTPStatus.UNPROCESSABLE_ENTITY, + "Wrong HTTP status code", + ) + self.assertIn( + norm( + "Error at vnffgd nfpd[id='{}']:nfp-position-element-id='{}' " + "does not match any nfp-position-element".format(nfpd["id"], "test") + ), + norm(str(e.exception)), + "Wrong exception text", + ) + + def test_validate_vnffgd_descriptor_not_matching_constituent_base_element_id( + self, + ): + indata = yaml.safe_load(db_sfc_nsds_text)[0] + vnffgd = indata.get("vnffgd") + fg = vnffgd[0] + fg["nfpd"][0]["position-desc-id"][0]["cp-profile-id"][0][ + "constituent-profile-elements" + ][0]["constituent-base-element-id"] = "error_vnf" + with self.assertRaises(EngineException) as e: + self.topic.validate_vnffgd_data(fg, indata) + self.assertEqual( + e.exception.http_code, + HTTPStatus.UNPROCESSABLE_ENTITY, + "Wrong HTTP status code", + ) + self.assertIn( + norm( + "Error at vnffgd constituent_profile[id='{}']:vnfd-id='{}' " + "does not match any constituent-base-element-id".format( + "vnf1", "error_vnf" + ) + ), + norm(str(e.exception)), + "Wrong exception text", + ) + if __name__ == "__main__": unittest.main() diff --git a/osm_nbi/tests/test_pkg_descriptors.py b/osm_nbi/tests/test_pkg_descriptors.py index 39c28fe..d77b79f 100644 --- a/osm_nbi/tests/test_pkg_descriptors.py +++ b/osm_nbi/tests/test_pkg_descriptors.py @@ -295,3 +295,77 @@ db_nsds_text = """ - constituent-base-element-id: hackfest_vnf2 constituent-cpd-id: vnf-data-ext """ + +db_sfc_nsds_text = """ +- _admin: + userDefinedData: {} + revision: 1 + created: 1683713524.2696395 + modified: 1683713524.3553684 + projects_read: + - 93601899-b310-4a56-a765-91539d5f675d + projects_write: + - 93601899-b310-4a56-a765-91539d5f675d + onboardingState: ONBOARDED + operationalState: ENABLED + usageState: NOT_IN_USE + storage: + fs: mongo + path: /app/storage/ + folder: '2eb45633-03e3-4909-a87d-a564f5943948:1' + pkg-dir: cirros_vnffg_ns + descriptor: cirros_vnffg_ns/cirros_vnffg_nsd.yaml + zipfile: package.tar.gz + _id: 2eb45633-03e3-4909-a87d-a564f5943948 + id: cirros_vnffg-ns + designer: OSM + version: '1.0' + name: cirros_vnffg-ns + + vnfd-id: + - cirros_vnffg-vnf + + virtual-link-desc: + - id: osm-ext + mgmt-network: true + + vnffgd: + - id: vnffg1 + vnf-profile-id: + - Mid-vnf1 + nfpd: + - id: forwardingpath1 + position-desc-id: + - id: position1 + cp-profile-id: + - id: cpprofile2 + constituent-profile-elements: + - id: vnf1 + order: 0 + constituent-base-element-id: Mid-vnf1 + ingress-constituent-cpd-id: vnf-cp0-ext + egress-constituent-cpd-id: vnf-cp0-ext + match-attributes: + - id: rule1_80 + ip-proto: 6 + source-ip-address: 20.20.1.2 + destination-ip-address: 20.20.3.5 + source-port: 0 + destination-port: 80 + nfp-position-element-id: + - test + nfp-position-element: + - id: test + + df: + - id: default-df + vnf-profile: + - id: '1' + virtual-link-connectivity: + - constituent-cpd-id: + - constituent-base-element-id: '1' + constituent-cpd-id: eth0-ext + virtual-link-profile-id: osm-ext + vnfd-id: cirros_vnffg-vnf + description: Simple NS example with vnffgd +""" -- 2.17.1 From c72bc8e972e7fd1cafe7e570e6d0bb416c4440fa Mon Sep 17 00:00:00 2001 From: Rahul Date: Tue, 5 Dec 2023 11:54:38 +0000 Subject: [PATCH 14/16] Fix 2299 - Unable to logout from GUI when NBI uses keystone as backend Change-Id: I4e8a3592e7ea66645b9a8f19de576b7ba29e9d9c Signed-off-by: Rahul --- osm_nbi/nbi.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index 9aff857..8f87135 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -1095,9 +1095,13 @@ class Server(object): # for logging self._format_login(token_info) token_id = token_info["_id"] - token_details = self.engine.db.get_one("tokens", {"_id": token_id}) - current_user = token_details.get("username") - current_project = token_details.get("project_name") + if current_backend != "keystone": + token_details = self.engine.db.get_one("tokens", {"_id": token_id}) + current_user = token_details.get("username") + current_project = token_details.get("project_name") + else: + current_user = "keystone backend" + current_project = "keystone backend" outdata = self.authenticator.del_token(token_id) token_info = None cherrypy.session["Authorization"] = "logout" # pylint: disable=E1101 @@ -1939,6 +1943,7 @@ def _start_service(): global nbi_server global subscription_thread global cef_logger + global current_backend cherrypy.log.error("Starting osm_nbi") # update general cherrypy configuration update_dict = {} @@ -2053,6 +2058,7 @@ def _start_service(): # Do not capture except SubscriptionException backend = engine_config["authentication"]["backend"] + current_backend = backend cherrypy.log.error( "Starting OSM NBI Version '{} {}' with '{}' authentication backend".format( nbi_version, nbi_version_date, backend -- 2.17.1 From bd02208d93ce9e5319b911258f60b85803d1c3be Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Mon, 29 Jan 2024 18:43:30 +0100 Subject: [PATCH 15/16] Pin black version in tox.ini to 23.12.1 Change-Id: Ib84815d67d30355aaa306ba0f8f103f4d029aa3a Signed-off-by: garciadeblas --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 6521ae0..3c0217e 100644 --- a/tox.ini +++ b/tox.ini @@ -29,7 +29,7 @@ deps = -r{toxinidir}/requirements.txt ####################################################################################### [testenv:black] -deps = black +deps = black==23.12.1 skip_install = true commands = black --check --diff osm_nbi/ -- 2.17.1 From 48683b8ca543c63a03c8d594a768d48d4a1a87b9 Mon Sep 17 00:00:00 2001 From: Gabriel Cuba Date: Wed, 8 Nov 2023 00:14:33 -0500 Subject: [PATCH 16/16] Bug 1830 fixed: maps completed operations to original operation types Change-Id: I1a2f60f183ede39cabd9a7441ae64f10d7557232 Signed-off-by: Gabriel Cuba --- osm_nbi/notifications.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/osm_nbi/notifications.py b/osm_nbi/notifications.py index 63d4ce8..22413d0 100644 --- a/osm_nbi/notifications.py +++ b/osm_nbi/notifications.py @@ -235,6 +235,14 @@ class NotificationBase: class NsLcmNotification(NotificationBase): + # maps kafka commands of completed operations to the original operation type + completed_operation_map = { + "INSTANTIATED": "INSTANTIATE", + "SCALED": "SCALE", + "TERMINATED": "TERMINATE", + "UPDATED": "UPDATE", + "HEALED": "HEAL", + } # SOL005 response model for nslcm notifications response_models = { "NsLcmOperationOccurrenceNotification": { @@ -358,7 +366,8 @@ class NsLcmNotification(NotificationBase): if op_state: filter_q["operationStates"].append(op_state) if command: - filter_q["operationTypes"].append(command) + op_type = self.completed_operation_map.get(command, command) + filter_q["operationTypes"].append(op_type) # self.logger.debug("Db query is: {}".format(filter_q)) subscribers = [] try: -- 2.17.1