Started by upstream project "buildall-stage_2" build number 120 originally caused by: Started by user beierlm > git rev-parse --is-inside-work-tree # timeout=10 Setting origin to https://osm.etsi.org/gerrit/osm/osmclient.git > git config remote.origin.url https://osm.etsi.org/gerrit/osm/osmclient.git # timeout=10 Fetching origin... Fetching upstream changes from origin > git --version # timeout=10 > git config --get remote.origin.url # timeout=10 > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/* Seen branch in repository origin/bug1511 Seen branch in repository origin/feature5837 Seen branch in repository origin/feature7106 Seen branch in repository origin/feature7928 Seen branch in repository origin/master Seen branch in repository origin/netslice Seen branch in repository origin/ng-ro-refactor Seen branch in repository origin/rift300 Seen branch in repository origin/sol006 Seen branch in repository origin/sol006v331 Seen branch in repository origin/v10.0 Seen branch in repository origin/v11.0 Seen branch in repository origin/v2.0 Seen branch in repository origin/v3.1 Seen branch in repository origin/v4.0 Seen branch in repository origin/v5.0 Seen branch in repository origin/v6.0 Seen branch in repository origin/v7.0 Seen branch in repository origin/v8.0 Seen branch in repository origin/v9.0 Seen 20 remote branches Obtained Jenkinsfile from 1cbff09ebd242dcba9e0011c083e13e5623f1f5d Running in Durability level: MAX_SURVIVABILITY [Pipeline] properties [Pipeline] node Running on osm2 slave in /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0 [Pipeline] { [Pipeline] checkout No credentials specified Cloning the remote Git repository Cloning with configured refspecs honoured and without tags Cloning repository https://osm.etsi.org/gerrit/osm/osmclient.git > git init /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0 # timeout=10 Fetching upstream changes from https://osm.etsi.org/gerrit/osm/osmclient.git > git --version # timeout=10 > git fetch --no-tags --progress https://osm.etsi.org/gerrit/osm/osmclient.git +refs/heads/*:refs/remotes/origin/* > git config remote.origin.url https://osm.etsi.org/gerrit/osm/osmclient.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url https://osm.etsi.org/gerrit/osm/osmclient.git # timeout=10 Fetching without tags Fetching upstream changes from https://osm.etsi.org/gerrit/osm/osmclient.git > git fetch --no-tags --progress https://osm.etsi.org/gerrit/osm/osmclient.git +refs/heads/*:refs/remotes/origin/* Checking out Revision 1cbff09ebd242dcba9e0011c083e13e5623f1f5d (v9.0) > git config core.sparsecheckout # timeout=10 > git checkout -f 1cbff09ebd242dcba9e0011c083e13e5623f1f5d Commit message: "Fixes bug 1658 package-create update with sol006 templates" > git rev-list --no-walk 1cbff09ebd242dcba9e0011c083e13e5623f1f5d # timeout=10 Cleaning workspace > git rev-parse --verify HEAD # timeout=10 Resetting working tree > git reset --hard # timeout=10 > git clean -fdx # timeout=10 [Pipeline] dir Running in /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/devops [Pipeline] { [Pipeline] git No credentials specified Cloning the remote Git repository Cloning repository https://osm.etsi.org/gerrit/osm/devops > git init /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/devops # timeout=10 Fetching upstream changes from https://osm.etsi.org/gerrit/osm/devops > git --version # timeout=10 > git fetch --tags --progress https://osm.etsi.org/gerrit/osm/devops +refs/heads/*:refs/remotes/origin/* > git config remote.origin.url https://osm.etsi.org/gerrit/osm/devops # timeout=10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url https://osm.etsi.org/gerrit/osm/devops # timeout=10 Fetching upstream changes from https://osm.etsi.org/gerrit/osm/devops > git fetch --tags --progress https://osm.etsi.org/gerrit/osm/devops +refs/heads/*:refs/remotes/origin/* > git rev-parse refs/remotes/origin/v9.0^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/v9.0^{commit} # timeout=10 Checking out Revision ccabbe39368ab73645caa6ab469be795cae66df5 (refs/remotes/origin/v9.0) > git config core.sparsecheckout # timeout=10 > git checkout -f ccabbe39368ab73645caa6ab469be795cae66df5 > git branch -a -v --no-abbrev # timeout=10 > git checkout -b v9.0 ccabbe39368ab73645caa6ab469be795cae66df5 Commit message: "Fix bug 1811 - Disabling RO OpenNebula plugin" > git rev-list --no-walk b6386b4d84e74cefa71deebd6d30679171c162ed # timeout=10 [Pipeline] } [Pipeline] // dir [Pipeline] load [Pipeline] { (devops/jenkins/ci-pipelines/ci_stage_2.groovy) [Pipeline] } [Pipeline] // load [Pipeline] echo do_stage_3= false [Pipeline] load [Pipeline] { (devops/jenkins/ci-pipelines/ci_helper.groovy) [Pipeline] } [Pipeline] // load [Pipeline] stage [Pipeline] { (Prepare) [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + env JENKINS_HOME=/var/lib/jenkins MAIL=/var/mail/jenkins LC_TIME=fr_FR.UTF-8 SSH_CLIENT=195.238.226.13 56098 22 USER=jenkins RUN_CHANGES_DISPLAY_URL=https://osm.etsi.org/jenkins/job/osmclient-stage_2-merge/job/v9.0/28/display/redirect?page=changes GERRIT_PROJECT=osm/osmclient SHLVL=1 NODE_LABELS=docker osm2 osm2 slave pipeline HUDSON_URL=https://osm.etsi.org/jenkins/ OLDPWD=/home/jenkins HOME=/home/jenkins BUILD_URL=https://osm.etsi.org/jenkins/job/osmclient-stage_2-merge/job/v9.0/28/ HUDSON_COOKIE=e986092b-3cfe-4dd6-8c72-958272137665 JENKINS_SERVER_COOKIE=durable-1a38c1d1ca72c01b9eec3c3a8a4518f7 LC_MONETARY=fr_FR.UTF-8 GERRIT_PATCHSET_REVISION=1cbff09ebd242dcba9e0011c083e13e5623f1f5d WORKSPACE=/opt/jenkins/workspace/osmclient-stage_2-merge_v9.0 LOGNAME=jenkins NODE_NAME=osm2 slave GERRIT_BRANCH=v9.0 _=/usr/bin/java EXECUTOR_NUMBER=4 XDG_SESSION_ID=4763 BUILD_DISPLAY_NAME=#28 PROJECT_URL_PREFIX=https://osm.etsi.org/gerrit HUDSON_HOME=/var/lib/jenkins JOB_BASE_NAME=v9.0 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin LC_ADDRESS=fr_FR.UTF-8 BUILD_ID=28 XDG_RUNTIME_DIR=/run/user/1017 BUILD_TAG=jenkins-osmclient-stage_2-merge-v9.0-28 LC_TELEPHONE=fr_FR.UTF-8 JENKINS_URL=https://osm.etsi.org/jenkins/ LANG=en_US.UTF-8 JOB_URL=https://osm.etsi.org/jenkins/job/osmclient-stage_2-merge/job/v9.0/ BUILD_NUMBER=28 SHELL=/bin/bash XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt LC_NAME=fr_FR.UTF-8 RUN_DISPLAY_URL=https://osm.etsi.org/jenkins/job/osmclient-stage_2-merge/job/v9.0/28/display/redirect ARTIFACTORY_SERVER=artifactory-osm GERRIT_REFSPEC=refs/changes/76/11176/3 HUDSON_SERVER_COOKIE=6d3295a483c3e6d5 LC_MEASUREMENT=fr_FR.UTF-8 JOB_DISPLAY_URL=https://osm.etsi.org/jenkins/job/osmclient-stage_2-merge/job/v9.0/display/redirect LC_IDENTIFICATION=fr_FR.UTF-8 NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat JOB_NAME=osmclient-stage_2-merge/v9.0 TEST_INSTALL=false PWD=/opt/jenkins/workspace/osmclient-stage_2-merge_v9.0 LC_ALL=en_US.UTF-8 SSH_CONNECTION=195.238.226.13 56098 172.21.1.2 22 LC_NUMERIC=fr_FR.UTF-8 LC_PAPER=fr_FR.UTF-8 BRANCH_NAME=v9.0 [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Checkout) [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + git fetch --tags From https://osm.etsi.org/gerrit/osm/osmclient * [new tag] BUILD_v4.0.1_1 -> BUILD_v4.0.1_1 * [new tag] BUILD_v4.0.1_2 -> BUILD_v4.0.1_2 * [new tag] branch-bug1511-start -> branch-bug1511-start * [new tag] branch-ng-ro-refactor-start -> branch-ng-ro-refactor-start * [new tag] branch-sol006v331-start -> branch-sol006v331-start * [new tag] release-v10.0-start -> release-v10.0-start * [new tag] release-v11.0-start -> release-v11.0-start * [new tag] release-v8.0-start -> release-v8.0-start * [new tag] release-v9.0-start -> release-v9.0-start * [new tag] v10.0.0 -> v10.0.0 * [new tag] v10.0.1 -> v10.0.1 * [new tag] v10.0.2 -> v10.0.2 * [new tag] v10.0.3 -> v10.0.3 * [new tag] v11.0.0 -> v11.0.0 * [new tag] v11.0.0rc1 -> v11.0.0rc1 * [new tag] v11.0.0rc2 -> v11.0.0rc2 * [new tag] v2.0.0 -> v2.0.0 * [new tag] v2.0.1 -> v2.0.1 * [new tag] v2.0.2 -> v2.0.2 * [new tag] v3.0.0 -> v3.0.0 * [new tag] v3.0.0rc -> v3.0.0rc * [new tag] v3.0.0rc14 -> v3.0.0rc14 * [new tag] v3.0.0rc15 -> v3.0.0rc15 * [new tag] v3.0.0rc16 -> v3.0.0rc16 * [new tag] v3.0.0rc17 -> v3.0.0rc17 * [new tag] v3.0.0rc2 -> v3.0.0rc2 * [new tag] v3.0.1 -> v3.0.1 * [new tag] v3.0.2 -> v3.0.2 * [new tag] v3.0.3 -> v3.0.3 * [new tag] v3.1.0 -> v3.1.0 * [new tag] v4.0.0 -> v4.0.0 * [new tag] v4.0.1 -> v4.0.1 * [new tag] v5.0.0 -> v5.0.0 * [new tag] v5.0.1 -> v5.0.1 * [new tag] v5.0.2 -> v5.0.2 * [new tag] v5.0.3 -> v5.0.3 * [new tag] v5.0.4 -> v5.0.4 * [new tag] v5.0.5 -> v5.0.5 * [new tag] v6.0.0 -> v6.0.0 * [new tag] v6.0.1 -> v6.0.1 * [new tag] v6.0.2 -> v6.0.2 * [new tag] v6.0.2rc1 -> v6.0.2rc1 * [new tag] v6.0.3 -> v6.0.3 * [new tag] v6.0.4 -> v6.0.4 * [new tag] v6.0.4rc1 -> v6.0.4rc1 * [new tag] v7.0.0 -> v7.0.0 * [new tag] v7.0.0rc1 -> v7.0.0rc1 * [new tag] v7.0.1 -> v7.0.1 * [new tag] v7.0.1rc1 -> v7.0.1rc1 * [new tag] v7.0.1rc2 -> v7.0.1rc2 * [new tag] v7.0.1rc3 -> v7.0.1rc3 * [new tag] v7.1.0 -> v7.1.0 * [new tag] v7.1.0rc1 -> v7.1.0rc1 * [new tag] v7.1.0rc2 -> v7.1.0rc2 * [new tag] v7.1.0rc3 -> v7.1.0rc3 * [new tag] v7.1.0rc4 -> v7.1.0rc4 * [new tag] v7.1.0rc5 -> v7.1.0rc5 * [new tag] v7.1.0rc6 -> v7.1.0rc6 * [new tag] v7.1.2 -> v7.1.2 * [new tag] v7.1.3 -> v7.1.3 * [new tag] v7.1.4 -> v7.1.4 * [new tag] v7.1.5 -> v7.1.5 * [new tag] v8.0.0 -> v8.0.0 * [new tag] v8.0.0rc1 -> v8.0.0rc1 * [new tag] v8.0.0rc2 -> v8.0.0rc2 * [new tag] v8.0.0rc3 -> v8.0.0rc3 * [new tag] v8.0.1 -> v8.0.1 * [new tag] v8.0.1rc1 -> v8.0.1rc1 * [new tag] v8.0.2 -> v8.0.2 * [new tag] v8.0.3 -> v8.0.3 * [new tag] v8.0.4 -> v8.0.4 * [new tag] v9.0.0 -> v9.0.0 * [new tag] v9.0.0-dev -> v9.0.0-dev * [new tag] v9.0.0rc1 -> v9.0.0rc1 * [new tag] v9.1.0 -> v9.1.0 * [new tag] v9.1.1 -> v9.1.1 * [new tag] v9.1.1rc1 -> v9.1.1rc1 * [new tag] v9.1.2 -> v9.1.2 * [new tag] v9.1.3 -> v9.1.3 * [new tag] v9.1.4 -> v9.1.4 * [new tag] v9.1.5 -> v9.1.5 [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + git fetch origin refs/changes/76/11176/3 From https://osm.etsi.org/gerrit/osm/osmclient * branch refs/changes/76/11176/3 -> FETCH_HEAD [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + git checkout -f 1cbff09ebd242dcba9e0011c083e13e5623f1f5d HEAD is now at 1cbff09... Fixes bug 1658 package-create update with sol006 templates [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + sudo git clean -dfx Skipping repository devops/ [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (License Scan) [Pipeline] echo skip the scan for merge [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Docker-Build) [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + docker build -t osm/osmclient-v9.0 . Sending build context to Docker daemon 20.33MB Step 1/5 : FROM ubuntu:18.04 ---> 5a214d77f5d7 Step 2/5 : RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install debhelper git python3 python3-all python3-dev python3-setuptools ---> Using cache ---> f6e231fd46ba Step 3/5 : RUN python3 -m easy_install pip==21.0.1 ---> Using cache ---> 5ff91d394f4c Step 4/5 : RUN pip3 install tox==3.22.0 ---> Using cache ---> cde93d53ebeb Step 5/5 : RUN DEBIAN_FRONTEND=noninteractive apt-get -y install libcurl4-openssl-dev libssl-dev wget ---> Using cache ---> f99b3c1201e9 Successfully built f99b3c1201e9 Successfully tagged osm/osmclient-v9.0:latest [Pipeline] } [Pipeline] // stage [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + id -u [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + id -g [Pipeline] withDockerContainer osm2 slave does not seem to be running inside a container $ docker run -t -d -u 1017:1015 -u root -w /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0 -v /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0:/opt/jenkins/workspace/osmclient-stage_2-merge_v9.0:rw,z -v /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0@tmp:/opt/jenkins/workspace/osmclient-stage_2-merge_v9.0@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** --entrypoint cat osm/osmclient-v9.0 [Pipeline] { [Pipeline] stage [Pipeline] { (Test) [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + groupadd -o -g 1015 -r jenkins [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + pwd + useradd -o -u 1017 -d /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0 -r -g jenkins jenkins [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + echo #! /bin/sh [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + chmod 755 /usr/bin/mesg [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + runuser jenkins -c devops-stages/stage-test.sh black create: /tmp/.tox/black black installdeps: black black installed: black==21.12b0,click==8.0.3,dataclasses==0.8,importlib-metadata==4.8.2,mypy-extensions==0.4.3,pathspec==0.9.0,platformdirs==2.4.0,tomli==1.2.3,typed-ast==1.5.1,typing_extensions==4.0.1,zipp==3.6.0 black run-test-pre: PYTHONHASHSEED='1630188128' black run-test: commands[0] | - black --check --diff osmclient/ --- osmclient/client.py 2021-12-14 16:49:03.486515 +0000 +++ osmclient/client.py 2021-12-14 16:49:32.610132 +0000 @@ -21,33 +21,38 @@ from osmclient.v1 import client as client from osmclient.sol005 import client as sol005client import logging import verboselogs + verboselogs.install() def Client(version=1, host=None, sol005=True, *args, **kwargs): log_format_simple = "%(levelname)s %(message)s" log_format_complete = "%(asctime)s %(levelname)s %(name)s %(filename)s:%(lineno)s %(funcName)s(): %(message)s" - log_formatter_simple = logging.Formatter(log_format_simple, datefmt='%Y-%m-%dT%H:%M:%S') + log_formatter_simple = logging.Formatter( + log_format_simple, datefmt="%Y-%m-%dT%H:%M:%S" + ) handler = logging.StreamHandler() handler.setFormatter(log_formatter_simple) - logger = logging.getLogger('osmclient') + logger = logging.getLogger("osmclient") logger.setLevel(level=logging.WARNING) logger.addHandler(handler) - verbose = kwargs.get('verbose',0) - if verbose>0: - log_formatter = logging.Formatter(log_format_complete, datefmt='%Y-%m-%dT%H:%M:%S') - #handler = logging.StreamHandler() + verbose = kwargs.get("verbose", 0) + if verbose > 0: + log_formatter = logging.Formatter( + log_format_complete, datefmt="%Y-%m-%dT%H:%M:%S" + ) + # handler = logging.StreamHandler() handler.setFormatter(log_formatter) - #logger.addHandler(handler) - if verbose==1: + # logger.addHandler(handler) + if verbose == 1: logger.setLevel(level=logging.INFO) - elif verbose==2: + elif verbose == 2: logger.setLevel(level=logging.VERBOSE) - elif verbose>2: + elif verbose > 2: logger.setLevel(level=logging.DEBUG) if not sol005: if version == 1: return client.Client(host, *args, **kwargs) else: would reformat osmclient/client.py --- osmclient/common/test/test_utils.py 2021-12-14 16:49:03.486515 +0000 +++ osmclient/common/test/test_utils.py 2021-12-14 16:49:33.008682 +0000 @@ -18,50 +18,53 @@ import unittest from osmclient.common import utils class TestUtil(unittest.TestCase): - def test_wait_for_method_basic(self): def foobar(): return True + assert utils.wait_for_value(lambda: foobar()) def test_wait_for_method_timeout(self): def foobar(): return False + assert not utils.wait_for_value(lambda: foobar(), wait_time=0) def test_wait_for_method_paramter(self): def foobar(input): return input + assert not utils.wait_for_value(lambda: foobar(False), wait_time=0) assert utils.wait_for_value(lambda: foobar(True), wait_time=0) def test_wait_for_method_wait_for_change(self): def foobar(): if foobar.counter == 0: return True foobar.counter -= 1 return False + foobar.counter = 1 assert utils.wait_for_value(lambda: foobar(), wait_time=1) def test_wait_for_method_exception(self): def foobar(): - raise Exception('send exception') + raise Exception("send exception") + assert not utils.wait_for_value( - lambda: foobar(), - wait_time=0, - catch_exception=Exception) + lambda: foobar(), wait_time=0, catch_exception=Exception + ) def test_wait_for_method_first_exception(self): def foobar(): if foobar.counter == 0: return True foobar.counter -= 1 - raise Exception('send exception') + raise Exception("send exception") + foobar.counter = 1 assert utils.wait_for_value( - lambda: foobar(), - wait_time=1, - catch_exception=Exception) + lambda: foobar(), wait_time=1, catch_exception=Exception + ) would reformat osmclient/common/test/test_utils.py --- osmclient/common/utils.py 2021-12-14 16:49:03.486515 +0000 +++ osmclient/common/utils.py 2021-12-14 16:49:33.354809 +0000 @@ -57,38 +57,37 @@ # method opens up a package and finds the name of the resulting # descriptor (vnfd or nsd name) tar = tarfile.open(descriptor_file) yamlfile = None for member in tar.getmembers(): - if (re.match('.*.yaml', member.name) and - len(member.name.split('/')) == 2): + if re.match(".*.yaml", member.name) and len(member.name.split("/")) == 2: yamlfile = member.name break if yamlfile is None: return None dict = yaml.safe_load(tar.extractfile(yamlfile)) result = {} for k in dict: - if 'nsd' in k: - result['type'] = 'nsd' + if "nsd" in k: + result["type"] = "nsd" else: - result['type'] = 'vnfd' - if 'type' not in result: + result["type"] = "vnfd" + if "type" not in result: for k1, v1 in list(dict.items()): - if not k1.endswith('-catalog'): + if not k1.endswith("-catalog"): continue for k2, v2 in v1.items(): - if not k2.endswith('nsd') and not k2.endswith('vnfd'): + if not k2.endswith("nsd") and not k2.endswith("vnfd"): continue - if 'nsd' in k2: - result['type'] = 'nsd' + if "nsd" in k2: + result["type"] = "nsd" else: - result['type'] = 'vnfd' + result["type"] = "vnfd" for entry in v2: for k3, v3 in list(entry.items()): # strip off preceeding chars before : - key_name = k3.split(':').pop() + key_name = k3.split(":").pop() result[key_name] = v3 tar.close() return result would reformat osmclient/common/utils.py --- osmclient/common/wait.py 2021-12-14 16:49:03.486515 +0000 +++ osmclient/common/wait.py 2021-12-14 16:49:33.521926 +0000 @@ -54,14 +54,14 @@ ENABLED, DISABLED, ERROR, PROCESSING :param entity: can be NS, NSI, or other :return: two tuples with status completed strings, status failed string """ - if entity == 'NS' or entity == 'NSI': - return ('COMPLETED', 'PARTIALLY_COMPLETED'), ('FAILED_TEMP', 'FAILED') + if entity == "NS" or entity == "NSI": + return ("COMPLETED", "PARTIALLY_COMPLETED"), ("FAILED_TEMP", "FAILED") else: - return ('ENABLED', ), ('ERROR', ) + return ("ENABLED",), ("ERROR",) def _get_operational_state(resp, entity): """ The member name is either: @@ -70,14 +70,14 @@ '_admin.'operationalState' (other) :param resp: descriptor of the get response :param entity: can be NS, NSI, or other :return: status of the operation """ - if entity == 'NS' or entity == 'NSI': - return resp.get('operationState') + if entity == "NS" or entity == "NSI": + return resp.get("operationState") else: - return resp.get('_admin', {}).get('operationalState') + return resp.get("_admin", {}).get("operationalState") def _op_has_finished(resp, entity): """ Indicates if operation has finished ok or is processing @@ -93,13 +93,15 @@ op_state = _get_operational_state(resp, entity) if op_state: if op_state in finished_states_ok: return True elif op_state in finished_states_error: - raise ClientException("Operation failed with status '{}'".format(op_state)) + raise ClientException( + "Operation failed with status '{}'".format(op_state) + ) return False - raise ClientException('Unexpected response from server: {} '.format(resp)) + raise ClientException("Unexpected response from server: {} ".format(resp)) def _get_detailed_status(resp, entity): """ For VIM, WIM, SDN, 'detailed-status' is either: @@ -107,32 +109,43 @@ - a leaf node of the Nth element in the list '_admin.operations[]' (operations supported by LCM and NBI) :param resp: content of the get response :param entity: can be NS, NSI, or other :return: """ - if entity in ('NS', 'NSI'): + if entity in ("NS", "NSI"): # For NS and NSI, 'detailed-status' is a JSON "root" member: - return resp.get('detailed-status') + return resp.get("detailed-status") else: - ops = resp.get('_admin', {}).get('operations') - current_op = resp.get('_admin', {}).get('current_operation') + ops = resp.get("_admin", {}).get("operations") + current_op = resp.get("_admin", {}).get("current_operation") if ops and current_op is not None: # Operations are supported, verify operation index if isinstance(ops, dict) and current_op in ops: return ops[current_op].get("detailed-status") - elif isinstance(ops, list) and isinstance(current_op, int) or current_op.isdigit(): + elif ( + isinstance(ops, list) + and isinstance(current_op, int) + or current_op.isdigit() + ): current_op = int(current_op) - if current_op >= 0 and current_op < len(ops) and ops[current_op] and ops[current_op]["detailed-status"]: + if ( + current_op >= 0 + and current_op < len(ops) + and ops[current_op] + and ops[current_op]["detailed-status"] + ): return ops[current_op]["detailed-status"] # operation index is either non-numeric or out-of-range - return 'Unexpected error when getting detailed-status!' + return "Unexpected error when getting detailed-status!" else: # Operations are NOT supported - return resp.get('_admin', {}).get('detailed-status') + return resp.get("_admin", {}).get("detailed-status") -def wait_for_status(entity_label, entity_id, timeout, apiUrlStatus, http_cmd, deleteFlag=False): +def wait_for_status( + entity_label, entity_id, timeout, apiUrlStatus, http_cmd, deleteFlag=False +): """ Wait until operation ends, making polling every 5s. Prints detailed status when it changes :param entity_label: String describing the entities using '--wait': 'NS', 'NSI', 'SDNC', 'VIM', 'WIM' :param entity_id: The ID for an existing entity, the operation ID for an entity to create. :param timeout: Timeout in seconds @@ -147,37 +160,37 @@ detailed_status = None retries = 0 max_retries = 1 while True: try: - http_code, resp_unicode = http_cmd('{}/{}'.format(apiUrlStatus, entity_id)) + http_code, resp_unicode = http_cmd("{}/{}".format(apiUrlStatus, entity_id)) retries = 0 except NotFound: if deleteFlag: - _show_detailed_status(detailed_status, 'Deleted') + _show_detailed_status(detailed_status, "Deleted") return raise except ClientException: if retries >= max_retries or time() < time_to_finish: raise retries += 1 sleep(POLLING_TIME_INTERVAL) continue - resp = '' + resp = "" if resp_unicode: resp = json.loads(resp_unicode) new_detailed_status = _get_detailed_status(resp, entity_label) # print('DETAILED-STATUS: {}'.format(new_detailed_status)) if not new_detailed_status: - new_detailed_status = 'In progress' + new_detailed_status = "In progress" detailed_status = _show_detailed_status(detailed_status, new_detailed_status) # Get operation status if _op_has_finished(resp, entity_label): return if time() >= time_to_finish: # There was a timeout, so raise an exception - raise ClientException('operation timeout after {} seconds'.format(timeout)) + raise ClientException("operation timeout after {} seconds".format(timeout)) sleep(POLLING_TIME_INTERVAL) would reformat osmclient/common/wait.py --- osmclient/sol005/client.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/client.py 2021-12-14 16:49:33.568624 +0000 @@ -16,11 +16,11 @@ """ OSM SOL005 client API """ -#from osmclient.v1 import vca +# from osmclient.v1 import vca from osmclient.sol005 import vnfd from osmclient.sol005 import nsd from osmclient.sol005 import nst from osmclient.sol005 import nsi from osmclient.sol005 import ns @@ -41,43 +41,45 @@ import json import logging class Client(object): - def __init__( self, host=None, so_port=9999, - user='admin', - password='admin', - project='admin', - **kwargs): + user="admin", + password="admin", + project="admin", + **kwargs + ): self._user = user self._password = password self._project = project self._project_domain_name = kwargs.get("project_domain_name") self._user_domain_name = kwargs.get("user_domain_name") - self._logger = logging.getLogger('osmclient') - self._auth_endpoint = '/admin/v1/tokens' + self._logger = logging.getLogger("osmclient") + self._auth_endpoint = "/admin/v1/tokens" self._headers = {} self._token = None - if len(host.split(':')) > 1: + if len(host.split(":")) > 1: # backwards compatible, port provided as part of host - self._host = host.split(':')[0] - self._so_port = host.split(':')[1] + self._host = host.split(":")[0] + self._so_port = host.split(":")[1] else: self._host = host self._so_port = so_port self._http_client = http.Http( - 'https://{}:{}/osm'.format(self._host,self._so_port), **kwargs) - self._headers['Accept'] = 'application/json' - self._headers['Content-Type'] = 'application/yaml' - http_header = ['{}: {}'.format(key, val) - for (key, val) in list(self._headers.items())] + "https://{}:{}/osm".format(self._host, self._so_port), **kwargs + ) + self._headers["Accept"] = "application/json" + self._headers["Content-Type"] = "application/yaml" + http_header = [ + "{}: {}".format(key, val) for (key, val) in list(self._headers.items()) + ] self._http_client.set_http_header(http_header) self.vnfd = vnfd.Vnfd(self._http_client, client=self) self.nsd = nsd.Nsd(self._http_client, client=self) self.nst = nst.Nst(self._http_client, client=self) @@ -94,56 +96,62 @@ self.pdu = pdud.Pdu(self._http_client, client=self) self.k8scluster = k8scluster.K8scluster(self._http_client, client=self) self.repo = repo.Repo(self._http_client, client=self) self.osmrepo = osmrepo.OSMRepo(self._http_client, client=self) self.package_tool = package_tool.PackageTool(client=self) - ''' + """ self.vca = vca.Vca(http_client, client=self, **kwargs) self.utils = utils.Utils(http_client, **kwargs) - ''' + """ def get_token(self): self._logger.debug("") if self._token is None: - postfields_dict = {'username': self._user, - 'password': self._password, - 'project_id': self._project} + postfields_dict = { + "username": self._user, + "password": self._password, + "project_id": self._project, + } if self._project_domain_name: postfields_dict["project_domain_name"] = self._project_domain_name if self._user_domain_name: postfields_dict["user_domain_name"] = self._user_domain_name - http_code, resp = self._http_client.post_cmd(endpoint=self._auth_endpoint, - postfields_dict=postfields_dict, - skip_query_admin=True) -# if http_code not in (200, 201, 202, 204): -# message ='Authentication error: not possible to get auth token\nresp:\n{}'.format(resp) -# raise ClientException(message) + http_code, resp = self._http_client.post_cmd( + endpoint=self._auth_endpoint, + postfields_dict=postfields_dict, + skip_query_admin=True, + ) + # if http_code not in (200, 201, 202, 204): + # message ='Authentication error: not possible to get auth token\nresp:\n{}'.format(resp) + # raise ClientException(message) token = json.loads(resp) if resp else None - self._token = token['id'] + self._token = token["id"] if self._token is not None: - self._headers['Authorization'] = 'Bearer {}'.format(self._token) - http_header = ['{}: {}'.format(key, val) - for (key, val) in list(self._headers.items())] + self._headers["Authorization"] = "Bearer {}".format(self._token) + http_header = [ + "{}: {}".format(key, val) + for (key, val) in list(self._headers.items()) + ] self._http_client.set_http_header(http_header) def get_version(self): _, resp = self._http_client.get2_cmd(endpoint="/version", skip_query_admin=True) - #print(http_code, resp) + # print(http_code, resp) try: resp = json.loads(resp) version = resp.get("version") date = resp.get("date") except ValueError: version = resp.split()[2] date = resp.split()[4] return "{} {}".format(version, date) def set_default_params(self, **kwargs): - host = kwargs.pop('host', None) + host = kwargs.pop("host", None) if host != None: - self._host=host - port = kwargs.pop('port', None) + self._host = host + port = kwargs.pop("port", None) if port != None: - self._so_port=port + self._so_port = port self._http_client.set_query_admin(**kwargs) would reformat osmclient/sol005/client.py --- osmclient/common/http.py 2021-12-14 16:49:03.486515 +0000 +++ osmclient/common/http.py 2021-12-14 16:49:33.750012 +0000 @@ -18,12 +18,11 @@ import pycurl import json class Http(object): - - def __init__(self, url, user='admin', password='admin'): + def __init__(self, url, user="admin", password="admin"): self._url = url self._user = user self._password = password self._http_header = None @@ -33,51 +32,60 @@ def _get_curl_cmd(self, endpoint): curl_cmd = pycurl.Curl() curl_cmd.setopt(pycurl.URL, self._url + endpoint) curl_cmd.setopt(pycurl.SSL_VERIFYPEER, 0) curl_cmd.setopt(pycurl.SSL_VERIFYHOST, 0) - curl_cmd.setopt( - pycurl.USERPWD, - '{}:{}'.format( - self._user, - self._password)) + curl_cmd.setopt(pycurl.USERPWD, "{}:{}".format(self._user, self._password)) if self._http_header: curl_cmd.setopt(pycurl.HTTPHEADER, self._http_header) return curl_cmd def get_cmd(self, endpoint): data = BytesIO() curl_cmd = self._get_curl_cmd(endpoint) curl_cmd.setopt(pycurl.HTTPGET, 1) curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write) - self._logger.info("Request METHOD: {} URL: {}".format("GET",self._url + endpoint)) + self._logger.info( + "Request METHOD: {} URL: {}".format("GET", self._url + endpoint) + ) curl_cmd.perform() http_code = curl_cmd.getinfo(pycurl.HTTP_CODE) self._logger.info("Response HTTPCODE: {}".format(http_code)) curl_cmd.close() if data.getvalue(): - self._logger.debug("Response DATA: {}".format(json.loads(data.getvalue().decode()))) + self._logger.debug( + "Response DATA: {}".format(json.loads(data.getvalue().decode())) + ) return json.loads(data.getvalue().decode()) return None def delete_cmd(self, endpoint): data = BytesIO() curl_cmd = self._get_curl_cmd(endpoint) curl_cmd.setopt(pycurl.CUSTOMREQUEST, "DELETE") curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write) - self._logger.info("Request METHOD: {} URL: {}".format("DELETE",self._url + endpoint)) + self._logger.info( + "Request METHOD: {} URL: {}".format("DELETE", self._url + endpoint) + ) curl_cmd.perform() http_code = curl_cmd.getinfo(pycurl.HTTP_CODE) self._logger.info("Response HTTPCODE: {}".format(http_code)) curl_cmd.close() if data.getvalue(): - self._logger.debug("Response DATA: {}".format(json.loads(data.getvalue().decode()))) + self._logger.debug( + "Response DATA: {}".format(json.loads(data.getvalue().decode())) + ) return json.loads(data.getvalue().decode()) return None - def post_cmd(self, endpoint='', postfields_dict=None, formfile=None, ): + def post_cmd( + self, + endpoint="", + postfields_dict=None, + formfile=None, + ): data = BytesIO() curl_cmd = self._get_curl_cmd(endpoint) curl_cmd.setopt(pycurl.POST, 1) curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write) @@ -85,19 +93,21 @@ jsondata = json.dumps(postfields_dict) curl_cmd.setopt(pycurl.POSTFIELDS, jsondata) if formfile is not None: curl_cmd.setopt( - pycurl.HTTPPOST, - [((formfile[0], - (pycurl.FORM_FILE, - formfile[1])))]) + pycurl.HTTPPOST, [((formfile[0], (pycurl.FORM_FILE, formfile[1])))] + ) - self._logger.info("Request METHOD: {} URL: {}".format("POST",self._url + endpoint)) + self._logger.info( + "Request METHOD: {} URL: {}".format("POST", self._url + endpoint) + ) curl_cmd.perform() http_code = curl_cmd.getinfo(pycurl.HTTP_CODE) self._logger.info("Response HTTPCODE: {}".format(http_code)) curl_cmd.close() if data.getvalue(): - self._logger.debug("Response DATA: {}".format(json.loads(data.getvalue().decode()))) + self._logger.debug( + "Response DATA: {}".format(json.loads(data.getvalue().decode())) + ) return json.loads(data.getvalue().decode()) return None would reformat osmclient/common/http.py --- osmclient/sol005/k8scluster.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/k8scluster.py 2021-12-14 16:49:34.960437 +0000 @@ -19,41 +19,43 @@ from osmclient.common import utils from osmclient.common.exceptions import NotFound from osmclient.common.exceptions import ClientException import json + class K8scluster(object): def __init__(self, http=None, client=None): self._http = http self._client = client - self._apiName = '/admin' - self._apiVersion = '/v1' - self._apiResource = '/k8sclusters' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._apiName = "/admin" + self._apiVersion = "/v1" + self._apiResource = "/k8sclusters" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) def create(self, name, k8s_cluster): - def get_vim_account_id(vim_account): vim = self._client.vim.get(vim_account) if vim is None: raise NotFound("cannot find vim account '{}'".format(vim_account)) - return vim['_id'] + return vim["_id"] self._client.get_token() - k8s_cluster['vim_account'] = get_vim_account_id(k8s_cluster['vim_account']) - http_code, resp = self._http.post_cmd(endpoint=self._apiBase, - postfields_dict=k8s_cluster) - #print 'HTTP CODE: {}'.format(http_code) - #print 'RESP: {}'.format(resp) - #if http_code in (200, 201, 202, 204): + k8s_cluster["vim_account"] = get_vim_account_id(k8s_cluster["vim_account"]) + http_code, resp = self._http.post_cmd( + endpoint=self._apiBase, postfields_dict=k8s_cluster + ) + # print 'HTTP CODE: {}'.format(http_code) + # print 'RESP: {}'.format(resp) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format(resp)) - print(resp['id']) - #else: + if not resp or "id" not in resp: + raise ClientException("unexpected response from server - {}".format(resp)) + print(resp["id"]) + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: @@ -61,82 +63,83 @@ # raise ClientException("failed to add K8s cluster {} - {}".format(name, msg)) def update(self, name, k8s_cluster): self._client.get_token() cluster = self.get(name) - http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,cluster['_id']), - postfields_dict=k8s_cluster) + http_code, resp = self._http.put_cmd( + endpoint="{}/{}".format(self._apiBase, cluster["_id"]), + postfields_dict=k8s_cluster, + ) # print 'HTTP CODE: {}'.format(http_code) # print 'RESP: {}'.format(resp) - #if http_code in (200, 201, 202, 204): + # if http_code in (200, 201, 202, 204): # pass - #else: + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException("failed to update K8s cluster {} - {}".format(name, msg)) def get_id(self, name): - """Returns a K8s cluster id from a K8s cluster name - """ + """Returns a K8s cluster id from a K8s cluster name""" for cluster in self.list(): - if name == cluster['name']: - return cluster['_id'] + if name == cluster["name"]: + return cluster["_id"] raise NotFound("K8s cluster {} not found".format(name)) def delete(self, name, force=False): self._client.get_token() cluster_id = name if not utils.validate_uuid4(name): cluster_id = self.get_id(name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - cluster_id, querystring)) - #print 'HTTP CODE: {}'.format(http_code) - #print 'RESP: {}'.format(resp) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, cluster_id, querystring) + ) + # print 'HTTP CODE: {}'.format(http_code) + # print 'RESP: {}'.format(resp) if http_code == 202: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') + print("Deleted") else: msg = resp or "" - # if resp: - # try: - # msg = json.loads(resp) - # except ValueError: - # msg = resp - raise ClientException("failed to delete K8s cluster {} - {}".format(name, msg)) + # if resp: + # try: + # msg = json.loads(resp) + # except ValueError: + # msg = resp + raise ClientException( + "failed to delete K8s cluster {} - {}".format(name, msg) + ) def list(self, filter=None): - """Returns a list of K8s clusters - """ + """Returns a list of K8s clusters""" self._client.get_token() - filter_string = '' + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) if resp: - return json.loads(resp) + return json.loads(resp) return list() def get(self, name): - """Returns a K8s cluster based on name or id - """ + """Returns a K8s cluster based on name or id""" self._client.get_token() cluster_id = name if not utils.validate_uuid4(name): cluster_id = self.get_id(name) try: - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase,cluster_id)) + _, resp = self._http.get2_cmd("{}/{}".format(self._apiBase, cluster_id)) if resp: resp = json.loads(resp) - if not resp or '_id' not in resp: - raise ClientException('failed to get K8s cluster info: {}'.format(resp)) + if not resp or "_id" not in resp: + raise ClientException("failed to get K8s cluster info: {}".format(resp)) return resp except NotFound: raise NotFound("K8s cluster {} not found".format(name)) - would reformat osmclient/sol005/k8scluster.py --- osmclient/sol005/nst.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/nst.py 2021-12-14 16:49:35.896352 +0000 @@ -23,114 +23,119 @@ from osmclient.common import utils import json import magic import logging import os.path -#from os import stat -#from os.path import basename + +# from os import stat +# from os.path import basename + class Nst(object): - def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/nst' - self._apiVersion = '/v1' - self._apiResource = '/netslice_templates' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/nst" + self._apiVersion = "/v1" + self._apiResource = "/netslice_templates" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) def list(self, filter=None): self._logger.debug("") self._client.get_token() - filter_string = '' + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase, filter_string)) - #print(yaml.safe_dump(resp)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) + # print(yaml.safe_dump(resp)) if resp: return json.loads(resp) return list() def get(self, name): self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for nst in self.list(): - if name == nst['_id']: + if name == nst["_id"]: return nst else: for nst in self.list(): - if 'name' in nst and name == nst['name']: + if "name" in nst and name == nst["name"]: return nst raise NotFound("nst {} not found".format(name)) def get_individual(self, name): self._logger.debug("") nst = self.get(name) # It is redundant, since the previous one already gets the whole nstinfo # The only difference is that a different primitive is exercised try: - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, nst['_id'])) - #print(yaml.safe_dump(resp)) + _, resp = self._http.get2_cmd("{}/{}".format(self._apiBase, nst["_id"])) + # print(yaml.safe_dump(resp)) if resp: return json.loads(resp) except NotFound: raise NotFound("nst '{}' not found".format(name)) raise NotFound("nst '{}' not found".format(name)) def get_thing(self, name, thing, filename): self._logger.debug("") nst = self.get(name) headers = self._client._headers - headers['Accept'] = 'application/binary' + headers["Accept"] = "application/binary" try: - http_code, resp = self._http.get2_cmd('{}/{}/{}'.format(self._apiBase, nst['_id'], thing)) + http_code, resp = self._http.get2_cmd( + "{}/{}/{}".format(self._apiBase, nst["_id"], thing) + ) except NotFound: raise NotFound("nst '{} 'not found".format(name)) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: - #store in a file + # store in a file return json.loads(resp) - #else: + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException("failed to get {} from {} - {}".format(thing, name, msg)) def get_descriptor(self, name, filename): self._logger.debug("") - self.get_thing(name, 'nst', filename) + self.get_thing(name, "nst", filename) def get_package(self, name, filename): self._logger.debug("") - self.get_thing(name, 'nst_content', filename) + self.get_thing(name, "nst_content", filename) def get_artifact(self, name, artifact, filename): self._logger.debug("") - self.get_thing(name, 'artifacts/{}'.format(artifact), filename) + self.get_thing(name, "artifacts/{}".format(artifact), filename) def delete(self, name, force=False): self._logger.debug("") nst = self.get(name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - nst['_id'], querystring)) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, nst["_id"], querystring) + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) if http_code == 202: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') + print("Deleted") else: msg = resp or "" # if resp: # try: # resp = json.loads(resp) @@ -139,70 +144,86 @@ raise ClientException("failed to delete nst {} - {}".format(name, msg)) def create(self, filename, overwrite=None, update_endpoint=None): self._logger.debug("") if os.path.isdir(filename): - charm_folder = filename.rstrip('/') + charm_folder = filename.rstrip("/") for files in os.listdir(charm_folder): if "nst.yaml" in files: - results = self._client.package_tool.validate(charm_folder, recursive=False) + results = self._client.package_tool.validate( + charm_folder, recursive=False + ) for result in results: if result["valid"] != "OK": - raise ClientException('There was an error validating the file: {} ' - 'with error: {}'.format(result["path"], result["error"])) + raise ClientException( + "There was an error validating the file: {} " + "with error: {}".format(result["path"], result["error"]) + ) result = self._client.package_tool.build(charm_folder) - if 'Created' in result: + if "Created" in result: filename = "{}.tar.gz".format(charm_folder) else: - raise ClientException('Failed in {}tar.gz creation'.format(charm_folder)) + raise ClientException( + "Failed in {}tar.gz creation".format(charm_folder) + ) self.create(filename, overwrite, update_endpoint) else: self._client.get_token() mime_type = magic.from_file(filename, mime=True) if mime_type is None: raise ClientException( - "Unexpected MIME type for file {}: MIME type {}".format( - filename, mime_type) - ) - headers= self._client._headers - if mime_type in ['application/yaml', 'text/plain']: - headers['Content-Type'] = 'application/yaml' - elif mime_type in ['application/gzip', 'application/x-gzip']: - headers['Content-Type'] = 'application/gzip' - #headers['Content-Type'] = 'application/binary' + "Unexpected MIME type for file {}: MIME type {}".format( + filename, mime_type + ) + ) + headers = self._client._headers + if mime_type in ["application/yaml", "text/plain"]: + headers["Content-Type"] = "application/yaml" + elif mime_type in ["application/gzip", "application/x-gzip"]: + headers["Content-Type"] = "application/gzip" + # headers['Content-Type'] = 'application/binary' # Next three lines are to be removed in next version - #headers['Content-Filename'] = basename(filename) - #file_size = stat(filename).st_size - #headers['Content-Range'] = 'bytes 0-{}/{}'.format(file_size - 1, file_size) + # headers['Content-Filename'] = basename(filename) + # file_size = stat(filename).st_size + # headers['Content-Range'] = 'bytes 0-{}/{}'.format(file_size - 1, file_size) else: raise ClientException( - "Unexpected MIME type for file {}: MIME type {}".format( - filename, mime_type) - ) + "Unexpected MIME type for file {}: MIME type {}".format( + filename, mime_type + ) + ) headers["Content-File-MD5"] = utils.md5(filename) - http_header = ['{}: {}'.format(key,val) - for (key,val) in list(headers.items())] + http_header = [ + "{}: {}".format(key, val) for (key, val) in list(headers.items()) + ] self._http.set_http_header(http_header) if update_endpoint: - http_code, resp = self._http.put_cmd(endpoint=update_endpoint, filename=filename) + http_code, resp = self._http.put_cmd( + endpoint=update_endpoint, filename=filename + ) else: - ow_string = '' + ow_string = "" if overwrite: - ow_string = '?{}'.format(overwrite) - self._apiResource = '/netslice_templates_content' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) - endpoint = '{}{}'.format(self._apiBase,ow_string) - http_code, resp = self._http.post_cmd(endpoint=endpoint, filename=filename) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) + ow_string = "?{}".format(overwrite) + self._apiResource = "/netslice_templates_content" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) + endpoint = "{}{}".format(self._apiBase, ow_string) + http_code, resp = self._http.post_cmd( + endpoint=endpoint, filename=filename + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format(resp)) - print(resp['id']) + if not resp or "id" not in resp: + raise ClientException( + "unexpected response from server - {}".format(resp) + ) + print(resp["id"]) # else: # msg = "Error {}".format(http_code) # if resp: # try: # msg = "{} - {}".format(msg, json.loads(resp)) @@ -211,8 +232,7 @@ # raise ClientException("failed to create/update nst - {}".format(msg)) def update(self, name, filename): self._logger.debug("") nst = self.get(name) - endpoint = '{}/{}/nst_content'.format(self._apiBase, nst['_id']) + endpoint = "{}/{}/nst_content".format(self._apiBase, nst["_id"]) self.create(filename=filename, update_endpoint=endpoint) - would reformat osmclient/sol005/nst.py --- osmclient/sol005/http.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/http.py 2021-12-14 16:49:36.406885 +0000 @@ -25,23 +25,23 @@ class Http(http.Http): CONNECT_TIMEOUT = 15 - def __init__(self, url, user='admin', password='admin', **kwargs): + def __init__(self, url, user="admin", password="admin", **kwargs): self._url = url self._user = user self._password = password self._http_header = None - self._logger = logging.getLogger('osmclient') + self._logger = logging.getLogger("osmclient") self._default_query_admin = None self._all_projects = None self._public = None - if 'all_projects' in kwargs: - self._all_projects = kwargs['all_projects'] - if 'public' in kwargs: - self._public = kwargs['public'] + if "all_projects" in kwargs: + self._all_projects = kwargs["all_projects"] + if "public" in kwargs: + self._public = kwargs["public"] self._default_query_admin = self._complete_default_query_admin() def _complete_default_query_admin(self): query_string_list = [] if self._all_projects: @@ -50,14 +50,14 @@ query_string_list.append("PUBLIC={}".format(self._public)) return "&".join(query_string_list) def _complete_endpoint(self, endpoint): if self._default_query_admin: - if '?' in endpoint: - endpoint = '&'.join([endpoint, self._default_query_admin]) + if "?" in endpoint: + endpoint = "&".join([endpoint, self._default_query_admin]) else: - endpoint = '?'.join([endpoint, self._default_query_admin]) + endpoint = "?".join([endpoint, self._default_query_admin]) return endpoint def _get_curl_cmd(self, endpoint, skip_query_admin=False): self._logger.debug("") curl_cmd = pycurl.Curl() @@ -77,11 +77,13 @@ self._logger.debug("") data = BytesIO() curl_cmd = self._get_curl_cmd(endpoint, skip_query_admin) curl_cmd.setopt(pycurl.CUSTOMREQUEST, "DELETE") curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write) - self._logger.info("Request METHOD: {} URL: {}".format("DELETE", self._url + endpoint)) + self._logger.info( + "Request METHOD: {} URL: {}".format("DELETE", self._url + endpoint) + ) curl_cmd.perform() http_code = curl_cmd.getinfo(pycurl.HTTP_CODE) self._logger.info("Response HTTPCODE: {}".format(http_code)) curl_cmd.close() self.check_http_response(http_code, data) @@ -91,14 +93,20 @@ self._logger.verbose("Response DATA: {}".format(data_text)) return http_code, data_text else: return http_code, None - def send_cmd(self, endpoint='', postfields_dict=None, - formfile=None, filename=None, - put_method=False, patch_method=False, - skip_query_admin=False): + def send_cmd( + self, + endpoint="", + postfields_dict=None, + formfile=None, + filename=None, + put_method=False, + patch_method=False, + skip_query_admin=False, + ): self._logger.debug("") data = BytesIO() curl_cmd = self._get_curl_cmd(endpoint, skip_query_admin) if put_method: curl_cmd.setopt(pycurl.CUSTOMREQUEST, "PUT") @@ -107,36 +115,40 @@ curl_cmd.setopt(pycurl.POST, 1) curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write) if postfields_dict is not None: jsondata = json.dumps(postfields_dict) - if 'password' in postfields_dict: + if "password" in postfields_dict: postfields_dict_copy = copy.deepcopy(postfields_dict) - postfields_dict_copy['password'] = '******' + postfields_dict_copy["password"] = "******" jsondata_log = json.dumps(postfields_dict_copy) else: jsondata_log = jsondata self._logger.verbose("Request POSTFIELDS: {}".format(jsondata_log)) curl_cmd.setopt(pycurl.POSTFIELDS, jsondata) elif formfile is not None: curl_cmd.setopt( - pycurl.HTTPPOST, - [((formfile[0], - (pycurl.FORM_FILE, - formfile[1])))]) + pycurl.HTTPPOST, [((formfile[0], (pycurl.FORM_FILE, formfile[1])))] + ) elif filename is not None: - with open(filename, 'rb') as stream: + with open(filename, "rb") as stream: postdata = stream.read() self._logger.verbose("Request POSTFIELDS: Binary content") curl_cmd.setopt(pycurl.POSTFIELDS, postdata) if put_method: - self._logger.info("Request METHOD: {} URL: {}".format("PUT", self._url + endpoint)) + self._logger.info( + "Request METHOD: {} URL: {}".format("PUT", self._url + endpoint) + ) elif patch_method: - self._logger.info("Request METHOD: {} URL: {}".format("PATCH", self._url + endpoint)) + self._logger.info( + "Request METHOD: {} URL: {}".format("PATCH", self._url + endpoint) + ) else: - self._logger.info("Request METHOD: {} URL: {}".format("POST", self._url + endpoint)) + self._logger.info( + "Request METHOD: {} URL: {}".format("POST", self._url + endpoint) + ) curl_cmd.perform() http_code = curl_cmd.getinfo(pycurl.HTTP_CODE) self._logger.info("Response HTTPCODE: {}".format(http_code)) curl_cmd.close() self.check_http_response(http_code, data) @@ -145,47 +157,76 @@ self._logger.verbose("Response DATA: {}".format(data_text)) return http_code, data_text else: return http_code, None - def post_cmd(self, endpoint='', postfields_dict=None, - formfile=None, filename=None, - skip_query_admin=False): - self._logger.debug("") - return self.send_cmd(endpoint=endpoint, - postfields_dict=postfields_dict, - formfile=formfile, filename=filename, - put_method=False, patch_method=False, - skip_query_admin=skip_query_admin) - - def put_cmd(self, endpoint='', postfields_dict=None, - formfile=None, filename=None, - skip_query_admin=False): - self._logger.debug("") - return self.send_cmd(endpoint=endpoint, - postfields_dict=postfields_dict, - formfile=formfile, filename=filename, - put_method=True, patch_method=False, - skip_query_admin=skip_query_admin) - - def patch_cmd(self, endpoint='', postfields_dict=None, - formfile=None, filename=None, - skip_query_admin=False): - self._logger.debug("") - return self.send_cmd(endpoint=endpoint, - postfields_dict=postfields_dict, - formfile=formfile, filename=filename, - put_method=False, patch_method=True, - skip_query_admin=skip_query_admin) + def post_cmd( + self, + endpoint="", + postfields_dict=None, + formfile=None, + filename=None, + skip_query_admin=False, + ): + self._logger.debug("") + return self.send_cmd( + endpoint=endpoint, + postfields_dict=postfields_dict, + formfile=formfile, + filename=filename, + put_method=False, + patch_method=False, + skip_query_admin=skip_query_admin, + ) + + def put_cmd( + self, + endpoint="", + postfields_dict=None, + formfile=None, + filename=None, + skip_query_admin=False, + ): + self._logger.debug("") + return self.send_cmd( + endpoint=endpoint, + postfields_dict=postfields_dict, + formfile=formfile, + filename=filename, + put_method=True, + patch_method=False, + skip_query_admin=skip_query_admin, + ) + + def patch_cmd( + self, + endpoint="", + postfields_dict=None, + formfile=None, + filename=None, + skip_query_admin=False, + ): + self._logger.debug("") + return self.send_cmd( + endpoint=endpoint, + postfields_dict=postfields_dict, + formfile=formfile, + filename=filename, + put_method=False, + patch_method=True, + skip_query_admin=skip_query_admin, + ) def get2_cmd(self, endpoint, skip_query_admin=False): self._logger.debug("") data = BytesIO() curl_cmd = self._get_curl_cmd(endpoint, skip_query_admin) curl_cmd.setopt(pycurl.HTTPGET, 1) curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write) - self._logger.info("Request METHOD: {} URL: {}".format("GET", self._url + endpoint)) + self._logger.info( + "Request METHOD: {} URL: {}".format("GET", self._url + endpoint) + ) curl_cmd.perform() http_code = curl_cmd.getinfo(pycurl.HTTP_CODE) self._logger.info("Response HTTPCODE: {}".format(http_code)) curl_cmd.close() self.check_http_response(http_code, data) @@ -198,19 +239,21 @@ def check_http_response(self, http_code, data): if http_code >= 300: resp = "" if data.getvalue(): data_text = data.getvalue().decode() - self._logger.verbose("Response {} DATA: {}".format(http_code, data_text)) + self._logger.verbose( + "Response {} DATA: {}".format(http_code, data_text) + ) resp = ": " + data_text else: self._logger.verbose("Response {}".format(http_code)) if http_code == 404: raise NotFound("Error {}{}".format(http_code, resp)) raise OsmHttpException("Error {}{}".format(http_code, resp)) def set_query_admin(self, **kwargs): - if 'all_projects' in kwargs: - self._all_projects = kwargs['all_projects'] - if 'public' in kwargs: - self._public = kwargs['public'] + if "all_projects" in kwargs: + self._all_projects = kwargs["all_projects"] + if "public" in kwargs: + self._public = kwargs["public"] self._default_query_admin = self._complete_default_query_admin() would reformat osmclient/sol005/http.py --- osmclient/sol005/package.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/package.py 2021-12-14 16:49:37.382079 +0000 @@ -16,12 +16,12 @@ """ OSM package API handling """ -#from os import stat -#from os.path import basename +# from os import stat +# from os.path import basename from osmclient.common.exceptions import ClientException from osmclient.common.exceptions import NotFound from osmclient.common import utils import json import logging @@ -30,21 +30,21 @@ class Package(object): def __init__(self, http=None, client=None): self._client = client self._http = http - self._logger = logging.getLogger('osmclient') + self._logger = logging.getLogger("osmclient") def get_key_val_from_pkg(self, descriptor_file): self._logger.debug("") return utils.get_key_val_from_pkg(descriptor_file) def _wait_for_package(self, pkg_type): self._logger.debug("") - if 'vnfd' in pkg_type['type']: + if "vnfd" in pkg_type["type"]: get_method = self._client.vnfd.get - elif 'nsd' in pkg_type['type']: + elif "nsd" in pkg_type["type"]: get_method = self._client.nsd.get else: raise ClientException("no valid package type found") # helper method to check if pkg exists @@ -54,67 +54,70 @@ func() except NotFound: return False return True - return utils.wait_for_value(lambda: - check_exists(lambda: - get_method(pkg_type['name']))) + return utils.wait_for_value( + lambda: check_exists(lambda: get_method(pkg_type["name"])) + ) def wait_for_upload(self, filename): """wait(block) for an upload to succeed. - The filename passed is assumed to be a descriptor tarball. + The filename passed is assumed to be a descriptor tarball. """ self._logger.debug("") self._client.get_token() pkg_type = utils.get_key_val_from_pkg(filename) if pkg_type is None: raise ClientException("Cannot determine package type") if not self._wait_for_package(pkg_type): - raise ClientException("package {} failed to upload" - .format(filename)) + raise ClientException("package {} failed to upload".format(filename)) def upload(self, filename, skip_charm_build=False): self._logger.debug("") if os.path.isdir(filename): - filename = filename.rstrip('/') - filename = self._client.package_tool.build(filename, skip_validation=False, skip_charm_build=skip_charm_build) + filename = filename.rstrip("/") + filename = self._client.package_tool.build( + filename, skip_validation=False, skip_charm_build=skip_charm_build + ) self.upload(filename) else: self._client.get_token() pkg_type = utils.get_key_val_from_pkg(filename) if pkg_type is None: raise ClientException("Cannot determine package type") - if pkg_type['type'] == 'nsd': - endpoint = '/nsd/v1/ns_descriptors_content' + if pkg_type["type"] == "nsd": + endpoint = "/nsd/v1/ns_descriptors_content" else: - endpoint = '/vnfpkgm/v1/vnf_packages_content' - #endpoint = '/nsds' if pkg_type['type'] == 'nsd' else '/vnfds' - #print('Endpoint: {}'.format(endpoint)) + endpoint = "/vnfpkgm/v1/vnf_packages_content" + # endpoint = '/nsds' if pkg_type['type'] == 'nsd' else '/vnfds' + # print('Endpoint: {}'.format(endpoint)) headers = self._client._headers - headers['Content-Type'] = 'application/gzip' - #headers['Content-Type'] = 'application/binary' + headers["Content-Type"] = "application/gzip" + # headers['Content-Type'] = 'application/binary' # Next three lines are to be removed in next version - #headers['Content-Filename'] = basename(filename) - #file_size = stat(filename).st_size - #headers['Content-Range'] = 'bytes 0-{}/{}'.format(file_size - 1, file_size) + # headers['Content-Filename'] = basename(filename) + # file_size = stat(filename).st_size + # headers['Content-Range'] = 'bytes 0-{}/{}'.format(file_size - 1, file_size) headers["Content-File-MD5"] = utils.md5(filename) - http_header = ['{}: {}'.format(key,val) - for (key,val) in list(headers.items())] + http_header = [ + "{}: {}".format(key, val) for (key, val) in list(headers.items()) + ] self._http.set_http_header(http_header) http_code, resp = self._http.post_cmd(endpoint=endpoint, filename=filename) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format( - resp)) - print(resp['id']) + if not resp or "id" not in resp: + raise ClientException( + "unexpected response from server - {}".format(resp) + ) + print(resp["id"]) # else: # msg = "" # if resp: # try: # msg = json.loads(resp) would reformat osmclient/sol005/package.py --- osmclient/sol005/nsd.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/nsd.py 2021-12-14 16:49:37.503486 +0000 @@ -27,54 +27,54 @@ import logging import os.path class Nsd(object): - def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/nsd' - self._apiVersion = '/v1' - self._apiResource = '/ns_descriptors' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/nsd" + self._apiVersion = "/v1" + self._apiResource = "/ns_descriptors" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) def list(self, filter=None): self._logger.debug("") self._client.get_token() - filter_string = '' + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase, filter_string)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) if resp: return json.loads(resp) return list() def get(self, name): self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for nsd in self.list(): - if name == nsd['_id']: + if name == nsd["_id"]: return nsd else: for nsd in self.list(): - if 'name' in nsd and name == nsd['name']: + if "name" in nsd and name == nsd["name"]: return nsd raise NotFound("nsd {} not found".format(name)) def get_individual(self, name): self._logger.debug("") # Call to get_token not required, because will be implicitly called by get. try: nsd = self.get(name) # It is redundant, since the previous one already gets the whole nsdinfo # The only difference is that a different primitive is exercised - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, nsd['_id'])) + _, resp = self._http.get2_cmd("{}/{}".format(self._apiBase, nsd["_id"])) if resp: return json.loads(resp) except NotFound: raise NotFound("nsd '{}' not found".format(name)) raise NotFound("nsd '{}' not found".format(name)) @@ -82,99 +82,117 @@ def get_thing(self, name, thing, filename): self._logger.debug("") # Call to get_token not required, because will be implicitly called by get. nsd = self.get(name) headers = self._client._headers - headers['Accept'] = 'application/binary' - http_code, resp = self._http.get2_cmd('{}/{}/{}'.format(self._apiBase, nsd['_id'], thing)) + headers["Accept"] = "application/binary" + http_code, resp = self._http.get2_cmd( + "{}/{}/{}".format(self._apiBase, nsd["_id"], thing) + ) if resp: return json.loads(resp) else: msg = resp or "" - raise ClientException("failed to get {} from {} - {}".format(thing, name, msg)) + raise ClientException( + "failed to get {} from {} - {}".format(thing, name, msg) + ) def get_descriptor(self, name, filename): self._logger.debug("") - self.get_thing(name, 'nsd', filename) + self.get_thing(name, "nsd", filename) def get_package(self, name, filename): self._logger.debug("") - self.get_thing(name, 'package_content', filename) + self.get_thing(name, "package_content", filename) def get_artifact(self, name, artifact, filename): self._logger.debug("") - self.get_thing(name, 'artifacts/{}'.format(artifact), filename) + self.get_thing(name, "artifacts/{}".format(artifact), filename) def delete(self, name, force=False): self._logger.debug("") nsd = self.get(name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - nsd['_id'], querystring)) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, nsd["_id"], querystring) + ) if http_code == 202: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') + print("Deleted") else: msg = resp or "" raise ClientException("failed to delete nsd {} - {}".format(name, msg)) - def create(self, filename, overwrite=None, update_endpoint=None, skip_charm_build=False): + def create( + self, filename, overwrite=None, update_endpoint=None, skip_charm_build=False + ): self._logger.debug("") if os.path.isdir(filename): - filename = filename.rstrip('/') - filename = self._client.package_tool.build(filename, skip_validation=False, - skip_charm_build=skip_charm_build) + filename = filename.rstrip("/") + filename = self._client.package_tool.build( + filename, skip_validation=False, skip_charm_build=skip_charm_build + ) self.create(filename, overwrite=overwrite, update_endpoint=update_endpoint) else: self._client.get_token() mime_type = magic.from_file(filename, mime=True) if mime_type is None: raise ClientException( "Unexpected MIME type for file {}: MIME type {}".format( - filename, mime_type) + filename, mime_type + ) ) headers = self._client._headers - headers['Content-Filename'] = basename(filename) - if mime_type in ['application/yaml', 'text/plain', 'application/json']: - headers['Content-Type'] = 'text/plain' - elif mime_type in ['application/gzip', 'application/x-gzip']: - headers['Content-Type'] = 'application/gzip' + headers["Content-Filename"] = basename(filename) + if mime_type in ["application/yaml", "text/plain", "application/json"]: + headers["Content-Type"] = "text/plain" + elif mime_type in ["application/gzip", "application/x-gzip"]: + headers["Content-Type"] = "application/gzip" else: raise ClientException( "Unexpected MIME type for file {}: MIME type {}".format( - filename, mime_type) + filename, mime_type + ) ) headers["Content-File-MD5"] = utils.md5(filename) - http_header = ['{}: {}'.format(key, val) - for (key, val) in list(headers.items())] + http_header = [ + "{}: {}".format(key, val) for (key, val) in list(headers.items()) + ] self._http.set_http_header(http_header) if update_endpoint: - http_code, resp = self._http.put_cmd(endpoint=update_endpoint, filename=filename) + http_code, resp = self._http.put_cmd( + endpoint=update_endpoint, filename=filename + ) else: - ow_string = '' + ow_string = "" if overwrite: - ow_string = '?{}'.format(overwrite) - self._apiResource = '/ns_descriptors_content' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) - endpoint = '{}{}'.format(self._apiBase, ow_string) - http_code, resp = self._http.post_cmd(endpoint=endpoint, filename=filename) + ow_string = "?{}".format(overwrite) + self._apiResource = "/ns_descriptors_content" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) + endpoint = "{}{}".format(self._apiBase, ow_string) + http_code, resp = self._http.post_cmd( + endpoint=endpoint, filename=filename + ) if http_code in (200, 201, 202): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format(resp)) - print(resp['id']) + if not resp or "id" not in resp: + raise ClientException( + "unexpected response from server - {}".format(resp) + ) + print(resp["id"]) elif http_code == 204: - print('Updated') + print("Updated") def update(self, name, filename): self._logger.debug("") nsd = self.get(name) - endpoint = '{}/{}/nsd_content'.format(self._apiBase, nsd['_id']) + endpoint = "{}/{}/nsd_content".format(self._apiBase, nsd["_id"]) self.create(filename=filename, update_endpoint=endpoint) would reformat osmclient/sol005/nsd.py --- osmclient/sol005/pdud.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/pdud.py 2021-12-14 16:49:38.400227 +0000 @@ -24,73 +24,74 @@ import json import logging class Pdu(object): - def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/pdu' - self._apiVersion = '/v1' - self._apiResource = '/pdu_descriptors' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/pdu" + self._apiVersion = "/v1" + self._apiResource = "/pdu_descriptors" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) def list(self, filter=None): self._logger.debug("") self._client.get_token() - filter_string = '' + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) if resp: return json.loads(resp) return list() def get(self, name): self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for pdud in self.list(): - if name == pdud['_id']: + if name == pdud["_id"]: return pdud else: for pdud in self.list(): - if 'name' in pdud and name == pdud['name']: + if "name" in pdud and name == pdud["name"]: return pdud raise NotFound("pdud {} not found".format(name)) def get_individual(self, name): self._logger.debug("") pdud = self.get(name) # It is redundant, since the previous one already gets the whole pdudInfo # The only difference is that a different primitive is exercised try: - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, pdud['_id'])) + _, resp = self._http.get2_cmd("{}/{}".format(self._apiBase, pdud["_id"])) except NotFound: raise NotFound("pdu '{}' not found".format(name)) - #print(yaml.safe_dump(resp)) + # print(yaml.safe_dump(resp)) if resp: return json.loads(resp) raise NotFound("pdu '{}' not found".format(name)) def delete(self, name, force=False): self._logger.debug("") pdud = self.get(name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - pdud['_id'], querystring)) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, pdud["_id"], querystring) + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) if http_code == 202: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') + print("Deleted") else: msg = resp or "" # if resp: # try: # msg = json.loads(resp) @@ -99,31 +100,35 @@ raise ClientException("failed to delete pdu {} - {}".format(name, msg)) def create(self, pdu, update_endpoint=None): self._logger.debug("") self._client.get_token() - headers= self._client._headers - headers['Content-Type'] = 'application/yaml' - http_header = ['{}: {}'.format(key,val) - for (key,val) in list(headers.items())] + headers = self._client._headers + headers["Content-Type"] = "application/yaml" + http_header = [ + "{}: {}".format(key, val) for (key, val) in list(headers.items()) + ] self._http.set_http_header(http_header) if update_endpoint: - http_code, resp = self._http.put_cmd(endpoint=update_endpoint, postfields_dict=pdu) + http_code, resp = self._http.put_cmd( + endpoint=update_endpoint, postfields_dict=pdu + ) else: endpoint = self._apiBase - #endpoint = '{}{}'.format(self._apiBase,ow_string) - http_code, resp = self._http.post_cmd(endpoint=endpoint, postfields_dict=pdu) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + # endpoint = '{}{}'.format(self._apiBase,ow_string) + http_code, resp = self._http.post_cmd( + endpoint=endpoint, postfields_dict=pdu + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server: {}'.format( - resp)) - print(resp['id']) - #else: + if not resp or "id" not in resp: + raise ClientException("unexpected response from server: {}".format(resp)) + print(resp["id"]) + # else: # msg = "Error {}".format(http_code) # if resp: # try: # msg = "{} - {}".format(msg, json.loads(resp)) # except ValueError: @@ -131,8 +136,7 @@ # raise ClientException("failed to create/update pdu - {}".format(msg)) def update(self, name, filename): self._logger.debug("") pdud = self.get(name) - endpoint = '{}/{}'.format(self._apiBase, pdud['_id']) + endpoint = "{}/{}".format(self._apiBase, pdud["_id"]) self.create(filename=filename, update_endpoint=endpoint) - would reformat osmclient/sol005/pdud.py --- osmclient/sol005/nsi.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/nsi.py 2021-12-14 16:49:38.448107 +0000 @@ -26,117 +26,127 @@ import json import logging class Nsi(object): - def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/nsilcm' - self._apiVersion = '/v1' - self._apiResource = '/netslice_instances_content' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/nsilcm" + self._apiVersion = "/v1" + self._apiResource = "/netslice_instances_content" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) # NSI '--wait' option def _wait(self, id, wait_time, deleteFlag=False): self._logger.debug("") self._client.get_token() # Endpoint to get operation status - apiUrlStatus = '{}{}{}'.format(self._apiName, self._apiVersion, '/nsi_lcm_op_occs') + apiUrlStatus = "{}{}{}".format( + self._apiName, self._apiVersion, "/nsi_lcm_op_occs" + ) # Wait for status for NSI instance creation/update/deletion if isinstance(wait_time, bool): wait_time = WaitForStatus.TIMEOUT_NSI_OPERATION WaitForStatus.wait_for_status( - 'NSI', + "NSI", str(id), wait_time, apiUrlStatus, self._http.get2_cmd, - deleteFlag=deleteFlag) + deleteFlag=deleteFlag, + ) def list(self, filter=None): - """Returns a list of NSI - """ - self._logger.debug("") - self._client.get_token() - filter_string = '' + """Returns a list of NSI""" + self._logger.debug("") + self._client.get_token() + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) if resp: return json.loads(resp) return list() def get(self, name): - """Returns an NSI based on name or id - """ + """Returns an NSI based on name or id""" self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for nsi in self.list(): - if name == nsi['_id']: + if name == nsi["_id"]: return nsi else: for nsi in self.list(): - if name == nsi['name']: + if name == nsi["name"]: return nsi raise NotFound("nsi {} not found".format(name)) def get_individual(self, name): self._logger.debug("") nsi_id = name self._client.get_token() if not utils.validate_uuid4(name): for nsi in self.list(): - if name == nsi['name']: - nsi_id = nsi['_id'] + if name == nsi["name"]: + nsi_id = nsi["_id"] break try: - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, nsi_id)) - #resp = self._http.get_cmd('{}/{}/nsd_content'.format(self._apiBase, nsi_id)) - #print(yaml.safe_dump(resp)) + _, resp = self._http.get2_cmd("{}/{}".format(self._apiBase, nsi_id)) + # resp = self._http.get_cmd('{}/{}/nsd_content'.format(self._apiBase, nsi_id)) + # print(yaml.safe_dump(resp)) if resp: return json.loads(resp) except NotFound: raise NotFound("nsi '{}' not found".format(name)) raise NotFound("nsi {} not found".format(name)) def delete(self, name, force=False, wait=False): self._logger.debug("") nsi = self.get(name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - nsi['_id'], querystring)) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, nsi["_id"], querystring) + ) # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) if http_code == 202: if wait and resp: resp = json.loads(resp) # Wait for status for NSI instance deletion # For the 'delete' operation, '_id' is used - self._wait(resp.get('_id'), wait, deleteFlag=True) + self._wait(resp.get("_id"), wait, deleteFlag=True) else: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') + print("Deleted") else: msg = resp or "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp raise ClientException("failed to delete nsi {} - {}".format(name, msg)) - def create(self, nst_name, nsi_name, account, config=None, - ssh_keys=None, description='default description', - admin_status='ENABLED', wait=False): + def create( + self, + nst_name, + nsi_name, + account, + config=None, + ssh_keys=None, + description="default description", + admin_status="ENABLED", + wait=False, + ): self._logger.debug("") self._client.get_token() nst = self._client.nst.get(nst_name) @@ -148,221 +158,251 @@ return vim_account_id[vim_account] vim = self._client.vim.get(vim_account) if vim is None: raise NotFound("cannot find vim account '{}'".format(vim_account)) - vim_account_id[vim_account] = vim['_id'] - return vim['_id'] + vim_account_id[vim_account] = vim["_id"] + return vim["_id"] nsi = {} - nsi['nstId'] = nst['_id'] - nsi['nsiName'] = nsi_name - nsi['nsiDescription'] = description - nsi['vimAccountId'] = get_vim_account_id(account) - #nsi['userdata'] = {} - #nsi['userdata']['key1']='value1' - #nsi['userdata']['key2']='value2' + nsi["nstId"] = nst["_id"] + nsi["nsiName"] = nsi_name + nsi["nsiDescription"] = description + nsi["vimAccountId"] = get_vim_account_id(account) + # nsi['userdata'] = {} + # nsi['userdata']['key1']='value1' + # nsi['userdata']['key2']='value2' if ssh_keys is not None: # ssh_keys is comma separate list # ssh_keys_format = [] # for key in ssh_keys.split(','): # ssh_keys_format.append({'key-pair-ref': key}) # # ns['ssh-authorized-key'] = ssh_keys_format - nsi['ssh_keys'] = [] - for pubkeyfile in ssh_keys.split(','): - with open(pubkeyfile, 'r') as f: - nsi['ssh_keys'].append(f.read()) + nsi["ssh_keys"] = [] + for pubkeyfile in ssh_keys.split(","): + with open(pubkeyfile, "r") as f: + nsi["ssh_keys"].append(f.read()) if config: nsi_config = yaml.safe_load(config) if "netslice-vld" in nsi_config: for vld in nsi_config["netslice-vld"]: if vld.get("vim-network-name"): if isinstance(vld["vim-network-name"], dict): vim_network_name_dict = {} - for vim_account, vim_net in list(vld["vim-network-name"].items()): - vim_network_name_dict[get_vim_account_id(vim_account)] = vim_net + for vim_account, vim_net in list( + vld["vim-network-name"].items() + ): + vim_network_name_dict[ + get_vim_account_id(vim_account) + ] = vim_net vld["vim-network-name"] = vim_network_name_dict nsi["netslice-vld"] = nsi_config["netslice-vld"] if "netslice-subnet" in nsi_config: for nssubnet in nsi_config["netslice-subnet"]: if "vld" in nssubnet: for vld in nssubnet["vld"]: if vld.get("vim-network-name"): if isinstance(vld["vim-network-name"], dict): vim_network_name_dict = {} - for vim_account, vim_net in list(vld["vim-network-name"].items()): - vim_network_name_dict[get_vim_account_id(vim_account)] = vim_net + for vim_account, vim_net in list( + vld["vim-network-name"].items() + ): + vim_network_name_dict[ + get_vim_account_id(vim_account) + ] = vim_net vld["vim-network-name"] = vim_network_name_dict if "vnf" in nssubnet: for vnf in nssubnet["vnf"]: if vnf.get("vim_account"): - vnf["vimAccountId"] = get_vim_account_id(vnf.pop("vim_account")) + vnf["vimAccountId"] = get_vim_account_id( + vnf.pop("vim_account") + ) nsi["netslice-subnet"] = nsi_config["netslice-subnet"] if "additionalParamsForNsi" in nsi_config: nsi["additionalParamsForNsi"] = nsi_config.pop("additionalParamsForNsi") if not isinstance(nsi["additionalParamsForNsi"], dict): - raise ValueError("Error at --config 'additionalParamsForNsi' must be a dictionary") + raise ValueError( + "Error at --config 'additionalParamsForNsi' must be a dictionary" + ) if "additionalParamsForSubnet" in nsi_config: - nsi["additionalParamsForSubnet"] = nsi_config.pop("additionalParamsForSubnet") + nsi["additionalParamsForSubnet"] = nsi_config.pop( + "additionalParamsForSubnet" + ) if not isinstance(nsi["additionalParamsForSubnet"], list): - raise ValueError("Error at --config 'additionalParamsForSubnet' must be a list") + raise ValueError( + "Error at --config 'additionalParamsForSubnet' must be a list" + ) for additional_param_subnet in nsi["additionalParamsForSubnet"]: if not isinstance(additional_param_subnet, dict): - raise ValueError("Error at --config 'additionalParamsForSubnet' items must be dictionaries") + raise ValueError( + "Error at --config 'additionalParamsForSubnet' items must be dictionaries" + ) if not additional_param_subnet.get("id"): - raise ValueError("Error at --config 'additionalParamsForSubnet' items must contain subnet 'id'") - if not additional_param_subnet.get("additionalParamsForNs") and\ - not additional_param_subnet.get("additionalParamsForVnf"): - raise ValueError("Error at --config 'additionalParamsForSubnet' items must contain " - "'additionalParamsForNs' and/or 'additionalParamsForVnf'") + raise ValueError( + "Error at --config 'additionalParamsForSubnet' items must contain subnet 'id'" + ) + if not additional_param_subnet.get( + "additionalParamsForNs" + ) and not additional_param_subnet.get("additionalParamsForVnf"): + raise ValueError( + "Error at --config 'additionalParamsForSubnet' items must contain " + "'additionalParamsForNs' and/or 'additionalParamsForVnf'" + ) if "timeout_nsi_deploy" in nsi_config: nsi["timeout_nsi_deploy"] = nsi_config.pop("timeout_nsi_deploy") # print(yaml.safe_dump(nsi)) try: - self._apiResource = '/netslice_instances_content' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._apiResource = "/netslice_instances_content" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) headers = self._client._headers - headers['Content-Type'] = 'application/yaml' - http_header = ['{}: {}'.format(key,val) - for (key,val) in list(headers.items())] + headers["Content-Type"] = "application/yaml" + http_header = [ + "{}: {}".format(key, val) for (key, val) in list(headers.items()) + ] self._http.set_http_header(http_header) - http_code, resp = self._http.post_cmd(endpoint=self._apiBase, - postfields_dict=nsi) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + http_code, resp = self._http.post_cmd( + endpoint=self._apiBase, postfields_dict=nsi + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {} '.format( - resp)) + if not resp or "id" not in resp: + raise ClientException( + "unexpected response from server - {} ".format(resp) + ) if wait: # Wait for status for NSI instance creation - self._wait(resp.get('nsilcmop_id'), wait) - print(resp['id']) - #else: + self._wait(resp.get("nsilcmop_id"), wait) + print(resp["id"]) + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException(msg) except ClientException as exc: - message="failed to create nsi: {} nst: {}\nerror:\n{}".format( - nsi_name, - nst_name, - str(exc)) + message = "failed to create nsi: {} nst: {}\nerror:\n{}".format( + nsi_name, nst_name, str(exc) + ) raise ClientException(message) def list_op(self, name, filter=None): - """Returns the list of operations of a NSI - """ + """Returns the list of operations of a NSI""" self._logger.debug("") nsi = self.get(name) try: - self._apiResource = '/nsi_lcm_op_occs' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) - filter_string = '' + self._apiResource = "/nsi_lcm_op_occs" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) + filter_string = "" if filter: - filter_string = '&{}'.format(filter) - http_code, resp = self._http.get2_cmd('{}?netsliceInstanceId={}{}'.format( - self._apiBase, nsi['_id'], - filter_string) ) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code == 200: + filter_string = "&{}".format(filter) + http_code, resp = self._http.get2_cmd( + "{}?netsliceInstanceId={}{}".format( + self._apiBase, nsi["_id"], filter_string + ) + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code == 200: if resp: resp = json.loads(resp) return resp else: - raise ClientException('unexpected response from server') - #else: + raise ClientException("unexpected response from server") + # else: # msg = "" # if resp: # try: # resp = json.loads(resp) # msg = resp['detail'] # except ValueError: # msg = resp # raise ClientException(msg) except ClientException as exc: - message="failed to get operation list of NSI {}:\nerror:\n{}".format( - name, - str(exc)) + message = "failed to get operation list of NSI {}:\nerror:\n{}".format( + name, str(exc) + ) raise ClientException(message) def get_op(self, operationId): - """Returns the status of an operation - """ + """Returns the status of an operation""" self._logger.debug("") self._client.get_token() try: - self._apiResource = '/nsi_lcm_op_occs' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) - http_code, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, operationId)) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code == 200: + self._apiResource = "/nsi_lcm_op_occs" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) + http_code, resp = self._http.get2_cmd( + "{}/{}".format(self._apiBase, operationId) + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code == 200: if resp: resp = json.loads(resp) return resp else: - raise ClientException('unexpected response from server') - #else: + raise ClientException("unexpected response from server") + # else: # msg = "" # if resp: # try: # resp = json.loads(resp) # msg = resp['detail'] # except ValueError: # msg = resp # raise ClientException(msg) except ClientException as exc: - message="failed to get status of operation {}:\nerror:\n{}".format( - operationId, - str(exc)) + message = "failed to get status of operation {}:\nerror:\n{}".format( + operationId, str(exc) + ) raise ClientException(message) def exec_op(self, name, op_name, op_data=None): - """Executes an operation on a NSI - """ + """Executes an operation on a NSI""" self._logger.debug("") nsi = self.get(name) try: - self._apiResource = '/netslice_instances' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) - endpoint = '{}/{}/{}'.format(self._apiBase, nsi['_id'], op_name) - #print('OP_NAME: {}'.format(op_name)) - #print('OP_DATA: {}'.format(json.dumps(op_data))) - http_code, resp = self._http.post_cmd(endpoint=endpoint, postfields_dict=op_data) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + self._apiResource = "/netslice_instances" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) + endpoint = "{}/{}/{}".format(self._apiBase, nsi["_id"], op_name) + # print('OP_NAME: {}'.format(op_name)) + # print('OP_DATA: {}'.format(json.dumps(op_data))) + http_code, resp = self._http.post_cmd( + endpoint=endpoint, postfields_dict=op_data + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format( - resp)) - print(resp['id']) - #else: + if not resp or "id" not in resp: + raise ClientException( + "unexpected response from server - {}".format(resp) + ) + print(resp["id"]) + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException(msg) except ClientException as exc: - message="failed to exec operation {}:\nerror:\n{}".format( - name, - str(exc)) + message = "failed to exec operation {}:\nerror:\n{}".format(name, str(exc)) raise ClientException(message) - would reformat osmclient/sol005/nsi.py --- osmclient/sol005/repo.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/repo.py 2021-12-14 16:49:38.736442 +0000 @@ -19,34 +19,36 @@ from osmclient.common import utils from osmclient.common.exceptions import ClientException from osmclient.common.exceptions import NotFound import json + class Repo(object): def __init__(self, http=None, client=None): self._http = http self._client = client - self._apiName = '/admin' - self._apiVersion = '/v1' - self._apiResource = '/k8srepos' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._apiName = "/admin" + self._apiVersion = "/v1" + self._apiResource = "/k8srepos" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) def create(self, name, repo): self._client.get_token() - http_code, resp = self._http.post_cmd(endpoint=self._apiBase, - postfields_dict=repo) - #print 'HTTP CODE: {}'.format(http_code) - #print 'RESP: {}'.format(resp) - #if http_code in (200, 201, 202, 204): + http_code, resp = self._http.post_cmd( + endpoint=self._apiBase, postfields_dict=repo + ) + # print 'HTTP CODE: {}'.format(http_code) + # print 'RESP: {}'.format(resp) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format( - resp)) - print(resp['id']) - #else: + if not resp or "id" not in resp: + raise ClientException("unexpected response from server - {}".format(resp)) + print(resp["id"]) + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: @@ -54,83 +56,82 @@ # raise ClientException("failed to add repo {} - {}".format(name, msg)) def update(self, name, repo): self._client.get_token() repo_dict = self.get(name) - http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,repo_dict['_id']), - postfields_dict=repo) + http_code, resp = self._http.put_cmd( + endpoint="{}/{}".format(self._apiBase, repo_dict["_id"]), + postfields_dict=repo, + ) # print 'HTTP CODE: {}'.format(http_code) # print 'RESP: {}'.format(resp) - #if http_code in (200, 201, 202, 204): + # if http_code in (200, 201, 202, 204): # pass - #else: + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException("failed to update repo {} - {}".format(name, msg)) def get_id(self, name): - """Returns a repo id from a repo name - """ + """Returns a repo id from a repo name""" self._client.get_token() for repo in self.list(): - if name == repo['name']: - return repo['_id'] + if name == repo["name"]: + return repo["_id"] raise NotFound("Repo {} not found".format(name)) def delete(self, name, force=False): self._client.get_token() repo_id = name if not utils.validate_uuid4(name): repo_id = self.get_id(name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - repo_id, querystring)) - #print 'HTTP CODE: {}'.format(http_code) - #print 'RESP: {}'.format(resp) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, repo_id, querystring) + ) + # print 'HTTP CODE: {}'.format(http_code) + # print 'RESP: {}'.format(resp) if http_code == 202: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') + print("Deleted") else: msg = resp or "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp raise ClientException("failed to delete repo {} - {}".format(name, msg)) def list(self, filter=None): - """Returns a list of repos - """ + """Returns a list of repos""" self._client.get_token() - filter_string = '' + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) if resp: return json.loads(resp) return list() def get(self, name): - """Returns a repo based on name or id - """ + """Returns a repo based on name or id""" self._client.get_token() repo_id = name if not utils.validate_uuid4(name): repo_id = self.get_id(name) try: - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase,repo_id)) + _, resp = self._http.get2_cmd("{}/{}".format(self._apiBase, repo_id)) if resp: resp = json.loads(resp) - if not resp or '_id' not in resp: - raise ClientException('failed to get repo info: {}'.format(resp)) + if not resp or "_id" not in resp: + raise ClientException("failed to get repo info: {}".format(resp)) return resp except NotFound: raise NotFound("Repo {} not found".format(name)) - would reformat osmclient/sol005/repo.py --- osmclient/sol005/ns.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/ns.py 2021-12-14 16:49:39.221535 +0000 @@ -26,78 +26,79 @@ import json import logging class Ns(object): - def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/nslcm' - self._apiVersion = '/v1' - self._apiResource = '/ns_instances_content' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/nslcm" + self._apiVersion = "/v1" + self._apiResource = "/ns_instances_content" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) # NS '--wait' option def _wait(self, id, wait_time, deleteFlag=False): self._logger.debug("") # Endpoint to get operation status - apiUrlStatus = '{}{}{}'.format(self._apiName, self._apiVersion, '/ns_lcm_op_occs') + apiUrlStatus = "{}{}{}".format( + self._apiName, self._apiVersion, "/ns_lcm_op_occs" + ) # Wait for status for NS instance creation/update/deletion if isinstance(wait_time, bool): wait_time = WaitForStatus.TIMEOUT_NS_OPERATION WaitForStatus.wait_for_status( - 'NS', + "NS", str(id), wait_time, apiUrlStatus, self._http.get2_cmd, - deleteFlag=deleteFlag) + deleteFlag=deleteFlag, + ) def list(self, filter=None): - """Returns a list of NS - """ - self._logger.debug("") - self._client.get_token() - filter_string = '' + """Returns a list of NS""" + self._logger.debug("") + self._client.get_token() + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) if resp: return json.loads(resp) return list() def get(self, name): - """Returns an NS based on name or id - """ + """Returns an NS based on name or id""" self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for ns in self.list(): - if name == ns['_id']: + if name == ns["_id"]: return ns else: for ns in self.list(): - if name == ns['name']: + if name == ns["name"]: return ns raise NotFound("ns '{}' not found".format(name)) def get_individual(self, name): self._logger.debug("") self._client.get_token() ns_id = name if not utils.validate_uuid4(name): for ns in self.list(): - if name == ns['name']: - ns_id = ns['_id'] + if name == ns["name"]: + ns_id = ns["_id"] break try: - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, ns_id)) - #resp = self._http.get_cmd('{}/{}/nsd_content'.format(self._apiBase, ns_id)) - #print(yaml.safe_dump(resp)) + _, resp = self._http.get2_cmd("{}/{}".format(self._apiBase, ns_id)) + # resp = self._http.get_cmd('{}/{}/nsd_content'.format(self._apiBase, ns_id)) + # print(yaml.safe_dump(resp)) if resp: return json.loads(resp) except NotFound: raise NotFound("ns '{}' not found".format(name)) raise NotFound("ns '{}' not found".format(name)) @@ -116,46 +117,55 @@ :return: None. Exception if fail """ self._logger.debug("") ns = self.get(name) querystring_list = [] - querystring = '' + querystring = "" if config: ns_config = yaml.safe_load(config) querystring_list += ["{}={}".format(k, v) for k, v in ns_config.items()] if force: - querystring_list.append('FORCE=True') + querystring_list.append("FORCE=True") if querystring_list: querystring = "?" + "&".join(querystring_list) - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - ns['_id'], querystring)) + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, ns["_id"], querystring) + ) # TODO change to use a POST self._http.post_cmd('{}/{}/terminate{}'.format(_apiBase, ns['_id'], querystring), # postfields_dict=ns_config) # seting autoremove as True by default # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) if http_code == 202: if wait and resp: resp = json.loads(resp) # For the 'delete' operation, '_id' is used - self._wait(resp.get('_id'), wait, deleteFlag=True) + self._wait(resp.get("_id"), wait, deleteFlag=True) else: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') + print("Deleted") else: msg = resp or "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp raise ClientException("failed to delete ns {} - {}".format(name, msg)) - def create(self, nsd_name, nsr_name, account, config=None, - ssh_keys=None, description='default description', - admin_status='ENABLED', wait=False): + def create( + self, + nsd_name, + nsr_name, + account, + config=None, + ssh_keys=None, + description="default description", + admin_status="ENABLED", + wait=False, + ): self._logger.debug("") self._client.get_token() nsd = self._client.nsd.get(nsd_name) vim_account_id = {} @@ -166,12 +176,12 @@ if vim_account_id.get(vim_account): return vim_account_id[vim_account] vim = self._client.vim.get(vim_account) if vim is None: raise NotFound("cannot find vim account '{}'".format(vim_account)) - vim_account_id[vim_account] = vim['_id'] - return vim['_id'] + vim_account_id[vim_account] = vim["_id"] + return vim["_id"] def get_wim_account_id(wim_account): self._logger.debug("") # wim_account can be False (boolean) to indicate not use wim account if not isinstance(wim_account, str): @@ -179,230 +189,264 @@ if wim_account_id.get(wim_account): return wim_account_id[wim_account] wim = self._client.wim.get(wim_account) if wim is None: raise NotFound("cannot find wim account '{}'".format(wim_account)) - wim_account_id[wim_account] = wim['_id'] - return wim['_id'] + wim_account_id[wim_account] = wim["_id"] + return wim["_id"] ns = {} - ns['nsdId'] = nsd['_id'] - ns['nsName'] = nsr_name - ns['nsDescription'] = description - ns['vimAccountId'] = get_vim_account_id(account) - #ns['userdata'] = {} - #ns['userdata']['key1']='value1' - #ns['userdata']['key2']='value2' + ns["nsdId"] = nsd["_id"] + ns["nsName"] = nsr_name + ns["nsDescription"] = description + ns["vimAccountId"] = get_vim_account_id(account) + # ns['userdata'] = {} + # ns['userdata']['key1']='value1' + # ns['userdata']['key2']='value2' if ssh_keys is not None: - ns['ssh_keys'] = [] - for pubkeyfile in ssh_keys.split(','): - with open(pubkeyfile, 'r') as f: - ns['ssh_keys'].append(f.read()) + ns["ssh_keys"] = [] + for pubkeyfile in ssh_keys.split(","): + with open(pubkeyfile, "r") as f: + ns["ssh_keys"].append(f.read()) if config: ns_config = yaml.safe_load(config) if "vim-network-name" in ns_config: ns_config["vld"] = ns_config.pop("vim-network-name") if "vld" in ns_config: if not isinstance(ns_config["vld"], list): - raise ClientException("Error at --config 'vld' must be a list of dictionaries") + raise ClientException( + "Error at --config 'vld' must be a list of dictionaries" + ) for vld in ns_config["vld"]: if not isinstance(vld, dict): - raise ClientException("Error at --config 'vld' must be a list of dictionaries") + raise ClientException( + "Error at --config 'vld' must be a list of dictionaries" + ) if vld.get("vim-network-name"): if isinstance(vld["vim-network-name"], dict): vim_network_name_dict = {} for vim_account, vim_net in vld["vim-network-name"].items(): - vim_network_name_dict[get_vim_account_id(vim_account)] = vim_net + vim_network_name_dict[ + get_vim_account_id(vim_account) + ] = vim_net vld["vim-network-name"] = vim_network_name_dict if "wim_account" in vld and vld["wim_account"] is not None: vld["wimAccountId"] = get_wim_account_id(vld.pop("wim_account")) if "vnf" in ns_config: for vnf in ns_config["vnf"]: if vnf.get("vim_account"): vnf["vimAccountId"] = get_vim_account_id(vnf.pop("vim_account")) if "additionalParamsForNs" in ns_config: if not isinstance(ns_config["additionalParamsForNs"], dict): - raise ClientException("Error at --config 'additionalParamsForNs' must be a dictionary") + raise ClientException( + "Error at --config 'additionalParamsForNs' must be a dictionary" + ) if "additionalParamsForVnf" in ns_config: if not isinstance(ns_config["additionalParamsForVnf"], list): - raise ClientException("Error at --config 'additionalParamsForVnf' must be a list") + raise ClientException( + "Error at --config 'additionalParamsForVnf' must be a list" + ) for additional_param_vnf in ns_config["additionalParamsForVnf"]: if not isinstance(additional_param_vnf, dict): - raise ClientException("Error at --config 'additionalParamsForVnf' items must be dictionaries") + raise ClientException( + "Error at --config 'additionalParamsForVnf' items must be dictionaries" + ) if not additional_param_vnf.get("member-vnf-index"): - raise ClientException("Error at --config 'additionalParamsForVnf' items must contain " - "'member-vnf-index'") + raise ClientException( + "Error at --config 'additionalParamsForVnf' items must contain " + "'member-vnf-index'" + ) if "wim_account" in ns_config: wim_account = ns_config.pop("wim_account") if wim_account is not None: - ns['wimAccountId'] = get_wim_account_id(wim_account) + ns["wimAccountId"] = get_wim_account_id(wim_account) # rest of parameters without any transformation or checking # "timeout_ns_deploy" # "placement-engine" ns.update(ns_config) # print(yaml.safe_dump(ns)) try: - self._apiResource = '/ns_instances_content' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._apiResource = "/ns_instances_content" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) headers = self._client._headers - headers['Content-Type'] = 'application/yaml' - http_header = ['{}: {}'.format(key,val) - for (key,val) in list(headers.items())] + headers["Content-Type"] = "application/yaml" + http_header = [ + "{}: {}".format(key, val) for (key, val) in list(headers.items()) + ] self._http.set_http_header(http_header) - http_code, resp = self._http.post_cmd(endpoint=self._apiBase, - postfields_dict=ns) - # print('HTTP CODE: {}'.format(http_code)) - # print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + http_code, resp = self._http.post_cmd( + endpoint=self._apiBase, postfields_dict=ns + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {} '.format( - resp)) + if not resp or "id" not in resp: + raise ClientException( + "unexpected response from server - {} ".format(resp) + ) if wait: # Wait for status for NS instance creation - self._wait(resp.get('nslcmop_id'), wait) - print(resp['id']) - return resp['id'] - #else: + self._wait(resp.get("nslcmop_id"), wait) + print(resp["id"]) + return resp["id"] + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException(msg) except ClientException as exc: - message="failed to create ns: {} nsd: {}\nerror:\n{}".format( - nsr_name, - nsd_name, - str(exc)) + message = "failed to create ns: {} nsd: {}\nerror:\n{}".format( + nsr_name, nsd_name, str(exc) + ) raise ClientException(message) def list_op(self, name, filter=None): - """Returns the list of operations of a NS - """ + """Returns the list of operations of a NS""" self._logger.debug("") ns = self.get(name) try: - self._apiResource = '/ns_lcm_op_occs' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) - filter_string = '' + self._apiResource = "/ns_lcm_op_occs" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) + filter_string = "" if filter: - filter_string = '&{}'.format(filter) - http_code, resp = self._http.get2_cmd('{}?nsInstanceId={}{}'.format( - self._apiBase, ns['_id'], - filter_string) ) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) + filter_string = "&{}".format(filter) + http_code, resp = self._http.get2_cmd( + "{}?nsInstanceId={}{}".format(self._apiBase, ns["_id"], filter_string) + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) if http_code == 200: if resp: resp = json.loads(resp) return resp else: - raise ClientException('unexpected response from server') + raise ClientException("unexpected response from server") else: msg = resp or "" - # if resp: - # try: - # resp = json.loads(resp) - # msg = resp['detail'] - # except ValueError: - # msg = resp + # if resp: + # try: + # resp = json.loads(resp) + # msg = resp['detail'] + # except ValueError: + # msg = resp raise ClientException(msg) except ClientException as exc: - message="failed to get operation list of NS {}:\nerror:\n{}".format( - name, - str(exc)) + message = "failed to get operation list of NS {}:\nerror:\n{}".format( + name, str(exc) + ) raise ClientException(message) def get_op(self, operationId): - """Returns the status of an operation - """ - self._logger.debug("") - self._client.get_token() - try: - self._apiResource = '/ns_lcm_op_occs' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) - http_code, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, operationId)) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) + """Returns the status of an operation""" + self._logger.debug("") + self._client.get_token() + try: + self._apiResource = "/ns_lcm_op_occs" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) + http_code, resp = self._http.get2_cmd( + "{}/{}".format(self._apiBase, operationId) + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) if http_code == 200: if resp: resp = json.loads(resp) return resp else: - raise ClientException('unexpected response from server') + raise ClientException("unexpected response from server") else: msg = resp or "" - # if resp: - # try: - # resp = json.loads(resp) - # msg = resp['detail'] - # except ValueError: - # msg = resp + # if resp: + # try: + # resp = json.loads(resp) + # msg = resp['detail'] + # except ValueError: + # msg = resp raise ClientException(msg) except ClientException as exc: - message="failed to get status of operation {}:\nerror:\n{}".format( - operationId, - str(exc)) - raise ClientException(message) - - def exec_op(self, name, op_name, op_data=None, wait=False, ): - """Executes an operation on a NS - """ + message = "failed to get status of operation {}:\nerror:\n{}".format( + operationId, str(exc) + ) + raise ClientException(message) + + def exec_op( + self, + name, + op_name, + op_data=None, + wait=False, + ): + """Executes an operation on a NS""" self._logger.debug("") ns = self.get(name) try: ns = self.get(name) - self._apiResource = '/ns_instances' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) - endpoint = '{}/{}/{}'.format(self._apiBase, ns['_id'], op_name) - #print('OP_NAME: {}'.format(op_name)) - #print('OP_DATA: {}'.format(json.dumps(op_data))) - http_code, resp = self._http.post_cmd(endpoint=endpoint, postfields_dict=op_data) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + self._apiResource = "/ns_instances" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) + endpoint = "{}/{}/{}".format(self._apiBase, ns["_id"], op_name) + # print('OP_NAME: {}'.format(op_name)) + # print('OP_DATA: {}'.format(json.dumps(op_data))) + http_code, resp = self._http.post_cmd( + endpoint=endpoint, postfields_dict=op_data + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format( - resp)) + if not resp or "id" not in resp: + raise ClientException( + "unexpected response from server - {}".format(resp) + ) if wait: # Wait for status for NS instance action # For the 'action' operation, 'id' is used - self._wait(resp.get('id'), wait) - return resp['id'] - #else: + self._wait(resp.get("id"), wait) + return resp["id"] + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException(msg) except ClientException as exc: - message="failed to exec operation {}:\nerror:\n{}".format( - name, - str(exc)) - raise ClientException(message) - - def scale_vnf(self, ns_name, vnf_name, scaling_group, scale_in, scale_out, wait=False, timeout=None): - """Scales a VNF by adding/removing VDUs - """ - self._logger.debug("") - self._client.get_token() - try: - op_data={} + message = "failed to exec operation {}:\nerror:\n{}".format(name, str(exc)) + raise ClientException(message) + + def scale_vnf( + self, + ns_name, + vnf_name, + scaling_group, + scale_in, + scale_out, + wait=False, + timeout=None, + ): + """Scales a VNF by adding/removing VDUs""" + self._logger.debug("") + self._client.get_token() + try: + op_data = {} op_data["scaleType"] = "SCALE_VNF" op_data["scaleVnfData"] = {} if scale_in and not scale_out: op_data["scaleVnfData"]["scaleVnfType"] = "SCALE_IN" elif not scale_in and scale_out: @@ -413,102 +457,100 @@ "member-vnf-index": vnf_name, "scaling-group-descriptor": scaling_group, } if timeout: op_data["timeout_ns_scale"] = timeout - op_id = self.exec_op(ns_name, op_name='scale', op_data=op_data, wait=wait) + op_id = self.exec_op(ns_name, op_name="scale", op_data=op_data, wait=wait) print(str(op_id)) except ClientException as exc: - message="failed to scale vnf {} of ns {}:\nerror:\n{}".format( - vnf_name, ns_name, str(exc)) + message = "failed to scale vnf {} of ns {}:\nerror:\n{}".format( + vnf_name, ns_name, str(exc) + ) raise ClientException(message) def create_alarm(self, alarm): self._logger.debug("") self._client.get_token() data = {} data["create_alarm_request"] = {} data["create_alarm_request"]["alarm_create_request"] = alarm try: - http_code, resp = self._http.post_cmd(endpoint='/test/message/alarm_request', - postfields_dict=data) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) + http_code, resp = self._http.post_cmd( + endpoint="/test/message/alarm_request", postfields_dict=data + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) # if http_code in (200, 201, 202, 204): # resp = json.loads(resp) - print('Alarm created') - #else: + print("Alarm created") + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException('error: code: {}, resp: {}'.format( # http_code, msg)) except ClientException as exc: - message="failed to create alarm: alarm {}\n{}".format( - alarm, - str(exc)) + message = "failed to create alarm: alarm {}\n{}".format(alarm, str(exc)) raise ClientException(message) def delete_alarm(self, name): self._logger.debug("") self._client.get_token() data = {} data["delete_alarm_request"] = {} data["delete_alarm_request"]["alarm_delete_request"] = {} data["delete_alarm_request"]["alarm_delete_request"]["alarm_uuid"] = name try: - http_code, resp = self._http.post_cmd(endpoint='/test/message/alarm_request', - postfields_dict=data) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) + http_code, resp = self._http.post_cmd( + endpoint="/test/message/alarm_request", postfields_dict=data + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) # if http_code in (200, 201, 202, 204): # resp = json.loads(resp) - print('Alarm deleted') - #else: + print("Alarm deleted") + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException('error: code: {}, resp: {}'.format( # http_code, msg)) except ClientException as exc: - message="failed to delete alarm: alarm {}\n{}".format( - name, - str(exc)) + message = "failed to delete alarm: alarm {}\n{}".format(name, str(exc)) raise ClientException(message) def export_metric(self, metric): self._logger.debug("") self._client.get_token() data = {} data["read_metric_data_request"] = metric try: - http_code, resp = self._http.post_cmd(endpoint='/test/message/metric_request', - postfields_dict=data) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) + http_code, resp = self._http.post_cmd( + endpoint="/test/message/metric_request", postfields_dict=data + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) # if http_code in (200, 201, 202, 204): # resp = json.loads(resp) - return 'Metric exported' - #else: + return "Metric exported" + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException('error: code: {}, resp: {}'.format( # http_code, msg)) except ClientException as exc: - message="failed to export metric: metric {}\n{}".format( - metric, - str(exc)) + message = "failed to export metric: metric {}\n{}".format(metric, str(exc)) raise ClientException(message) def get_field(self, ns_name, field): self._logger.debug("") nsr = self.get(ns_name) @@ -518,6 +560,5 @@ if field in nsr: return nsr[field] raise NotFound("failed to find {} in ns {}".format(field, ns_name)) - would reformat osmclient/sol005/ns.py --- osmclient/sol005/project.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/project.py 2021-12-14 16:49:39.320445 +0000 @@ -28,126 +28,125 @@ class Project(object): def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/admin' - self._apiVersion = '/v1' - self._apiResource = '/projects' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/admin" + self._apiVersion = "/v1" + self._apiResource = "/projects" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) def create(self, name, project): - """Creates a new OSM project - """ + """Creates a new OSM project""" self._logger.debug("") self._client.get_token() - http_code, resp = self._http.post_cmd(endpoint=self._apiBase, - postfields_dict=project, - skip_query_admin=True) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + http_code, resp = self._http.post_cmd( + endpoint=self._apiBase, postfields_dict=project, skip_query_admin=True + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format( - resp)) - print(resp['id']) - #else: + if not resp or "id" not in resp: + raise ClientException("unexpected response from server - {}".format(resp)) + print(resp["id"]) + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException("failed to create project {} - {}".format(name, msg)) def update(self, project, project_changes): - """Updates an OSM project identified by name - """ + """Updates an OSM project identified by name""" self._logger.debug("") self._client.get_token() proj = self.get(project) - http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase, proj['_id']), - postfields_dict=project_changes, - skip_query_admin=True) + http_code, resp = self._http.patch_cmd( + endpoint="{}/{}".format(self._apiBase, proj["_id"]), + postfields_dict=project_changes, + skip_query_admin=True, + ) # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) if http_code in (200, 201, 202): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format( - resp)) - print(resp['id']) + if not resp or "id" not in resp: + raise ClientException( + "unexpected response from server - {}".format(resp) + ) + print(resp["id"]) elif http_code == 204: print("Updated") - #else: + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException("failed to update project {} - {}".format(project, msg)) def delete(self, name, force=False): - """Deletes an OSM project identified by name - """ + """Deletes an OSM project identified by name""" self._logger.debug("") self._client.get_token() project = self.get(name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - project['_id'], querystring), - skip_query_admin=True) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, project["_id"], querystring), + skip_query_admin=True, + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) if http_code == 202: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') - elif resp and 'result' in resp: - print('Deleted') + print("Deleted") + elif resp and "result" in resp: + print("Deleted") else: msg = resp or "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp raise ClientException("failed to delete project {} - {}".format(name, msg)) def list(self, filter=None): - """Returns the list of OSM projects - """ + """Returns the list of OSM projects""" self._logger.debug("") self._client.get_token() - filter_string = '' + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string), - skip_query_admin=True) - #print('RESP: {}'.format(resp)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd( + "{}{}".format(self._apiBase, filter_string), skip_query_admin=True + ) + # print('RESP: {}'.format(resp)) if resp: return json.loads(resp) return list() def get(self, name): - """Returns a specific OSM project based on name or id - """ + """Returns a specific OSM project based on name or id""" self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for proj in self.list(): - if name == proj['_id']: + if name == proj["_id"]: return proj else: for proj in self.list(): - if name == proj['name']: + if name == proj["name"]: return proj raise NotFound("Project {} not found".format(name)) - would reformat osmclient/sol005/project.py --- osmclient/sol005/sdncontroller.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/sdncontroller.py 2021-12-14 16:49:40.569398 +0000 @@ -29,95 +29,98 @@ class SdnController(object): def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/admin' - self._apiVersion = '/v1' - self._apiResource = '/sdns' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/admin" + self._apiVersion = "/v1" + self._apiResource = "/sdns" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) # SDNC '--wait' option def _wait(self, id, wait_time, deleteFlag=False): self._logger.debug("") self._client.get_token() # Endpoint to get operation status - apiUrlStatus = '{}{}{}'.format(self._apiName, self._apiVersion, '/sdns') + apiUrlStatus = "{}{}{}".format(self._apiName, self._apiVersion, "/sdns") # Wait for status for SDN instance creation/update/deletion if isinstance(wait_time, bool): wait_time = WaitForStatus.TIMEOUT_SDNC_OPERATION WaitForStatus.wait_for_status( - 'SDNC', + "SDNC", str(id), wait_time, apiUrlStatus, self._http.get2_cmd, - deleteFlag=deleteFlag) + deleteFlag=deleteFlag, + ) def _get_id_for_wait(self, name): - """Returns id of name, or the id itself if given as argument - """ + """Returns id of name, or the id itself if given as argument""" self._logger.debug("") for sdnc in self.list(): - if name == sdnc['_id']: - return sdnc['_id'] + if name == sdnc["_id"]: + return sdnc["_id"] for sdnc in self.list(): - if name == sdnc['name']: - return sdnc['_id'] - return '' + if name == sdnc["name"]: + return sdnc["_id"] + return "" def create(self, name, sdn_controller, wait=False): self._logger.debug("") - if 'config' in sdn_controller and isinstance(sdn_controller["config"], str): + if "config" in sdn_controller and isinstance(sdn_controller["config"], str): sdn_controller["config"] = yaml.safe_load(sdn_controller["config"]) self._client.get_token() - http_code, resp = self._http.post_cmd(endpoint=self._apiBase, - postfields_dict=sdn_controller) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + http_code, resp = self._http.post_cmd( + endpoint=self._apiBase, postfields_dict=sdn_controller + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format( - resp)) + if not resp or "id" not in resp: + raise ClientException("unexpected response from server - {}".format(resp)) if wait: # Wait for status for SDNC instance creation - self._wait(resp.get('id'), wait) - print(resp['id']) - #else: + self._wait(resp.get("id"), wait) + print(resp["id"]) + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException("failed to create SDN controller {} - {}".format(name, msg)) def update(self, name, sdn_controller, wait=False): self._logger.debug("") - if 'config' in sdn_controller and isinstance(sdn_controller["config"], str): + if "config" in sdn_controller and isinstance(sdn_controller["config"], str): sdn_controller["config"] = yaml.safe_load(sdn_controller["config"]) self._client.get_token() sdnc = self.get(name) sdnc_id_for_wait = self._get_id_for_wait(name) - http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase,sdnc['_id']), - postfields_dict=sdn_controller) + http_code, resp = self._http.patch_cmd( + endpoint="{}/{}".format(self._apiBase, sdnc["_id"]), + postfields_dict=sdn_controller, + ) # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + # if http_code in (200, 201, 202, 204): if wait: # In this case, 'resp' always returns None, so 'resp['id']' cannot be used. # Use the previously obtained id instead. wait_id = sdnc_id_for_wait # Wait for status for VI instance update self._wait(wait_id, wait) # else: # pass - #else: + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: @@ -127,60 +130,60 @@ def delete(self, name, force=False, wait=False): self._logger.debug("") self._client.get_token() sdn_controller = self.get(name) sdnc_id_for_wait = self._get_id_for_wait(name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - sdn_controller['_id'], querystring)) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, sdn_controller["_id"], querystring) + ) # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) if http_code == 202: if wait: # Wait for status for SDNC instance deletion self._wait(sdnc_id_for_wait, wait, deleteFlag=True) else: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') - elif resp and 'result' in resp: - print('Deleted') + print("Deleted") + elif resp and "result" in resp: + print("Deleted") else: msg = resp or "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp - raise ClientException("failed to delete SDN controller {} - {}".format(name, msg)) + raise ClientException( + "failed to delete SDN controller {} - {}".format(name, msg) + ) def list(self, filter=None): - """Returns a list of SDN controllers - """ + """Returns a list of SDN controllers""" self._logger.debug("") self._client.get_token() - filter_string = '' + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) - #print('RESP: {}'.format(resp)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) + # print('RESP: {}'.format(resp)) if resp: return json.loads(resp) return list() def get(self, name): - """Returns an SDN controller based on name or id - """ + """Returns an SDN controller based on name or id""" self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for sdnc in self.list(): - if name == sdnc['_id']: + if name == sdnc["_id"]: return sdnc else: for sdnc in self.list(): - if name == sdnc['name']: + if name == sdnc["name"]: return sdnc raise NotFound("SDN controller {} not found".format(name)) - would reformat osmclient/sol005/sdncontroller.py --- osmclient/common/package_tool.py 2021-12-14 16:49:03.486515 +0000 +++ osmclient/common/package_tool.py 2021-12-14 16:49:40.458308 +0000 @@ -33,201 +33,350 @@ class PackageTool(object): def __init__(self, client=None): self._client = client - self._logger = logging.getLogger('osmclient') + self._logger = logging.getLogger("osmclient") self._validator = validation_im() - def create(self, package_type, base_directory, package_name, override, image, vdus, vcpu, memory, storage, - interfaces, vendor, detailed, netslice_subnets, netslice_vlds, old): - """ - **Create a package descriptor** - - :params: - - package_type: [vnf, ns, nst] - - base directory: path of destination folder - - package_name: is the name of the package to be created - - image: specify the image of the vdu - - vcpu: number of virtual cpus of the vdu - - memory: amount of memory in MB pf the vdu - - storage: amount of storage in GB of the vdu - - interfaces: number of interfaces besides management interface - - vendor: vendor name of the vnf/ns - - detailed: include all possible values for NSD, VNFD, NST - - netslice_subnets: number of netslice_subnets for the NST - - netslice_vlds: number of virtual link descriptors for the NST - - old: flag to create a package using the IM of OSM<9 - - :return: status + def create( + self, + package_type, + base_directory, + package_name, + override, + image, + vdus, + vcpu, + memory, + storage, + interfaces, + vendor, + detailed, + netslice_subnets, + netslice_vlds, + old, + ): + """ + **Create a package descriptor** + + :params: + - package_type: [vnf, ns, nst] + - base directory: path of destination folder + - package_name: is the name of the package to be created + - image: specify the image of the vdu + - vcpu: number of virtual cpus of the vdu + - memory: amount of memory in MB pf the vdu + - storage: amount of storage in GB of the vdu + - interfaces: number of interfaces besides management interface + - vendor: vendor name of the vnf/ns + - detailed: include all possible values for NSD, VNFD, NST + - netslice_subnets: number of netslice_subnets for the NST + - netslice_vlds: number of virtual link descriptors for the NST + - old: flag to create a package using the IM of OSM<9 + + :return: status """ self._logger.debug("") # print("location: {}".format(osmclient.__path__)) file_loader = PackageLoader("osmclient") env = Environment(loader=file_loader) - if package_type == 'ns': + if package_type == "ns": template = env.get_template("nsd.yaml.j2" if not old else "nsd_old.yaml.j2") - content = {"name": package_name, "vendor": vendor, "vdus": vdus, "clean": False, "interfaces": interfaces, - "detailed": detailed} - elif package_type == 'vnf': - template = env.get_template("vnfd.yaml.j2" if not old else "vnfd_old.yaml.j2") - content = {"name": package_name, "vendor": vendor, "vdus": vdus, "clean": False, "interfaces": interfaces, - "image": image, "vcpu": vcpu, "memory": memory, "storage": storage, "detailed": detailed} - elif package_type == 'nst': - template = env.get_template('nst.yaml.j2') - content = {"name": package_name, "vendor": vendor, "interfaces": interfaces, - "netslice_subnets": netslice_subnets, "netslice_vlds": netslice_vlds, "detailed": detailed} + content = { + "name": package_name, + "vendor": vendor, + "vdus": vdus, + "clean": False, + "interfaces": interfaces, + "detailed": detailed, + } + elif package_type == "vnf": + template = env.get_template( + "vnfd.yaml.j2" if not old else "vnfd_old.yaml.j2" + ) + content = { + "name": package_name, + "vendor": vendor, + "vdus": vdus, + "clean": False, + "interfaces": interfaces, + "image": image, + "vcpu": vcpu, + "memory": memory, + "storage": storage, + "detailed": detailed, + } + elif package_type == "nst": + template = env.get_template("nst.yaml.j2") + content = { + "name": package_name, + "vendor": vendor, + "interfaces": interfaces, + "netslice_subnets": netslice_subnets, + "netslice_vlds": netslice_vlds, + "detailed": detailed, + } else: - raise ClientException("Wrong descriptor type {}. Options: ns, vnf, nst".format(package_type)) + raise ClientException( + "Wrong descriptor type {}. Options: ns, vnf, nst".format(package_type) + ) # print("To be rendered: {}".format(content)) output = template.render(content) # print(output) - structure = self.discover_folder_structure(base_directory, package_name, override) + structure = self.discover_folder_structure( + base_directory, package_name, override + ) if structure.get("folders"): self.create_folders(structure["folders"], package_type) if structure.get("files"): self.create_files(structure["files"], output, package_type) return "Created" def validate(self, base_directory, recursive=True, old_format=False): """ - **Validate OSM Descriptors given a path** - - :params: - - base_directory is the root path for all descriptors - - :return: List of dict of validated descriptors. keys: type, path, valid, error + **Validate OSM Descriptors given a path** + + :params: + - base_directory is the root path for all descriptors + + :return: List of dict of validated descriptors. keys: type, path, valid, error """ self._logger.debug("") table = [] if recursive: - descriptors_paths = [f for f in glob.glob(base_directory + "/**/*.yaml", recursive=recursive)] + descriptors_paths = [ + f for f in glob.glob(base_directory + "/**/*.yaml", recursive=recursive) + ] else: - descriptors_paths = [f for f in glob.glob(base_directory + "/*.yaml", recursive=recursive)] + descriptors_paths = [ + f for f in glob.glob(base_directory + "/*.yaml", recursive=recursive) + ] print("Base directory: {}".format(base_directory)) print("{} Descriptors found to validate".format(len(descriptors_paths))) for desc_path in descriptors_paths: with open(desc_path) as descriptor_file: descriptor_data = descriptor_file.read() desc_type = "-" try: - desc_type, descriptor_data = validation_im.yaml_validation(self, descriptor_data) + desc_type, descriptor_data = validation_im.yaml_validation( + self, descriptor_data + ) if not old_format: - if ( desc_type=="vnfd" or desc_type=="nsd" ): - print("OSM descriptor '{}' written in an unsupported format. Please update to ETSI SOL006 format".format(desc_path)) - print("Package validation skipped. It can still be done with 'osm package-validate --old'") - print("Package build can still be done with 'osm package-build --skip-validation'") + if desc_type == "vnfd" or desc_type == "nsd": + print( + "OSM descriptor '{}' written in an unsupported format. Please update to ETSI SOL006 format".format( + desc_path + ) + ) + print( + "Package validation skipped. It can still be done with 'osm package-validate --old'" + ) + print( + "Package build can still be done with 'osm package-build --skip-validation'" + ) raise Exception("Not SOL006 format") validation_im.pyangbind_validation(self, desc_type, descriptor_data) - table.append({"type": desc_type, "path": desc_path, "valid": "OK", "error": "-"}) + table.append( + {"type": desc_type, "path": desc_path, "valid": "OK", "error": "-"} + ) except Exception as e: - table.append({"type": desc_type, "path": desc_path, "valid": "ERROR", "error": str(e)}) + table.append( + { + "type": desc_type, + "path": desc_path, + "valid": "ERROR", + "error": str(e), + } + ) return table def translate(self, base_directory, recursive=True, dryrun=False): """ - **Translate OSM Packages given a path** - - :params: - - base_directory is the root path for all packages - - :return: List of dict of translated packages. keys: current type, new type, path, valid, translated, error + **Translate OSM Packages given a path** + + :params: + - base_directory is the root path for all packages + + :return: List of dict of translated packages. keys: current type, new type, path, valid, translated, error """ self._logger.debug("") table = [] if recursive: - descriptors_paths = [f for f in glob.glob(base_directory + "/**/*.yaml", recursive=recursive)] + descriptors_paths = [ + f for f in glob.glob(base_directory + "/**/*.yaml", recursive=recursive) + ] else: - descriptors_paths = [f for f in glob.glob(base_directory + "/*.yaml", recursive=recursive)] + descriptors_paths = [ + f for f in glob.glob(base_directory + "/*.yaml", recursive=recursive) + ] print("Base directory: {}".format(base_directory)) print("{} Descriptors found to validate".format(len(descriptors_paths))) for desc_path in descriptors_paths: with open(desc_path) as descriptor_file: descriptor_data = descriptor_file.read() desc_type = "-" try: - desc_type, descriptor_data = validation_im.yaml_validation(self, descriptor_data) + desc_type, descriptor_data = validation_im.yaml_validation( + self, descriptor_data + ) self._logger.debug("desc_type: {}".format(desc_type)) self._logger.debug("descriptor_data:\n{}".format(descriptor_data)) self._validator.pyangbind_validation(desc_type, descriptor_data) - if not ( desc_type=="vnfd" or desc_type=="nsd" ): - table.append({"current type": desc_type, "new type": desc_type, "path": desc_path, "valid": "OK", "translated": "N/A", "error": "-"}) + if not (desc_type == "vnfd" or desc_type == "nsd"): + table.append( + { + "current type": desc_type, + "new type": desc_type, + "path": desc_path, + "valid": "OK", + "translated": "N/A", + "error": "-", + } + ) else: new_desc_type = desc_type try: - sol006_model = yaml.safe_dump(im_translation.translate_im_model_to_sol006(descriptor_data), indent=4, default_flow_style=False) - new_desc_type, new_descriptor_data = self._validator.yaml_validation(sol006_model) - self._validator.pyangbind_validation(new_desc_type, new_descriptor_data) + sol006_model = yaml.safe_dump( + im_translation.translate_im_model_to_sol006( + descriptor_data + ), + indent=4, + default_flow_style=False, + ) + ( + new_desc_type, + new_descriptor_data, + ) = self._validator.yaml_validation(sol006_model) + self._validator.pyangbind_validation( + new_desc_type, new_descriptor_data + ) if not dryrun: - with open(desc_path, 'w') as descriptor_file: + with open(desc_path, "w") as descriptor_file: descriptor_file.write(sol006_model) - table.append({"current type": desc_type, "new type": new_desc_type, "path": desc_path, "valid": "OK", "translated": "OK", "error": "-"}) + table.append( + { + "current type": desc_type, + "new type": new_desc_type, + "path": desc_path, + "valid": "OK", + "translated": "OK", + "error": "-", + } + ) except ValidationException as ve2: - table.append({"current type": desc_type, "new type": new_desc_type, "path": desc_path, "valid": "OK", "translated": "ERROR", "error": "Error in the post-validation: {}".format(str(ve2))}) + table.append( + { + "current type": desc_type, + "new type": new_desc_type, + "path": desc_path, + "valid": "OK", + "translated": "ERROR", + "error": "Error in the post-validation: {}".format( + str(ve2) + ), + } + ) except Exception as e2: - table.append({"current type": desc_type, "new type": new_desc_type, "path": desc_path, "valid": "OK", "translated": "ERROR", "error": "Error in the translation: {}".format(str(e2))}) + table.append( + { + "current type": desc_type, + "new type": new_desc_type, + "path": desc_path, + "valid": "OK", + "translated": "ERROR", + "error": "Error in the translation: {}".format(str(e2)), + } + ) except ValidationException as ve: - table.append({"current type": desc_type, "new type": "N/A", "path": desc_path, "valid": "ERROR", "translated": "N/A", "error": "Error in the pre-validation: {}".format(str(ve))}) + table.append( + { + "current type": desc_type, + "new type": "N/A", + "path": desc_path, + "valid": "ERROR", + "translated": "N/A", + "error": "Error in the pre-validation: {}".format(str(ve)), + } + ) except Exception as e: - table.append({"current type": desc_type, "new type": "N/A", "path": desc_path, "valid": "ERROR", "translated": "N/A", "error": str(e)}) + table.append( + { + "current type": desc_type, + "new type": "N/A", + "path": desc_path, + "valid": "ERROR", + "translated": "N/A", + "error": str(e), + } + ) return table def descriptor_translate(self, descriptor_file): """ - **Translate input descriptor file from Rel EIGHT OSM to SOL006** - - :params: - - base_directory is the root path for all packages - - :return: YAML descriptor in the new format - """ - self._logger.debug("") - with open(descriptor_file, 'r') as df: + **Translate input descriptor file from Rel EIGHT OSM to SOL006** + + :params: + - base_directory is the root path for all packages + + :return: YAML descriptor in the new format + """ + self._logger.debug("") + with open(descriptor_file, "r") as df: im_model = yaml.safe_load(df.read()) sol006_model = im_translation.translate_im_model_to_sol006(im_model) return yaml.safe_dump(sol006_model, indent=4, default_flow_style=False) def build(self, package_folder, skip_validation=False, skip_charm_build=False): """ - **Creates a .tar.gz file given a package_folder** - - :params: - - package_folder: is the name of the folder to be packaged - - skip_validation: is the flag to validate or not the descriptors on the folder before build - - :returns: message result for the build process - """ - self._logger.debug("") - package_folder = package_folder.rstrip('/') + **Creates a .tar.gz file given a package_folder** + + :params: + - package_folder: is the name of the folder to be packaged + - skip_validation: is the flag to validate or not the descriptors on the folder before build + + :returns: message result for the build process + """ + self._logger.debug("") + package_folder = package_folder.rstrip("/") if not os.path.exists("{}".format(package_folder)): return "Fail, package is not in the specified path" if not skip_validation: - print('Validating package {}'.format(package_folder)) + print("Validating package {}".format(package_folder)) results = self.validate(package_folder, recursive=False) if results: for result in results: if result["valid"] != "OK": - raise ClientException("There was an error validating the file {} with error: {}" - .format(result["path"], result["error"])) - print('Validation OK') + raise ClientException( + "There was an error validating the file {} with error: {}".format( + result["path"], result["error"] + ) + ) + print("Validation OK") else: - raise ClientException("No descriptor file found in: {}".format(package_folder)) + raise ClientException( + "No descriptor file found in: {}".format(package_folder) + ) charm_list = self.build_all_charms(package_folder, skip_charm_build) return self.build_tarfile(package_folder, charm_list) def calculate_checksum(self, package_folder): """ - **Function to calculate the checksum given a folder** - - :params: - - package_folder: is the folder where we have the files to calculate the checksum - :returns: None - """ - self._logger.debug("") - files = [f for f in glob.glob(package_folder + "/**/*.*", recursive=True) if os.path.isfile(f)] + **Function to calculate the checksum given a folder** + + :params: + - package_folder: is the folder where we have the files to calculate the checksum + :returns: None + """ + self._logger.debug("") + files = [ + f + for f in glob.glob(package_folder + "/**/*.*", recursive=True) + if os.path.isfile(f) + ] with open("{}/checksums.txt".format(package_folder), "w+") as checksum: for file_item in files: if "checksums.txt" in file_item: continue # from https://www.quickprogrammingtips.com/python/how-to-calculate-md5-hash-of-a-file-in-python.html @@ -238,16 +387,16 @@ md5_hash.update(byte_block) checksum.write("{}\t{}\n".format(md5_hash.hexdigest(), file_item)) def create_folders(self, folders, package_type): """ - **Create folder given a list of folders** - - :params: - - folders: [List] list of folders paths to be created - - package_type: is the type of package to be created - :return: None + **Create folder given a list of folders** + + :params: + - folders: [List] list of folders paths to be created + - package_type: is the type of package to be created + :return: None """ self._logger.debug("") for folder in folders: try: # print("Folder {} == package_type {}".format(folder[1], package_type)) @@ -257,16 +406,16 @@ except FileExistsError: pass def save_file(self, file_name, file_body): """ - **Create a file given a name and the content** - - :params: - - file_name: is the name of the file with the relative route - - file_body: is the content of the file - :return: None + **Create a file given a name and the content** + + :params: + - file_name: is the name of the file with the relative route + - file_body: is the content of the file + :return: None """ self._logger.debug("") print("Creating file: \t{}".format(file_name)) try: with open(file_name, "w+") as f: @@ -274,37 +423,38 @@ except Exception as e: raise ClientException(e) def generate_readme(self): """ - **Creates the README content** - - :returns: readme content + **Creates the README content** + + :returns: readme content """ self._logger.debug("") return """# Descriptor created by OSM descriptor package generated\n\n**Created on {} **""".format( - time.strftime("%m/%d/%Y, %H:%M:%S", time.localtime())) + time.strftime("%m/%d/%Y, %H:%M:%S", time.localtime()) + ) def generate_cloud_init(self): """ - **Creates the cloud-init content** - - :returns: cloud-init content + **Creates the cloud-init content** + + :returns: cloud-init content """ self._logger.debug("") return "---\n#cloud-config" def create_files(self, files, file_content, package_type): """ - **Creates the files given the file list and type** - - :params: - - files: is the list of files structure - - file_content: is the content of the descriptor rendered by the template - - package_type: is the type of package to filter the creation structure - - :return: None + **Creates the files given the file list and type** + + :params: + - files: is the list of files structure + - file_content: is the content of the descriptor rendered by the template + - package_type: is the type of package to filter the creation structure + + :return: None """ self._logger.debug("") for file_item, file_package, file_type in files: if package_type == file_package: if file_type == "descriptor": @@ -314,17 +464,17 @@ elif file_type == "cloud_init": self.save_file(file_item, self.generate_cloud_init()) def check_files_folders(self, path_list, override): """ - **Find files and folders missing given a directory structure {"folders": [], "files": []}** - - :params: - - path_list: is the list of files and folders to be created - - override: is the flag used to indicate the creation of the list even if the file exist to override it - - :return: Missing paths Dict + **Find files and folders missing given a directory structure {"folders": [], "files": []}** + + :params: + - path_list: is the list of files and folders to be created + - override: is the flag used to indicate the creation of the list even if the file exist to override it + + :return: Missing paths Dict """ self._logger.debug("") missing_paths = {} folders = [] files = [] @@ -340,77 +490,99 @@ return missing_paths def build_all_charms(self, package_folder, skip_charm_build): """ - **Read the descriptor file, check that the charms referenced are in the folder and compiles them** - - :params: - - packet_folder: is the location of the package - :return: Files and Folders not found. In case of override, it will return all file list + **Read the descriptor file, check that the charms referenced are in the folder and compiles them** + + :params: + - packet_folder: is the location of the package + :return: Files and Folders not found. In case of override, it will return all file list """ self._logger.debug("") listCharms = [] descriptor_file = False descriptors_paths = [f for f in glob.glob(package_folder + "/*.yaml")] for file in descriptors_paths: - if file.endswith('nfd.yaml'): + if file.endswith("nfd.yaml"): descriptor_file = True - listCharms = self.charms_search(file, 'vnf') - if file.endswith('nsd.yaml'): + listCharms = self.charms_search(file, "vnf") + if file.endswith("nsd.yaml"): descriptor_file = True - listCharms = self.charms_search(file, 'ns') + listCharms = self.charms_search(file, "ns") print("List of charms in the descriptor: {}".format(listCharms)) if not descriptor_file: - raise ClientException('Descriptor filename is not correct in: {}. It should end with "nfd.yaml" or "nsd.yaml"'.format(package_folder)) + raise ClientException( + 'Descriptor filename is not correct in: {}. It should end with "nfd.yaml" or "nsd.yaml"'.format( + package_folder + ) + ) if listCharms and not skip_charm_build: for charmName in listCharms: - if os.path.isdir('{}/charms/layers/{}'.format(package_folder, charmName)): - print('Building charm {}/charms/layers/{}'.format(package_folder, charmName)) + if os.path.isdir( + "{}/charms/layers/{}".format(package_folder, charmName) + ): + print( + "Building charm {}/charms/layers/{}".format( + package_folder, charmName + ) + ) self.charm_build(package_folder, charmName) - print('Charm built: {}'.format(charmName)) + print("Charm built: {}".format(charmName)) else: - if not os.path.isdir('{}/charms/{}'.format(package_folder, charmName)): - raise ClientException('The charm: {} referenced in the descriptor file ' - 'is not present either in {}/charms or in {}/charms/layers'. - format(charmName, package_folder, package_folder)) + if not os.path.isdir( + "{}/charms/{}".format(package_folder, charmName) + ): + raise ClientException( + "The charm: {} referenced in the descriptor file " + "is not present either in {}/charms or in {}/charms/layers".format( + charmName, package_folder, package_folder + ) + ) self._logger.debug("Return list of charms: {}".format(listCharms)) return listCharms def discover_folder_structure(self, base_directory, name, override): """ - **Discover files and folders structure for OSM descriptors given a base_directory and name** - - :params: - - base_directory: is the location of the package to be created - - name: is the name of the package - - override: is the flag used to indicate the creation of the list even if the file exist to override it - :return: Files and Folders not found. In case of override, it will return all file list + **Discover files and folders structure for OSM descriptors given a base_directory and name** + + :params: + - base_directory: is the location of the package to be created + - name: is the name of the package + - override: is the flag used to indicate the creation of the list even if the file exist to override it + :return: Files and Folders not found. In case of override, it will return all file list """ self._logger.debug("") prefix = "{}/{}".format(base_directory, name) - files_folders = {"folders": [("{}_ns".format(prefix), "ns"), - ("{}_ns/icons".format(prefix), "ns"), - ("{}_ns/charms".format(prefix), "ns"), - ("{}_vnf".format(name), "vnf"), - ("{}_vnf/charms".format(prefix), "vnf"), - ("{}_vnf/cloud_init".format(prefix), "vnf"), - ("{}_vnf/images".format(prefix), "vnf"), - ("{}_vnf/icons".format(prefix), "vnf"), - ("{}_vnf/scripts".format(prefix), "vnf"), - ("{}_nst".format(prefix), "nst"), - ("{}_nst/icons".format(prefix), "nst") - ], - "files": [("{}_ns/{}_nsd.yaml".format(prefix, name), "ns", "descriptor"), - ("{}_ns/README.md".format(prefix), "ns", "readme"), - ("{}_vnf/{}_vnfd.yaml".format(prefix, name), "vnf", "descriptor"), - ("{}_vnf/cloud_init/cloud-config.txt".format(prefix), "vnf", "cloud_init"), - ("{}_vnf/README.md".format(prefix), "vnf", "readme"), - ("{}_nst/{}_nst.yaml".format(prefix, name), "nst", "descriptor"), - ("{}_nst/README.md".format(prefix), "nst", "readme") - ] - } + files_folders = { + "folders": [ + ("{}_ns".format(prefix), "ns"), + ("{}_ns/icons".format(prefix), "ns"), + ("{}_ns/charms".format(prefix), "ns"), + ("{}_vnf".format(name), "vnf"), + ("{}_vnf/charms".format(prefix), "vnf"), + ("{}_vnf/cloud_init".format(prefix), "vnf"), + ("{}_vnf/images".format(prefix), "vnf"), + ("{}_vnf/icons".format(prefix), "vnf"), + ("{}_vnf/scripts".format(prefix), "vnf"), + ("{}_nst".format(prefix), "nst"), + ("{}_nst/icons".format(prefix), "nst"), + ], + "files": [ + ("{}_ns/{}_nsd.yaml".format(prefix, name), "ns", "descriptor"), + ("{}_ns/README.md".format(prefix), "ns", "readme"), + ("{}_vnf/{}_vnfd.yaml".format(prefix, name), "vnf", "descriptor"), + ( + "{}_vnf/cloud_init/cloud-config.txt".format(prefix), + "vnf", + "cloud_init", + ), + ("{}_vnf/README.md".format(prefix), "vnf", "readme"), + ("{}_nst/{}_nst.yaml".format(prefix, name), "nst", "descriptor"), + ("{}_nst/README.md".format(prefix), "nst", "readme"), + ], + } missing_files_folders = self.check_files_folders(files_folders, override) # print("Missing files and folders: {}".format(missing_files_folders)) return missing_files_folders def charm_build(self, charms_folder, build_name): @@ -418,17 +590,21 @@ Build the charms inside the package. params: package_folder is the name of the folder where is the charms to compile. build_name is the name of the layer or interface """ self._logger.debug("") - os.environ['JUJU_REPOSITORY'] = "{}/charms".format(charms_folder) - os.environ['CHARM_LAYERS_DIR'] = "{}/layers".format(os.environ['JUJU_REPOSITORY']) - os.environ['CHARM_INTERFACES_DIR'] = "{}/interfaces".format(os.environ['JUJU_REPOSITORY']) - os.environ['CHARM_BUILD_DIR'] = "{}/charms/builds".format(charms_folder) - if not os.path.exists(os.environ['CHARM_BUILD_DIR']): - os.makedirs(os.environ['CHARM_BUILD_DIR']) - src_folder = '{}/{}'.format(os.environ['CHARM_LAYERS_DIR'], build_name) + os.environ["JUJU_REPOSITORY"] = "{}/charms".format(charms_folder) + os.environ["CHARM_LAYERS_DIR"] = "{}/layers".format( + os.environ["JUJU_REPOSITORY"] + ) + os.environ["CHARM_INTERFACES_DIR"] = "{}/interfaces".format( + os.environ["JUJU_REPOSITORY"] + ) + os.environ["CHARM_BUILD_DIR"] = "{}/charms/builds".format(charms_folder) + if not os.path.exists(os.environ["CHARM_BUILD_DIR"]): + os.makedirs(os.environ["CHARM_BUILD_DIR"]) + src_folder = "{}/{}".format(os.environ["CHARM_LAYERS_DIR"], build_name) result = subprocess.run(["charm", "build", "{}".format(src_folder)]) if result.returncode == 1: raise ClientException("failed to build the charm: {}".format(src_folder)) self._logger.verbose("charm {} built".format(src_folder)) @@ -439,42 +615,51 @@ returns: .tar.gz name """ self._logger.debug("") cwd = None try: - directory_name, package_name = self.create_temp_dir(package_folder, charm_list) + directory_name, package_name = self.create_temp_dir( + package_folder, charm_list + ) cwd = os.getcwd() os.chdir(directory_name) self.calculate_checksum(package_name) - with tarfile.open("{}.tar.gz".format(package_name), mode='w:gz') as archive: + with tarfile.open("{}.tar.gz".format(package_name), mode="w:gz") as archive: print("Adding File: {}".format(package_name)) - archive.add('{}'.format(package_name), recursive=True) + archive.add("{}".format(package_name), recursive=True) # return "Created {}.tar.gz".format(package_folder) # self.build("{}".format(os.path.basename(package_folder))) os.chdir(cwd) cwd = None - created_package = "{}/{}.tar.gz".format(os.path.dirname(package_folder) or '.', package_name) - os.rename("{}/{}.tar.gz".format(directory_name, package_name), - created_package) - os.rename("{}/{}/checksums.txt".format(directory_name, package_name), - "{}/checksums.txt".format(package_folder)) + created_package = "{}/{}.tar.gz".format( + os.path.dirname(package_folder) or ".", package_name + ) + os.rename( + "{}/{}.tar.gz".format(directory_name, package_name), created_package + ) + os.rename( + "{}/{}/checksums.txt".format(directory_name, package_name), + "{}/checksums.txt".format(package_folder), + ) print("Package created: {}".format(created_package)) return created_package except Exception as exc: - raise ClientException('failure during build of targz file (create temp dir, calculate checksum, ' - 'tar.gz file): {}'.format(exc)) + raise ClientException( + "failure during build of targz file (create temp dir, calculate checksum, " + "tar.gz file): {}".format(exc) + ) finally: if cwd: os.chdir(cwd) shutil.rmtree(os.path.join(package_folder, "tmp")) def create_temp_dir(self, package_folder, charm_list=None): """ Method to create a temporary folder where we can move the files in package_folder """ self._logger.debug("") - ignore_patterns = ('.gitignore') + ignore_patterns = ".gitignore" ignore = shutil.ignore_patterns(ignore_patterns) directory_name = os.path.abspath(package_folder) package_name = os.path.basename(directory_name) directory_name += "/tmp" os.makedirs("{}/{}".format(directory_name, package_name), exist_ok=True) @@ -493,16 +678,23 @@ if charm in os.listdir(s): s_charm = os.path.join(s, charm) elif charm in os.listdir(s_builds): s_charm = os.path.join(s_builds, charm) else: - raise ClientException('The charm {} referenced in the descriptor file ' - 'could not be found in {}/charms or in {}/charms/builds'. - format(charm, package_folder, package_folder)) + raise ClientException( + "The charm {} referenced in the descriptor file " + "could not be found in {}/charms or in {}/charms/builds".format( + charm, package_folder, package_folder + ) + ) d_temp = os.path.join(d, charm) - self._logger.debug("Copying tree: {} -> {}".format(s_charm, d_temp)) - shutil.copytree(s_charm, d_temp, symlinks=True, ignore=ignore) + self._logger.debug( + "Copying tree: {} -> {}".format(s_charm, d_temp) + ) + shutil.copytree( + s_charm, d_temp, symlinks=True, ignore=ignore + ) self._logger.debug("DONE") else: self._logger.debug("Copying tree: {} -> {}".format(s, d)) shutil.copytree(s, d, symlinks=True, ignore=ignore) self._logger.debug("DONE") @@ -513,19 +705,33 @@ shutil.copy2(s, d) self._logger.debug("DONE") return directory_name, package_name def charms_search(self, descriptor_file, desc_type): - self._logger.debug("descriptor_file: {}, desc_type: {}".format(descriptor_file, - desc_type)) + self._logger.debug( + "descriptor_file: {}, desc_type: {}".format(descriptor_file, desc_type) + ) with open("{}".format(descriptor_file)) as yaml_desc: descriptor_dict = yaml.safe_load(yaml_desc) - #self._logger.debug("\n"+yaml.safe_dump(descriptor_dict, indent=4, default_flow_style=False)) - - if ( (desc_type=="vnf" and ("vnfd:vnfd-catalog" in descriptor_dict or "vnfd-catalog" in descriptor_dict)) or - (desc_type=="ns" and ( "nsd:nsd-catalog" in descriptor_dict or "nsd-catalog" in descriptor_dict)) ): - charms_list = self._charms_search_on_osm_im_dict(descriptor_dict, desc_type) + # self._logger.debug("\n"+yaml.safe_dump(descriptor_dict, indent=4, default_flow_style=False)) + + if ( + desc_type == "vnf" + and ( + "vnfd:vnfd-catalog" in descriptor_dict + or "vnfd-catalog" in descriptor_dict + ) + ) or ( + desc_type == "ns" + and ( + "nsd:nsd-catalog" in descriptor_dict + or "nsd-catalog" in descriptor_dict + ) + ): + charms_list = self._charms_search_on_osm_im_dict( + descriptor_dict, desc_type + ) else: if desc_type == "ns": get_charm_list = self._charms_search_on_nsd_sol006_dict elif desc_type == "vnf": get_charm_list = self._charms_search_on_vnfd_sol006_dict @@ -538,22 +744,22 @@ self._logger.debug("") charms_list = [] for k1, v1 in osm_im_dict.items(): for k2, v2 in v1.items(): for entry in v2: - if '{}-configuration'.format(desc_type) in entry: - vnf_config = entry['{}-configuration'.format(desc_type)] + if "{}-configuration".format(desc_type) in entry: + vnf_config = entry["{}-configuration".format(desc_type)] for k3, v3 in vnf_config.items(): - if 'charm' in v3: - charms_list.append((v3['charm'])) - if 'vdu' in entry: - vdus = entry['vdu'] + if "charm" in v3: + charms_list.append((v3["charm"])) + if "vdu" in entry: + vdus = entry["vdu"] for vdu in vdus: - if 'vdu-configuration' in vdu: - for k4, v4 in vdu['vdu-configuration'].items(): - if 'charm' in v4: - charms_list.append((v4['charm'])) + if "vdu-configuration" in vdu: + for k4, v4 in vdu["vdu-configuration"].items(): + if "charm" in v4: + charms_list.append((v4["charm"])) return charms_list def _charms_search_on_vnfd_sol006_dict(self, sol006_dict): self._logger.debug("") charms_list = [] @@ -563,13 +769,15 @@ for df in v2: lcm_ops = df.get("lcm-operations-configuration", {}) ops_config = lcm_ops.get("operate-vnf-op-config", {}) for day_12_config in ops_config.get("day1-2", []): self._logger.debug("Execution environment found") - for ee in day_12_config.get("execution-environment-list", []): + for ee in day_12_config.get( + "execution-environment-list", [] + ): if "juju" in ee: - charms_list.append((ee["juju"]['charm'])) + charms_list.append((ee["juju"]["charm"])) return charms_list def _charms_search_on_nsd_sol006_dict(self, sol006_dict): self._logger.debug("") charms_list = [] would reformat osmclient/common/package_tool.py --- osmclient/sol005/vnf.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/vnf.py 2021-12-14 16:49:40.734530 +0000 @@ -21,69 +21,68 @@ from osmclient.common import utils from osmclient.common.exceptions import NotFound import logging import json + class Vnf(object): - def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/nslcm' - self._apiVersion = '/v1' - self._apiResource = '/vnfrs' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/nslcm" + self._apiVersion = "/v1" + self._apiResource = "/vnfrs" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) def list(self, ns=None, filter=None): - """Returns a list of VNF instances - """ + """Returns a list of VNF instances""" self._logger.debug("") self._client.get_token() - filter_string = '' + filter_string = "" if filter: - filter_string = '?{}'.format(filter) + filter_string = "?{}".format(filter) if ns: ns_instance = self._client.ns.get(ns) if filter_string: - filter_string += ',nsr-id-ref={}'.format(ns_instance['_id']) + filter_string += ",nsr-id-ref={}".format(ns_instance["_id"]) else: - filter_string = '?nsr-id-ref={}'.format(ns_instance['_id']) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) - #print('RESP: {}'.format(resp)) + filter_string = "?nsr-id-ref={}".format(ns_instance["_id"]) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) + # print('RESP: {}'.format(resp)) if resp: return json.loads(resp) return list() def get(self, name): - """Returns a VNF instance based on name or id - """ + """Returns a VNF instance based on name or id""" self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for vnf in self.list(): - if name == vnf['_id']: + if name == vnf["_id"]: return vnf else: for vnf in self.list(): - if name == vnf.get('name'): + if name == vnf.get("name"): return vnf raise NotFound("vnf {} not found".format(name)) def get_individual(self, name): self._logger.debug("") self._client.get_token() vnf_id = name if not utils.validate_uuid4(name): for vnf in self.list(): - if name == vnf['name']: - vnf_id = vnf['_id'] + if name == vnf["name"]: + vnf_id = vnf["_id"] break try: - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, vnf_id)) - #print('RESP: {}'.format(resp)) + _, resp = self._http.get2_cmd("{}/{}".format(self._apiBase, vnf_id)) + # print('RESP: {}'.format(resp)) if resp: return json.loads(resp) except NotFound: raise NotFound("vnf '{}' not found".format(name)) raise NotFound("vnf '{}' not found".format(name)) would reformat osmclient/sol005/vnf.py --- osmclient/sol005/vim.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/vim.py 2021-12-14 16:49:41.159320 +0000 @@ -29,225 +29,231 @@ class Vim(object): def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/admin' - self._apiVersion = '/v1' - self._apiResource = '/vim_accounts' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/admin" + self._apiVersion = "/v1" + self._apiResource = "/vim_accounts" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) # VIM '--wait' option def _wait(self, id, wait_time, deleteFlag=False): self._logger.debug("") self._client.get_token() # Endpoint to get operation status - apiUrlStatus = '{}{}{}'.format(self._apiName, self._apiVersion, '/vim_accounts') + apiUrlStatus = "{}{}{}".format(self._apiName, self._apiVersion, "/vim_accounts") # Wait for status for VIM instance creation/deletion if isinstance(wait_time, bool): wait_time = WaitForStatus.TIMEOUT_VIM_OPERATION WaitForStatus.wait_for_status( - 'VIM', + "VIM", str(id), wait_time, apiUrlStatus, self._http.get2_cmd, - deleteFlag=deleteFlag) + deleteFlag=deleteFlag, + ) def _get_id_for_wait(self, name): - """ Returns id of name, or the id itself if given as argument - """ + """Returns id of name, or the id itself if given as argument""" self._logger.debug("") self._client.get_token() for vim in self.list(): - if name == vim['uuid']: - return vim['uuid'] + if name == vim["uuid"]: + return vim["uuid"] for vim in self.list(): - if name == vim['name']: - return vim['uuid'] - return '' - - def create(self, name, vim_access, sdn_controller=None, sdn_port_mapping=None, wait=False): - self._logger.debug("") - self._client.get_token() - if 'vim-type' not in vim_access: + if name == vim["name"]: + return vim["uuid"] + return "" + + def create( + self, name, vim_access, sdn_controller=None, sdn_port_mapping=None, wait=False + ): + self._logger.debug("") + self._client.get_token() + if "vim-type" not in vim_access: #'openstack' not in vim_access['vim-type']): raise Exception("vim type not provided") vim_account = {} - vim_account['name'] = name + vim_account["name"] = name vim_account = self.update_vim_account_dict(vim_account, vim_access) vim_config = {} - if 'config' in vim_access and vim_access['config'] is not None: - vim_config = yaml.safe_load(vim_access['config']) + if "config" in vim_access and vim_access["config"] is not None: + vim_config = yaml.safe_load(vim_access["config"]) if sdn_controller: sdnc = self._client.sdnc.get(sdn_controller) - vim_config['sdn-controller'] = sdnc['_id'] + vim_config["sdn-controller"] = sdnc["_id"] if sdn_port_mapping: - with open(sdn_port_mapping, 'r') as f: - vim_config['sdn-port-mapping'] = yaml.safe_load(f.read()) + with open(sdn_port_mapping, "r") as f: + vim_config["sdn-port-mapping"] = yaml.safe_load(f.read()) if vim_config: - vim_account['config'] = vim_config - #vim_account['config'] = json.dumps(vim_config) - - http_code, resp = self._http.post_cmd(endpoint=self._apiBase, - postfields_dict=vim_account) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + vim_account["config"] = vim_config + # vim_account['config'] = json.dumps(vim_config) + + http_code, resp = self._http.post_cmd( + endpoint=self._apiBase, postfields_dict=vim_account + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format( - resp)) + if not resp or "id" not in resp: + raise ClientException("unexpected response from server - {}".format(resp)) if wait: # Wait for status for VIM instance creation - self._wait(resp.get('id'), wait) - print(resp['id']) - #else: + self._wait(resp.get("id"), wait) + print(resp["id"]) + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException("failed to create vim {} - {}".format(name, msg)) - def update(self, vim_name, vim_account, sdn_controller, sdn_port_mapping, wait=False): + def update( + self, vim_name, vim_account, sdn_controller, sdn_port_mapping, wait=False + ): self._logger.debug("") self._client.get_token() vim = self.get(vim_name) vim_id_for_wait = self._get_id_for_wait(vim_name) vim_config = {} - if 'config' in vim_account: - if vim_account.get('config')=="" and (sdn_controller or sdn_port_mapping): - raise ClientException("clearing config is incompatible with updating SDN info") - if vim_account.get('config')=="": + if "config" in vim_account: + if vim_account.get("config") == "" and (sdn_controller or sdn_port_mapping): + raise ClientException( + "clearing config is incompatible with updating SDN info" + ) + if vim_account.get("config") == "": vim_config = None else: - vim_config = yaml.safe_load(vim_account['config']) + vim_config = yaml.safe_load(vim_account["config"]) if sdn_controller == "": - vim_config['sdn-controller'] = None - vim_config['sdn-port-mapping'] = None + vim_config["sdn-controller"] = None + vim_config["sdn-port-mapping"] = None else: if sdn_controller: sdnc = self._client.sdnc.get(sdn_controller) - vim_config['sdn-controller'] = sdnc['_id'] + vim_config["sdn-controller"] = sdnc["_id"] if sdn_port_mapping: - with open(sdn_port_mapping, 'r') as f: - vim_config['sdn-port-mapping'] = yaml.safe_load(f.read()) - vim_account['config'] = vim_config - #vim_account['config'] = json.dumps(vim_config) - http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase,vim['_id']), - postfields_dict=vim_account) + with open(sdn_port_mapping, "r") as f: + vim_config["sdn-port-mapping"] = yaml.safe_load(f.read()) + vim_account["config"] = vim_config + # vim_account['config'] = json.dumps(vim_config) + http_code, resp = self._http.patch_cmd( + endpoint="{}/{}".format(self._apiBase, vim["_id"]), + postfields_dict=vim_account, + ) # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + # if http_code in (200, 201, 202, 204): if wait: # In this case, 'resp' always returns None, so 'resp['id']' cannot be used. # Use the previously obtained id instead. wait_id = vim_id_for_wait # Wait for status for VI instance update self._wait(wait_id, wait) # else: # pass - #else: + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException("failed to update vim {} - {}".format(vim_name, msg)) def update_vim_account_dict(self, vim_account, vim_access): self._logger.debug("") - vim_account['vim_type'] = vim_access['vim-type'] - vim_account['description'] = vim_access['description'] - vim_account['vim_url'] = vim_access['vim-url'] - vim_account['vim_user'] = vim_access['vim-username'] - vim_account['vim_password'] = vim_access['vim-password'] - vim_account['vim_tenant_name'] = vim_access['vim-tenant-name'] + vim_account["vim_type"] = vim_access["vim-type"] + vim_account["description"] = vim_access["description"] + vim_account["vim_url"] = vim_access["vim-url"] + vim_account["vim_user"] = vim_access["vim-username"] + vim_account["vim_password"] = vim_access["vim-password"] + vim_account["vim_tenant_name"] = vim_access["vim-tenant-name"] return vim_account def get_id(self, name): - """Returns a VIM id from a VIM name - """ + """Returns a VIM id from a VIM name""" self._logger.debug("") for vim in self.list(): - if name == vim['name']: - return vim['uuid'] + if name == vim["name"]: + return vim["uuid"] raise NotFound("vim {} not found".format(name)) def delete(self, vim_name, force=False, wait=False): self._logger.debug("") self._client.get_token() vim_id = vim_name if not utils.validate_uuid4(vim_name): vim_id = self.get_id(vim_name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - vim_id, querystring)) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, vim_id, querystring) + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) if http_code == 202: if wait: # When deleting an account, 'resp' may be None. # In such a case, the 'id' from 'resp' cannot be used, so use 'vim_id' instead wait_id = vim_id if resp: resp = json.loads(resp) - wait_id = resp.get('id') + wait_id = resp.get("id") # Wait for status for VIM account deletion self._wait(wait_id, wait, deleteFlag=True) else: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') + print("Deleted") else: msg = resp or "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp raise ClientException("failed to delete vim {} - {}".format(vim_name, msg)) def list(self, filter=None): - """Returns a list of VIM accounts - """ - self._logger.debug("") - self._client.get_token() - filter_string = '' + """Returns a list of VIM accounts""" + self._logger.debug("") + self._client.get_token() + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) if not resp: return list() vim_accounts = json.loads(resp) for datacenter in vim_accounts: - datacenter["uuid"] = datacenter.get('_id') # backward compatibility? + datacenter["uuid"] = datacenter.get("_id") # backward compatibility? return vim_accounts def get(self, name): - """Returns a VIM account based on name or id - """ + """Returns a VIM account based on name or id""" self._logger.debug("") self._client.get_token() vim_id = name if not utils.validate_uuid4(name): vim_id = self.get_id(name) try: - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase,vim_id)) + _, resp = self._http.get2_cmd("{}/{}".format(self._apiBase, vim_id)) if resp: resp = json.loads(resp) - if not resp or '_id' not in resp: - raise ClientException('failed to get vim info: {}'.format(resp)) + if not resp or "_id" not in resp: + raise ClientException("failed to get vim info: {}".format(resp)) return resp except NotFound: raise NotFound("vim '{}' not found".format(name)) - would reformat osmclient/sol005/vim.py --- osmclient/sol005/osmrepo.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/osmrepo.py 2021-12-14 16:49:41.194440 +0000 @@ -36,148 +36,170 @@ class OSMRepo(Repo): def __init__(self, http=None, client=None): self._http = http self._client = client - self._apiName = '/admin' - self._apiVersion = '/v1' - self._apiResource = '/osmrepos' - self._logger = logging.getLogger('osmclient') - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._apiName = "/admin" + self._apiVersion = "/v1" + self._apiResource = "/osmrepos" + self._logger = logging.getLogger("osmclient") + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) def pkg_list(self, pkgtype, filter=None, repo=None): """ - Returns a repo based on name or id + Returns a repo based on name or id """ self._logger.debug("") self._client.get_token() # Get OSM registered repository list repositories = self.list() if repo: repositories = [r for r in repositories if r["name"] == repo] if not repositories: - raise ClientException('Not repository found') + raise ClientException("Not repository found") vnf_repos = [] for repository in repositories: try: - r = requests.get('{}/index.yaml'.format(repository.get('url'))) + r = requests.get("{}/index.yaml".format(repository.get("url"))) if r.status_code == 200: repo_list = yaml.safe_load(r.text) - vnf_packages = repo_list.get('{}_packages'.format(pkgtype)) + vnf_packages = repo_list.get("{}_packages".format(pkgtype)) for repo in vnf_packages: versions = vnf_packages.get(repo) - latest = versions.get('latest') - del versions['latest'] + latest = versions.get("latest") + del versions["latest"] for version in versions: latest_version = False if version == latest: latest_version = True - vnf_repos.append({'vendor': versions[version].get("vendor"), - 'name': versions[version].get("name"), - 'version': version, - 'description': versions[version].get("description"), - 'location': versions[version].get("path"), - 'repository': repository.get('name'), - 'repourl': repository.get('url'), - 'latest': latest_version - }) + vnf_repos.append( + { + "vendor": versions[version].get("vendor"), + "name": versions[version].get("name"), + "version": version, + "description": versions[version].get("description"), + "location": versions[version].get("path"), + "repository": repository.get("name"), + "repourl": repository.get("url"), + "latest": latest_version, + } + ) else: - raise Exception('repository in url {} unreachable'.format(repository.get('url'))) + raise Exception( + "repository in url {} unreachable".format(repository.get("url")) + ) except Exception as e: self._logger.error( "Error cannot read from repository {} '{}': {}".format( repository["name"], repository["url"], e ), - exc_info=True + exc_info=True, ) continue vnf_repos_filtered = [] if filter: for vnf_repo in vnf_repos: for k, v in vnf_repo.items(): if v: - kf, vf = filter.split('=') + kf, vf = filter.split("=") if k == kf and vf in v: vnf_repos_filtered.append(vnf_repo) break vnf_repos = vnf_repos_filtered return vnf_repos def get_pkg(self, pkgtype, name, repo, filter, version): """ - Returns the filename of the PKG downloaded to disk + Returns the filename of the PKG downloaded to disk """ self._logger.debug("") self._client.get_token() f = None f_name = None # Get OSM registered repository list pkgs = self.pkg_list(pkgtype, filter, repo) for pkg in pkgs: - if pkg.get('repository') == repo and pkg.get('name') == name: - if 'latest' in version: - if not pkg.get('latest'): + if pkg.get("repository") == repo and pkg.get("name") == name: + if "latest" in version: + if not pkg.get("latest"): continue else: - version = pkg.get('version') - if pkg.get('version') == version: - r = requests.get('{}{}'.format(pkg.get('repourl'), pkg.get('location')), stream=True) + version = pkg.get("version") + if pkg.get("version") == version: + r = requests.get( + "{}{}".format(pkg.get("repourl"), pkg.get("location")), + stream=True, + ) if r.status_code != 200: raise ClientException("Package not found") with tempfile.NamedTemporaryFile(delete=False) as f: f.write(r.raw.read()) f_name = f.name if not f_name: - raise ClientException("{} {} not found at repo {}".format(pkgtype, name, repo)) + raise ClientException( + "{} {} not found at repo {}".format(pkgtype, name, repo) + ) return f_name def pkg_get(self, pkgtype, name, repo, version, filter): pkg_name = self.get_pkg(pkgtype, name, repo, filter, version) if not pkg_name: - raise ClientException('Package not found') + raise ClientException("Package not found") folder, descriptor = self.zip_extraction(pkg_name) with open(descriptor) as pkg: pkg_descriptor = yaml.safe_load(pkg) rmtree(folder, ignore_errors=False) - if ((pkgtype == 'vnf' and (pkg_descriptor.get('vnfd') or pkg_descriptor.get('vnfd:vnfd_catalog'))) or - (pkgtype == 'ns' and (pkg_descriptor.get('nsd') or pkg_descriptor.get('nsd:nsd_catalog')))): - raise ClientException('Wrong Package type') + if ( + pkgtype == "vnf" + and (pkg_descriptor.get("vnfd") or pkg_descriptor.get("vnfd:vnfd_catalog")) + ) or ( + pkgtype == "ns" + and (pkg_descriptor.get("nsd") or pkg_descriptor.get("nsd:nsd_catalog")) + ): + raise ClientException("Wrong Package type") return pkg_descriptor - def repo_index(self, origin=".", destination='.'): - """ - Repo Index main function - :param origin: origin directory for getting all the artifacts - :param destination: destination folder for create and index the valid artifacts + def repo_index(self, origin=".", destination="."): + """ + Repo Index main function + :param origin: origin directory for getting all the artifacts + :param destination: destination folder for create and index the valid artifacts """ self._logger.debug("Starting index composition") if destination == ".": if origin == destination: - destination = 'repository' + destination = "repository" destination = abspath(destination) origin = abspath(origin) self._logger.debug(f"Paths {destination}, {origin}") if origin[0] != "/": origin = join(getcwd(), origin) - if destination[0] != '/': + if destination[0] != "/": destination = join(getcwd(), destination) self.init_directory(destination) artifacts = [] directories = [] for f in listdir(origin): - if isfile(join(origin, f)) and f.endswith('.tar.gz'): + if isfile(join(origin, f)) and f.endswith(".tar.gz"): artifacts.append(f) - elif isdir(join(origin, f)) and f != destination.split('/')[-1] and not f.startswith('.'): - directories.append(f) # TODO: Document that nested directories are not supported + elif ( + isdir(join(origin, f)) + and f != destination.split("/")[-1] + and not f.startswith(".") + ): + directories.append( + f + ) # TODO: Document that nested directories are not supported else: self._logger.debug(f"Ignoring {f}") for artifact in artifacts: self.register_artifact_in_repository( join(origin, artifact), destination, source="artifact" @@ -201,13 +223,13 @@ + str(len(glob.glob(destination + "/nst/*/*/metadata.yaml"))) ) def md5(self, fname): """ - Checksum generator - :param fname: file path - :return: checksum string + Checksum generator + :param fname: file path + :return: checksum string """ self._logger.debug("") hash_md5 = hashlib.md5() with open(fname, "rb") as f: for chunk in iter(lambda: f.read(4096), b""): @@ -223,37 +245,43 @@ :return: fields """ self._logger.debug("") fields = {} - base_path = '/{}/'.format(package_type) + base_path = "/{}/".format(package_type) aux_dict = {} if package_type == "vnf": if descriptor_dict.get("vnfd-catalog", False): aux_dict = descriptor_dict.get("vnfd-catalog", {}).get("vnfd", [{}])[0] elif descriptor_dict.get("vnfd:vnfd-catalog"): - aux_dict = descriptor_dict.get("vnfd:vnfd-catalog", {}).get("vnfd", [{}])[0] + aux_dict = descriptor_dict.get("vnfd:vnfd-catalog", {}).get( + "vnfd", [{}] + )[0] elif descriptor_dict.get("vnfd"): aux_dict = descriptor_dict["vnfd"] if aux_dict.get("vnfd"): - aux_dict = aux_dict['vnfd'][0] + aux_dict = aux_dict["vnfd"][0] else: msg = f"Unexpected descriptor format {descriptor_dict}" self._logger.error(msg) raise ValueError(msg) - self._logger.debug(f"Extracted descriptor info for {package_type}: {aux_dict}") + self._logger.debug( + f"Extracted descriptor info for {package_type}: {aux_dict}" + ) images = [] - for vdu in aux_dict.get("vdu", aux_dict.get('kdu', ())): - images.append(vdu.get("image", vdu.get('name'))) + for vdu in aux_dict.get("vdu", aux_dict.get("kdu", ())): + images.append(vdu.get("image", vdu.get("name"))) fields["images"] = images elif package_type == "ns": if descriptor_dict.get("nsd-catalog", False): aux_dict = descriptor_dict.get("nsd-catalog", {}).get("nsd", [{}])[0] elif descriptor_dict.get("nsd:nsd-catalog"): - aux_dict = descriptor_dict.get("nsd:nsd-catalog", {}).get("nsd", [{}])[0] + aux_dict = descriptor_dict.get("nsd:nsd-catalog", {}).get("nsd", [{}])[ + 0 + ] elif descriptor_dict.get("nsd"): - aux_dict = descriptor_dict['nsd'] + aux_dict = descriptor_dict["nsd"] if aux_dict.get("nsd"): aux_dict = descriptor_dict["nsd"]["nsd"][0] else: msg = f"Unexpected descriptor format {descriptor_dict}" self._logger.error(msg) @@ -261,20 +289,22 @@ vnfs = [] if aux_dict.get("constituent-vnfd"): for vnf in aux_dict.get("constituent-vnfd", ()): vnfs.append(vnf.get("vnfd-id-ref")) else: - vnfs = aux_dict.get('vnfd-id') + vnfs = aux_dict.get("vnfd-id") self._logger.debug("Used VNFS in the NSD: " + str(vnfs)) fields["vnfd-id-ref"] = vnfs - elif package_type == 'nst': + elif package_type == "nst": if descriptor_dict.get("nst-catalog", False): aux_dict = descriptor_dict.get("nst-catalog", {}).get("nst", [{}])[0] elif descriptor_dict.get("nst:nst-catalog"): - aux_dict = descriptor_dict.get("nst:nst-catalog", {}).get("nst", [{}])[0] + aux_dict = descriptor_dict.get("nst:nst-catalog", {}).get("nst", [{}])[ + 0 + ] elif descriptor_dict.get("nst"): - aux_dict = descriptor_dict['nst'] + aux_dict = descriptor_dict["nst"] if aux_dict.get("nst"): aux_dict = descriptor_dict["nst"]["nst"][0] nsds = [] for nsd in aux_dict.get("netslice-subnet", ()): nsds.append(nsd.get("nsd-ref")) @@ -303,45 +333,45 @@ ) return fields def zip_extraction(self, file_name): """ - Validation of artifact. - :param file: file path - :return: status details, status, fields, package_type + Validation of artifact. + :param file: file path + :return: status details, status, fields, package_type """ self._logger.debug("Decompressing package file") - temp_file = '/tmp/{}'.format(file_name.split('/')[-1]) + temp_file = "/tmp/{}".format(file_name.split("/")[-1]) if file_name != temp_file: copyfile(file_name, temp_file) with tarfile.open(temp_file, "r:gz") as tar: - folder = tar.getnames()[0].split('/')[0] + folder = tar.getnames()[0].split("/")[0] tar.extractall() remove(temp_file) - descriptor_file = glob.glob('{}/*.y*ml'.format(folder))[0] + descriptor_file = glob.glob("{}/*.y*ml".format(folder))[0] return folder, descriptor_file def validate_artifact(self, path, source): """ Validation of artifact. :param path: file path :param source: flag to select the correct file type (directory or artifact) :return: status details, status, fields, package_type """ self._logger.debug("") - package_type = '' - folder = '' + package_type = "" + folder = "" try: - if source == 'directory': - descriptor_file = glob.glob('{}/*.y*ml'.format(path))[0] + if source == "directory": + descriptor_file = glob.glob("{}/*.y*ml".format(path))[0] else: folder, descriptor_file = self.zip_extraction(path) self._logger.debug("Opening descriptor file: {}".format(descriptor_file)) - with open(descriptor_file, 'r') as f: + with open(descriptor_file, "r") as f: descriptor_data = f.read() self._logger.debug(f"Descriptor data: {descriptor_data}") validation = validation_im() desc_type, descriptor_dict = validation.yaml_validation(descriptor_data) try: @@ -379,13 +409,13 @@ if folder: rmtree(folder, ignore_errors=True) def register_artifact_in_repository(self, path, destination, source): """ - Registration of one artifact in a repository - file: VNF or NS - destination: path for index creation + Registration of one artifact in a repository + file: VNF or NS + destination: path for index creation """ self._logger.debug("") pt = PackageTool() compressed = False try: @@ -402,70 +432,130 @@ compressed = True fields["checksum"] = self.md5(path) self.indexation(destination, path, package_type, fields) except Exception as e: - self._logger.exception("Error registering artifact in Repository: {}".format(e)) + self._logger.exception( + "Error registering artifact in Repository: {}".format(e) + ) finally: if source == "directory" and compressed: remove(path) def indexation(self, destination, path, package_type, fields): """ - Process for index packages - :param destination: index repository path - :param path: path of the package - :param package_type: package type (vnf, ns) - :param fields: dict with the required values - """ - self._logger.debug("") - data_ind = {'name': fields.get('name'), 'description': fields.get('description'), - 'vendor': fields.get('vendor'), 'path': fields.get('path')} - - final_path = join(destination, package_type, fields.get('id'), fields.get('version')) - if isdir(join(destination, package_type, fields.get('id'))): + Process for index packages + :param destination: index repository path + :param path: path of the package + :param package_type: package type (vnf, ns) + :param fields: dict with the required values + """ + self._logger.debug("") + data_ind = { + "name": fields.get("name"), + "description": fields.get("description"), + "vendor": fields.get("vendor"), + "path": fields.get("path"), + } + + final_path = join( + destination, package_type, fields.get("id"), fields.get("version") + ) + if isdir(join(destination, package_type, fields.get("id"))): if isdir(final_path): - self._logger.warning('{} {} already exists'.format(package_type.upper(), str(path))) + self._logger.warning( + "{} {} already exists".format(package_type.upper(), str(path)) + ) else: mkdir(final_path) - copyfile(path, - final_path + '/' + fields.get('id') + "-" + fields.get('version') + '.tar.gz') - yaml.safe_dump(fields, open(final_path + '/' + 'metadata.yaml', 'w'), - default_flow_style=False, width=80, indent=4) - index = yaml.safe_load(open(destination + '/index.yaml')) - - index['{}_packages'.format(package_type)][fields.get('id')][fields.get('version')] = data_ind - if versioning.parse(index['{}_packages'.format(package_type)][fields.get('id')][ - 'latest']) < versioning.parse(fields.get('version')): - index['{}_packages'.format(package_type)][fields.get('id')]['latest'] = fields.get( - 'version') - yaml.safe_dump(index, open(destination + '/index.yaml', 'w'), - default_flow_style=False, width=80, indent=4) - self._logger.info('{} {} added in the repository'.format(package_type.upper(), str(path))) + copyfile( + path, + final_path + + "/" + + fields.get("id") + + "-" + + fields.get("version") + + ".tar.gz", + ) + yaml.safe_dump( + fields, + open(final_path + "/" + "metadata.yaml", "w"), + default_flow_style=False, + width=80, + indent=4, + ) + index = yaml.safe_load(open(destination + "/index.yaml")) + + index["{}_packages".format(package_type)][fields.get("id")][ + fields.get("version") + ] = data_ind + if versioning.parse( + index["{}_packages".format(package_type)][fields.get("id")][ + "latest" + ] + ) < versioning.parse(fields.get("version")): + index["{}_packages".format(package_type)][fields.get("id")][ + "latest" + ] = fields.get("version") + yaml.safe_dump( + index, + open(destination + "/index.yaml", "w"), + default_flow_style=False, + width=80, + indent=4, + ) + self._logger.info( + "{} {} added in the repository".format( + package_type.upper(), str(path) + ) + ) else: - mkdir(destination + '/{}/'.format(package_type) + fields.get('id')) + mkdir(destination + "/{}/".format(package_type) + fields.get("id")) mkdir(final_path) - copyfile(path, - final_path + '/' + fields.get('id') + "-" + fields.get('version') + '.tar.gz') - yaml.safe_dump(fields, open(join(final_path, 'metadata.yaml'), 'w'), - default_flow_style=False, width=80, indent=4) - index = yaml.safe_load(open(destination + '/index.yaml')) - - index['{}_packages'.format(package_type)][fields.get('id')] = {fields.get('version'): data_ind} - index['{}_packages'.format(package_type)][fields.get('id')]['latest'] = fields.get('version') - yaml.safe_dump(index, open(join(destination, 'index.yaml'), 'w'), - default_flow_style=False, width=80, indent=4) - self._logger.info('{} {} added in the repository'.format(package_type.upper(), str(path))) + copyfile( + path, + final_path + + "/" + + fields.get("id") + + "-" + + fields.get("version") + + ".tar.gz", + ) + yaml.safe_dump( + fields, + open(join(final_path, "metadata.yaml"), "w"), + default_flow_style=False, + width=80, + indent=4, + ) + index = yaml.safe_load(open(destination + "/index.yaml")) + + index["{}_packages".format(package_type)][fields.get("id")] = { + fields.get("version"): data_ind + } + index["{}_packages".format(package_type)][fields.get("id")][ + "latest" + ] = fields.get("version") + yaml.safe_dump( + index, + open(join(destination, "index.yaml"), "w"), + default_flow_style=False, + width=80, + indent=4, + ) + self._logger.info( + "{} {} added in the repository".format(package_type.upper(), str(path)) + ) def current_datetime(self): """ - Datetime Generator - :return: Datetime as string with the following structure "2020-04-29T08:41:07.681653Z" - """ - self._logger.debug("") - return time.strftime('%Y-%m-%dT%H:%M:%S.%sZ') + Datetime Generator + :return: Datetime as string with the following structure "2020-04-29T08:41:07.681653Z" + """ + self._logger.debug("") + return time.strftime("%Y-%m-%dT%H:%M:%S.%sZ") def init_directory(self, destination): """ Initialize the index directory. Creation of index.yaml, and the directories for vnf and ns :param destination: would reformat osmclient/sol005/osmrepo.py --- osmclient/v1/key.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/v1/key.py 2021-12-14 16:49:41.447022 +0000 @@ -22,20 +22,19 @@ import pycurl from io import BytesIO class Key(object): - def __init__(self, client=None): self._client = client def list(self): data = BytesIO() - curl_cmd = self._client.get_curl_cmd('v1/api/config/key-pair?deep') + curl_cmd = self._client.get_curl_cmd("v1/api/config/key-pair?deep") curl_cmd.setopt(pycurl.HTTPGET, 1) curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write) curl_cmd.perform() curl_cmd.close() resp = json.loads(data.getvalue().decode()) - if 'nsr:key-pair' in resp: - return resp['nsr:key-pair'] + if "nsr:key-pair" in resp: + return resp["nsr:key-pair"] return list() would reformat osmclient/v1/key.py --- osmclient/sol005/role.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/role.py 2021-12-14 16:49:41.700430 +0000 @@ -30,16 +30,17 @@ class Role(object): def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/admin' - self._apiVersion = '/v1' - self._apiResource = '/roles' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/admin" + self._apiVersion = "/v1" + self._apiResource = "/roles" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) def create(self, name, permissions): """ Creates a new OSM role. @@ -54,31 +55,36 @@ if permissions: role_permissions = yaml.safe_load(permissions) if not isinstance(role_permissions, dict): - raise ClientException('Role permissions should be provided in a key-value fashion') + raise ClientException( + "Role permissions should be provided in a key-value fashion" + ) for key, value in role_permissions.items(): if not isinstance(value, bool): - raise ClientException("Value of '{}' in a role permissions should be boolean".format(key)) + raise ClientException( + "Value of '{}' in a role permissions should be boolean".format( + key + ) + ) role["permissions"] = role_permissions - http_code, resp = self._http.post_cmd(endpoint=self._apiBase, - postfields_dict=role, - skip_query_admin=True) + http_code, resp = self._http.post_cmd( + endpoint=self._apiBase, postfields_dict=role, skip_query_admin=True + ) # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('Unexpected response from server - {}'.format( - resp)) - print(resp['id']) - #else: + if not resp or "id" not in resp: + raise ClientException("Unexpected response from server - {}".format(resp)) + print(resp["id"]) + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: @@ -100,71 +106,84 @@ :raises ClientException: when fails updating a role. """ self._logger.debug("") self._client.get_token() if new_name is None and permissions is None and add is None and remove is None: - raise ClientException('At least one option should be provided') + raise ClientException("At least one option should be provided") elif permissions and (add or remove): - raise ClientException('permissions and add/remove are mutually exclusive') + raise ClientException("permissions and add/remove are mutually exclusive") role_obj = self.get(name) new_role_obj = {"permissions": {}} if new_name: new_role_obj["name"] = new_name if permissions: role_definition = yaml.safe_load(permissions) if not isinstance(role_definition, dict): - raise ClientException('Role permissions should be provided in a key-value fashion') + raise ClientException( + "Role permissions should be provided in a key-value fashion" + ) for key, value in role_definition.items(): if not isinstance(value, bool) and value is not None: - raise ClientException('Value in a role permissions should be boolean or None to remove') + raise ClientException( + "Value in a role permissions should be boolean or None to remove" + ) new_role_obj["permissions"] = role_definition else: if remove: keys_from_remove = yaml.safe_load(remove) if not isinstance(keys_from_remove, list): - raise ClientException('Keys should be provided in a list fashion') + raise ClientException("Keys should be provided in a list fashion") for key in keys_from_remove: if not isinstance(key, str): - raise ClientException('Individual keys should be strings') + raise ClientException("Individual keys should be strings") new_role_obj["permissions"][key] = None if add: add_roles = yaml.safe_load(add) if not isinstance(add_roles, dict): - raise ClientException('Add should be provided in a key-value fashion') + raise ClientException( + "Add should be provided in a key-value fashion" + ) for key, value in add_roles.items(): if not isinstance(value, bool): - raise ClientException("Value '{}' in a role permissions should be boolean".format(key)) + raise ClientException( + "Value '{}' in a role permissions should be boolean".format( + key + ) + ) new_role_obj["permissions"][key] = value if not new_role_obj["permissions"]: del new_role_obj["permissions"] - http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase, role_obj['_id']), - postfields_dict=new_role_obj, - skip_query_admin=True) + http_code, resp = self._http.patch_cmd( + endpoint="{}/{}".format(self._apiBase, role_obj["_id"]), + postfields_dict=new_role_obj, + skip_query_admin=True, + ) # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) if http_code in (200, 201, 202): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('Unexpected response from server - {}'.format( - resp)) - print(resp['id']) + if not resp or "id" not in resp: + raise ClientException( + "Unexpected response from server - {}".format(resp) + ) + print(resp["id"]) elif http_code == 204: print("Updated") - #else: + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: @@ -180,24 +199,25 @@ :raises ClientException: when fails to delete a role. """ self._logger.debug("") self._client.get_token() role = self.get(name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - role['_id'], querystring), - skip_query_admin=True) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, role["_id"], querystring), + skip_query_admin=True, + ) # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) if http_code == 202: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') - elif resp and 'result' in resp: - print('Deleted') + print("Deleted") + elif resp and "result" in resp: + print("Deleted") else: msg = resp or "" # if resp: # try: # msg = json.loads(resp) @@ -212,14 +232,16 @@ :param filter: :returns: """ self._logger.debug("") self._client.get_token() - filter_string = '' + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase, filter_string),skip_query_admin=True) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd( + "{}{}".format(self._apiBase, filter_string), skip_query_admin=True + ) # print('RESP: {}'.format(resp)) if resp: return json.loads(resp) return list() @@ -233,13 +255,12 @@ """ self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for role in self.list(): - if name == role['_id']: + if name == role["_id"]: return role else: for role in self.list(): - if name == role['name']: + if name == role["name"]: return role raise NotFound("Role {} not found".format(name)) - would reformat osmclient/sol005/role.py --- osmclient/sol005/user.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/user.py 2021-12-14 16:49:41.828865 +0000 @@ -27,23 +27,25 @@ class User(object): def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/admin' - self._apiVersion = '/v1' - self._apiResource = '/users' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/admin" + self._apiVersion = "/v1" + self._apiResource = "/users" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) def create(self, name, user): - """Creates a new OSM user - """ - self._logger.debug("") - self._client.get_token() - if not user["projects"] or (len(user["projects"]) == 1 and not user["projects"][0]): + """Creates a new OSM user""" + self._logger.debug("") + self._client.get_token() + if not user["projects"] or ( + len(user["projects"]) == 1 and not user["projects"][0] + ): del user["projects"] elif len(user["projects"]) == 1: user["projects"] = user["projects"][0].split(",") if user["project_role_mappings"]: @@ -60,34 +62,32 @@ project_role_mappings.append(mapping) user["project_role_mappings"] = project_role_mappings else: del user["project_role_mappings"] - http_code, resp = self._http.post_cmd(endpoint=self._apiBase, - postfields_dict=user, - skip_query_admin=True) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + http_code, resp = self._http.post_cmd( + endpoint=self._apiBase, postfields_dict=user, skip_query_admin=True + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format( - resp)) - print(resp['id']) - #else: + if not resp or "id" not in resp: + raise ClientException("unexpected response from server - {}".format(resp)) + print(resp["id"]) + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException("failed to create user {} - {}".format(name, msg)) def update(self, name, user): - """Updates an existing OSM user identified by name - """ + """Updates an existing OSM user identified by name""" self._logger.debug("") self._client.get_token() # print(user) myuser = self.get(name) update_user = { @@ -111,28 +111,37 @@ update_user["remove_project_role_mappings"].append({"project": project}) for role in roles: mapping = {"project": project, "role": role} update_user["add_project_role_mappings"].append(mapping) - + if user["remove-project"]: for remove_project in user["remove-project"]: - update_user["remove_project_role_mappings"].append({"project": remove_project}) + update_user["remove_project_role_mappings"].append( + {"project": remove_project} + ) if user["add-project-role"]: for add_project_role in user["add-project-role"]: - add_project_role_clean = [m.strip() for m in add_project_role.split(",")] + add_project_role_clean = [ + m.strip() for m in add_project_role.split(",") + ] project, roles = add_project_role_clean[0], add_project_role_clean[1:] for role in roles: mapping = {"project": project, "role": role} update_user["add_project_role_mappings"].append(mapping) if user["remove-project-role"]: for remove_project_role in user["remove-project-role"]: - remove_project_role_clean = [m.strip() for m in remove_project_role.split(",")] - project, roles = remove_project_role_clean[0], remove_project_role_clean[1:] + remove_project_role_clean = [ + m.strip() for m in remove_project_role.split(",") + ] + project, roles = ( + remove_project_role_clean[0], + remove_project_role_clean[1:], + ) for role in roles: mapping = {"project": project, "role": role} update_user["remove_project_role_mappings"].append(mapping) @@ -141,85 +150,89 @@ if not update_user["add_project_role_mappings"]: del update_user["add_project_role_mappings"] if not update_user: raise ClientException("At least something should be changed.") - http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase, myuser['_id']), - postfields_dict=update_user, skip_query_admin=True) + http_code, resp = self._http.patch_cmd( + endpoint="{}/{}".format(self._apiBase, myuser["_id"]), + postfields_dict=update_user, + skip_query_admin=True, + ) # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) if http_code in (200, 201, 202): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format( - resp)) - print(resp['id']) + if not resp or "id" not in resp: + raise ClientException( + "unexpected response from server - {}".format(resp) + ) + print(resp["id"]) elif http_code == 204: - print('Updated') - #else: + print("Updated") + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp # raise ClientException("failed to update user {} - {}".format(name, msg)) def delete(self, name, force=False): - """Deletes an existing OSM user identified by name - """ + """Deletes an existing OSM user identified by name""" self._logger.debug("") self._client.get_token() user = self.get(name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - user['_id'], querystring), skip_query_admin=True) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, user["_id"], querystring), + skip_query_admin=True, + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) if http_code == 202: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') - elif resp and 'result' in resp: - print('Deleted') + print("Deleted") + elif resp and "result" in resp: + print("Deleted") else: msg = resp or "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp raise ClientException("failed to delete user {} - {}".format(name, msg)) def list(self, filter=None): - """Returns the list of OSM users - """ - self._logger.debug("") - self._client.get_token() - filter_string = '' + """Returns the list of OSM users""" + self._logger.debug("") + self._client.get_token() + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string), skip_query_admin=True) - #print('RESP: {}'.format(resp)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd( + "{}{}".format(self._apiBase, filter_string), skip_query_admin=True + ) + # print('RESP: {}'.format(resp)) if resp: return json.loads(resp) return list() def get(self, name): - """Returns an OSM user based on name or id - """ + """Returns an OSM user based on name or id""" self._logger.debug("") self._client.get_token() # keystone with external LDAP contains large ids, not uuid format # utils.validate_uuid4(name) cannot be used user_list = self.list() for user in user_list: - if name == user['_id']: + if name == user["_id"]: return user for user in user_list: - if name == user['username']: + if name == user["username"]: return user raise NotFound("User {} not found".format(name)) - would reformat osmclient/sol005/user.py --- osmclient/v1/nsd.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/v1/nsd.py 2021-12-14 16:49:41.968861 +0000 @@ -21,40 +21,42 @@ from osmclient.common.exceptions import NotFound from osmclient.common.exceptions import ClientException class Nsd(object): - def __init__(self, http=None, client=None): self._http = http self._client = client def list(self): - resp = self._http.get_cmd('api/running/{}nsd-catalog/nsd' - .format(self._client.so_rbac_project_path)) - - if self._client._so_version == 'v3': - if resp and 'project-nsd:nsd' in resp: - return resp['project-nsd:nsd'] + resp = self._http.get_cmd( + "api/running/{}nsd-catalog/nsd".format(self._client.so_rbac_project_path) + ) + + if self._client._so_version == "v3": + if resp and "project-nsd:nsd" in resp: + return resp["project-nsd:nsd"] else: # Backwards Compatibility - if resp and 'nsd:nsd' in resp: - return resp['nsd:nsd'] + if resp and "nsd:nsd" in resp: + return resp["nsd:nsd"] return list() def get(self, name): for nsd in self.list(): - if name == nsd['name']: + if name == nsd["name"]: return nsd raise NotFound("cannot find nsd {}".format(name)) def delete(self, nsd_name): nsd = self.get(nsd_name) if nsd is None: raise NotFound("cannot find nsd {}".format(nsd_name)) resp = self._http.delete_cmd( - 'api/running/{}nsd-catalog/nsd/{}' - .format(self._client.so_rbac_project_path, nsd['id'])) - if 'success' not in resp: + "api/running/{}nsd-catalog/nsd/{}".format( + self._client.so_rbac_project_path, nsd["id"] + ) + ) + if "success" not in resp: raise ClientException("failed to delete nsd {}".format(nsd_name)) would reformat osmclient/v1/nsd.py --- osmclient/v1/tests/test_ns.py 2021-12-14 16:49:03.494514 +0000 +++ osmclient/v1/tests/test_ns.py 2021-12-14 16:49:42.290498 +0000 @@ -19,26 +19,33 @@ from osmclient.v1 import ns from osmclient.v1 import client from osmclient.common.exceptions import NotFound -class TestNs(unittest.TestCase): +class TestNs(unittest.TestCase): def test_list_empty(self): mock = Mock() mock.get_cmd.return_value = list() - assert len(ns.Ns(mock, client=client.Client(host='127.0.0.1')).list()) == 0 + assert len(ns.Ns(mock, client=client.Client(host="127.0.0.1")).list()) == 0 def test_get_notfound(self): mock = Mock() - mock.get_cmd.return_value = 'foo' - self.assertRaises(NotFound, ns.Ns(mock, client=client.Client(host='127.0.0.1')).get, 'bar') + mock.get_cmd.return_value = "foo" + self.assertRaises( + NotFound, ns.Ns(mock, client=client.Client(host="127.0.0.1")).get, "bar" + ) def test_get_found(self): mock = Mock() - mock.get_cmd.return_value = {'nsr:ns-instance-config': - {'nsr': [{'name': 'foo'}]}} - assert ns.Ns(mock, client=client.Client(host='127.0.0.1')).get('foo') + mock.get_cmd.return_value = { + "nsr:ns-instance-config": {"nsr": [{"name": "foo"}]} + } + assert ns.Ns(mock, client=client.Client(host="127.0.0.1")).get("foo") def test_get_monitoring_notfound(self): mock = Mock() - mock.get_cmd.return_value = 'foo' - self.assertRaises(NotFound, ns.Ns(mock, client=client.Client(host='127.0.0.1')).get_monitoring, 'bar') + mock.get_cmd.return_value = "foo" + self.assertRaises( + NotFound, + ns.Ns(mock, client=client.Client(host="127.0.0.1")).get_monitoring, + "bar", + ) would reformat osmclient/v1/tests/test_ns.py --- osmclient/v1/tests/test_nsd.py 2021-12-14 16:49:03.494514 +0000 +++ osmclient/v1/tests/test_nsd.py 2021-12-14 16:49:42.471690 +0000 @@ -23,20 +23,22 @@ class TestNsd(unittest.TestCase): def test_list_empty(self): mock = Mock() mock.get_cmd.return_value = list() - assert len(nsd.Nsd(mock, client=client.Client(host='127.0.0.1')).list()) == 0 + assert len(nsd.Nsd(mock, client=client.Client(host="127.0.0.1")).list()) == 0 def test_get_notfound(self): mock = Mock() - mock.get_cmd.return_value = 'foo' - self.assertRaises(NotFound, nsd.Nsd(mock, client=client.Client(host='127.0.0.1')).get, 'bar') + mock.get_cmd.return_value = "foo" + self.assertRaises( + NotFound, nsd.Nsd(mock, client=client.Client(host="127.0.0.1")).get, "bar" + ) def test_get_found(self): mock = Mock() - if client.Client(host='127.0.0.1')._so_version == 'v3': - mock.get_cmd.return_value = {'project-nsd:nsd': [{'name': 'foo'}]} + if client.Client(host="127.0.0.1")._so_version == "v3": + mock.get_cmd.return_value = {"project-nsd:nsd": [{"name": "foo"}]} else: # Backwards Compatibility - mock.get_cmd.return_value = {'nsd:nsd': [{'name': 'foo'}]} - assert nsd.Nsd(mock, client=client.Client(host='127.0.0.1')).get('foo') + mock.get_cmd.return_value = {"nsd:nsd": [{"name": "foo"}]} + assert nsd.Nsd(mock, client=client.Client(host="127.0.0.1")).get("foo") would reformat osmclient/v1/tests/test_nsd.py --- osmclient/v1/package.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/v1/package.py 2021-12-14 16:49:42.662451 +0000 @@ -28,13 +28,13 @@ self._client = client self._http = http self._upload_http = upload_http def _wait_for_package(self, pkg_type): - if 'vnfd' in pkg_type['type']: + if "vnfd" in pkg_type["type"]: get_method = self._client.vnfd.get - elif 'nsd' in pkg_type['type']: + elif "nsd" in pkg_type["type"]: get_method = self._client.nsd.get else: raise ClientException("no valid package type found") # helper method to check if pkg exists @@ -43,29 +43,28 @@ func() except NotFound: return False return True - return utils.wait_for_value(lambda: - check_exists(lambda: - get_method(pkg_type['name']))) + return utils.wait_for_value( + lambda: check_exists(lambda: get_method(pkg_type["name"])) + ) def get_key_val_from_pkg(self, descriptor_file): return utils.get_key_val_from_pkg(descriptor_file) def wait_for_upload(self, filename): """wait(block) for an upload to succeed. - The filename passed is assumed to be a descriptor tarball. + The filename passed is assumed to be a descriptor tarball. """ pkg_type = utils.get_key_val_from_pkg(filename) if pkg_type is None: raise ClientException("Cannot determine package type") if not self._wait_for_package(pkg_type): - raise ClientException("package {} failed to upload" - .format(filename)) + raise ClientException("package {} failed to upload".format(filename)) def upload(self, filename): - resp = self._upload_http.post_cmd(formfile=('package', filename)) - if not resp or 'transaction_id' not in resp: + resp = self._upload_http.post_cmd(formfile=("package", filename)) + if not resp or "transaction_id" not in resp: raise ClientException("failed to upload package") would reformat osmclient/v1/package.py --- osmclient/v1/client.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/v1/client.py 2021-12-14 16:49:42.740322 +0000 @@ -29,100 +29,95 @@ from osmclient.common import http from osmclient.common import package_tool class Client(object): - def __init__( self, host=None, so_port=8008, - so_project='default', + so_project="default", ro_host=None, ro_port=9090, upload_port=8443, - **kwargs): - self._user = 'admin' - self._password = 'admin' + **kwargs + ): + self._user = "admin" + self._password = "admin" - if len(host.split(':')) > 1: + if len(host.split(":")) > 1: # backwards compatible, port provided as part of host - self._host = host.split(':')[0] - self._so_port = host.split(':')[1] + self._host = host.split(":")[0] + self._so_port = host.split(":")[1] else: self._host = host self._so_port = so_port self._so_project = so_project - http_client = http.Http( - 'https://{}:{}/'.format( - self._host, - self._so_port)) + http_client = http.Http("https://{}:{}/".format(self._host, self._so_port)) http_client.set_http_header( - ['Accept: application/vnd.yand.data+json', - 'Content-Type: application/json']) + ["Accept: application/vnd.yand.data+json", "Content-Type: application/json"] + ) self._so_version = self.get_so_version(http_client) if ro_host is None: ro_host = host - ro_http_client = http.Http('http://{}:{}/'.format(ro_host, ro_port)) + ro_http_client = http.Http("http://{}:{}/".format(ro_host, ro_port)) ro_http_client.set_http_header( - ['Accept: application/vnd.yand.data+json', - 'Content-Type: application/json']) + ["Accept: application/vnd.yand.data+json", "Content-Type: application/json"] + ) - upload_client_url = 'https://{}:{}/composer/upload?api_server={}{}'.format( - self._host, - upload_port, - 'https://localhost&upload_server=https://', - self._host) + upload_client_url = "https://{}:{}/composer/upload?api_server={}{}".format( + self._host, + upload_port, + "https://localhost&upload_server=https://", + self._host, + ) - if self._so_version == 'v3': - upload_client_url = 'https://{}:{}/composer/upload?api_server={}{}&project_name={}'.format( - self._host, - upload_port, - 'https://localhost&upload_server=https://', - self._host, - self._so_project) + if self._so_version == "v3": + upload_client_url = ( + "https://{}:{}/composer/upload?api_server={}{}&project_name={}".format( + self._host, + upload_port, + "https://localhost&upload_server=https://", + self._host, + self._so_project, + ) + ) upload_client = http.Http(upload_client_url) self.vnf = vnf.Vnf(http_client, client=self, **kwargs) self.vnfd = vnfd.Vnfd(http_client, client=self, **kwargs) self.ns = ns.Ns(http=http_client, client=self, **kwargs) self.nsd = nsd.Nsd(http_client, client=self, **kwargs) self.vim = vim.Vim( - http=http_client, - ro_http=ro_http_client, - client=self, - **kwargs) + http=http_client, ro_http=ro_http_client, client=self, **kwargs + ) self.package = package.Package( - http=http_client, - upload_http=upload_client, - client=self, - **kwargs) + http=http_client, upload_http=upload_client, client=self, **kwargs + ) self.vca = vca.Vca(http_client, client=self, **kwargs) self.utils = utils.Utils(http_client, **kwargs) self.package_tool = package_tool.PackageTool(client=self) @property def so_rbac_project_path(self): - if self._so_version == 'v3': - return 'project/{}/'.format(self._so_project) + if self._so_version == "v3": + return "project/{}/".format(self._so_project) else: - return '' + return "" def get_so_version(self, http_client): try: - resp = http_client.get_cmd('api/operational/version') - if not resp or 'rw-base:version' not in resp: - return 'v2' + resp = http_client.get_cmd("api/operational/version") + if not resp or "rw-base:version" not in resp: + return "v2" - if resp['rw-base:version']['version'].split('.')[0] == '5': + if resp["rw-base:version"]["version"].split(".")[0] == "5": # SO Version 5.x.x.x.x translates to OSM V3 - return 'v3' - return 'v2' + return "v3" + return "v2" except Exception: - return 'v2' - - + return "v2" would reformat osmclient/v1/client.py --- osmclient/v1/tests/test_package.py 2021-12-14 16:49:03.494514 +0000 +++ osmclient/v1/tests/test_package.py 2021-12-14 16:49:42.786241 +0000 @@ -19,22 +19,23 @@ from osmclient.v1 import package from osmclient.common.exceptions import ClientException class TestPackage(unittest.TestCase): - def test_upload_fail(self): mock = Mock() - mock.post_cmd.return_value = 'foo' - self.assertRaises(ClientException, - package.Package(upload_http=mock).upload, 'bar') + mock.post_cmd.return_value = "foo" + self.assertRaises( + ClientException, package.Package(upload_http=mock).upload, "bar" + ) mock.post_cmd.return_value = None - self.assertRaises(ClientException, - package.Package(upload_http=mock).upload, 'bar') + self.assertRaises( + ClientException, package.Package(upload_http=mock).upload, "bar" + ) def test_wait_for_upload_bad_file(self): mock = Mock() - mock.post_cmd.return_value = 'foo' - self.assertRaises(IOError, - package.Package(upload_http=mock).wait_for_upload, - 'invalidfile') + mock.post_cmd.return_value = "foo" + self.assertRaises( + IOError, package.Package(upload_http=mock).wait_for_upload, "invalidfile" + ) would reformat osmclient/v1/tests/test_package.py --- osmclient/v1/tests/test_vnf.py 2021-12-14 16:49:03.494514 +0000 +++ osmclient/v1/tests/test_vnf.py 2021-12-14 16:49:42.933649 +0000 @@ -23,27 +23,36 @@ class TestVnf(unittest.TestCase): def test_list_empty(self): mock = Mock() mock.get_cmd.return_value = list() - assert len(vnf.Vnf(mock, client=client.Client(host='127.0.0.1')).list()) == 0 + assert len(vnf.Vnf(mock, client=client.Client(host="127.0.0.1")).list()) == 0 def test_get_notfound(self): mock = Mock() - mock.get_cmd.return_value = 'foo' - self.assertRaises(NotFound, vnf.Vnf(mock, client=client.Client(host='127.0.0.1')).get, 'bar') + mock.get_cmd.return_value = "foo" + self.assertRaises( + NotFound, vnf.Vnf(mock, client=client.Client(host="127.0.0.1")).get, "bar" + ) def test_get_found(self): mock = Mock() - mock.get_cmd.return_value = {'vnfr:vnfr': [{'name': 'foo'}]} - assert vnf.Vnf(mock, client=client.Client(host='127.0.0.1')).get('foo') + mock.get_cmd.return_value = {"vnfr:vnfr": [{"name": "foo"}]} + assert vnf.Vnf(mock, client=client.Client(host="127.0.0.1")).get("foo") def test_get_monitoring_notfound(self): mock = Mock() - mock.get_cmd.return_value = 'foo' - self.assertRaises(NotFound, vnf.Vnf(mock, client=client.Client(host='127.0.0.1')).get_monitoring, 'bar') + mock.get_cmd.return_value = "foo" + self.assertRaises( + NotFound, + vnf.Vnf(mock, client=client.Client(host="127.0.0.1")).get_monitoring, + "bar", + ) def test_get_monitoring_found(self): mock = Mock() - mock.get_cmd.return_value = {'vnfr:vnfr': [{'name': 'foo', - 'monitoring-param': True}]} - assert vnf.Vnf(mock, client=client.Client(host='127.0.0.1')).get_monitoring('foo') + mock.get_cmd.return_value = { + "vnfr:vnfr": [{"name": "foo", "monitoring-param": True}] + } + assert vnf.Vnf(mock, client=client.Client(host="127.0.0.1")).get_monitoring( + "foo" + ) would reformat osmclient/v1/tests/test_vnf.py --- osmclient/v1/utils.py 2021-12-14 16:49:03.494514 +0000 +++ osmclient/v1/utils.py 2021-12-14 16:49:43.207008 +0000 @@ -22,9 +22,9 @@ class Utils(object): def __init__(self, http=None): self._http = http def get_vcs_info(self): - resp = self._http.get_cmd('api/operational/vcs/info') + resp = self._http.get_cmd("api/operational/vcs/info") if resp: - return resp['rw-base:info']['components']['component_info'] + return resp["rw-base:info"]["components"]["component_info"] return list() --- osmclient/sol005/wim.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/wim.py 2021-12-14 16:49:43.259175 +0000 @@ -29,80 +29,81 @@ class Wim(object): def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/admin' - self._apiVersion = '/v1' - self._apiResource = '/wim_accounts' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/admin" + self._apiVersion = "/v1" + self._apiResource = "/wim_accounts" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) # WIM '--wait' option def _wait(self, id, wait_time, deleteFlag=False): self._logger.debug("") self._client.get_token() # Endpoint to get operation status - apiUrlStatus = '{}{}{}'.format(self._apiName, self._apiVersion, '/wim_accounts') + apiUrlStatus = "{}{}{}".format(self._apiName, self._apiVersion, "/wim_accounts") # Wait for status for WIM instance creation/deletion if isinstance(wait_time, bool): wait_time = WaitForStatus.TIMEOUT_WIM_OPERATION WaitForStatus.wait_for_status( - 'WIM', + "WIM", str(id), wait_time, apiUrlStatus, self._http.get2_cmd, - deleteFlag=deleteFlag) + deleteFlag=deleteFlag, + ) def _get_id_for_wait(self, name): - """Returns id of name, or the id itself if given as argument - """ + """Returns id of name, or the id itself if given as argument""" self._logger.debug("") for wim in self.list(): - if name == wim['uuid']: - return wim['uuid'] + if name == wim["uuid"]: + return wim["uuid"] for wim in self.list(): - if name == wim['name']: - return wim['uuid'] - return '' + if name == wim["name"]: + return wim["uuid"] + return "" def create(self, name, wim_input, wim_port_mapping=None, wait=False): self._logger.debug("") self._client.get_token() - if 'wim_type' not in wim_input: + if "wim_type" not in wim_input: raise Exception("wim type not provided") wim_account = wim_input wim_account["name"] = name wim_config = {} - if 'config' in wim_input and wim_input['config'] is not None: - wim_config = yaml.safe_load(wim_input['config']) + if "config" in wim_input and wim_input["config"] is not None: + wim_config = yaml.safe_load(wim_input["config"]) if wim_port_mapping: - with open(wim_port_mapping, 'r') as f: - wim_config['wim_port_mapping'] = yaml.safe_load(f.read()) + with open(wim_port_mapping, "r") as f: + wim_config["wim_port_mapping"] = yaml.safe_load(f.read()) if wim_config: - wim_account['config'] = wim_config - #wim_account['config'] = json.dumps(wim_config) - - http_code, resp = self._http.post_cmd(endpoint=self._apiBase, - postfields_dict=wim_account) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + wim_account["config"] = wim_config + # wim_account['config'] = json.dumps(wim_config) + + http_code, resp = self._http.post_cmd( + endpoint=self._apiBase, postfields_dict=wim_account + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server - {}'.format( - resp)) + if not resp or "id" not in resp: + raise ClientException("unexpected response from server - {}".format(resp)) if wait: # Wait for status for WIM instance creation - self._wait(resp.get('id'), wait) - print(resp['id']) - #else: + self._wait(resp.get("id"), wait) + print(resp["id"]) + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: @@ -113,36 +114,40 @@ self._logger.debug("") self._client.get_token() wim = self.get(wim_name) wim_id_for_wait = self._get_id_for_wait(wim_name) wim_config = {} - if 'config' in wim_account: - if wim_account.get('config')=="" and (wim_port_mapping): - raise ClientException("clearing config is incompatible with updating SDN info") - if wim_account.get('config')=="": + if "config" in wim_account: + if wim_account.get("config") == "" and (wim_port_mapping): + raise ClientException( + "clearing config is incompatible with updating SDN info" + ) + if wim_account.get("config") == "": wim_config = None else: - wim_config = yaml.safe_load(wim_account['config']) + wim_config = yaml.safe_load(wim_account["config"]) if wim_port_mapping: - with open(wim_port_mapping, 'r') as f: - wim_config['wim_port_mapping'] = yaml.safe_load(f.read()) - wim_account['config'] = wim_config - #wim_account['config'] = json.dumps(wim_config) - http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase,wim['_id']), - postfields_dict=wim_account) - #print('HTTP CODE: {}'.format(http_code)) - #print('RESP: {}'.format(resp)) - #if http_code in (200, 201, 202, 204): + with open(wim_port_mapping, "r") as f: + wim_config["wim_port_mapping"] = yaml.safe_load(f.read()) + wim_account["config"] = wim_config + # wim_account['config'] = json.dumps(wim_config) + http_code, resp = self._http.patch_cmd( + endpoint="{}/{}".format(self._apiBase, wim["_id"]), + postfields_dict=wim_account, + ) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # if http_code in (200, 201, 202, 204): if wait: # In this case, 'resp' always returns None, so 'resp['id']' cannot be used. # Use the previously obtained id instead. wait_id = wim_id_for_wait # Wait for status for WIM instance update self._wait(wait_id, wait) # else: # pass - #else: + # else: # msg = "" # if resp: # try: # msg = json.loads(resp) # except ValueError: @@ -150,94 +155,95 @@ # raise ClientException("failed to update wim {} - {}".format(wim_name, msg)) def update_wim_account_dict(self, wim_account, wim_input): self._logger.debug("") self._logger.debug(str(wim_input)) - wim_account['wim_type'] = wim_input['wim_type'] - wim_account['description'] = wim_input['description'] - wim_account['wim_url'] = wim_input['url'] - wim_account['user'] = wim_input.get('wim-username') - wim_account['password'] = wim_input.get('wim-password') + wim_account["wim_type"] = wim_input["wim_type"] + wim_account["description"] = wim_input["description"] + wim_account["wim_url"] = wim_input["url"] + wim_account["user"] = wim_input.get("wim-username") + wim_account["password"] = wim_input.get("wim-password") return wim_account def get_id(self, name): - """Returns a WIM id from a WIM name - """ + """Returns a WIM id from a WIM name""" self._logger.debug("") for wim in self.list(): - if name == wim['name']: - return wim['uuid'] + if name == wim["name"]: + return wim["uuid"] raise NotFound("wim {} not found".format(name)) def delete(self, wim_name, force=False, wait=False): self._logger.debug("") self._client.get_token() wim_id = wim_name wim_id_for_wait = self._get_id_for_wait(wim_name) if not utils.validate_uuid4(wim_name): wim_id = self.get_id(wim_name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - wim_id, querystring)) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, wim_id, querystring) + ) # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) # print('WIM_ID: {}'.format(wim_id)) if http_code == 202: if wait: # 'resp' may be None. # In that case, 'resp['id']' cannot be used, so use the previously obtained id instead wait_id = wim_id_for_wait if resp: resp = json.loads(resp) - wait_id = resp.get('id') + wait_id = resp.get("id") # Wait for status for WIM account deletion self._wait(wait_id, wait, deleteFlag=True) else: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') + print("Deleted") else: - msg = resp or "" + msg = resp or "" # if resp: # try: # msg = json.loads(resp) # except ValueError: # msg = resp raise ClientException("failed to delete wim {} - {}".format(wim_name, msg)) def list(self, filter=None): - """Returns a list of VIM accounts - """ - self._logger.debug("") - self._client.get_token() - filter_string = '' + """Returns a list of VIM accounts""" + self._logger.debug("") + self._client.get_token() + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) if not resp: return list() wim_accounts = [] for datacenter in json.loads(resp): - wim_accounts.append({"name": datacenter['name'], "uuid": datacenter['_id'] - if '_id' in datacenter else None}) + wim_accounts.append( + { + "name": datacenter["name"], + "uuid": datacenter["_id"] if "_id" in datacenter else None, + } + ) return wim_accounts def get(self, name): - """Returns a VIM account based on name or id - """ + """Returns a VIM account based on name or id""" self._logger.debug("") self._client.get_token() wim_id = name if not utils.validate_uuid4(name): wim_id = self.get_id(name) try: - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase,wim_id)) + _, resp = self._http.get2_cmd("{}/{}".format(self._apiBase, wim_id)) if resp: - resp = json.loads(resp) - if not resp or '_id' not in resp: - raise ClientException('failed to get wim info: {}'.format(resp)) + resp = json.loads(resp) + if not resp or "_id" not in resp: + raise ClientException("failed to get wim info: {}".format(resp)) return resp except NotFound: raise NotFound("wim '{}' not found".format(name)) - would reformat osmclient/v1/utils.py would reformat osmclient/sol005/wim.py --- osmclient/v1/tests/test_vnfd.py 2021-12-14 16:49:03.494514 +0000 +++ osmclient/v1/tests/test_vnfd.py 2021-12-14 16:49:43.302470 +0000 @@ -23,21 +23,23 @@ class TestVnfd(unittest.TestCase): def test_list_empty(self): mock = Mock() mock.get_cmd.return_value = list() - assert len(vnfd.Vnfd(mock, client=client.Client(host='127.0.0.1')).list()) == 0 + assert len(vnfd.Vnfd(mock, client=client.Client(host="127.0.0.1")).list()) == 0 def test_get_notfound(self): mock = Mock() - mock.get_cmd.return_value = 'foo' - self.assertRaises(NotFound, vnfd.Vnfd(mock, client=client.Client(host='127.0.0.1')).get, 'bar') + mock.get_cmd.return_value = "foo" + self.assertRaises( + NotFound, vnfd.Vnfd(mock, client=client.Client(host="127.0.0.1")).get, "bar" + ) def test_get_found(self): mock = Mock() - if client.Client(host='127.0.0.1')._so_version == 'v3': - mock.get_cmd.return_value = {'project-vnfd:vnfd': [{'name': 'foo'}]} + if client.Client(host="127.0.0.1")._so_version == "v3": + mock.get_cmd.return_value = {"project-vnfd:vnfd": [{"name": "foo"}]} else: # Backwards Compatibility - mock.get_cmd.return_value = {'vnfd:vnfd': [{'name': 'foo'}]} + mock.get_cmd.return_value = {"vnfd:vnfd": [{"name": "foo"}]} - assert vnfd.Vnfd(mock, client=client.Client(host='127.0.0.1')).get('foo') + assert vnfd.Vnfd(mock, client=client.Client(host="127.0.0.1")).get("foo") would reformat osmclient/v1/tests/test_vnfd.py --- osmclient/v1/vca.py 2021-12-14 16:49:03.494514 +0000 +++ osmclient/v1/vca.py 2021-12-14 16:49:43.921211 +0000 @@ -20,41 +20,43 @@ from osmclient.common.exceptions import ClientException class Vca(object): - def __init__(self, http=None, client=None): self._http = http self._client = client def list(self): - resp = self._http.get_cmd('api/config/{}config-agent' - .format(self._client.so_rbac_project_path)) - if resp and 'rw-config-agent:config-agent' in resp: - return resp['rw-config-agent:config-agent']['account'] + resp = self._http.get_cmd( + "api/config/{}config-agent".format(self._client.so_rbac_project_path) + ) + if resp and "rw-config-agent:config-agent" in resp: + return resp["rw-config-agent:config-agent"]["account"] return list() def delete(self, name): - if ('success' not in - self._http.delete_cmd('api/config/{}config-agent/account/{}' - .format(self._client.so_rbac_project_path, name))): - raise ClientException("failed to delete config agent {}" - .format(name)) + if "success" not in self._http.delete_cmd( + "api/config/{}config-agent/account/{}".format( + self._client.so_rbac_project_path, name + ) + ): + raise ClientException("failed to delete config agent {}".format(name)) def create(self, name, account_type, server, user, secret): postdata = {} - postdata['account'] = list() + postdata["account"] = list() account = {} - account['name'] = name - account['account-type'] = account_type - account['juju'] = {} - account['juju']['user'] = user - account['juju']['secret'] = secret - account['juju']['ip-address'] = server - postdata['account'].append(account) + account["name"] = name + account["account-type"] = account_type + account["juju"] = {} + account["juju"]["user"] = user + account["juju"]["secret"] = secret + account["juju"]["ip-address"] = server + postdata["account"].append(account) - if 'success' not in self._http.post_cmd('api/config/{}config-agent' - .format(self._client.so_rbac_project_path), postdata): - raise ClientException("failed to create config agent {}" - .format(name)) + if "success" not in self._http.post_cmd( + "api/config/{}config-agent".format(self._client.so_rbac_project_path), + postdata, + ): + raise ClientException("failed to create config agent {}".format(name)) would reformat osmclient/v1/vca.py --- osmclient/v1/vnfd.py 2021-12-14 16:49:03.494514 +0000 +++ osmclient/v1/vnfd.py 2021-12-14 16:49:43.956858 +0000 @@ -21,36 +21,39 @@ from osmclient.common.exceptions import NotFound from osmclient.common.exceptions import ClientException class Vnfd(object): - def __init__(self, http=None, client=None): self._http = http self._client = client def list(self): - resp = self._http.get_cmd('api/running/{}vnfd-catalog/vnfd' - .format(self._client.so_rbac_project_path)) + resp = self._http.get_cmd( + "api/running/{}vnfd-catalog/vnfd".format(self._client.so_rbac_project_path) + ) - if self._client._so_version == 'v3': - if resp and 'project-vnfd:vnfd' in resp: - return resp['project-vnfd:vnfd'] + if self._client._so_version == "v3": + if resp and "project-vnfd:vnfd" in resp: + return resp["project-vnfd:vnfd"] else: # Backwards Compatibility - if resp and 'vnfd:vnfd' in resp: - return resp['vnfd:vnfd'] - + if resp and "vnfd:vnfd" in resp: + return resp["vnfd:vnfd"] + return list() def get(self, name): for vnfd in self.list(): - if name == vnfd['name']: + if name == vnfd["name"]: return vnfd raise NotFound("vnfd {} not found".format(name)) def delete(self, vnfd_name): vnfd = self.get(vnfd_name) - resp = self._http.delete_cmd('api/running/{}vnfd-catalog/vnfd/{}' - .format(self._client.so_rbac_project_path, vnfd['id'])) - if 'success' not in resp: + resp = self._http.delete_cmd( + "api/running/{}vnfd-catalog/vnfd/{}".format( + self._client.so_rbac_project_path, vnfd["id"] + ) + ) + if "success" not in resp: raise ClientException("failed to delete vnfd {}".format(vnfd_name)) would reformat osmclient/v1/vnfd.py --- osmclient/v1/vnf.py 2021-12-14 16:49:03.494514 +0000 +++ osmclient/v1/vnf.py 2021-12-14 16:49:44.074156 +0000 @@ -25,25 +25,28 @@ def __init__(self, http=None, client=None): self._http = http self._client = client def list(self): - resp = self._http.get_cmd('v1/api/operational/{}vnfr-catalog/vnfr' - .format(self._client.so_rbac_project_path)) - if resp and 'vnfr:vnfr' in resp: - return resp['vnfr:vnfr'] + resp = self._http.get_cmd( + "v1/api/operational/{}vnfr-catalog/vnfr".format( + self._client.so_rbac_project_path + ) + ) + if resp and "vnfr:vnfr" in resp: + return resp["vnfr:vnfr"] return list() def get(self, vnf_name): vnfs = self.list() for vnf in vnfs: - if vnf_name == vnf['name']: + if vnf_name == vnf["name"]: return vnf - if vnf_name == vnf['id']: + if vnf_name == vnf["id"]: return vnf raise NotFound("vnf {} not found".format(vnf_name)) def get_monitoring(self, vnf_name): vnf = self.get(vnf_name) - if vnf and 'monitoring-param' in vnf: - return vnf['monitoring-param'] + if vnf and "monitoring-param" in vnf: + return vnf["monitoring-param"] return None would reformat osmclient/v1/vnf.py --- osmclient/v1/ns.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/v1/ns.py 2021-12-14 16:49:44.254455 +0000 @@ -24,159 +24,179 @@ import uuid import yaml class Ns(object): - def __init__(self, http=None, client=None): self._http = http self._client = client def list(self): - """Returns a list of ns's - """ - resp = self._http.get_cmd('api/running/{}ns-instance-config' - .format(self._client.so_rbac_project_path)) - if not resp or 'nsr:ns-instance-config' not in resp: + """Returns a list of ns's""" + resp = self._http.get_cmd( + "api/running/{}ns-instance-config".format(self._client.so_rbac_project_path) + ) + if not resp or "nsr:ns-instance-config" not in resp: return list() - if 'nsr' not in resp['nsr:ns-instance-config']: + if "nsr" not in resp["nsr:ns-instance-config"]: return list() - return resp['nsr:ns-instance-config']['nsr'] + return resp["nsr:ns-instance-config"]["nsr"] def get(self, name): - """Returns an ns based on name - """ + """Returns an ns based on name""" for ns in self.list(): - if name == ns['name']: + if name == ns["name"]: return ns raise NotFound("ns {} not found".format(name)) def scale(self, ns_name, ns_scale_group, instance_index): postdata = {} - postdata['instance'] = list() + postdata["instance"] = list() instance = {} - instance['id'] = instance_index - postdata['instance'].append(instance) + instance["id"] = instance_index + postdata["instance"].append(instance) ns = self.get(ns_name) resp = self._http.post_cmd( - 'v1/api/config/{}ns-instance-config/nsr/{}/scaling-group/{}/instance' - .format(self._client.so_rbac_project_path, ns['id'], ns_scale_group), postdata) - if 'success' not in resp: + "v1/api/config/{}ns-instance-config/nsr/{}/scaling-group/{}/instance".format( + self._client.so_rbac_project_path, ns["id"], ns_scale_group + ), + postdata, + ) + if "success" not in resp: raise ClientException( - "failed to scale ns: {} result: {}".format( - ns_name, - resp)) - - def create(self, nsd_name, nsr_name, account, config=None, - ssh_keys=None, description='default description', - admin_status='ENABLED'): + "failed to scale ns: {} result: {}".format(ns_name, resp) + ) + + def create( + self, + nsd_name, + nsr_name, + account, + config=None, + ssh_keys=None, + description="default description", + admin_status="ENABLED", + ): postdata = {} - postdata['nsr'] = list() + postdata["nsr"] = list() nsr = {} - nsr['id'] = str(uuid.uuid1()) + nsr["id"] = str(uuid.uuid1()) nsd = self._client.nsd.get(nsd_name) - - if self._client._so_version == 'v3': + + if self._client._so_version == "v3": datacenter, resource_orchestrator = self._client.vim.get_datacenter(account) if datacenter is None or resource_orchestrator is None: raise NotFound("cannot find datacenter account {}".format(account)) - if 'uuid' not in datacenter: - raise NotFound("The RO Datacenter - {} is invalid. Please select another".format(account)) + if "uuid" not in datacenter: + raise NotFound( + "The RO Datacenter - {} is invalid. Please select another".format( + account + ) + ) else: # Backwards Compatiility datacenter = self._client.vim.get_datacenter(account) if datacenter is None: raise NotFound("cannot find datacenter account {}".format(account)) - nsr['nsd'] = nsd - nsr['name'] = nsr_name - nsr['short-name'] = nsr_name - nsr['description'] = description - nsr['admin-status'] = admin_status - - if self._client._so_version == 'v3': + nsr["nsd"] = nsd + nsr["name"] = nsr_name + nsr["short-name"] = nsr_name + nsr["description"] = description + nsr["admin-status"] = admin_status + + if self._client._so_version == "v3": # New format for V3 - nsr['resource-orchestrator'] = resource_orchestrator - nsr['datacenter'] = datacenter['name'] + nsr["resource-orchestrator"] = resource_orchestrator + nsr["datacenter"] = datacenter["name"] else: # Backwards Compatiility - nsr['om-datacenter'] = datacenter['uuid'] + nsr["om-datacenter"] = datacenter["uuid"] if ssh_keys is not None: # ssh_keys is comma separate list ssh_keys_format = [] - for key in ssh_keys.split(','): - ssh_keys_format.append({'key-pair-ref': key}) - - nsr['ssh-authorized-key'] = ssh_keys_format + for key in ssh_keys.split(","): + ssh_keys_format.append({"key-pair-ref": key}) + + nsr["ssh-authorized-key"] = ssh_keys_format ns_config = {} - if config: + if config: ns_config = yaml.safe_load(config) - if ns_config and 'vim-network-name' in ns_config: - for network in ns_config['vim-network-name']: + if ns_config and "vim-network-name" in ns_config: + for network in ns_config["vim-network-name"]: # now find this network - vld_name = network['name'] + vld_name = network["name"] # vim_vld_name = network['vim-network-name'] - for index, vld in enumerate(nsr['nsd']['vld']): - if vld['name'] == vld_name: - nsr['nsd']['vld'][index]['vim-network-name'] = network['vim-network-name'] - - postdata['nsr'].append(nsr) + for index, vld in enumerate(nsr["nsd"]["vld"]): + if vld["name"] == vld_name: + nsr["nsd"]["vld"][index]["vim-network-name"] = network[ + "vim-network-name" + ] + + postdata["nsr"].append(nsr) resp = self._http.post_cmd( - 'api/config/{}ns-instance-config/nsr' - .format(self._client.so_rbac_project_path), - postdata) - - if 'success' not in resp: + "api/config/{}ns-instance-config/nsr".format( + self._client.so_rbac_project_path + ), + postdata, + ) + + if "success" not in resp: raise ClientException( "failed to create ns: {} nsd: {} result: {}".format( - nsr_name, - nsd_name, - resp)) + nsr_name, nsd_name, resp + ) + ) def get_opdata(self, id): return self._http.get_cmd( - 'api/operational/{}ns-instance-opdata/nsr/{}?deep' - .format(self._client.so_rbac_project_path, id)) + "api/operational/{}ns-instance-opdata/nsr/{}?deep".format( + self._client.so_rbac_project_path, id + ) + ) def get_field(self, ns_name, field): nsr = self.get(ns_name) if nsr is None: raise NotFound("failed to retrieve ns {}".format(ns_name)) if field in nsr: return nsr[field] - nsopdata = self.get_opdata(nsr['id']) - - if field in nsopdata['nsr:nsr']: - return nsopdata['nsr:nsr'][field] + nsopdata = self.get_opdata(nsr["id"]) + + if field in nsopdata["nsr:nsr"]: + return nsopdata["nsr:nsr"][field] raise NotFound("failed to find {} in ns {}".format(field, ns_name)) def _terminate(self, ns_name): ns = self.get(ns_name) if ns is None: raise NotFound("cannot find ns {}".format(ns_name)) - return self._http.delete_cmd('api/config/{}ns-instance-config/nsr/{}' - .format(self._client.so_rbac_project_path, ns['id'])) + return self._http.delete_cmd( + "api/config/{}ns-instance-config/nsr/{}".format( + self._client.so_rbac_project_path, ns["id"] + ) + ) def delete(self, ns_name, wait=True): - vnfs = self.get_field(ns_name, 'constituent-vnfr-ref') + vnfs = self.get_field(ns_name, "constituent-vnfr-ref") resp = self._terminate(ns_name) - if 'success' not in resp: + if "success" not in resp: raise ClientException("failed to delete ns {}".format(ns_name)) # helper method to check if pkg exists def check_not_exists(func): try: @@ -184,29 +204,27 @@ return False except NotFound: return True for vnf in vnfs: - if (not utils.wait_for_value( - lambda: - check_not_exists(lambda: - self._client.vnf.get(vnf['vnfr-id'])))): - raise ClientException( - "vnf {} failed to delete".format(vnf['vnfr-id'])) - if not utils.wait_for_value(lambda: - check_not_exists(lambda: - self.get(ns_name))): + if not utils.wait_for_value( + lambda: check_not_exists(lambda: self._client.vnf.get(vnf["vnfr-id"])) + ): + raise ClientException("vnf {} failed to delete".format(vnf["vnfr-id"])) + if not utils.wait_for_value( + lambda: check_not_exists(lambda: self.get(ns_name)) + ): raise ClientException("ns {} failed to delete".format(ns_name)) def get_monitoring(self, ns_name): ns = self.get(ns_name) mon_list = {} if ns is None: return mon_list vnfs = self._client.vnf.list() for vnf in vnfs: - if ns['id'] == vnf['nsr-id-ref']: - if 'monitoring-param' in vnf: - mon_list[vnf['name']] = vnf['monitoring-param'] + if ns["id"] == vnf["nsr-id-ref"]: + if "monitoring-param" in vnf: + mon_list[vnf["name"]] = vnf["monitoring-param"] return mon_list would reformat osmclient/v1/ns.py --- osmclient/v1/vim.py 2021-12-14 16:49:03.494514 +0000 +++ osmclient/v1/vim.py 2021-12-14 16:49:45.120330 +0000 @@ -18,257 +18,282 @@ OSM vim API handling """ from osmclient.common.exceptions import ClientException from osmclient.common.exceptions import NotFound -import yaml +import yaml import time class Vim(object): def __init__(self, http=None, ro_http=None, client=None): self._client = client self._ro_http = ro_http self._http = http def _attach(self, vim_name, vim_account): - tenant_name = 'osm' + tenant_name = "osm" tenant = self._get_ro_tenant() if tenant is None: raise ClientException("tenant {} not found".format(tenant_name)) datacenter = self._get_ro_datacenter(vim_name) if datacenter is None: - raise Exception('datacenter {} not found'.format(vim_name)) - - return self._ro_http.post_cmd('openmano/{}/datacenters/{}' - .format(tenant['uuid'], - datacenter['uuid']), vim_account) + raise Exception("datacenter {} not found".format(vim_name)) + + return self._ro_http.post_cmd( + "openmano/{}/datacenters/{}".format(tenant["uuid"], datacenter["uuid"]), + vim_account, + ) def _detach(self, vim_name): - tenant_name = 'osm' + tenant_name = "osm" tenant = self._get_ro_tenant() if tenant is None: raise ClientException("tenant {} not found".format(tenant_name)) - return self._ro_http.delete_cmd('openmano/{}/datacenters/{}' - .format(tenant["uuid"], vim_name)) + return self._ro_http.delete_cmd( + "openmano/{}/datacenters/{}".format(tenant["uuid"], vim_name) + ) def create(self, name, vim_access): vim_account = {} - vim_account['datacenter'] = {} + vim_account["datacenter"] = {} # currently assumes vim_acc - if ('vim-type' not in vim_access): - #'openstack' not in vim_access['vim-type']): + if "vim-type" not in vim_access: + #'openstack' not in vim_access['vim-type']): raise Exception("vim type not provided") - vim_account['datacenter']['name'] = name - vim_account['datacenter']['type'] = vim_access['vim-type'] + vim_account["datacenter"]["name"] = name + vim_account["datacenter"]["type"] = vim_access["vim-type"] vim_config = {} - if 'config' in vim_access and vim_access['config'] is not None: - vim_config = yaml.safe_load(vim_access['config']) + if "config" in vim_access and vim_access["config"] is not None: + vim_config = yaml.safe_load(vim_access["config"]) if vim_config: - vim_account['datacenter']['config'] = vim_config + vim_account["datacenter"]["config"] = vim_config vim_account = self.update_vim_account_dict(vim_account, vim_access, vim_config) - resp = self._ro_http.post_cmd('openmano/datacenters', vim_account) - if resp and 'error' in resp: + resp = self._ro_http.post_cmd("openmano/datacenters", vim_account) + if resp and "error" in resp: raise ClientException("failed to create vim") else: self._attach(name, vim_account) self._update_ro_accounts() - def _update_ro_accounts(self): - get_ro_accounts = self._http.get_cmd('api/operational/{}ro-account' - .format(self._client.so_rbac_project_path)) - if not get_ro_accounts or 'rw-ro-account:ro-account' not in get_ro_accounts: + get_ro_accounts = self._http.get_cmd( + "api/operational/{}ro-account".format(self._client.so_rbac_project_path) + ) + if not get_ro_accounts or "rw-ro-account:ro-account" not in get_ro_accounts: return - for account in get_ro_accounts['rw-ro-account:ro-account']['account']: - if account['ro-account-type'] == 'openmano': + for account in get_ro_accounts["rw-ro-account:ro-account"]["account"]: + if account["ro-account-type"] == "openmano": # Refresh the Account Status - refresh_body = {"input": { - "ro-account": account['name'], - "project-name": self._client._so_project - } - } - refresh_status = self._http.post_cmd('api/operations/update-ro-account-status', - refresh_body) - if refresh_status and 'error' in refresh_status: + refresh_body = { + "input": { + "ro-account": account["name"], + "project-name": self._client._so_project, + } + } + refresh_status = self._http.post_cmd( + "api/operations/update-ro-account-status", refresh_body + ) + if refresh_status and "error" in refresh_status: raise ClientException("Failed to refersh RO Account Status") - def update_vim_account_dict(self, vim_account, vim_access, vim_config): - if vim_access['vim-type'] == 'vmware': - if 'admin_username' in vim_config: - vim_account['datacenter']['admin_username'] = vim_config['admin_username'] - if 'admin_password' in vim_config: - vim_account['datacenter']['admin_password'] = vim_config['admin_password'] - if 'nsx_manager' in vim_config: - vim_account['datacenter']['nsx_manager'] = vim_config['nsx_manager'] - if 'nsx_user' in vim_config: - vim_account['datacenter']['nsx_user'] = vim_config['nsx_user'] - if 'nsx_password' in vim_config: - vim_account['datacenter']['nsx_password'] = vim_config['nsx_password'] - if 'orgname' in vim_config: - vim_account['datacenter']['orgname'] = vim_config['orgname'] - if 'vcenter_ip' in vim_config: - vim_account['datacenter']['vcenter_ip'] = vim_config['vcenter_ip'] - if 'vcenter_user' in vim_config: - vim_account['datacenter']['vcenter_user'] = vim_config['vcenter_user'] - if 'vcenter_password' in vim_config: - vim_account['datacenter']['vcenter_password'] = vim_config['vcenter_password'] - if 'vcenter_port' in vim_config: - vim_account['datacenter']['vcenter_port'] = vim_config['vcenter_port'] - vim_account['datacenter']['vim_url'] = vim_access['vim-url'] - vim_account['datacenter']['vim_url_admin'] = vim_access['vim-url'] - vim_account['datacenter']['description'] = vim_access['description'] - vim_account['datacenter']['vim_username'] = vim_access['vim-username'] - vim_account['datacenter']['vim_password'] = vim_access['vim-password'] - vim_account['datacenter']['vim_tenant_name'] = vim_access['vim-tenant-name'] - else: - vim_account['datacenter']['vim_url'] = vim_access['vim-url'] - vim_account['datacenter']['vim_url_admin'] = vim_access['vim-url'] - vim_account['datacenter']['description'] = vim_access['description'] - vim_account['datacenter']['vim_username'] = vim_access['vim-username'] - vim_account['datacenter']['vim_password'] = vim_access['vim-password'] - vim_account['datacenter']['vim_tenant_name'] = vim_access['vim-tenant-name'] + if vim_access["vim-type"] == "vmware": + if "admin_username" in vim_config: + vim_account["datacenter"]["admin_username"] = vim_config[ + "admin_username" + ] + if "admin_password" in vim_config: + vim_account["datacenter"]["admin_password"] = vim_config[ + "admin_password" + ] + if "nsx_manager" in vim_config: + vim_account["datacenter"]["nsx_manager"] = vim_config["nsx_manager"] + if "nsx_user" in vim_config: + vim_account["datacenter"]["nsx_user"] = vim_config["nsx_user"] + if "nsx_password" in vim_config: + vim_account["datacenter"]["nsx_password"] = vim_config["nsx_password"] + if "orgname" in vim_config: + vim_account["datacenter"]["orgname"] = vim_config["orgname"] + if "vcenter_ip" in vim_config: + vim_account["datacenter"]["vcenter_ip"] = vim_config["vcenter_ip"] + if "vcenter_user" in vim_config: + vim_account["datacenter"]["vcenter_user"] = vim_config["vcenter_user"] + if "vcenter_password" in vim_config: + vim_account["datacenter"]["vcenter_password"] = vim_config[ + "vcenter_password" + ] + if "vcenter_port" in vim_config: + vim_account["datacenter"]["vcenter_port"] = vim_config["vcenter_port"] + vim_account["datacenter"]["vim_url"] = vim_access["vim-url"] + vim_account["datacenter"]["vim_url_admin"] = vim_access["vim-url"] + vim_account["datacenter"]["description"] = vim_access["description"] + vim_account["datacenter"]["vim_username"] = vim_access["vim-username"] + vim_account["datacenter"]["vim_password"] = vim_access["vim-password"] + vim_account["datacenter"]["vim_tenant_name"] = vim_access["vim-tenant-name"] + else: + vim_account["datacenter"]["vim_url"] = vim_access["vim-url"] + vim_account["datacenter"]["vim_url_admin"] = vim_access["vim-url"] + vim_account["datacenter"]["description"] = vim_access["description"] + vim_account["datacenter"]["vim_username"] = vim_access["vim-username"] + vim_account["datacenter"]["vim_password"] = vim_access["vim-password"] + vim_account["datacenter"]["vim_tenant_name"] = vim_access["vim-tenant-name"] return vim_account def delete(self, vim_name): # first detach self._detach(vim_name) # detach. continue if error, # it could be the datacenter is left without attachment - resp = self._ro_http.delete_cmd('openmano/datacenters/{}' - .format(vim_name)) - if 'result' not in resp: + resp = self._ro_http.delete_cmd("openmano/datacenters/{}".format(vim_name)) + if "result" not in resp: raise ClientException("failed to delete vim {} - {}".format(vim_name, resp)) self._update_ro_accounts() def list(self, ro_update): if ro_update: self._update_ro_accounts() # the ro_update needs to be made synchronous, for now this works around the issue # and waits a resonable amount of time for the update to finish time.sleep(2) - if self._client._so_version == 'v3': - resp = self._http.get_cmd('v1/api/operational/{}ro-account-state' - .format(self._client.so_rbac_project_path)) + if self._client._so_version == "v3": + resp = self._http.get_cmd( + "v1/api/operational/{}ro-account-state".format( + self._client.so_rbac_project_path + ) + ) datacenters = [] - if not resp or 'rw-ro-account:ro-account-state' not in resp: + if not resp or "rw-ro-account:ro-account-state" not in resp: return list() - ro_accounts = resp['rw-ro-account:ro-account-state'] - for ro_account in ro_accounts['account']: - if 'datacenters' not in ro_account: - continue - if 'datacenters' not in ro_account['datacenters']: - continue - for datacenter in ro_account['datacenters']['datacenters']: - datacenters.append({"name": datacenter['name'], "uuid": datacenter['uuid'] - if 'uuid' in datacenter else None}) + ro_accounts = resp["rw-ro-account:ro-account-state"] + for ro_account in ro_accounts["account"]: + if "datacenters" not in ro_account: + continue + if "datacenters" not in ro_account["datacenters"]: + continue + for datacenter in ro_account["datacenters"]["datacenters"]: + datacenters.append( + { + "name": datacenter["name"], + "uuid": datacenter["uuid"] + if "uuid" in datacenter + else None, + } + ) vim_accounts = datacenters return vim_accounts else: # Backwards Compatibility - resp = self._http.get_cmd('v1/api/operational/datacenters') - if not resp or 'rw-launchpad:datacenters' not in resp: + resp = self._http.get_cmd("v1/api/operational/datacenters") + if not resp or "rw-launchpad:datacenters" not in resp: return list() - - datacenters = resp['rw-launchpad:datacenters'] - + + datacenters = resp["rw-launchpad:datacenters"] + vim_accounts = list() - if 'ro-accounts' not in datacenters: + if "ro-accounts" not in datacenters: return vim_accounts - + tenant = self._get_ro_tenant() if tenant is None: return vim_accounts - - for roaccount in datacenters['ro-accounts']: - if 'datacenters' not in roaccount: - continue - for datacenter in roaccount['datacenters']: - vim_accounts.append(self._get_ro_datacenter(datacenter['name'], - tenant['uuid'])) + + for roaccount in datacenters["ro-accounts"]: + if "datacenters" not in roaccount: + continue + for datacenter in roaccount["datacenters"]: + vim_accounts.append( + self._get_ro_datacenter(datacenter["name"], tenant["uuid"]) + ) return vim_accounts - def _get_ro_tenant(self, name='osm'): - resp = self._ro_http.get_cmd('openmano/tenants/{}'.format(name)) + def _get_ro_tenant(self, name="osm"): + resp = self._ro_http.get_cmd("openmano/tenants/{}".format(name)) if not resp: return None - if 'tenant' in resp and 'uuid' in resp['tenant']: - return resp['tenant'] - else: - return None - - def _get_ro_datacenter(self, name, tenant_uuid='any'): - resp = self._ro_http.get_cmd('openmano/{}/datacenters/{}' - .format(tenant_uuid, name)) + if "tenant" in resp and "uuid" in resp["tenant"]: + return resp["tenant"] + else: + return None + + def _get_ro_datacenter(self, name, tenant_uuid="any"): + resp = self._ro_http.get_cmd( + "openmano/{}/datacenters/{}".format(tenant_uuid, name) + ) if not resp: raise NotFound("datacenter {} not found".format(name)) - if 'datacenter' in resp and 'uuid' in resp['datacenter']: - return resp['datacenter'] + if "datacenter" in resp and "uuid" in resp["datacenter"]: + return resp["datacenter"] else: raise NotFound("datacenter {} not found".format(name)) def get(self, name): tenant = self._get_ro_tenant() if tenant is None: raise NotFound("no ro tenant found") - return self._get_ro_datacenter(name, tenant['uuid']) + return self._get_ro_datacenter(name, tenant["uuid"]) def get_datacenter(self, name): - if self._client._so_version == 'v3': - resp = self._http.get_cmd('v1/api/operational/{}ro-account-state' - .format(self._client.so_rbac_project_path)) + if self._client._so_version == "v3": + resp = self._http.get_cmd( + "v1/api/operational/{}ro-account-state".format( + self._client.so_rbac_project_path + ) + ) if not resp: return None, None - if not resp or 'rw-ro-account:ro-account-state' not in resp: + if not resp or "rw-ro-account:ro-account-state" not in resp: return None, None - ro_accounts = resp['rw-ro-account:ro-account-state'] - for ro_account in ro_accounts['account']: - if 'datacenters' not in ro_account: - continue - if 'datacenters' not in ro_account['datacenters']: - continue - for datacenter in ro_account['datacenters']['datacenters']: - if datacenter['name'] == name: - return datacenter, ro_account['name'] + ro_accounts = resp["rw-ro-account:ro-account-state"] + for ro_account in ro_accounts["account"]: + if "datacenters" not in ro_account: + continue + if "datacenters" not in ro_account["datacenters"]: + continue + for datacenter in ro_account["datacenters"]["datacenters"]: + if datacenter["name"] == name: + return datacenter, ro_account["name"] return None, None else: # Backwards Compatibility - resp = self._http.get_cmd('v1/api/operational/datacenters') + resp = self._http.get_cmd("v1/api/operational/datacenters") if not resp: return None - - if not resp or 'rw-launchpad:datacenters' not in resp: + + if not resp or "rw-launchpad:datacenters" not in resp: return None - if 'ro-accounts' not in resp['rw-launchpad:datacenters']: + if "ro-accounts" not in resp["rw-launchpad:datacenters"]: return None - for roaccount in resp['rw-launchpad:datacenters']['ro-accounts']: - if 'datacenters' not in roaccount: - continue - for datacenter in roaccount['datacenters']: - if datacenter['name'] == name: + for roaccount in resp["rw-launchpad:datacenters"]["ro-accounts"]: + if "datacenters" not in roaccount: + continue + for datacenter in roaccount["datacenters"]: + if datacenter["name"] == name: return datacenter return None def get_resource_orchestrator(self): - resp = self._http.get_cmd('v1/api/operational/{}resource-orchestrator' - .format(self._client.so_rbac_project_path)) - - if not resp or 'rw-launchpad:resource-orchestrator' not in resp: - return None - return resp['rw-launchpad:resource-orchestrator'] + resp = self._http.get_cmd( + "v1/api/operational/{}resource-orchestrator".format( + self._client.so_rbac_project_path + ) + ) + + if not resp or "rw-launchpad:resource-orchestrator" not in resp: + return None + return resp["rw-launchpad:resource-orchestrator"] would reformat osmclient/v1/vim.py --- osmclient/sol005/vnfd.py 2021-12-14 16:49:03.490515 +0000 +++ osmclient/sol005/vnfd.py 2021-12-14 16:49:45.598157 +0000 @@ -31,251 +31,310 @@ import tarfile from osm_im.validation import Validation as validation_im class Vnfd(object): - def __init__(self, http=None, client=None): self._http = http self._client = client - self._logger = logging.getLogger('osmclient') - self._apiName = '/vnfpkgm' - self._apiVersion = '/v1' - self._apiResource = '/vnf_packages' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) + self._logger = logging.getLogger("osmclient") + self._apiName = "/vnfpkgm" + self._apiVersion = "/v1" + self._apiResource = "/vnf_packages" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) def list(self, filter=None): self._logger.debug("") self._client.get_token() - filter_string = '' + filter_string = "" if filter: - filter_string = '?{}'.format(filter) - _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase, filter_string)) + filter_string = "?{}".format(filter) + _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string)) if resp: return json.loads(resp) return list() def get(self, name): self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for vnfd in self.list(): - if name == vnfd['_id']: + if name == vnfd["_id"]: return vnfd else: for vnfd in self.list(): - if 'product-name' in vnfd and name == vnfd['product-name']: + if "product-name" in vnfd and name == vnfd["product-name"]: return vnfd - elif 'name' in vnfd and name == vnfd['name']: + elif "name" in vnfd and name == vnfd["name"]: return vnfd raise NotFound("vnfd {} not found".format(name)) def get_individual(self, name): self._logger.debug("") vnfd = self.get(name) # It is redundant, since the previous one already gets the whole vnfpkginfo # The only difference is that a different primitive is exercised try: - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, vnfd['_id'])) + _, resp = self._http.get2_cmd("{}/{}".format(self._apiBase, vnfd["_id"])) if resp: return json.loads(resp) except NotFound: raise NotFound("vnfd '{}' not found".format(name)) raise NotFound("vnfd '{}' not found".format(name)) def get_thing(self, name, thing, filename): self._logger.debug("") vnfd = self.get(name) headers = self._client._headers - headers['Accept'] = 'application/binary' - http_code, resp = self._http.get2_cmd('{}/{}/{}'.format(self._apiBase, vnfd['_id'], thing)) + headers["Accept"] = "application/binary" + http_code, resp = self._http.get2_cmd( + "{}/{}/{}".format(self._apiBase, vnfd["_id"], thing) + ) if resp: return json.loads(resp) def get_descriptor(self, name, filename): self._logger.debug("") - self.get_thing(name, 'vnfd', filename) + self.get_thing(name, "vnfd", filename) def get_package(self, name, filename): self._logger.debug("") - self.get_thing(name, 'package_content', filename) + self.get_thing(name, "package_content", filename) def get_artifact(self, name, artifact, filename): self._logger.debug("") - self.get_thing(name, 'artifacts/{}'.format(artifact), filename) + self.get_thing(name, "artifacts/{}".format(artifact), filename) def delete(self, name, force=False): self._logger.debug("") self._client.get_token() vnfd = self.get(name) - querystring = '' + querystring = "" if force: - querystring = '?FORCE=True' - http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, - vnfd['_id'], querystring)) + querystring = "?FORCE=True" + http_code, resp = self._http.delete_cmd( + "{}/{}{}".format(self._apiBase, vnfd["_id"], querystring) + ) if http_code == 202: - print('Deletion in progress') + print("Deletion in progress") elif http_code == 204: - print('Deleted') + print("Deleted") else: msg = resp or "" raise ClientException("failed to delete vnfd {} - {}".format(name, msg)) - def create(self, filename, overwrite=None, update_endpoint=None, skip_charm_build=False, - override_epa=False, override_nonepa=False, override_paravirt=False): + def create( + self, + filename, + overwrite=None, + update_endpoint=None, + skip_charm_build=False, + override_epa=False, + override_nonepa=False, + override_paravirt=False, + ): self._logger.debug("") if os.path.isdir(filename): - filename = filename.rstrip('/') - filename = self._client.package_tool.build(filename, skip_validation=False, - skip_charm_build=skip_charm_build) - - print('Uploading package {}'.format(filename)) - self.create(filename, overwrite=overwrite, update_endpoint=update_endpoint, - override_epa=override_epa, override_nonepa=override_nonepa, - override_paravirt=override_paravirt) + filename = filename.rstrip("/") + filename = self._client.package_tool.build( + filename, skip_validation=False, skip_charm_build=skip_charm_build + ) + + print("Uploading package {}".format(filename)) + self.create( + filename, + overwrite=overwrite, + update_endpoint=update_endpoint, + override_epa=override_epa, + override_nonepa=override_nonepa, + override_paravirt=override_paravirt, + ) else: self._client.get_token() mime_type = magic.from_file(filename, mime=True) if mime_type is None: raise ClientException( "Unexpected MIME type for file {}: MIME type {}".format( - filename, mime_type) + filename, mime_type + ) ) headers = self._client._headers - headers['Content-Filename'] = basename(filename) - if mime_type in ['application/yaml', 'text/plain', 'application/json']: - headers['Content-Type'] = 'text/plain' - elif mime_type in ['application/gzip', 'application/x-gzip']: - headers['Content-Type'] = 'application/gzip' + headers["Content-Filename"] = basename(filename) + if mime_type in ["application/yaml", "text/plain", "application/json"]: + headers["Content-Type"] = "text/plain" + elif mime_type in ["application/gzip", "application/x-gzip"]: + headers["Content-Type"] = "application/gzip" else: raise ClientException( "Unexpected MIME type for file {}: MIME type {}".format( - filename, mime_type) - ) - - special_override_string = '' + filename, mime_type + ) + ) + + special_override_string = "" if override_epa or override_nonepa or override_paravirt: # If override for EPA, non-EPA or paravirt is required, get the descriptor data descriptor_data = None - if mime_type in ['application/yaml', 'text/plain', 'application/json']: + if mime_type in ["application/yaml", "text/plain", "application/json"]: with open(filename) as df: descriptor_data = df.read() - elif mime_type in ['application/gzip', 'application/x-gzip']: + elif mime_type in ["application/gzip", "application/x-gzip"]: tar_object = tarfile.open(filename, "r:gz") descriptor_list = [] for member in tar_object: if member.isreg(): - if '/' not in os.path.dirname(member.name) and member.name.endswith('.yaml'): + if "/" not in os.path.dirname( + member.name + ) and member.name.endswith(".yaml"): descriptor_list.append(member.name) if len(descriptor_list) > 1: - raise ClientException('Found more than one potential descriptor in the tar.gz file') + raise ClientException( + "Found more than one potential descriptor in the tar.gz file" + ) elif len(descriptor_list) == 0: - raise ClientException('No descriptor was found in the tar.gz file') + raise ClientException( + "No descriptor was found in the tar.gz file" + ) with tar_object.extractfile(descriptor_list[0]) as df: descriptor_data = df.read() tar_object.close() if not descriptor_data: - raise ClientException('Descriptor could not be read') + raise ClientException("Descriptor could not be read") desc_type, vnfd = validation_im().yaml_validation(descriptor_data) validation_im().pyangbind_validation(desc_type, vnfd) vnfd = yaml.safe_load(descriptor_data) vcd_list = [] vdu_list = [] for k in vnfd: # Get only the first descriptor in case there are many in the yaml file # k can be vnfd or etsi-nfv-vnfd:vnfd. This check is skipped first_vnfd = vnfd.get(k, {}) - vcd_list = first_vnfd.get('virtual-compute-desc', []) - vdu_list = first_vnfd.get('vdu', []) + vcd_list = first_vnfd.get("virtual-compute-desc", []) + vdu_list = first_vnfd.get("vdu", []) break for vcd_number, vcd in enumerate(vcd_list): if override_epa: virtual_memory = vcd["virtual-memory"] virtual_memory["mempage-size"] = "LARGE" virtual_memory["numa-enabled"] = True virtual_memory["numa-node-policy"] = { "node-cnt": 1, - "mem-policy": "STRICT" + "mem-policy": "STRICT", } virtual_cpu = vcd["virtual-cpu"] virtual_cpu["pinning"] = { "policy": "static", - "thread-policy": "PREFER" + "thread-policy": "PREFER", } - cpu_override_string = "virtual-compute-desc.{}.virtual-cpu={};"\ - .format(vcd_number, quote(yaml.safe_dump(virtual_cpu))) - memory_override_string = "virtual-compute-desc.{}.virtual-memory={};"\ - .format(vcd_number, quote(yaml.safe_dump(virtual_memory))) - special_override_string = "{}{}{}".format(special_override_string, - cpu_override_string, memory_override_string) - - headers['Query-String-Format'] = 'yaml' + cpu_override_string = ( + "virtual-compute-desc.{}.virtual-cpu={};".format( + vcd_number, quote(yaml.safe_dump(virtual_cpu)) + ) + ) + memory_override_string = ( + "virtual-compute-desc.{}.virtual-memory={};".format( + vcd_number, quote(yaml.safe_dump(virtual_memory)) + ) + ) + special_override_string = "{}{}{}".format( + special_override_string, + cpu_override_string, + memory_override_string, + ) + + headers["Query-String-Format"] = "yaml" if override_nonepa: virtual_memory = vcd["virtual-memory"] virtual_memory["mempage-size"] = "" virtual_memory["numa-enabled"] = "" virtual_memory["numa-node-policy"] = {} virtual_cpu = vcd["virtual-cpu"] virtual_cpu["pinning"] = {} - cpu_override_string = "virtual-compute-desc.{}.virtual-cpu={};"\ - .format(vcd_number, quote(yaml.safe_dump(virtual_cpu))) - memory_override_string = "virtual-compute-desc.{}.virtual-memory={};"\ - .format(vcd_number, quote(yaml.safe_dump(virtual_memory))) - special_override_string = "{}{}{}".format(special_override_string, - cpu_override_string, memory_override_string) + cpu_override_string = ( + "virtual-compute-desc.{}.virtual-cpu={};".format( + vcd_number, quote(yaml.safe_dump(virtual_cpu)) + ) + ) + memory_override_string = ( + "virtual-compute-desc.{}.virtual-memory={};".format( + vcd_number, quote(yaml.safe_dump(virtual_memory)) + ) + ) + special_override_string = "{}{}{}".format( + special_override_string, + cpu_override_string, + memory_override_string, + ) if override_paravirt: for vdu_number, vdu in enumerate(vdu_list): for cpd_number, cpd in enumerate(vdu["int-cpd"]): - for vnir_number, vnir in enumerate(cpd['virtual-network-interface-requirement']): - special_override_string = "{}vdu.{}.int-cpd.{}.virtual-network-interface-" \ - "requirement.{}.virtual-interface.type=PARAVIRT;"\ - .format(special_override_string, vdu_number, cpd_number, vnir_number) + for vnir_number, vnir in enumerate( + cpd["virtual-network-interface-requirement"] + ): + special_override_string = ( + "{}vdu.{}.int-cpd.{}.virtual-network-interface-" + "requirement.{}.virtual-interface.type=PARAVIRT;".format( + special_override_string, + vdu_number, + cpd_number, + vnir_number, + ) + ) special_override_string = special_override_string.rstrip(";") headers["Content-File-MD5"] = utils.md5(filename) - http_header = ['{}: {}'.format(key, val) - for (key, val) in list(headers.items())] + http_header = [ + "{}: {}".format(key, val) for (key, val) in list(headers.items()) + ] self._http.set_http_header(http_header) if update_endpoint: - http_code, resp = self._http.put_cmd(endpoint=update_endpoint, filename=filename) + http_code, resp = self._http.put_cmd( + endpoint=update_endpoint, filename=filename + ) else: - ow_string = '' + ow_string = "" if special_override_string: if overwrite: overwrite = "{};{}".format(overwrite, special_override_string) else: overwrite = special_override_string if overwrite: - ow_string = '?{}'.format(overwrite) - self._apiResource = '/vnf_packages_content' - self._apiBase = '{}{}{}'.format(self._apiName, - self._apiVersion, self._apiResource) - endpoint = '{}{}'.format(self._apiBase, ow_string) - http_code, resp = self._http.post_cmd(endpoint=endpoint, filename=filename) + ow_string = "?{}".format(overwrite) + self._apiResource = "/vnf_packages_content" + self._apiBase = "{}{}{}".format( + self._apiName, self._apiVersion, self._apiResource + ) + endpoint = "{}{}".format(self._apiBase, ow_string) + http_code, resp = self._http.post_cmd( + endpoint=endpoint, filename=filename + ) if http_code in (200, 201, 202): if resp: resp = json.loads(resp) - if not resp or 'id' not in resp: - raise ClientException('unexpected response from server: {}'.format(resp)) - print(resp['id']) + if not resp or "id" not in resp: + raise ClientException( + "unexpected response from server: {}".format(resp) + ) + print(resp["id"]) elif http_code == 204: - print('Updated') + print("Updated") def update(self, name, filename): self._logger.debug("") self._client.get_token() vnfd = self.get(name) - endpoint = '{}/{}/package_content'.format(self._apiBase, vnfd['_id']) + endpoint = "{}/{}/package_content".format(self._apiBase, vnfd["_id"]) self.create(filename=filename, update_endpoint=endpoint) would reformat osmclient/sol005/vnfd.py --- osmclient/scripts/osm.py 2021-12-14 16:49:03.486515 +0000 +++ osmclient/scripts/osm.py 2021-12-14 16:49:56.964698 +0000 @@ -33,175 +33,207 @@ from datetime import datetime # Global variables -CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'], max_content_width=160) +CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"], max_content_width=160) + def wrap_text(text, width): wrapper = textwrap.TextWrapper(width=width) lines = text.splitlines() return "\n".join(map(wrapper.fill, lines)) def trunc_text(text, length): - if len(text) > length: - return text[:(length - 3)] + '...' - else: - return text - - -def check_client_version(obj, what, version='sol005'): + if len(text) > length: + return text[: (length - 3)] + "..." + else: + return text + + +def check_client_version(obj, what, version="sol005"): """ Checks the version of the client object and raises error if it not the expected. :param obj: the client object :what: the function or command under evaluation (used when an error is raised) :return: - :raises ClientError: if the specified version does not match the client version """ logger.debug("") fullclassname = obj.__module__ + "." + obj.__class__.__name__ - message = 'The following commands or options are only supported with the option "--sol005": {}'.format(what) - if version == 'v1': - message = 'The following commands or options are not supported when using option "--sol005": {}'.format(what) - if fullclassname != 'osmclient.{}.client.Client'.format(version): + message = 'The following commands or options are only supported with the option "--sol005": {}'.format( + what + ) + if version == "v1": + message = 'The following commands or options are not supported when using option "--sol005": {}'.format( + what + ) + if fullclassname != "osmclient.{}.client.Client".format(version): raise ClientException(message) return def get_project(project_list, item): # project_list = ctx.obj.project.list() - item_project_list = item.get('_admin', {}).get('projects_read') - project_id = 'None' - project_name = 'None' + item_project_list = item.get("_admin", {}).get("projects_read") + project_id = "None" + project_name = "None" if item_project_list: for p1 in item_project_list: project_id = p1 for p2 in project_list: - if p2['_id'] == project_id: - project_name = p2['name'] + if p2["_id"] == project_id: + project_name = p2["name"] return project_id, project_name return project_id, project_name def get_vim_name(vim_list, vim_id): - vim_name = '-' + vim_name = "-" for v in vim_list: - if v['uuid'] == vim_id: - vim_name = v['name'] + if v["uuid"] == vim_id: + vim_name = v["name"] break return vim_name -@click.group(context_settings=dict(help_option_names=['-h', '--help'], max_content_width=160)) -@click.option('--hostname', - default="127.0.0.1", - envvar='OSM_HOSTNAME', - help='hostname of server. ' + - 'Also can set OSM_HOSTNAME in environment') -#@click.option('--sol005/--no-sol005', +@click.group( + context_settings=dict(help_option_names=["-h", "--help"], max_content_width=160) +) +@click.option( + "--hostname", + default="127.0.0.1", + envvar="OSM_HOSTNAME", + help="hostname of server. " + "Also can set OSM_HOSTNAME in environment", +) +# @click.option('--sol005/--no-sol005', # default=True, # envvar='OSM_SOL005', # help='Use ETSI NFV SOL005 API (default) or the previous SO API. ' + # 'Also can set OSM_SOL005 in environment') -@click.option('--user', - default=None, - envvar='OSM_USER', - help='user (defaults to admin). ' + - 'Also can set OSM_USER in environment') -@click.option('--password', - default=None, - envvar='OSM_PASSWORD', - help='password (defaults to admin). ' + - 'Also can set OSM_PASSWORD in environment') -@click.option('--project', - default=None, - envvar='OSM_PROJECT', - help='project (defaults to admin). ' + - 'Also can set OSM_PROJECT in environment') -@click.option('-v', '--verbose', count=True, - help='increase verbosity (-v INFO, -vv VERBOSE, -vvv DEBUG)') -@click.option('--all-projects', - default=None, - is_flag=True, - help='include all projects') -@click.option('--public/--no-public', default=None, - help='flag for public items (packages, instances, VIM accounts, etc.)') -@click.option('--project-domain-name', 'project_domain_name', - default=None, - envvar='OSM_PROJECT_DOMAIN_NAME', - help='project domain name for keystone authentication (default to None). ' + - 'Also can set OSM_PROJECT_DOMAIN_NAME in environment') -@click.option('--user-domain-name', 'user_domain_name', - default=None, - envvar='OSM_USER_DOMAIN_NAME', - help='user domain name for keystone authentication (default to None). ' + - 'Also can set OSM_USER_DOMAIN_NAME in environment') -#@click.option('--so-port', +@click.option( + "--user", + default=None, + envvar="OSM_USER", + help="user (defaults to admin). " + "Also can set OSM_USER in environment", +) +@click.option( + "--password", + default=None, + envvar="OSM_PASSWORD", + help="password (defaults to admin). " + "Also can set OSM_PASSWORD in environment", +) +@click.option( + "--project", + default=None, + envvar="OSM_PROJECT", + help="project (defaults to admin). " + "Also can set OSM_PROJECT in environment", +) +@click.option( + "-v", + "--verbose", + count=True, + help="increase verbosity (-v INFO, -vv VERBOSE, -vvv DEBUG)", +) +@click.option("--all-projects", default=None, is_flag=True, help="include all projects") +@click.option( + "--public/--no-public", + default=None, + help="flag for public items (packages, instances, VIM accounts, etc.)", +) +@click.option( + "--project-domain-name", + "project_domain_name", + default=None, + envvar="OSM_PROJECT_DOMAIN_NAME", + help="project domain name for keystone authentication (default to None). " + + "Also can set OSM_PROJECT_DOMAIN_NAME in environment", +) +@click.option( + "--user-domain-name", + "user_domain_name", + default=None, + envvar="OSM_USER_DOMAIN_NAME", + help="user domain name for keystone authentication (default to None). " + + "Also can set OSM_USER_DOMAIN_NAME in environment", +) +# @click.option('--so-port', # default=None, # envvar='OSM_SO_PORT', # help='hostname of server. ' + # 'Also can set OSM_SO_PORT in environment') -#@click.option('--so-project', +# @click.option('--so-project', # default=None, # envvar='OSM_SO_PROJECT', # help='Project Name in SO. ' + # 'Also can set OSM_SO_PROJECT in environment') -#@click.option('--ro-hostname', +# @click.option('--ro-hostname', # default=None, # envvar='OSM_RO_HOSTNAME', # help='hostname of RO server. ' + # 'Also can set OSM_RO_HOSTNAME in environment') -#@click.option('--ro-port', +# @click.option('--ro-port', # default=None, # envvar='OSM_RO_PORT', # help='hostname of RO server. ' + # 'Also can set OSM_RO_PORT in environment') @click.pass_context def cli_osm(ctx, **kwargs): global logger hostname = kwargs.pop("hostname", None) if hostname is None: - print(( - "either hostname option or OSM_HOSTNAME " + - "environment variable needs to be specified")) + print( + ( + "either hostname option or OSM_HOSTNAME " + + "environment variable needs to be specified" + ) + ) exit(1) # Remove None values kwargs = {k: v for k, v in kwargs.items() if v is not None} -# if so_port is not None: -# kwargs['so_port']=so_port -# if so_project is not None: -# kwargs['so_project']=so_project -# if ro_hostname is not None: -# kwargs['ro_host']=ro_hostname -# if ro_port is not None: -# kwargs['ro_port']=ro_port - sol005 = os.getenv('OSM_SOL005', True) -# if user is not None: -# kwargs['user']=user -# if password is not None: -# kwargs['password']=password -# if project is not None: -# kwargs['project']=project -# if all_projects: -# kwargs['all_projects']=all_projects -# if public is not None: -# kwargs['public']=public + # if so_port is not None: + # kwargs['so_port']=so_port + # if so_project is not None: + # kwargs['so_project']=so_project + # if ro_hostname is not None: + # kwargs['ro_host']=ro_hostname + # if ro_port is not None: + # kwargs['ro_port']=ro_port + sol005 = os.getenv("OSM_SOL005", True) + # if user is not None: + # kwargs['user']=user + # if password is not None: + # kwargs['password']=password + # if project is not None: + # kwargs['project']=project + # if all_projects: + # kwargs['all_projects']=all_projects + # if public is not None: + # kwargs['public']=public ctx.obj = client.Client(host=hostname, sol005=sol005, **kwargs) - logger = logging.getLogger('osmclient') + logger = logging.getLogger("osmclient") #################### # LIST operations #################### -@cli_osm.command(name='ns-list', short_help='list all NS instances') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NS instances matching the filter.') -@click.option('--long', is_flag=True, - help='get more details of the NS (project, vim, deployment status, configuration status.') + +@cli_osm.command(name="ns-list", short_help="list all NS instances") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NS instances matching the filter.", +) +@click.option( + "--long", + is_flag=True, + help="get more details of the NS (project, vim, deployment status, configuration status.", +) @click.pass_context def ns_list(ctx, filter, long): """list all NS instances \b @@ -247,353 +279,464 @@ --filter nsd-ref= --filter nsd.vendor= --filter nsd.vendor=&nsd-ref= --filter nsd.constituent-vnfd.vnfd-id-ref= """ + def summarize_deployment_status(status_dict): - #Nets + # Nets summary = "" if not status_dict: return summary n_nets = 0 status_nets = {} - net_list = status_dict.get('nets',[]) + net_list = status_dict.get("nets", []) for net in net_list: n_nets += 1 - if net['status'] not in status_nets: - status_nets[net['status']] = 1 + if net["status"] not in status_nets: + status_nets[net["status"]] = 1 else: - status_nets[net['status']] +=1 + status_nets[net["status"]] += 1 message = "Nets: " - for k,v in status_nets.items(): - message += "{}:{},".format(k,v) + for k, v in status_nets.items(): + message += "{}:{},".format(k, v) message += "TOTAL:{}".format(n_nets) summary += "{}".format(message) - #VMs and VNFs + # VMs and VNFs n_vms = 0 status_vms = {} status_vnfs = {} - vnf_list = status_dict['vnfs'] + vnf_list = status_dict["vnfs"] for vnf in vnf_list: - member_vnf_index = vnf['member_vnf_index'] + member_vnf_index = vnf["member_vnf_index"] if member_vnf_index not in status_vnfs: status_vnfs[member_vnf_index] = {} - for vm in vnf['vms']: + for vm in vnf["vms"]: n_vms += 1 - if vm['status'] not in status_vms: - status_vms[vm['status']] = 1 + if vm["status"] not in status_vms: + status_vms[vm["status"]] = 1 else: - status_vms[vm['status']] +=1 - if vm['status'] not in status_vnfs[member_vnf_index]: - status_vnfs[member_vnf_index][vm['status']] = 1 + status_vms[vm["status"]] += 1 + if vm["status"] not in status_vnfs[member_vnf_index]: + status_vnfs[member_vnf_index][vm["status"]] = 1 else: - status_vnfs[member_vnf_index][vm['status']] += 1 + status_vnfs[member_vnf_index][vm["status"]] += 1 message = "VMs: " - for k,v in status_vms.items(): - message += "{}:{},".format(k,v) + for k, v in status_vms.items(): + message += "{}:{},".format(k, v) message += "TOTAL:{}".format(n_vms) summary += "\n{}".format(message) summary += "\nNFs:" - for k,v in status_vnfs.items(): + for k, v in status_vnfs.items(): total = 0 message = "\n {} VMs: ".format(k) - for k2,v2 in v.items(): - message += "{}:{},".format(k2,v2) + for k2, v2 in v.items(): + message += "{}:{},".format(k2, v2) total += v2 message += "TOTAL:{}".format(total) summary += message return summary - + def summarize_config_status(ee_list): summary = "" if not ee_list: return summary n_ee = 0 status_ee = {} for ee in ee_list: n_ee += 1 - if ee['elementType'] not in status_ee: - status_ee[ee['elementType']] = {} - status_ee[ee['elementType']][ee['status']] = 1 + if ee["elementType"] not in status_ee: + status_ee[ee["elementType"]] = {} + status_ee[ee["elementType"]][ee["status"]] = 1 continue - if ee['status'] in status_ee[ee['elementType']]: - status_ee[ee['elementType']][ee['status']] += 1 + if ee["status"] in status_ee[ee["elementType"]]: + status_ee[ee["elementType"]][ee["status"]] += 1 else: - status_ee[ee['elementType']][ee['status']] = 1 + status_ee[ee["elementType"]][ee["status"]] = 1 for elementType in ["KDU", "VDU", "PDU", "VNF", "NS"]: if elementType in status_ee: message = "" total = 0 - for k,v in status_ee[elementType].items(): - message += "{}:{},".format(k,v) + for k, v in status_ee[elementType].items(): + message += "{}:{},".format(k, v) total += v message += "TOTAL:{}\n".format(total) summary += "{}: {}".format(elementType, message) summary += "TOTAL Exec. Env.: {}".format(n_ee) return summary logger.debug("") if filter: - check_client_version(ctx.obj, '--filter') - filter='&'.join(filter) + check_client_version(ctx.obj, "--filter") + filter = "&".join(filter) resp = ctx.obj.ns.list(filter) else: resp = ctx.obj.ns.list() if long: table = PrettyTable( - ['ns instance name', - 'id', - 'date', - 'ns state', - 'current operation', - 'error details', - 'project', - 'vim (inst param)', - 'deployment status', - 'configuration status']) + [ + "ns instance name", + "id", + "date", + "ns state", + "current operation", + "error details", + "project", + "vim (inst param)", + "deployment status", + "configuration status", + ] + ) project_list = ctx.obj.project.list() try: vim_list = ctx.obj.vim.list() except: vim_list = [] else: table = PrettyTable( - ['ns instance name', - 'id', - 'date', - 'ns state', - 'current operation', - 'error details']) + [ + "ns instance name", + "id", + "date", + "ns state", + "current operation", + "error details", + ] + ) for ns in resp: fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ - if fullclassname == 'osmclient.sol005.client.Client': + if fullclassname == "osmclient.sol005.client.Client": nsr = ns - logger.debug('NS info: {}'.format(nsr)) - nsr_name = nsr['name'] - nsr_id = nsr['_id'] - date = datetime.fromtimestamp(nsr['create-time']).strftime("%Y-%m-%dT%H:%M:%S") - ns_state = nsr.get('nsState', nsr['_admin']['nsState']) + logger.debug("NS info: {}".format(nsr)) + nsr_name = nsr["name"] + nsr_id = nsr["_id"] + date = datetime.fromtimestamp(nsr["create-time"]).strftime( + "%Y-%m-%dT%H:%M:%S" + ) + ns_state = nsr.get("nsState", nsr["_admin"]["nsState"]) if long: - deployment_status = summarize_deployment_status(nsr.get('deploymentStatus')) - config_status = summarize_config_status(nsr.get('configurationStatus')) + deployment_status = summarize_deployment_status( + nsr.get("deploymentStatus") + ) + config_status = summarize_config_status(nsr.get("configurationStatus")) project_id, project_name = get_project(project_list, nsr) - #project = '{} ({})'.format(project_name, project_id) + # project = '{} ({})'.format(project_name, project_id) project = project_name - vim_id = nsr.get('datacenter') + vim_id = nsr.get("datacenter") vim_name = get_vim_name(vim_list, vim_id) - #vim = '{} ({})'.format(vim_name, vim_id) + # vim = '{} ({})'.format(vim_name, vim_id) vim = vim_name - if 'currentOperation' in nsr: - current_operation = "{} ({})".format(nsr['currentOperation'],nsr['currentOperationID']) + if "currentOperation" in nsr: + current_operation = "{} ({})".format( + nsr["currentOperation"], nsr["currentOperationID"] + ) else: - current_operation = "{} ({})".format(nsr['_admin'].get('current-operation','-'), nsr['_admin']['nslcmop']) + current_operation = "{} ({})".format( + nsr["_admin"].get("current-operation", "-"), + nsr["_admin"]["nslcmop"], + ) error_details = "N/A" - if ns_state == "BROKEN" or ns_state == "DEGRADED" or \ - ('currentOperation' not in nsr and nsr.get('errorDescription')): - error_details = "{}\nDetail: {}".format(nsr['errorDescription'], nsr['errorDetail']) + if ( + ns_state == "BROKEN" + or ns_state == "DEGRADED" + or ("currentOperation" not in nsr and nsr.get("errorDescription")) + ): + error_details = "{}\nDetail: {}".format( + nsr["errorDescription"], nsr["errorDetail"] + ) else: - nsopdata = ctx.obj.ns.get_opdata(ns['id']) - nsr = nsopdata['nsr:nsr'] - nsr_name = nsr['name-ref'] - nsr_id = nsr['ns-instance-config-ref'] - date = '-' - project = '-' - deployment_status = nsr['operational-status'] if 'operational-status' in nsr else 'Not found' + nsopdata = ctx.obj.ns.get_opdata(ns["id"]) + nsr = nsopdata["nsr:nsr"] + nsr_name = nsr["name-ref"] + nsr_id = nsr["ns-instance-config-ref"] + date = "-" + project = "-" + deployment_status = ( + nsr["operational-status"] + if "operational-status" in nsr + else "Not found" + ) ns_state = deployment_status - config_status = nsr.get('config-status', 'Not found') + config_status = nsr.get("config-status", "Not found") current_operation = "Unknown" - error_details = nsr.get('detailed-status', 'Not found') + error_details = nsr.get("detailed-status", "Not found") if config_status == "config_not_needed": config_status = "configured (no charms)" if long: table.add_row( - [nsr_name, - nsr_id, - date, - ns_state, - current_operation, - wrap_text(text=error_details,width=40), - project, - vim, - deployment_status, - config_status]) + [ + nsr_name, + nsr_id, + date, + ns_state, + current_operation, + wrap_text(text=error_details, width=40), + project, + vim, + deployment_status, + config_status, + ] + ) else: table.add_row( - [nsr_name, - nsr_id, - date, - ns_state, - current_operation, - wrap_text(text=error_details,width=40)]) - table.align = 'l' + [ + nsr_name, + nsr_id, + date, + ns_state, + current_operation, + wrap_text(text=error_details, width=40), + ] + ) + table.align = "l" print(table) print('To get the history of all operations over a NS, run "osm ns-op-list NS_ID"') - print('For more details on the current operation, run "osm ns-op-show OPERATION_ID"') + print( + 'For more details on the current operation, run "osm ns-op-show OPERATION_ID"' + ) + def nsd_list(ctx, filter, long): logger.debug("") if filter: - check_client_version(ctx.obj, '--filter') - filter='&'.join(filter) + check_client_version(ctx.obj, "--filter") + filter = "&".join(filter) resp = ctx.obj.nsd.list(filter) else: resp = ctx.obj.nsd.list() # print(yaml.safe_dump(resp)) fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ - if fullclassname == 'osmclient.sol005.client.Client': + if fullclassname == "osmclient.sol005.client.Client": if long: - table = PrettyTable(['nsd name', 'id', 'onboarding state', 'operational state', - 'usage state', 'date', 'last update']) + table = PrettyTable( + [ + "nsd name", + "id", + "onboarding state", + "operational state", + "usage state", + "date", + "last update", + ] + ) else: - table = PrettyTable(['nsd name', 'id']) + table = PrettyTable(["nsd name", "id"]) for nsd in resp: - name = nsd.get('id', '-') + name = nsd.get("id", "-") if long: - onb_state = nsd['_admin'].get('onboardingState','-') - op_state = nsd['_admin'].get('operationalState','-') - usage_state = nsd['_admin'].get('usageState','-') - date = datetime.fromtimestamp(nsd['_admin']['created']).strftime("%Y-%m-%dT%H:%M:%S") - last_update = datetime.fromtimestamp(nsd['_admin']['modified']).strftime("%Y-%m-%dT%H:%M:%S") - table.add_row([name, nsd['_id'], onb_state, op_state, usage_state, date, last_update]) + onb_state = nsd["_admin"].get("onboardingState", "-") + op_state = nsd["_admin"].get("operationalState", "-") + usage_state = nsd["_admin"].get("usageState", "-") + date = datetime.fromtimestamp(nsd["_admin"]["created"]).strftime( + "%Y-%m-%dT%H:%M:%S" + ) + last_update = datetime.fromtimestamp( + nsd["_admin"]["modified"] + ).strftime("%Y-%m-%dT%H:%M:%S") + table.add_row( + [ + name, + nsd["_id"], + onb_state, + op_state, + usage_state, + date, + last_update, + ] + ) else: - table.add_row([name, nsd['_id']]) + table.add_row([name, nsd["_id"]]) else: - table = PrettyTable(['nsd name', 'id']) + table = PrettyTable(["nsd name", "id"]) for nsd in resp: - table.add_row([nsd['name'], nsd['id']]) - table.align = 'l' + table.add_row([nsd["name"], nsd["id"]]) + table.align = "l" print(table) -@cli_osm.command(name='nsd-list', short_help='list all NS packages') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NSD/NSpkg matching the filter') -@click.option('--long', is_flag=True, help='get more details') +@cli_osm.command(name="nsd-list", short_help="list all NS packages") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NSD/NSpkg matching the filter", +) +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def nsd_list1(ctx, filter, long): """list all NSD/NS pkg in the system""" logger.debug("") nsd_list(ctx, filter, long) -@cli_osm.command(name='nspkg-list', short_help='list all NS packages') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NSD/NSpkg matching the filter') -@click.option('--long', is_flag=True, help='get more details') +@cli_osm.command(name="nspkg-list", short_help="list all NS packages") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NSD/NSpkg matching the filter", +) +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def nsd_list2(ctx, filter, long): """list all NS packages""" logger.debug("") nsd_list(ctx, filter, long) def pkg_repo_list(ctx, pkgtype, filter, repo, long): resp = ctx.obj.osmrepo.pkg_list(pkgtype, filter, repo) if long: - table = PrettyTable(['nfpkg name', 'vendor', 'version', 'latest', 'description', 'repository']) + table = PrettyTable( + ["nfpkg name", "vendor", "version", "latest", "description", "repository"] + ) else: - table = PrettyTable(['nfpkg name', 'repository']) + table = PrettyTable(["nfpkg name", "repository"]) for vnfd in resp: - name = vnfd.get('id', vnfd.get('name','-')) - repository = vnfd.get('repository') + name = vnfd.get("id", vnfd.get("name", "-")) + repository = vnfd.get("repository") if long: - vendor = vnfd.get('provider', vnfd.get('vendor')) - version = vnfd.get('version') - description = vnfd.get('description') - latest = vnfd.get('latest') + vendor = vnfd.get("provider", vnfd.get("vendor")) + version = vnfd.get("version") + description = vnfd.get("description") + latest = vnfd.get("latest") table.add_row([name, vendor, version, latest, description, repository]) else: table.add_row([name, repository]) - table.align = 'l' + table.align = "l" print(table) + def vnfd_list(ctx, nf_type, filter, long): logger.debug("") if nf_type: - check_client_version(ctx.obj, '--nf_type') + check_client_version(ctx.obj, "--nf_type") elif filter: - check_client_version(ctx.obj, '--filter') + check_client_version(ctx.obj, "--filter") if filter: - filter='&'.join(filter) + filter = "&".join(filter) if nf_type: if nf_type == "vnf": nf_filter = "_admin.type=vnfd" elif nf_type == "pnf": nf_filter = "_admin.type=pnfd" elif nf_type == "hnf": nf_filter = "_admin.type=hnfd" else: - raise ClientException('wrong value for "--nf_type" option, allowed values: vnf, pnf, hnf') + raise ClientException( + 'wrong value for "--nf_type" option, allowed values: vnf, pnf, hnf' + ) if filter: - filter = '{}&{}'.format(nf_filter, filter) + filter = "{}&{}".format(nf_filter, filter) else: filter = nf_filter if filter: resp = ctx.obj.vnfd.list(filter) else: resp = ctx.obj.vnfd.list() # print(yaml.safe_dump(resp)) fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ - if fullclassname == 'osmclient.sol005.client.Client': + if fullclassname == "osmclient.sol005.client.Client": if long: - table = PrettyTable(['nfpkg name', 'id', 'desc type', 'vendor', 'version', 'onboarding state', 'operational state', - 'usage state', 'date', 'last update']) + table = PrettyTable( + [ + "nfpkg name", + "id", + "desc type", + "vendor", + "version", + "onboarding state", + "operational state", + "usage state", + "date", + "last update", + ] + ) else: - table = PrettyTable(['nfpkg name', 'id', 'desc type']) + table = PrettyTable(["nfpkg name", "id", "desc type"]) for vnfd in resp: - name = vnfd.get('id', vnfd.get('name','-')) - descriptor_type = 'sol006' if 'product-name' in vnfd else 'rel8' + name = vnfd.get("id", vnfd.get("name", "-")) + descriptor_type = "sol006" if "product-name" in vnfd else "rel8" if long: - onb_state = vnfd['_admin'].get('onboardingState','-') - op_state = vnfd['_admin'].get('operationalState','-') - vendor = vnfd.get('provider', vnfd.get('vendor')) - version = vnfd.get('version') - usage_state = vnfd['_admin'].get('usageState','-') - date = datetime.fromtimestamp(vnfd['_admin']['created']).strftime("%Y-%m-%dT%H:%M:%S") - last_update = datetime.fromtimestamp(vnfd['_admin']['modified']).strftime("%Y-%m-%dT%H:%M:%S") - table.add_row([name, vnfd['_id'], descriptor_type, vendor, version, onb_state, op_state, usage_state, date, last_update]) + onb_state = vnfd["_admin"].get("onboardingState", "-") + op_state = vnfd["_admin"].get("operationalState", "-") + vendor = vnfd.get("provider", vnfd.get("vendor")) + version = vnfd.get("version") + usage_state = vnfd["_admin"].get("usageState", "-") + date = datetime.fromtimestamp(vnfd["_admin"]["created"]).strftime( + "%Y-%m-%dT%H:%M:%S" + ) + last_update = datetime.fromtimestamp( + vnfd["_admin"]["modified"] + ).strftime("%Y-%m-%dT%H:%M:%S") + table.add_row( + [ + name, + vnfd["_id"], + descriptor_type, + vendor, + version, + onb_state, + op_state, + usage_state, + date, + last_update, + ] + ) else: - table.add_row([name, vnfd['_id'], descriptor_type]) + table.add_row([name, vnfd["_id"], descriptor_type]) else: - table = PrettyTable(['nfpkg name', 'id']) + table = PrettyTable(["nfpkg name", "id"]) for vnfd in resp: - table.add_row([vnfd['name'], vnfd['id']]) - table.align = 'l' + table.add_row([vnfd["name"], vnfd["id"]]) + table.align = "l" print(table) -@cli_osm.command(name='vnfd-list', short_help='list all xNF packages (VNF, HNF, PNF)') -@click.option('--nf_type', help='type of NF (vnf, pnf, hnf)') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NF pkg matching the filter') -@click.option('--long', is_flag=True, help='get more details') +@cli_osm.command(name="vnfd-list", short_help="list all xNF packages (VNF, HNF, PNF)") +@click.option("--nf_type", help="type of NF (vnf, pnf, hnf)") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NF pkg matching the filter", +) +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def vnfd_list1(ctx, nf_type, filter, long): """list all xNF packages (VNF, HNF, PNF)""" logger.debug("") vnfd_list(ctx, nf_type, filter, long) -@cli_osm.command(name='vnfpkg-list', short_help='list all xNF packages (VNF, HNF, PNF)') -@click.option('--nf_type', help='type of NF (vnf, pnf, hnf)') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NFpkg matching the filter') -@click.option('--long', is_flag=True, help='get more details') +@cli_osm.command(name="vnfpkg-list", short_help="list all xNF packages (VNF, HNF, PNF)") +@click.option("--nf_type", help="type of NF (vnf, pnf, hnf)") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NFpkg matching the filter", +) +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def vnfd_list2(ctx, nf_type, filter, long): """list all xNF packages (VNF, HNF, PNF)""" logger.debug("") vnfd_list(ctx, nf_type, filter, long) -@cli_osm.command(name='nfpkg-list', short_help='list all xNF packages (VNF, HNF, PNF)') -@click.option('--nf_type', help='type of NF (vnf, pnf, hnf)') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NFpkg matching the filter') -@click.option('--long', is_flag=True, help='get more details') +@cli_osm.command(name="nfpkg-list", short_help="list all xNF packages (VNF, HNF, PNF)") +@click.option("--nf_type", help="type of NF (vnf, pnf, hnf)") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NFpkg matching the filter", +) +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def nfpkg_list(ctx, nf_type, filter, long): """list all xNF packages (VNF, HNF, PNF)""" logger.debug("") # try: @@ -602,127 +745,191 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='vnfpkg-repo-list', short_help='list all xNF from OSM repositories') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NFpkg matching the filter') -@click.option('--repo', default=None, - help='restricts the list to a particular OSM repository') -@click.option('--long', is_flag=True, help='get more details') +@cli_osm.command( + name="vnfpkg-repo-list", short_help="list all xNF from OSM repositories" +) +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NFpkg matching the filter", +) +@click.option( + "--repo", default=None, help="restricts the list to a particular OSM repository" +) +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def nfpkg_repo_list1(ctx, filter, repo, long): """list xNF packages from OSM repositories""" - pkgtype = 'vnf' + pkgtype = "vnf" pkg_repo_list(ctx, pkgtype, filter, repo, long) -@cli_osm.command(name='nfpkg-repo-list', short_help='list all xNF from OSM repositories') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NFpkg matching the filter') -@click.option('--repo', default=None, - help='restricts the list to a particular OSM repository') -@click.option('--long', is_flag=True, help='get more details') + +@cli_osm.command( + name="nfpkg-repo-list", short_help="list all xNF from OSM repositories" +) +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NFpkg matching the filter", +) +@click.option( + "--repo", default=None, help="restricts the list to a particular OSM repository" +) +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def nfpkg_repo_list2(ctx, filter, repo, long): """list xNF packages from OSM repositories""" - pkgtype = 'vnf' + pkgtype = "vnf" pkg_repo_list(ctx, pkgtype, filter, repo, long) def vnf_list(ctx, ns, filter, long): # try: if ns or filter: if ns: - check_client_version(ctx.obj, '--ns') + check_client_version(ctx.obj, "--ns") if filter: - filter='&'.join(filter) - check_client_version(ctx.obj, '--filter') + filter = "&".join(filter) + check_client_version(ctx.obj, "--filter") resp = ctx.obj.vnf.list(ns, filter) else: resp = ctx.obj.vnf.list() # except ClientException as e: # print(str(e)) # exit(1) fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ - if fullclassname == 'osmclient.sol005.client.Client': - field_names = ['vnf id', 'name', 'ns id', 'vnf member index', - 'vnfd name', 'vim account id', 'ip address'] + if fullclassname == "osmclient.sol005.client.Client": + field_names = [ + "vnf id", + "name", + "ns id", + "vnf member index", + "vnfd name", + "vim account id", + "ip address", + ] if long: - field_names = ['vnf id', 'name', 'ns id', 'vnf member index', - 'vnfd name', 'vim account id', 'ip address', - 'date', 'last update'] + field_names = [ + "vnf id", + "name", + "ns id", + "vnf member index", + "vnfd name", + "vim account id", + "ip address", + "date", + "last update", + ] table = PrettyTable(field_names) for vnfr in resp: - name = vnfr['name'] if 'name' in vnfr else '-' - new_row = [vnfr['_id'], name, vnfr['nsr-id-ref'], - vnfr['member-vnf-index-ref'], vnfr['vnfd-ref'], - vnfr['vim-account-id'], vnfr['ip-address']] + name = vnfr["name"] if "name" in vnfr else "-" + new_row = [ + vnfr["_id"], + name, + vnfr["nsr-id-ref"], + vnfr["member-vnf-index-ref"], + vnfr["vnfd-ref"], + vnfr["vim-account-id"], + vnfr["ip-address"], + ] if long: - date = datetime.fromtimestamp(vnfr['_admin']['created']).strftime("%Y-%m-%dT%H:%M:%S") - last_update = datetime.fromtimestamp(vnfr['_admin']['modified']).strftime("%Y-%m-%dT%H:%M:%S") + date = datetime.fromtimestamp(vnfr["_admin"]["created"]).strftime( + "%Y-%m-%dT%H:%M:%S" + ) + last_update = datetime.fromtimestamp( + vnfr["_admin"]["modified"] + ).strftime("%Y-%m-%dT%H:%M:%S") new_row.extend([date, last_update]) table.add_row(new_row) else: - table = PrettyTable( - ['vnf name', - 'id', - 'operational status', - 'config status']) + table = PrettyTable(["vnf name", "id", "operational status", "config status"]) for vnfr in resp: - if 'mgmt-interface' not in vnfr: - vnfr['mgmt-interface'] = {} - vnfr['mgmt-interface']['ip-address'] = None + if "mgmt-interface" not in vnfr: + vnfr["mgmt-interface"] = {} + vnfr["mgmt-interface"]["ip-address"] = None table.add_row( - [vnfr['name'], - vnfr['id'], - vnfr['operational-status'], - vnfr['config-status']]) - table.align = 'l' + [ + vnfr["name"], + vnfr["id"], + vnfr["operational-status"], + vnfr["config-status"], + ] + ) + table.align = "l" print(table) -@cli_osm.command(name='vnf-list', short_help='list all NF instances') -@click.option('--ns', default=None, help='NS instance id or name to restrict the NF list') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NF instances matching the filter.') -@click.option('--long', is_flag=True, help='get more details') +@cli_osm.command(name="vnf-list", short_help="list all NF instances") +@click.option( + "--ns", default=None, help="NS instance id or name to restrict the NF list" +) +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NF instances matching the filter.", +) +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def vnf_list1(ctx, ns, filter, long): """list all NF instances""" logger.debug("") vnf_list(ctx, ns, filter, long) -@cli_osm.command(name='nsd-repo-list', short_help='list all NS from OSM repositories') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NS matching the filter') -@click.option('--repo', default=None, - help='restricts the list to a particular OSM repository') -@click.option('--long', is_flag=True, help='get more details') + +@cli_osm.command(name="nsd-repo-list", short_help="list all NS from OSM repositories") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NS matching the filter", +) +@click.option( + "--repo", default=None, help="restricts the list to a particular OSM repository" +) +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def nspkg_repo_list(ctx, filter, repo, long): """list xNF packages from OSM repositories""" - pkgtype = 'ns' + pkgtype = "ns" pkg_repo_list(ctx, pkgtype, filter, repo, long) -@cli_osm.command(name='nspkg-repo-list', short_help='list all NS from OSM repositories') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NS matching the filter') -@click.option('--repo', default=None, - help='restricts the list to a particular OSM repository') -@click.option('--long', is_flag=True, help='get more details') + +@cli_osm.command(name="nspkg-repo-list", short_help="list all NS from OSM repositories") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NS matching the filter", +) +@click.option( + "--repo", default=None, help="restricts the list to a particular OSM repository" +) +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def nspkg_repo_list2(ctx, filter, repo, long): """list xNF packages from OSM repositories""" - pkgtype = 'ns' + pkgtype = "ns" pkg_repo_list(ctx, pkgtype, filter, repo, long) -@cli_osm.command(name='nf-list', short_help='list all NF instances') -@click.option('--ns', default=None, help='NS instance id or name to restrict the NF list') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NF instances matching the filter.') -@click.option('--long', is_flag=True, help='get more details') + +@cli_osm.command(name="nf-list", short_help="list all NF instances") +@click.option( + "--ns", default=None, help="NS instance id or name to restrict the NF list" +) +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NF instances matching the filter.", +) +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def nf_list(ctx, ns, filter, long): """list all NF instances \b @@ -772,30 +979,34 @@ """ logger.debug("") vnf_list(ctx, ns, filter, long) -@cli_osm.command(name='ns-op-list', short_help='shows the history of operations over a NS instance') -@click.argument('name') -@click.option('--long', is_flag=True, - help='get more details of the NS operation (date, ).') +@cli_osm.command( + name="ns-op-list", short_help="shows the history of operations over a NS instance" +) +@click.argument("name") +@click.option( + "--long", is_flag=True, help="get more details of the NS operation (date, )." +) @click.pass_context def ns_op_list(ctx, name, long): """shows the history of operations over a NS instance NAME: name or ID of the NS instance """ + def formatParams(params): - if params['lcmOperationType']=='instantiate': - params.pop('nsDescription') - params.pop('nsName') - params.pop('nsdId') - params.pop('nsr_id') - elif params['lcmOperationType']=='action': - params.pop('primitive') - params.pop('lcmOperationType') - params.pop('nsInstanceId') + if params["lcmOperationType"] == "instantiate": + params.pop("nsDescription") + params.pop("nsName") + params.pop("nsdId") + params.pop("nsr_id") + elif params["lcmOperationType"] == "action": + params.pop("primitive") + params.pop("lcmOperationType") + params.pop("nsInstanceId") return params logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) @@ -803,94 +1014,136 @@ # except ClientException as e: # print(str(e)) # exit(1) if long: - table = PrettyTable(['id', 'operation', 'action_name', 'operation_params', 'status', 'date', 'last update', 'detail']) + table = PrettyTable( + [ + "id", + "operation", + "action_name", + "operation_params", + "status", + "date", + "last update", + "detail", + ] + ) else: - table = PrettyTable(['id', 'operation', 'action_name', 'status', 'date', 'detail']) - - #print(yaml.safe_dump(resp)) + table = PrettyTable( + ["id", "operation", "action_name", "status", "date", "detail"] + ) + + # print(yaml.safe_dump(resp)) for op in resp: action_name = "N/A" - if op['lcmOperationType']=='action': - action_name = op['operationParams']['primitive'] + if op["lcmOperationType"] == "action": + action_name = op["operationParams"]["primitive"] detail = "-" - if op['operationState'] == 'PROCESSING': - if op['queuePosition'] is not None and op['queuePosition'] > 0: - detail = "In queue. Current position: {}".format(op['queuePosition']) - elif op['lcmOperationType'] in ('instantiate', 'terminate'): - if op['stage']: - detail = op['stage'] - elif op['operationState'] in ('FAILED', 'FAILED_TEMP'): - detail = op.get('errorMessage','-') - date = datetime.fromtimestamp(op['startTime']).strftime("%Y-%m-%dT%H:%M:%S") - last_update = datetime.fromtimestamp(op['statusEnteredTime']).strftime("%Y-%m-%dT%H:%M:%S") + if op["operationState"] == "PROCESSING": + if op["queuePosition"] is not None and op["queuePosition"] > 0: + detail = "In queue. Current position: {}".format(op["queuePosition"]) + elif op["lcmOperationType"] in ("instantiate", "terminate"): + if op["stage"]: + detail = op["stage"] + elif op["operationState"] in ("FAILED", "FAILED_TEMP"): + detail = op.get("errorMessage", "-") + date = datetime.fromtimestamp(op["startTime"]).strftime("%Y-%m-%dT%H:%M:%S") + last_update = datetime.fromtimestamp(op["statusEnteredTime"]).strftime( + "%Y-%m-%dT%H:%M:%S" + ) if long: - table.add_row([op['id'], - op['lcmOperationType'], - action_name, - wrap_text(text=json.dumps(formatParams(op['operationParams']),indent=2),width=50), - op['operationState'], - date, - last_update, - wrap_text(text=detail,width=50)]) + table.add_row( + [ + op["id"], + op["lcmOperationType"], + action_name, + wrap_text( + text=json.dumps(formatParams(op["operationParams"]), indent=2), + width=50, + ), + op["operationState"], + date, + last_update, + wrap_text(text=detail, width=50), + ] + ) else: - table.add_row([op['id'], op['lcmOperationType'], action_name, - op['operationState'], date, wrap_text(text=detail or "",width=50)]) - table.align = 'l' + table.add_row( + [ + op["id"], + op["lcmOperationType"], + action_name, + op["operationState"], + date, + wrap_text(text=detail or "", width=50), + ] + ) + table.align = "l" print(table) def nsi_list(ctx, filter): """list all Network Slice Instances""" logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) if filter: - filter='&'.join(filter) + filter = "&".join(filter) resp = ctx.obj.nsi.list(filter) # except ClientException as e: # print(str(e)) # exit(1) table = PrettyTable( - ['netslice instance name', - 'id', - 'operational status', - 'config status', - 'detailed status']) + [ + "netslice instance name", + "id", + "operational status", + "config status", + "detailed status", + ] + ) for nsi in resp: - nsi_name = nsi['name'] - nsi_id = nsi['_id'] - opstatus = nsi['operational-status'] if 'operational-status' in nsi else 'Not found' - configstatus = nsi['config-status'] if 'config-status' in nsi else 'Not found' - detailed_status = nsi['detailed-status'] if 'detailed-status' in nsi else 'Not found' + nsi_name = nsi["name"] + nsi_id = nsi["_id"] + opstatus = ( + nsi["operational-status"] if "operational-status" in nsi else "Not found" + ) + configstatus = nsi["config-status"] if "config-status" in nsi else "Not found" + detailed_status = ( + nsi["detailed-status"] if "detailed-status" in nsi else "Not found" + ) if configstatus == "config_not_needed": configstatus = "configured (no charms)" - table.add_row( - [nsi_name, - nsi_id, - opstatus, - configstatus, - detailed_status]) - table.align = 'l' + table.add_row([nsi_name, nsi_id, opstatus, configstatus, detailed_status]) + table.align = "l" print(table) -@cli_osm.command(name='nsi-list', short_help='list all Network Slice Instances (NSI)') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the Network Slice Instances matching the filter') +@cli_osm.command(name="nsi-list", short_help="list all Network Slice Instances (NSI)") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the Network Slice Instances matching the filter", +) @click.pass_context def nsi_list1(ctx, filter): """list all Network Slice Instances (NSI)""" logger.debug("") nsi_list(ctx, filter) -@cli_osm.command(name='netslice-instance-list', short_help='list all Network Slice Instances (NSI)') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the Network Slice Instances matching the filter') +@cli_osm.command( + name="netslice-instance-list", short_help="list all Network Slice Instances (NSI)" +) +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the Network Slice Instances matching the filter", +) @click.pass_context def nsi_list2(ctx, filter): """list all Network Slice Instances (NSI)""" logger.debug("") nsi_list(ctx, filter) @@ -899,37 +1152,47 @@ def nst_list(ctx, filter): logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) if filter: - filter='&'.join(filter) + filter = "&".join(filter) resp = ctx.obj.nst.list(filter) # except ClientException as e: # print(str(e)) # exit(1) # print(yaml.safe_dump(resp)) - table = PrettyTable(['nst name', 'id']) + table = PrettyTable(["nst name", "id"]) for nst in resp: - name = nst['name'] if 'name' in nst else '-' - table.add_row([name, nst['_id']]) - table.align = 'l' + name = nst["name"] if "name" in nst else "-" + table.add_row([name, nst["_id"]]) + table.align = "l" print(table) -@cli_osm.command(name='nst-list', short_help='list all Network Slice Templates (NST)') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NST matching the filter') +@cli_osm.command(name="nst-list", short_help="list all Network Slice Templates (NST)") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NST matching the filter", +) @click.pass_context def nst_list1(ctx, filter): """list all Network Slice Templates (NST) in the system""" logger.debug("") nst_list(ctx, filter) -@cli_osm.command(name='netslice-template-list', short_help='list all Network Slice Templates (NST)') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the NST matching the filter') +@cli_osm.command( + name="netslice-template-list", short_help="list all Network Slice Templates (NST)" +) +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the NST matching the filter", +) @click.pass_context def nst_list2(ctx, filter): """list all Network Slice Templates (NST) in the system""" logger.debug("") nst_list(ctx, filter) @@ -941,84 +1204,86 @@ check_client_version(ctx.obj, ctx.command.name) resp = ctx.obj.nsi.list_op(name) # except ClientException as e: # print(str(e)) # exit(1) - table = PrettyTable(['id', 'operation', 'status']) + table = PrettyTable(["id", "operation", "status"]) for op in resp: - table.add_row([op['id'], op['lcmOperationType'], - op['operationState']]) - table.align = 'l' + table.add_row([op["id"], op["lcmOperationType"], op["operationState"]]) + table.align = "l" print(table) -@cli_osm.command(name='nsi-op-list', short_help='shows the history of operations over a Network Slice Instance (NSI)') -@click.argument('name') +@cli_osm.command( + name="nsi-op-list", + short_help="shows the history of operations over a Network Slice Instance (NSI)", +) +@click.argument("name") @click.pass_context def nsi_op_list1(ctx, name): """shows the history of operations over a Network Slice Instance (NSI) NAME: name or ID of the Network Slice Instance """ logger.debug("") nsi_op_list(ctx, name) -@cli_osm.command(name='netslice-instance-op-list', short_help='shows the history of operations over a Network Slice Instance (NSI)') -@click.argument('name') +@cli_osm.command( + name="netslice-instance-op-list", + short_help="shows the history of operations over a Network Slice Instance (NSI)", +) +@click.argument("name") @click.pass_context def nsi_op_list2(ctx, name): """shows the history of operations over a Network Slice Instance (NSI) NAME: name or ID of the Network Slice Instance """ logger.debug("") nsi_op_list(ctx, name) -@cli_osm.command(name='pdu-list', short_help='list all Physical Deployment Units (PDU)') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the Physical Deployment Units matching the filter') +@cli_osm.command(name="pdu-list", short_help="list all Physical Deployment Units (PDU)") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the Physical Deployment Units matching the filter", +) @click.pass_context def pdu_list(ctx, filter): """list all Physical Deployment Units (PDU)""" logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) if filter: - filter='&'.join(filter) + filter = "&".join(filter) resp = ctx.obj.pdu.list(filter) # except ClientException as e: # print(str(e)) # exit(1) - table = PrettyTable( - ['pdu name', - 'id', - 'type', - 'mgmt ip address']) + table = PrettyTable(["pdu name", "id", "type", "mgmt ip address"]) for pdu in resp: - pdu_name = pdu['name'] - pdu_id = pdu['_id'] - pdu_type = pdu['type'] + pdu_name = pdu["name"] + pdu_id = pdu["_id"] + pdu_type = pdu["type"] pdu_ipaddress = "None" - for iface in pdu['interfaces']: - if iface['mgmt']: - pdu_ipaddress = iface['ip-address'] + for iface in pdu["interfaces"]: + if iface["mgmt"]: + pdu_ipaddress = iface["ip-address"] break - table.add_row( - [pdu_name, - pdu_id, - pdu_type, - pdu_ipaddress]) - table.align = 'l' + table.add_row([pdu_name, pdu_id, pdu_type, pdu_ipaddress]) + table.align = "l" print(table) #################### # SHOW operations #################### + def nsd_show(ctx, name, literal): logger.debug("") # try: resp = ctx.obj.nsd.get(name) # resp = ctx.obj.nsd.get_individual(name) @@ -1028,35 +1293,33 @@ if literal: print(yaml.safe_dump(resp, indent=4, default_flow_style=False)) return - table = PrettyTable(['field', 'value']) + table = PrettyTable(["field", "value"]) for k, v in list(resp.items()): - table.add_row([k, wrap_text(text=json.dumps(v, indent=2),width=100)]) - table.align = 'l' + table.add_row([k, wrap_text(text=json.dumps(v, indent=2), width=100)]) + table.align = "l" print(table) -@cli_osm.command(name='nsd-show', short_help='shows the details of a NS package') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.argument('name') +@cli_osm.command(name="nsd-show", short_help="shows the details of a NS package") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.argument("name") @click.pass_context def nsd_show1(ctx, name, literal): """shows the content of a NSD NAME: name or ID of the NSD/NSpkg """ logger.debug("") nsd_show(ctx, name, literal) -@cli_osm.command(name='nspkg-show', short_help='shows the details of a NS package') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.argument('name') +@cli_osm.command(name="nspkg-show", short_help="shows the details of a NS package") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.argument("name") @click.pass_context def nsd_show2(ctx, name, literal): """shows the content of a NSD NAME: name or ID of the NSD/NSpkg @@ -1076,176 +1339,165 @@ if literal: print(yaml.safe_dump(resp, indent=4, default_flow_style=False)) return - table = PrettyTable(['field', 'value']) + table = PrettyTable(["field", "value"]) for k, v in list(resp.items()): - table.add_row([k, wrap_text(text=json.dumps(v, indent=2),width=100)]) - table.align = 'l' + table.add_row([k, wrap_text(text=json.dumps(v, indent=2), width=100)]) + table.align = "l" print(table) def pkg_repo_show(ctx, pkgtype, name, repo, version, filter, literal): logger.debug("") if filter: - filter='&'.join(filter) + filter = "&".join(filter) # try: resp = ctx.obj.osmrepo.pkg_get(pkgtype, name, repo, version, filter) if literal: print(yaml.safe_dump(resp, indent=4, default_flow_style=False)) return - pkgtype += 'd' - catalog = pkgtype + '-catalog' - full_catalog = pkgtype + ':' + catalog + pkgtype += "d" + catalog = pkgtype + "-catalog" + full_catalog = pkgtype + ":" + catalog if resp.get(catalog): resp = resp.pop(catalog)[pkgtype][0] elif resp.get(full_catalog): resp = resp.pop(full_catalog)[pkgtype][0] - table = PrettyTable(['field', 'value']) + table = PrettyTable(["field", "value"]) for k, v in list(resp.items()): table.add_row([k, wrap_text(text=json.dumps(v, indent=2), width=100)]) - table.align = 'l' + table.align = "l" print(table) -@cli_osm.command(name='vnfd-show', short_help='shows the details of a NF package') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.argument('name') +@cli_osm.command(name="vnfd-show", short_help="shows the details of a NF package") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.argument("name") @click.pass_context def vnfd_show1(ctx, name, literal): """shows the content of a VNFD NAME: name or ID of the VNFD/VNFpkg """ logger.debug("") vnfd_show(ctx, name, literal) -@cli_osm.command(name='vnfpkg-show', short_help='shows the details of a NF package') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.argument('name') +@cli_osm.command(name="vnfpkg-show", short_help="shows the details of a NF package") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.argument("name") @click.pass_context def vnfd_show2(ctx, name, literal): """shows the content of a VNFD NAME: name or ID of the VNFD/VNFpkg """ logger.debug("") vnfd_show(ctx, name, literal) -@cli_osm.command(name='vnfpkg-repo-show', short_help='shows the details of a NF package in an OSM repository') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.option('--repo', - required=True, - help='Repository name') -@click.argument('name') -@click.option('--filter', default=None, multiple=True, - help='filter by fields') -@click.option('--version', - default='latest', - help='package version') + +@cli_osm.command( + name="vnfpkg-repo-show", + short_help="shows the details of a NF package in an OSM repository", +) +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.option("--repo", required=True, help="Repository name") +@click.argument("name") +@click.option("--filter", default=None, multiple=True, help="filter by fields") +@click.option("--version", default="latest", help="package version") @click.pass_context def vnfd_show3(ctx, name, repo, version, literal=None, filter=None): """shows the content of a VNFD in a repository NAME: name or ID of the VNFD/VNFpkg """ - pkgtype = 'vnf' + pkgtype = "vnf" pkg_repo_show(ctx, pkgtype, name, repo, version, filter, literal) -@cli_osm.command(name='nsd-repo-show', short_help='shows the details of a NS package in an OSM repository') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.option('--repo', - required=True, - help='Repository name') -@click.argument('name') -@click.option('--filter', default=None, multiple=True, - help='filter by fields') -@click.option('--version', - default='latest', - help='package version') +@cli_osm.command( + name="nsd-repo-show", + short_help="shows the details of a NS package in an OSM repository", +) +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.option("--repo", required=True, help="Repository name") +@click.argument("name") +@click.option("--filter", default=None, multiple=True, help="filter by fields") +@click.option("--version", default="latest", help="package version") @click.pass_context def nsd_repo_show(ctx, name, repo, version, literal=None, filter=None): """shows the content of a VNFD in a repository NAME: name or ID of the VNFD/VNFpkg """ - pkgtype = 'ns' + pkgtype = "ns" pkg_repo_show(ctx, pkgtype, name, repo, version, filter, literal) -@cli_osm.command(name='nspkg-repo-show', short_help='shows the details of a NS package in an OSM repository') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.option('--repo', - required=True, - help='Repository name') -@click.argument('name') -@click.option('--filter', default=None, multiple=True, - help='filter by fields') -@click.option('--version', - default='latest', - help='package version') + +@cli_osm.command( + name="nspkg-repo-show", + short_help="shows the details of a NS package in an OSM repository", +) +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.option("--repo", required=True, help="Repository name") +@click.argument("name") +@click.option("--filter", default=None, multiple=True, help="filter by fields") +@click.option("--version", default="latest", help="package version") @click.pass_context def nsd_repo_show2(ctx, name, repo, version, literal=None, filter=None): """shows the content of a VNFD in a repository NAME: name or ID of the VNFD/VNFpkg """ - pkgtype = 'ns' + pkgtype = "ns" pkg_repo_show(ctx, pkgtype, name, repo, version, filter, literal) -@cli_osm.command(name='nfpkg-show', short_help='shows the details of a NF package') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.argument('name') +@cli_osm.command(name="nfpkg-show", short_help="shows the details of a NF package") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.argument("name") @click.pass_context def nfpkg_show(ctx, name, literal): """shows the content of a NF Descriptor NAME: name or ID of the NFpkg """ logger.debug("") vnfd_show(ctx, name, literal) -@cli_osm.command(name='nfpkg-repo-show', short_help='shows the details of a NF package in an OSM repository') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.option('--repo', - required=True, - help='Repository name') -@click.argument('name') -@click.option('--filter', default=None, multiple=True, - help='filter by fields') -@click.option('--version', - default='latest', - help='package version') +@cli_osm.command( + name="nfpkg-repo-show", + short_help="shows the details of a NF package in an OSM repository", +) +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.option("--repo", required=True, help="Repository name") +@click.argument("name") +@click.option("--filter", default=None, multiple=True, help="filter by fields") +@click.option("--version", default="latest", help="package version") @click.pass_context def vnfd_show4(ctx, name, repo, version, literal=None, filter=None): """shows the content of a VNFD in a repository NAME: name or ID of the VNFD/VNFpkg """ - pkgtype = 'vnf' + pkgtype = "vnf" pkg_repo_show(ctx, pkgtype, name, repo, version, filter, literal) -@cli_osm.command(name='ns-show', short_help='shows the info of a NS instance') -@click.argument('name') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.option('--filter', multiple=True, - help='restricts the information to the fields in the filter') +@cli_osm.command(name="ns-show", short_help="shows the info of a NS instance") +@click.argument("name") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.option( + "--filter", + multiple=True, + help="restricts the information to the fields in the filter", +) @click.pass_context def ns_show(ctx, name, literal, filter): """shows the info of a NS instance NAME: name or ID of the NS instance @@ -1259,54 +1511,63 @@ if literal: print(yaml.safe_dump(ns, indent=4, default_flow_style=False)) return - table = PrettyTable(['field', 'value']) + table = PrettyTable(["field", "value"]) for k, v in list(ns.items()): if not filter or k in filter: - table.add_row([k, wrap_text(text=json.dumps(v, indent=2),width=100)]) + table.add_row([k, wrap_text(text=json.dumps(v, indent=2), width=100)]) fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ - if fullclassname != 'osmclient.sol005.client.Client': - nsopdata = ctx.obj.ns.get_opdata(ns['id']) - nsr_optdata = nsopdata['nsr:nsr'] + if fullclassname != "osmclient.sol005.client.Client": + nsopdata = ctx.obj.ns.get_opdata(ns["id"]) + nsr_optdata = nsopdata["nsr:nsr"] for k, v in list(nsr_optdata.items()): if not filter or k in filter: - table.add_row([k, wrap_text(json.dumps(v, indent=2),width=100)]) - table.align = 'l' + table.add_row([k, wrap_text(json.dumps(v, indent=2), width=100)]) + table.align = "l" print(table) -@cli_osm.command(name='vnf-show', short_help='shows the info of a VNF instance') -@click.argument('name') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.option('--filter', multiple=True, - help='restricts the information to the fields in the filter') -@click.option('--kdu', default=None, help='KDU name (whose status will be shown)') +@cli_osm.command(name="vnf-show", short_help="shows the info of a VNF instance") +@click.argument("name") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.option( + "--filter", + multiple=True, + help="restricts the information to the fields in the filter", +) +@click.option("--kdu", default=None, help="KDU name (whose status will be shown)") @click.pass_context def vnf_show(ctx, name, literal, filter, kdu): """shows the info of a VNF instance NAME: name or ID of the VNF instance """ + def print_kdu_status(op_info_status): - """print KDU status properly formatted - """ + """print KDU status properly formatted""" try: op_status = yaml.safe_load(op_info_status) - if "namespace" in op_status and "info" in op_status and \ - "last_deployed" in op_status["info"] and "status" in op_status["info"] and \ - "code" in op_status["info"]["status"] and "resources" in op_status["info"]["status"] and \ - "seconds" in op_status["info"]["last_deployed"]: - last_deployed_time = datetime.fromtimestamp(op_status["info"]["last_deployed"]["seconds"]).strftime("%a %b %d %I:%M:%S %Y") + if ( + "namespace" in op_status + and "info" in op_status + and "last_deployed" in op_status["info"] + and "status" in op_status["info"] + and "code" in op_status["info"]["status"] + and "resources" in op_status["info"]["status"] + and "seconds" in op_status["info"]["last_deployed"] + ): + last_deployed_time = datetime.fromtimestamp( + op_status["info"]["last_deployed"]["seconds"] + ).strftime("%a %b %d %I:%M:%S %Y") print("LAST DEPLOYED: {}".format(last_deployed_time)) print("NAMESPACE: {}".format(op_status["namespace"])) status_code = "UNKNOWN" - if op_status["info"]["status"]["code"]==1: + if op_status["info"]["status"]["code"] == 1: status_code = "DEPLOYED" print("STATUS: {}".format(status_code)) print() print("RESOURCES:") print(op_status["info"]["status"]["resources"]) @@ -1319,56 +1580,60 @@ print(op_info_status) logger.debug("") if kdu: if literal: - raise ClientException('"--literal" option is incompatible with "--kdu" option') + raise ClientException( + '"--literal" option is incompatible with "--kdu" option' + ) if filter: - raise ClientException('"--filter" option is incompatible with "--kdu" option') + raise ClientException( + '"--filter" option is incompatible with "--kdu" option' + ) # try: check_client_version(ctx.obj, ctx.command.name) resp = ctx.obj.vnf.get(name) if kdu: - ns_id = resp['nsr-id-ref'] - op_data={} - op_data['member_vnf_index'] = resp['member-vnf-index-ref'] - op_data['kdu_name'] = kdu - op_data['primitive'] = 'status' - op_data['primitive_params'] = {} - op_id = ctx.obj.ns.exec_op(ns_id, op_name='action', op_data=op_data, wait=False) + ns_id = resp["nsr-id-ref"] + op_data = {} + op_data["member_vnf_index"] = resp["member-vnf-index-ref"] + op_data["kdu_name"] = kdu + op_data["primitive"] = "status" + op_data["primitive_params"] = {} + op_id = ctx.obj.ns.exec_op(ns_id, op_name="action", op_data=op_data, wait=False) t = 0 - while t<30: + while t < 30: op_info = ctx.obj.ns.get_op(op_id) - if op_info['operationState'] == 'COMPLETED': - print_kdu_status(op_info['detailed-status']) + if op_info["operationState"] == "COMPLETED": + print_kdu_status(op_info["detailed-status"]) return time.sleep(5) t += 5 - print ("Could not determine KDU status") + print("Could not determine KDU status") return if literal: print(yaml.safe_dump(resp, indent=4, default_flow_style=False)) return - table = PrettyTable(['field', 'value']) + table = PrettyTable(["field", "value"]) for k, v in list(resp.items()): if not filter or k in filter: - table.add_row([k, wrap_text(text=json.dumps(v,indent=2),width=100)]) - table.align = 'l' + table.add_row([k, wrap_text(text=json.dumps(v, indent=2), width=100)]) + table.align = "l" print(table) # except ClientException as e: # print(str(e)) # exit(1) -#@cli_osm.command(name='vnf-monitoring-show') -#@click.argument('vnf_name') -#@click.pass_context -#def vnf_monitoring_show(ctx, vnf_name): +# @cli_osm.command(name='vnf-monitoring-show') +# @click.argument('vnf_name') +# @click.pass_context +# def vnf_monitoring_show(ctx, vnf_name): # try: # check_client_version(ctx.obj, ctx.command.name, 'v1') # resp = ctx.obj.vnf.get_monitoring(vnf_name) # except ClientException as e: # print(str(e)) @@ -1384,14 +1649,14 @@ # monitor['units']]) # table.align = 'l' # print(table) -#@cli_osm.command(name='ns-monitoring-show') -#@click.argument('ns_name') -#@click.pass_context -#def ns_monitoring_show(ctx, ns_name): +# @cli_osm.command(name='ns-monitoring-show') +# @click.argument('ns_name') +# @click.pass_context +# def ns_monitoring_show(ctx, ns_name): # try: # check_client_version(ctx.obj, ctx.command.name, 'v1') # resp = ctx.obj.ns.get_monitoring(ns_name) # except ClientException as e: # print(str(e)) @@ -1407,16 +1672,18 @@ # monitor['units']]) # table.align = 'l' # print(table) -@cli_osm.command(name='ns-op-show', short_help='shows the info of a NS operation') -@click.argument('id') -@click.option('--filter', multiple=True, - help='restricts the information to the fields in the filter') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') +@cli_osm.command(name="ns-op-show", short_help="shows the info of a NS operation") +@click.argument("id") +@click.option( + "--filter", + multiple=True, + help="restricts the information to the fields in the filter", +) +@click.option("--literal", is_flag=True, help="print literally, no pretty table") @click.pass_context def ns_op_show(ctx, id, filter, literal): """shows the detailed info of a NS operation ID: operation identifier @@ -1431,57 +1698,60 @@ if literal: print(yaml.safe_dump(op_info, indent=4, default_flow_style=False)) return - table = PrettyTable(['field', 'value']) + table = PrettyTable(["field", "value"]) for k, v in list(op_info.items()): if not filter or k in filter: table.add_row([k, wrap_text(json.dumps(v, indent=2), 100)]) - table.align = 'l' + table.align = "l" print(table) def nst_show(ctx, name, literal): logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) resp = ctx.obj.nst.get(name) - #resp = ctx.obj.nst.get_individual(name) + # resp = ctx.obj.nst.get_individual(name) # except ClientException as e: # print(str(e)) # exit(1) if literal: print(yaml.safe_dump(resp, indent=4, default_flow_style=False)) return - table = PrettyTable(['field', 'value']) + table = PrettyTable(["field", "value"]) for k, v in list(resp.items()): table.add_row([k, wrap_text(json.dumps(v, indent=2), 100)]) - table.align = 'l' + table.align = "l" print(table) -@cli_osm.command(name='nst-show', short_help='shows the content of a Network Slice Template (NST)') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.argument('name') +@cli_osm.command( + name="nst-show", short_help="shows the content of a Network Slice Template (NST)" +) +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.argument("name") @click.pass_context def nst_show1(ctx, name, literal): """shows the content of a Network Slice Template (NST) NAME: name or ID of the NST """ logger.debug("") nst_show(ctx, name, literal) -@cli_osm.command(name='netslice-template-show', short_help='shows the content of a Network Slice Template (NST)') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.argument('name') +@cli_osm.command( + name="netslice-template-show", + short_help="shows the content of a Network Slice Template (NST)", +) +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.argument("name") @click.pass_context def nst_show2(ctx, name, literal): """shows the content of a Network Slice Template (NST) NAME: name or ID of the NST @@ -1501,42 +1771,51 @@ if literal: print(yaml.safe_dump(nsi, indent=4, default_flow_style=False)) return - table = PrettyTable(['field', 'value']) + table = PrettyTable(["field", "value"]) for k, v in list(nsi.items()): if not filter or k in filter: table.add_row([k, json.dumps(v, indent=2)]) - table.align = 'l' + table.align = "l" print(table) -@cli_osm.command(name='nsi-show', short_help='shows the content of a Network Slice Instance (NSI)') -@click.argument('name') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.option('--filter', multiple=True, - help='restricts the information to the fields in the filter') +@cli_osm.command( + name="nsi-show", short_help="shows the content of a Network Slice Instance (NSI)" +) +@click.argument("name") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.option( + "--filter", + multiple=True, + help="restricts the information to the fields in the filter", +) @click.pass_context def nsi_show1(ctx, name, literal, filter): """shows the content of a Network Slice Instance (NSI) NAME: name or ID of the Network Slice Instance """ logger.debug("") nsi_show(ctx, name, literal, filter) -@cli_osm.command(name='netslice-instance-show', short_help='shows the content of a Network Slice Instance (NSI)') -@click.argument('name') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.option('--filter', multiple=True, - help='restricts the information to the fields in the filter') +@cli_osm.command( + name="netslice-instance-show", + short_help="shows the content of a Network Slice Instance (NSI)", +) +@click.argument("name") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.option( + "--filter", + multiple=True, + help="restricts the information to the fields in the filter", +) @click.pass_context def nsi_show2(ctx, name, literal, filter): """shows the content of a Network Slice Instance (NSI) NAME: name or ID of the Network Slice Instance @@ -1552,52 +1831,68 @@ op_info = ctx.obj.nsi.get_op(id) # except ClientException as e: # print(str(e)) # exit(1) - table = PrettyTable(['field', 'value']) + table = PrettyTable(["field", "value"]) for k, v in list(op_info.items()): if not filter or k in filter: table.add_row([k, json.dumps(v, indent=2)]) - table.align = 'l' + table.align = "l" print(table) -@cli_osm.command(name='nsi-op-show', short_help='shows the info of an operation over a Network Slice Instance(NSI)') -@click.argument('id') -@click.option('--filter', multiple=True, - help='restricts the information to the fields in the filter') +@cli_osm.command( + name="nsi-op-show", + short_help="shows the info of an operation over a Network Slice Instance(NSI)", +) +@click.argument("id") +@click.option( + "--filter", + multiple=True, + help="restricts the information to the fields in the filter", +) @click.pass_context def nsi_op_show1(ctx, id, filter): """shows the info of an operation over a Network Slice Instance(NSI) ID: operation identifier """ logger.debug("") nsi_op_show(ctx, id, filter) -@cli_osm.command(name='netslice-instance-op-show', short_help='shows the info of an operation over a Network Slice Instance(NSI)') -@click.argument('id') -@click.option('--filter', multiple=True, - help='restricts the information to the fields in the filter') +@cli_osm.command( + name="netslice-instance-op-show", + short_help="shows the info of an operation over a Network Slice Instance(NSI)", +) +@click.argument("id") +@click.option( + "--filter", + multiple=True, + help="restricts the information to the fields in the filter", +) @click.pass_context def nsi_op_show2(ctx, id, filter): """shows the info of an operation over a Network Slice Instance(NSI) ID: operation identifier """ logger.debug("") nsi_op_show(ctx, id, filter) -@cli_osm.command(name='pdu-show', short_help='shows the content of a Physical Deployment Unit (PDU)') -@click.argument('name') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.option('--filter', multiple=True, - help='restricts the information to the fields in the filter') +@cli_osm.command( + name="pdu-show", short_help="shows the content of a Physical Deployment Unit (PDU)" +) +@click.argument("name") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.option( + "--filter", + multiple=True, + help="restricts the information to the fields in the filter", +) @click.pass_context def pdu_show(ctx, name, literal, filter): """shows the content of a Physical Deployment Unit (PDU) NAME: name or ID of the PDU @@ -1612,267 +1907,466 @@ if literal: print(yaml.safe_dump(pdu, indent=4, default_flow_style=False)) return - table = PrettyTable(['field', 'value']) + table = PrettyTable(["field", "value"]) for k, v in list(pdu.items()): if not filter or k in filter: table.add_row([k, json.dumps(v, indent=2)]) - table.align = 'l' + table.align = "l" print(table) #################### # CREATE operations #################### + def nsd_create(ctx, filename, overwrite, skip_charm_build, repo, vendor, version): logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) if repo: - filename = ctx.obj.osmrepo.get_pkg('ns', filename, repo, vendor, version) + filename = ctx.obj.osmrepo.get_pkg("ns", filename, repo, vendor, version) ctx.obj.nsd.create(filename, overwrite=overwrite, skip_charm_build=skip_charm_build) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='nsd-create', short_help='creates a new NSD/NSpkg') -@click.argument('filename') -@click.option('--overwrite', 'overwrite', default=None, # hidden=True, - help='Deprecated. Use override') -@click.option('--override', 'overwrite', default=None, - help='overrides fields in descriptor, format: ' - '"key1.key2...=value[;key3...=value;...]"') -@click.option('--skip-charm-build', default=False, is_flag=True, - help='The charm will not be compiled, it is assumed to already exist') -@click.option('--repo', default=None, - help='[repository]: Repository name') -@click.option('--vendor', default=None, - help='[repository]: filter by vendor]') -@click.option('--version', default='latest', - help='[repository]: filter by version. Default: latest') +@cli_osm.command(name="nsd-create", short_help="creates a new NSD/NSpkg") +@click.argument("filename") +@click.option( + "--overwrite", + "overwrite", + default=None, # hidden=True, + help="Deprecated. Use override", +) +@click.option( + "--override", + "overwrite", + default=None, + help="overrides fields in descriptor, format: " + '"key1.key2...=value[;key3...=value;...]"', +) +@click.option( + "--skip-charm-build", + default=False, + is_flag=True, + help="The charm will not be compiled, it is assumed to already exist", +) +@click.option("--repo", default=None, help="[repository]: Repository name") +@click.option("--vendor", default=None, help="[repository]: filter by vendor]") +@click.option( + "--version", + default="latest", + help="[repository]: filter by version. Default: latest", +) @click.pass_context def nsd_create1(ctx, filename, overwrite, skip_charm_build, repo, vendor, version): """onboards a new NSpkg (alias of nspkg-create) (TO BE DEPRECATED) \b FILENAME: NF Package tar.gz file, NF Descriptor YAML file or NF Package folder If FILENAME is a file (NF Package tar.gz or NF Descriptor YAML), it is onboarded. If FILENAME is an NF Package folder, it is built and then onboarded. """ logger.debug("") - nsd_create(ctx, filename, overwrite=overwrite, skip_charm_build=skip_charm_build, repo=repo, vendor=vendor, - version=version) - - -@cli_osm.command(name='nspkg-create', short_help='creates a new NSD/NSpkg') -@click.argument('filename') -@click.option('--overwrite', 'overwrite', default=None, # hidden=True, - help='Deprecated. Use override') -@click.option('--override', 'overwrite', default=None, - help='overrides fields in descriptor, format: ' - '"key1.key2...=value[;key3...=value;...]"') -@click.option('--skip-charm-build', default=False, is_flag=True, - help='The charm will not be compiled, it is assumed to already exist') -@click.option('--repo', default=None, - help='[repository]: Repository name') -@click.option('--vendor', default=None, - help='[repository]: filter by vendor]') -@click.option('--version', default='latest', - help='[repository]: filter by version. Default: latest') + nsd_create( + ctx, + filename, + overwrite=overwrite, + skip_charm_build=skip_charm_build, + repo=repo, + vendor=vendor, + version=version, + ) + + +@cli_osm.command(name="nspkg-create", short_help="creates a new NSD/NSpkg") +@click.argument("filename") +@click.option( + "--overwrite", + "overwrite", + default=None, # hidden=True, + help="Deprecated. Use override", +) +@click.option( + "--override", + "overwrite", + default=None, + help="overrides fields in descriptor, format: " + '"key1.key2...=value[;key3...=value;...]"', +) +@click.option( + "--skip-charm-build", + default=False, + is_flag=True, + help="The charm will not be compiled, it is assumed to already exist", +) +@click.option("--repo", default=None, help="[repository]: Repository name") +@click.option("--vendor", default=None, help="[repository]: filter by vendor]") +@click.option( + "--version", + default="latest", + help="[repository]: filter by version. Default: latest", +) @click.pass_context def nsd_pkg_create(ctx, filename, overwrite, skip_charm_build, repo, vendor, version): """onboards a new NSpkg \b FILENAME: NF Package tar.gz file, NF Descriptor YAML file or NF Package folder If FILENAME is a file (NF Package tar.gz or NF Descriptor YAML), it is onboarded. If FILENAME is an NF Package folder, it is built and then onboarded. """ logger.debug("") - nsd_create(ctx, filename, overwrite=overwrite, skip_charm_build=skip_charm_build, repo=repo, vendor=vendor, - version=version) - - -def vnfd_create(ctx, filename, overwrite, skip_charm_build, override_epa, override_nonepa, override_paravirt, - repo, vendor, version): + nsd_create( + ctx, + filename, + overwrite=overwrite, + skip_charm_build=skip_charm_build, + repo=repo, + vendor=vendor, + version=version, + ) + + +def vnfd_create( + ctx, + filename, + overwrite, + skip_charm_build, + override_epa, + override_nonepa, + override_paravirt, + repo, + vendor, + version, +): logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) if repo: - filename = ctx.obj.osmrepo.get_pkg('vnf', filename, repo, vendor, version) - ctx.obj.vnfd.create(filename, overwrite=overwrite, skip_charm_build=skip_charm_build, - override_epa=override_epa, override_nonepa=override_nonepa, - override_paravirt=override_paravirt) - # except ClientException as e: - # print(str(e)) - # exit(1) - - -@cli_osm.command(name='vnfd-create', short_help='creates a new VNFD/VNFpkg') -@click.argument('filename') -@click.option('--overwrite', 'overwrite', default=None, - help='overwrite deprecated, use override') -@click.option('--override', 'overwrite', default=None, - help='overrides fields in descriptor, format: ' - '"key1.key2...=value[;key3...=value;...]"') -@click.option('--skip-charm-build', default=False, is_flag=True, - help='The charm will not be compiled, it is assumed to already exist') -@click.option('--override-epa', required=False, default=False, is_flag=True, - help='adds guest-epa parameters to all VDU') -@click.option('--override-nonepa', required=False, default=False, is_flag=True, - help='removes all guest-epa parameters from all VDU') -@click.option('--override-paravirt', required=False, default=False, is_flag=True, - help='overrides all VDU interfaces to PARAVIRT') -@click.option('--repo', default=None, - help='[repository]: Repository name') -@click.option('--vendor', default=None, - help='[repository]: filter by vendor]') -@click.option('--version', default='latest', - help='[repository]: filter by version. Default: latest') -@click.pass_context -def vnfd_create1(ctx, filename, overwrite, skip_charm_build, override_epa, override_nonepa, override_paravirt, - repo,vendor, version): + filename = ctx.obj.osmrepo.get_pkg("vnf", filename, repo, vendor, version) + ctx.obj.vnfd.create( + filename, + overwrite=overwrite, + skip_charm_build=skip_charm_build, + override_epa=override_epa, + override_nonepa=override_nonepa, + override_paravirt=override_paravirt, + ) + # except ClientException as e: + # print(str(e)) + # exit(1) + + +@cli_osm.command(name="vnfd-create", short_help="creates a new VNFD/VNFpkg") +@click.argument("filename") +@click.option( + "--overwrite", "overwrite", default=None, help="overwrite deprecated, use override" +) +@click.option( + "--override", + "overwrite", + default=None, + help="overrides fields in descriptor, format: " + '"key1.key2...=value[;key3...=value;...]"', +) +@click.option( + "--skip-charm-build", + default=False, + is_flag=True, + help="The charm will not be compiled, it is assumed to already exist", +) +@click.option( + "--override-epa", + required=False, + default=False, + is_flag=True, + help="adds guest-epa parameters to all VDU", +) +@click.option( + "--override-nonepa", + required=False, + default=False, + is_flag=True, + help="removes all guest-epa parameters from all VDU", +) +@click.option( + "--override-paravirt", + required=False, + default=False, + is_flag=True, + help="overrides all VDU interfaces to PARAVIRT", +) +@click.option("--repo", default=None, help="[repository]: Repository name") +@click.option("--vendor", default=None, help="[repository]: filter by vendor]") +@click.option( + "--version", + default="latest", + help="[repository]: filter by version. Default: latest", +) +@click.pass_context +def vnfd_create1( + ctx, + filename, + overwrite, + skip_charm_build, + override_epa, + override_nonepa, + override_paravirt, + repo, + vendor, + version, +): """creates a new VNFD/VNFpkg \b FILENAME: NF Package tar.gz file, NF Descriptor YAML file or NF Package folder If FILENAME is a file (NF Package tar.gz or NF Descriptor YAML), it is onboarded. If FILENAME is an NF Package folder, it is built and then onboarded. """ logger.debug("") - vnfd_create(ctx, filename, overwrite=overwrite, skip_charm_build=skip_charm_build, - override_epa=override_epa, override_nonepa=override_nonepa, override_paravirt=override_paravirt, - repo=repo, vendor=vendor, version=version) - - -@cli_osm.command(name='vnfpkg-create', short_help='creates a new VNFD/VNFpkg') -@click.argument('filename') -@click.option('--overwrite', 'overwrite', default=None, # hidden=True, - help='Deprecated. Use override') -@click.option('--override', 'overwrite', default=None, - help='overrides fields in descriptor, format: ' - '"key1.key2...=value[;key3...=value;...]"') -@click.option('--skip-charm-build', default=False, is_flag=True, - help='The charm will not be compiled, it is assumed to already exist') -@click.option('--override-epa', required=False, default=False, is_flag=True, - help='adds guest-epa parameters to all VDU') -@click.option('--override-nonepa', required=False, default=False, is_flag=True, - help='removes all guest-epa parameters from all VDU') -@click.option('--override-paravirt', required=False, default=False, is_flag=True, - help='overrides all VDU interfaces to PARAVIRT') -@click.option('--repo', default=None, - help='[repository]: Repository name') -@click.option('--vendor', default=None, - help='[repository]: filter by vendor]') -@click.option('--version', default='latest', - help='[repository]: filter by version. Default: latest') -@click.pass_context -def vnfd_create2(ctx, filename, overwrite, skip_charm_build, override_epa, override_nonepa, override_paravirt, - repo, vendor, version): + vnfd_create( + ctx, + filename, + overwrite=overwrite, + skip_charm_build=skip_charm_build, + override_epa=override_epa, + override_nonepa=override_nonepa, + override_paravirt=override_paravirt, + repo=repo, + vendor=vendor, + version=version, + ) + + +@cli_osm.command(name="vnfpkg-create", short_help="creates a new VNFD/VNFpkg") +@click.argument("filename") +@click.option( + "--overwrite", + "overwrite", + default=None, # hidden=True, + help="Deprecated. Use override", +) +@click.option( + "--override", + "overwrite", + default=None, + help="overrides fields in descriptor, format: " + '"key1.key2...=value[;key3...=value;...]"', +) +@click.option( + "--skip-charm-build", + default=False, + is_flag=True, + help="The charm will not be compiled, it is assumed to already exist", +) +@click.option( + "--override-epa", + required=False, + default=False, + is_flag=True, + help="adds guest-epa parameters to all VDU", +) +@click.option( + "--override-nonepa", + required=False, + default=False, + is_flag=True, + help="removes all guest-epa parameters from all VDU", +) +@click.option( + "--override-paravirt", + required=False, + default=False, + is_flag=True, + help="overrides all VDU interfaces to PARAVIRT", +) +@click.option("--repo", default=None, help="[repository]: Repository name") +@click.option("--vendor", default=None, help="[repository]: filter by vendor]") +@click.option( + "--version", + default="latest", + help="[repository]: filter by version. Default: latest", +) +@click.pass_context +def vnfd_create2( + ctx, + filename, + overwrite, + skip_charm_build, + override_epa, + override_nonepa, + override_paravirt, + repo, + vendor, + version, +): """creates a new VNFD/VNFpkg \b FILENAME: NF Package tar.gz file, NF Descriptor YAML file or NF Package folder If FILENAME is a file (NF Package tar.gz or NF Descriptor YAML), it is onboarded. If FILENAME is an NF Package folder, it is built and then onboarded. """ logger.debug("") - vnfd_create(ctx, filename, overwrite=overwrite, skip_charm_build=skip_charm_build, - override_epa=override_epa, override_nonepa=override_nonepa, override_paravirt=override_paravirt, - repo=repo, vendor=vendor, version=version) - -@cli_osm.command(name='nfpkg-create', short_help='creates a new NFpkg') -@click.argument('filename') -@click.option('--overwrite', 'overwrite', default=None, # hidden=True, - help='Deprecated. Use override') -@click.option('--override', 'overwrite', default=None, - help='overrides fields in descriptor, format: ' - '"key1.key2...=value[;key3...=value;...]"') -@click.option('--skip-charm-build', default=False, is_flag=True, - help='The charm will not be compiled, it is assumed to already exist') -@click.option('--override-epa', required=False, default=False, is_flag=True, - help='adds guest-epa parameters to all VDU') -@click.option('--override-nonepa', required=False, default=False, is_flag=True, - help='removes all guest-epa parameters from all VDU') -@click.option('--override-paravirt', required=False, default=False, is_flag=True, - help='overrides all VDU interfaces to PARAVIRT') -@click.option('--repo', default=None, - help='[repository]: Repository name') -@click.option('--vendor', default=None, - help='[repository]: filter by vendor]') -@click.option('--version', default='latest', - help='[repository]: filter by version. Default: latest') -@click.pass_context -def nfpkg_create(ctx, filename, overwrite, skip_charm_build, override_epa, override_nonepa, override_paravirt, - repo, vendor, version): + vnfd_create( + ctx, + filename, + overwrite=overwrite, + skip_charm_build=skip_charm_build, + override_epa=override_epa, + override_nonepa=override_nonepa, + override_paravirt=override_paravirt, + repo=repo, + vendor=vendor, + version=version, + ) + + +@cli_osm.command(name="nfpkg-create", short_help="creates a new NFpkg") +@click.argument("filename") +@click.option( + "--overwrite", + "overwrite", + default=None, # hidden=True, + help="Deprecated. Use override", +) +@click.option( + "--override", + "overwrite", + default=None, + help="overrides fields in descriptor, format: " + '"key1.key2...=value[;key3...=value;...]"', +) +@click.option( + "--skip-charm-build", + default=False, + is_flag=True, + help="The charm will not be compiled, it is assumed to already exist", +) +@click.option( + "--override-epa", + required=False, + default=False, + is_flag=True, + help="adds guest-epa parameters to all VDU", +) +@click.option( + "--override-nonepa", + required=False, + default=False, + is_flag=True, + help="removes all guest-epa parameters from all VDU", +) +@click.option( + "--override-paravirt", + required=False, + default=False, + is_flag=True, + help="overrides all VDU interfaces to PARAVIRT", +) +@click.option("--repo", default=None, help="[repository]: Repository name") +@click.option("--vendor", default=None, help="[repository]: filter by vendor]") +@click.option( + "--version", + default="latest", + help="[repository]: filter by version. Default: latest", +) +@click.pass_context +def nfpkg_create( + ctx, + filename, + overwrite, + skip_charm_build, + override_epa, + override_nonepa, + override_paravirt, + repo, + vendor, + version, +): """creates a new NFpkg \b FILENAME: NF Package tar.gz file, NF Descriptor YAML file or NF Package folder If FILENAME is a file (NF Package tar.gz or NF Descriptor YAML), it is onboarded. If FILENAME is an NF Package folder, it is built and then onboarded. """ logger.debug("") - vnfd_create(ctx, filename, overwrite=overwrite, skip_charm_build=skip_charm_build, - override_epa=override_epa, override_nonepa=override_nonepa, override_paravirt=override_paravirt, - repo=repo, vendor=vendor, version=version) - - -@cli_osm.command(name='ns-create', short_help='creates a new Network Service instance') -@click.option('--ns_name', - prompt=True, help='name of the NS instance') -@click.option('--nsd_name', - prompt=True, help='name of the NS descriptor') -@click.option('--vim_account', - prompt=True, help='default VIM account id or name for the deployment') -@click.option('--admin_status', - default='ENABLED', - help='administration status') -@click.option('--ssh_keys', - default=None, - help='comma separated list of public key files to inject to vnfs') -@click.option('--config', - default=None, - help='ns specific yaml configuration') -@click.option('--config_file', - default=None, - help='ns specific yaml configuration file') -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it ' - 'until the operation is completed, or timeout') -@click.pass_context -def ns_create(ctx, - nsd_name, - ns_name, - vim_account, - admin_status, - ssh_keys, - config, - config_file, - wait): + vnfd_create( + ctx, + filename, + overwrite=overwrite, + skip_charm_build=skip_charm_build, + override_epa=override_epa, + override_nonepa=override_nonepa, + override_paravirt=override_paravirt, + repo=repo, + vendor=vendor, + version=version, + ) + + +@cli_osm.command(name="ns-create", short_help="creates a new Network Service instance") +@click.option("--ns_name", prompt=True, help="name of the NS instance") +@click.option("--nsd_name", prompt=True, help="name of the NS descriptor") +@click.option( + "--vim_account", + prompt=True, + help="default VIM account id or name for the deployment", +) +@click.option("--admin_status", default="ENABLED", help="administration status") +@click.option( + "--ssh_keys", + default=None, + help="comma separated list of public key files to inject to vnfs", +) +@click.option("--config", default=None, help="ns specific yaml configuration") +@click.option("--config_file", default=None, help="ns specific yaml configuration file") +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it " + "until the operation is completed, or timeout", +) +@click.pass_context +def ns_create( + ctx, + nsd_name, + ns_name, + vim_account, + admin_status, + ssh_keys, + config, + config_file, + wait, +): """creates a new NS instance""" logger.debug("") # try: if config_file: - check_client_version(ctx.obj, '--config_file') + check_client_version(ctx.obj, "--config_file") if config: - raise ClientException('"--config" option is incompatible with "--config_file" option') - with open(config_file, 'r') as cf: - config=cf.read() + raise ClientException( + '"--config" option is incompatible with "--config_file" option' + ) + with open(config_file, "r") as cf: + config = cf.read() ctx.obj.ns.create( nsd_name, ns_name, config=config, ssh_keys=ssh_keys, account=vim_account, - wait=wait) + wait=wait, + ) # except ClientException as e: # print(str(e)) # exit(1) @@ -1884,164 +2378,248 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='nst-create', short_help='creates a new Network Slice Template (NST)') -@click.argument('filename') -@click.option('--overwrite', 'overwrite', default=None, # hidden=True, - help='Deprecated. Use override') -@click.option('--override', 'overwrite', default=None, - help='overrides fields in descriptor, format: ' - '"key1.key2...=value[;key3...=value;...]"') +@cli_osm.command( + name="nst-create", short_help="creates a new Network Slice Template (NST)" +) +@click.argument("filename") +@click.option( + "--overwrite", + "overwrite", + default=None, # hidden=True, + help="Deprecated. Use override", +) +@click.option( + "--override", + "overwrite", + default=None, + help="overrides fields in descriptor, format: " + '"key1.key2...=value[;key3...=value;...]"', +) @click.pass_context def nst_create1(ctx, filename, overwrite): """creates a new Network Slice Template (NST) FILENAME: NST package folder, NST yaml file or NSTpkg tar.gz file """ logger.debug("") nst_create(ctx, filename, overwrite) -@cli_osm.command(name='netslice-template-create', short_help='creates a new Network Slice Template (NST)') -@click.argument('filename') -@click.option('--overwrite', 'overwrite', default=None, # hidden=True, - help='Deprecated. Use override') -@click.option('--override', 'overwrite', default=None, - help='overrides fields in descriptor, format: ' - '"key1.key2...=value[;key3...=value;...]"') +@cli_osm.command( + name="netslice-template-create", + short_help="creates a new Network Slice Template (NST)", +) +@click.argument("filename") +@click.option( + "--overwrite", + "overwrite", + default=None, # hidden=True, + help="Deprecated. Use override", +) +@click.option( + "--override", + "overwrite", + default=None, + help="overrides fields in descriptor, format: " + '"key1.key2...=value[;key3...=value;...]"', +) @click.pass_context def nst_create2(ctx, filename, overwrite): """creates a new Network Slice Template (NST) FILENAME: NST yaml file or NSTpkg tar.gz file """ logger.debug("") nst_create(ctx, filename, overwrite) -def nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file, wait): +def nsi_create( + ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file, wait +): """creates a new Network Slice Instance (NSI)""" logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) if config_file: if config: - raise ClientException('"--config" option is incompatible with "--config_file" option') - with open(config_file, 'r') as cf: - config=cf.read() - ctx.obj.nsi.create(nst_name, nsi_name, config=config, ssh_keys=ssh_keys, - account=vim_account, wait=wait) - # except ClientException as e: - # print(str(e)) - # exit(1) - - -@cli_osm.command(name='nsi-create', short_help='creates a new Network Slice Instance') -@click.option('--nsi_name', prompt=True, help='name of the Network Slice Instance') -@click.option('--nst_name', prompt=True, help='name of the Network Slice Template') -@click.option('--vim_account', prompt=True, help='default VIM account id or name for the deployment') -@click.option('--ssh_keys', default=None, - help='comma separated list of keys to inject to vnfs') -@click.option('--config', default=None, - help='Netslice specific yaml configuration:\n' - 'netslice_subnet: [\n' - 'id: TEXT, vim_account: TEXT,\n' - 'vnf: [member-vnf-index: TEXT, vim_account: TEXT]\n' - 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]\n' - 'additionalParamsForNsi: {param: value, ...}\n' - 'additionalParamsForsubnet: [{id: SUBNET_ID, additionalParamsForNs: {}, additionalParamsForVnf: {}}]\n' - '],\n' - 'netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]' - ) -@click.option('--config_file', - default=None, - help='nsi specific yaml configuration file') -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it ' - 'until the operation is completed, or timeout') -@click.pass_context -def nsi_create1(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file, wait): + raise ClientException( + '"--config" option is incompatible with "--config_file" option' + ) + with open(config_file, "r") as cf: + config = cf.read() + ctx.obj.nsi.create( + nst_name, + nsi_name, + config=config, + ssh_keys=ssh_keys, + account=vim_account, + wait=wait, + ) + # except ClientException as e: + # print(str(e)) + # exit(1) + + +@cli_osm.command(name="nsi-create", short_help="creates a new Network Slice Instance") +@click.option("--nsi_name", prompt=True, help="name of the Network Slice Instance") +@click.option("--nst_name", prompt=True, help="name of the Network Slice Template") +@click.option( + "--vim_account", + prompt=True, + help="default VIM account id or name for the deployment", +) +@click.option( + "--ssh_keys", default=None, help="comma separated list of keys to inject to vnfs" +) +@click.option( + "--config", + default=None, + help="Netslice specific yaml configuration:\n" + "netslice_subnet: [\n" + "id: TEXT, vim_account: TEXT,\n" + "vnf: [member-vnf-index: TEXT, vim_account: TEXT]\n" + "vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]\n" + "additionalParamsForNsi: {param: value, ...}\n" + "additionalParamsForsubnet: [{id: SUBNET_ID, additionalParamsForNs: {}, additionalParamsForVnf: {}}]\n" + "],\n" + "netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]", +) +@click.option( + "--config_file", default=None, help="nsi specific yaml configuration file" +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it " + "until the operation is completed, or timeout", +) +@click.pass_context +def nsi_create1( + ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file, wait +): """creates a new Network Slice Instance (NSI)""" logger.debug("") - nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file, wait=wait) - - -@cli_osm.command(name='netslice-instance-create', short_help='creates a new Network Slice Instance') -@click.option('--nsi_name', prompt=True, help='name of the Network Slice Instance') -@click.option('--nst_name', prompt=True, help='name of the Network Slice Template') -@click.option('--vim_account', prompt=True, help='default VIM account id or name for the deployment') -@click.option('--ssh_keys', default=None, - help='comma separated list of keys to inject to vnfs') -@click.option('--config', default=None, - help='Netslice specific yaml configuration:\n' - 'netslice_subnet: [\n' - 'id: TEXT, vim_account: TEXT,\n' - 'vnf: [member-vnf-index: TEXT, vim_account: TEXT]\n' - 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]' - '],\n' - 'netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]' - ) -@click.option('--config_file', - default=None, - help='nsi specific yaml configuration file') -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it ' - 'until the operation is completed, or timeout') -@click.pass_context -def nsi_create2(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file, wait): + nsi_create( + ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file, wait=wait + ) + + +@cli_osm.command( + name="netslice-instance-create", short_help="creates a new Network Slice Instance" +) +@click.option("--nsi_name", prompt=True, help="name of the Network Slice Instance") +@click.option("--nst_name", prompt=True, help="name of the Network Slice Template") +@click.option( + "--vim_account", + prompt=True, + help="default VIM account id or name for the deployment", +) +@click.option( + "--ssh_keys", default=None, help="comma separated list of keys to inject to vnfs" +) +@click.option( + "--config", + default=None, + help="Netslice specific yaml configuration:\n" + "netslice_subnet: [\n" + "id: TEXT, vim_account: TEXT,\n" + "vnf: [member-vnf-index: TEXT, vim_account: TEXT]\n" + "vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]" + "],\n" + "netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]", +) +@click.option( + "--config_file", default=None, help="nsi specific yaml configuration file" +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it " + "until the operation is completed, or timeout", +) +@click.pass_context +def nsi_create2( + ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file, wait +): """creates a new Network Slice Instance (NSI)""" logger.debug("") - nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file, wait=wait) - - -@cli_osm.command(name='pdu-create', short_help='adds a new Physical Deployment Unit to the catalog') -@click.option('--name', help='name of the Physical Deployment Unit') -@click.option('--pdu_type', help='type of PDU (e.g. router, firewall, FW001)') -@click.option('--interface', - help='interface(s) of the PDU: name=,mgmt=,ip-address='+ - '[,type=][,mac-address=][,vim-network-name=]', - multiple=True) -@click.option('--description', help='human readable description') -@click.option('--vim_account', help='list of VIM accounts (in the same VIM) that can reach this PDU', multiple=True) -@click.option('--descriptor_file', default=None, - help='PDU descriptor file (as an alternative to using the other arguments') -@click.pass_context -def pdu_create(ctx, name, pdu_type, interface, description, vim_account, descriptor_file): + nsi_create( + ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file, wait=wait + ) + + +@cli_osm.command( + name="pdu-create", short_help="adds a new Physical Deployment Unit to the catalog" +) +@click.option("--name", help="name of the Physical Deployment Unit") +@click.option("--pdu_type", help="type of PDU (e.g. router, firewall, FW001)") +@click.option( + "--interface", + help="interface(s) of the PDU: name=,mgmt=,ip-address=" + + "[,type=][,mac-address=][,vim-network-name=]", + multiple=True, +) +@click.option("--description", help="human readable description") +@click.option( + "--vim_account", + help="list of VIM accounts (in the same VIM) that can reach this PDU", + multiple=True, +) +@click.option( + "--descriptor_file", + default=None, + help="PDU descriptor file (as an alternative to using the other arguments", +) +@click.pass_context +def pdu_create( + ctx, name, pdu_type, interface, description, vim_account, descriptor_file +): """creates a new Physical Deployment Unit (PDU)""" logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) pdu = {} if not descriptor_file: if not name: - raise ClientException('in absence of descriptor file, option "--name" is mandatory') + raise ClientException( + 'in absence of descriptor file, option "--name" is mandatory' + ) if not pdu_type: - raise ClientException('in absence of descriptor file, option "--pdu_type" is mandatory') + raise ClientException( + 'in absence of descriptor file, option "--pdu_type" is mandatory' + ) if not interface: - raise ClientException('in absence of descriptor file, option "--interface" is mandatory (at least once)') + raise ClientException( + 'in absence of descriptor file, option "--interface" is mandatory (at least once)' + ) if not vim_account: - raise ClientException('in absence of descriptor file, option "--vim_account" is mandatory (at least once)') + raise ClientException( + 'in absence of descriptor file, option "--vim_account" is mandatory (at least once)' + ) else: - with open(descriptor_file, 'r') as df: + with open(descriptor_file, "r") as df: pdu = yaml.safe_load(df.read()) - if name: pdu["name"] = name - if pdu_type: pdu["type"] = pdu_type - if description: pdu["description"] = description - if vim_account: pdu["vim_accounts"] = vim_account + if name: + pdu["name"] = name + if pdu_type: + pdu["type"] = pdu_type + if description: + pdu["description"] = description + if vim_account: + pdu["vim_accounts"] = vim_account if interface: ifaces_list = [] for iface in interface: - new_iface={k:v for k,v in [i.split('=') for i in iface.split(',')]} - new_iface["mgmt"] = (new_iface.get("mgmt","false").lower() == "true") + new_iface = {k: v for k, v in [i.split("=") for i in iface.split(",")]} + new_iface["mgmt"] = new_iface.get("mgmt", "false").lower() == "true" ifaces_list.append(new_iface) pdu["interfaces"] = ifaces_list ctx.obj.pdu.create(pdu) # except ClientException as e: # print(str(e)) @@ -2050,38 +2628,45 @@ #################### # UPDATE operations #################### + def nsd_update(ctx, name, content): logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) ctx.obj.nsd.update(name, content) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='nsd-update', short_help='updates a NSD/NSpkg') -@click.argument('name') -@click.option('--content', default=None, - help='filename with the NSD/NSpkg replacing the current one') +@cli_osm.command(name="nsd-update", short_help="updates a NSD/NSpkg") +@click.argument("name") +@click.option( + "--content", + default=None, + help="filename with the NSD/NSpkg replacing the current one", +) @click.pass_context def nsd_update1(ctx, name, content): """updates a NSD/NSpkg NAME: name or ID of the NSD/NSpkg """ logger.debug("") nsd_update(ctx, name, content) -@cli_osm.command(name='nspkg-update', short_help='updates a NSD/NSpkg') -@click.argument('name') -@click.option('--content', default=None, - help='filename with the NSD/NSpkg replacing the current one') +@cli_osm.command(name="nspkg-update", short_help="updates a NSD/NSpkg") +@click.argument("name") +@click.option( + "--content", + default=None, + help="filename with the NSD/NSpkg replacing the current one", +) @click.pass_context def nsd_update2(ctx, name, content): """updates a NSD/NSpkg NAME: name or ID of the NSD/NSpkg @@ -2098,42 +2683,49 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='vnfd-update', short_help='updates a new VNFD/VNFpkg') -@click.argument('name') -@click.option('--content', default=None, - help='filename with the VNFD/VNFpkg replacing the current one') +@cli_osm.command(name="vnfd-update", short_help="updates a new VNFD/VNFpkg") +@click.argument("name") +@click.option( + "--content", + default=None, + help="filename with the VNFD/VNFpkg replacing the current one", +) @click.pass_context def vnfd_update1(ctx, name, content): """updates a VNFD/VNFpkg NAME: name or ID of the VNFD/VNFpkg """ logger.debug("") vnfd_update(ctx, name, content) -@cli_osm.command(name='vnfpkg-update', short_help='updates a VNFD/VNFpkg') -@click.argument('name') -@click.option('--content', default=None, - help='filename with the VNFD/VNFpkg replacing the current one') +@cli_osm.command(name="vnfpkg-update", short_help="updates a VNFD/VNFpkg") +@click.argument("name") +@click.option( + "--content", + default=None, + help="filename with the VNFD/VNFpkg replacing the current one", +) @click.pass_context def vnfd_update2(ctx, name, content): """updates a VNFD/VNFpkg NAME: VNFD yaml file or VNFpkg tar.gz file """ logger.debug("") vnfd_update(ctx, name, content) -@cli_osm.command(name='nfpkg-update', short_help='updates a NFpkg') -@click.argument('name') -@click.option('--content', default=None, - help='filename with the NFpkg replacing the current one') +@cli_osm.command(name="nfpkg-update", short_help="updates a NFpkg") +@click.argument("name") +@click.option( + "--content", default=None, help="filename with the NFpkg replacing the current one" +) @click.pass_context def nfpkg_update(ctx, name, content): """updates a NFpkg NAME: NF Descriptor yaml file or NFpkg tar.gz file @@ -2150,28 +2742,36 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='nst-update', short_help='updates a Network Slice Template (NST)') -@click.argument('name') -@click.option('--content', default=None, - help='filename with the NST/NSTpkg replacing the current one') +@cli_osm.command(name="nst-update", short_help="updates a Network Slice Template (NST)") +@click.argument("name") +@click.option( + "--content", + default=None, + help="filename with the NST/NSTpkg replacing the current one", +) @click.pass_context def nst_update1(ctx, name, content): """updates a Network Slice Template (NST) NAME: name or ID of the NSD/NSpkg """ logger.debug("") nst_update(ctx, name, content) -@cli_osm.command(name='netslice-template-update', short_help='updates a Network Slice Template (NST)') -@click.argument('name') -@click.option('--content', default=None, - help='filename with the NST/NSTpkg replacing the current one') +@cli_osm.command( + name="netslice-template-update", short_help="updates a Network Slice Template (NST)" +) +@click.argument("name") +@click.option( + "--content", + default=None, + help="filename with the NST/NSTpkg replacing the current one", +) @click.pass_context def nst_update2(ctx, name, content): """updates a Network Slice Template (NST) NAME: name or ID of the NSD/NSpkg @@ -2182,39 +2782,44 @@ #################### # DELETE operations #################### + def nsd_delete(ctx, name, force): logger.debug("") # try: if not force: ctx.obj.nsd.delete(name) else: - check_client_version(ctx.obj, '--force') + check_client_version(ctx.obj, "--force") ctx.obj.nsd.delete(name, force) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='nsd-delete', short_help='deletes a NSD/NSpkg') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') +@cli_osm.command(name="nsd-delete", short_help="deletes a NSD/NSpkg") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) @click.pass_context def nsd_delete1(ctx, name, force): """deletes a NSD/NSpkg NAME: name or ID of the NSD/NSpkg to be deleted """ logger.debug("") nsd_delete(ctx, name, force) -@cli_osm.command(name='nspkg-delete', short_help='deletes a NSD/NSpkg') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') +@cli_osm.command(name="nspkg-delete", short_help="deletes a NSD/NSpkg") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) @click.pass_context def nsd_delete2(ctx, name, force): """deletes a NSD/NSpkg NAME: name or ID of the NSD/NSpkg to be deleted @@ -2227,68 +2832,81 @@ logger.debug("") # try: if not force: ctx.obj.vnfd.delete(name) else: - check_client_version(ctx.obj, '--force') + check_client_version(ctx.obj, "--force") ctx.obj.vnfd.delete(name, force) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='vnfd-delete', short_help='deletes a VNFD/VNFpkg') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') +@cli_osm.command(name="vnfd-delete", short_help="deletes a VNFD/VNFpkg") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) @click.pass_context def vnfd_delete1(ctx, name, force): """deletes a VNFD/VNFpkg NAME: name or ID of the VNFD/VNFpkg to be deleted """ logger.debug("") vnfd_delete(ctx, name, force) -@cli_osm.command(name='vnfpkg-delete', short_help='deletes a VNFD/VNFpkg') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') +@cli_osm.command(name="vnfpkg-delete", short_help="deletes a VNFD/VNFpkg") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) @click.pass_context def vnfd_delete2(ctx, name, force): """deletes a VNFD/VNFpkg NAME: name or ID of the VNFD/VNFpkg to be deleted """ logger.debug("") vnfd_delete(ctx, name, force) -@cli_osm.command(name='nfpkg-delete', short_help='deletes a NFpkg') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') +@cli_osm.command(name="nfpkg-delete", short_help="deletes a NFpkg") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) @click.pass_context def nfpkg_delete(ctx, name, force): """deletes a NFpkg NAME: name or ID of the NFpkg to be deleted """ logger.debug("") vnfd_delete(ctx, name, force) -@cli_osm.command(name='ns-delete', short_help='deletes a NS instance') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') -@click.option('--config', default=None, - help="specific yaml configuration for the termination, e.g. '{autoremove: False, timeout_ns_terminate: " - "600, skip_terminate_primitives: True}'") -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it ' - 'until the operation is completed, or timeout') +@cli_osm.command(name="ns-delete", short_help="deletes a NS instance") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) +@click.option( + "--config", + default=None, + help="specific yaml configuration for the termination, e.g. '{autoremove: False, timeout_ns_terminate: " + "600, skip_terminate_primitives: True}'", +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it " + "until the operation is completed, or timeout", +) @click.pass_context def ns_delete(ctx, name, force, config, wait): """deletes a NS instance NAME: name or ID of the NS instance to be deleted @@ -2296,11 +2914,11 @@ logger.debug("") # try: if not force: ctx.obj.ns.delete(name, config=config, wait=wait) else: - check_client_version(ctx.obj, '--force') + check_client_version(ctx.obj, "--force") ctx.obj.ns.delete(name, force, config=config, wait=wait) # except ClientException as e: # print(str(e)) # exit(1) @@ -2313,26 +2931,32 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='nst-delete', short_help='deletes a Network Slice Template (NST)') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') +@cli_osm.command(name="nst-delete", short_help="deletes a Network Slice Template (NST)") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) @click.pass_context def nst_delete1(ctx, name, force): """deletes a Network Slice Template (NST) NAME: name or ID of the NST/NSTpkg to be deleted """ logger.debug("") nst_delete(ctx, name, force) -@cli_osm.command(name='netslice-template-delete', short_help='deletes a Network Slice Template (NST)') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') +@cli_osm.command( + name="netslice-template-delete", short_help="deletes a Network Slice Template (NST)" +) +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) @click.pass_context def nst_delete2(ctx, name, force): """deletes a Network Slice Template (NST) NAME: name or ID of the NST/NSTpkg to be deleted @@ -2349,45 +2973,57 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='nsi-delete', short_help='deletes a Network Slice Instance (NSI)') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it ' - 'until the operation is completed, or timeout') +@cli_osm.command(name="nsi-delete", short_help="deletes a Network Slice Instance (NSI)") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it " + "until the operation is completed, or timeout", +) @click.pass_context def nsi_delete1(ctx, name, force, wait): """deletes a Network Slice Instance (NSI) NAME: name or ID of the Network Slice instance to be deleted """ logger.debug("") nsi_delete(ctx, name, force, wait=wait) -@cli_osm.command(name='netslice-instance-delete', short_help='deletes a Network Slice Instance (NSI)') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') +@cli_osm.command( + name="netslice-instance-delete", short_help="deletes a Network Slice Instance (NSI)" +) +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) @click.pass_context def nsi_delete2(ctx, name, force, wait): """deletes a Network Slice Instance (NSI) NAME: name or ID of the Network Slice instance to be deleted """ logger.debug("") nsi_delete(ctx, name, force, wait=wait) -@cli_osm.command(name='pdu-delete', short_help='deletes a Physical Deployment Unit (PDU)') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') +@cli_osm.command( + name="pdu-delete", short_help="deletes a Physical Deployment Unit (PDU)" +) +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) @click.pass_context def pdu_delete(ctx, name, force): """deletes a Physical Deployment Unit (PDU) NAME: name or ID of the PDU to be deleted @@ -2403,146 +3039,171 @@ ################# # VIM operations ################# -@cli_osm.command(name='vim-create', short_help='creates a new VIM account') -@click.option('--name', - prompt=True, - help='Name to create datacenter') -@click.option('--user', - prompt=True, - help='VIM username') -@click.option('--password', - prompt=True, - hide_input=True, - confirmation_prompt=True, - help='VIM password') -@click.option('--auth_url', - prompt=True, - help='VIM url') -@click.option('--tenant', - prompt=True, - help='VIM tenant name') -@click.option('--config', - default=None, - help='VIM specific config parameters') -@click.option('--account_type', - default='openstack', - help='VIM type') -@click.option('--description', - default=None, - help='human readable description') -@click.option('--sdn_controller', default=None, help='Name or id of the SDN controller associated to this VIM account') -@click.option('--sdn_port_mapping', default=None, help="File describing the port mapping between compute nodes' ports and switch ports") -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it ' - 'until the operation is completed, or timeout') -@click.pass_context -def vim_create(ctx, - name, - user, - password, - auth_url, - tenant, - config, - account_type, - description, - sdn_controller, - sdn_port_mapping, - wait): + +@cli_osm.command(name="vim-create", short_help="creates a new VIM account") +@click.option("--name", prompt=True, help="Name to create datacenter") +@click.option("--user", prompt=True, help="VIM username") +@click.option( + "--password", + prompt=True, + hide_input=True, + confirmation_prompt=True, + help="VIM password", +) +@click.option("--auth_url", prompt=True, help="VIM url") +@click.option("--tenant", prompt=True, help="VIM tenant name") +@click.option("--config", default=None, help="VIM specific config parameters") +@click.option("--account_type", default="openstack", help="VIM type") +@click.option("--description", default=None, help="human readable description") +@click.option( + "--sdn_controller", + default=None, + help="Name or id of the SDN controller associated to this VIM account", +) +@click.option( + "--sdn_port_mapping", + default=None, + help="File describing the port mapping between compute nodes' ports and switch ports", +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it " + "until the operation is completed, or timeout", +) +@click.pass_context +def vim_create( + ctx, + name, + user, + password, + auth_url, + tenant, + config, + account_type, + description, + sdn_controller, + sdn_port_mapping, + wait, +): """creates a new VIM account""" logger.debug("") # try: if sdn_controller: - check_client_version(ctx.obj, '--sdn_controller') + check_client_version(ctx.obj, "--sdn_controller") if sdn_port_mapping: - check_client_version(ctx.obj, '--sdn_port_mapping') + check_client_version(ctx.obj, "--sdn_port_mapping") vim = {} - vim['vim-username'] = user - vim['vim-password'] = password - vim['vim-url'] = auth_url - vim['vim-tenant-name'] = tenant - vim['vim-type'] = account_type - vim['description'] = description - vim['config'] = config + vim["vim-username"] = user + vim["vim-password"] = password + vim["vim-url"] = auth_url + vim["vim-tenant-name"] = tenant + vim["vim-type"] = account_type + vim["description"] = description + vim["config"] = config if sdn_controller or sdn_port_mapping: ctx.obj.vim.create(name, vim, sdn_controller, sdn_port_mapping, wait=wait) else: ctx.obj.vim.create(name, vim, wait=wait) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='vim-update', short_help='updates a VIM account') -@click.argument('name') -@click.option('--newname', help='New name for the VIM account') -@click.option('--user', help='VIM username') -@click.option('--password', help='VIM password') -@click.option('--auth_url', help='VIM url') -@click.option('--tenant', help='VIM tenant name') -@click.option('--config', help='VIM specific config parameters') -@click.option('--account_type', help='VIM type') -@click.option('--description', help='human readable description') -@click.option('--sdn_controller', default=None, help='Name or id of the SDN controller to be associated with this VIM' - 'account. Use empty string to disassociate') -@click.option('--sdn_port_mapping', default=None, help="File describing the port mapping between compute nodes' ports and switch ports") -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it ' - 'until the operation is completed, or timeout') -@click.pass_context -def vim_update(ctx, - name, - newname, - user, - password, - auth_url, - tenant, - config, - account_type, - description, - sdn_controller, - sdn_port_mapping, - wait): +@cli_osm.command(name="vim-update", short_help="updates a VIM account") +@click.argument("name") +@click.option("--newname", help="New name for the VIM account") +@click.option("--user", help="VIM username") +@click.option("--password", help="VIM password") +@click.option("--auth_url", help="VIM url") +@click.option("--tenant", help="VIM tenant name") +@click.option("--config", help="VIM specific config parameters") +@click.option("--account_type", help="VIM type") +@click.option("--description", help="human readable description") +@click.option( + "--sdn_controller", + default=None, + help="Name or id of the SDN controller to be associated with this VIM" + "account. Use empty string to disassociate", +) +@click.option( + "--sdn_port_mapping", + default=None, + help="File describing the port mapping between compute nodes' ports and switch ports", +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it " + "until the operation is completed, or timeout", +) +@click.pass_context +def vim_update( + ctx, + name, + newname, + user, + password, + auth_url, + tenant, + config, + account_type, + description, + sdn_controller, + sdn_port_mapping, + wait, +): """updates a VIM account NAME: name or ID of the VIM account """ logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) vim = {} - if newname: vim['name'] = newname - if user: vim['vim_user'] = user - if password: vim['vim_password'] = password - if auth_url: vim['vim_url'] = auth_url - if tenant: vim['vim-tenant-name'] = tenant - if account_type: vim['vim_type'] = account_type - if description: vim['description'] = description - if config: vim['config'] = config + if newname: + vim["name"] = newname + if user: + vim["vim_user"] = user + if password: + vim["vim_password"] = password + if auth_url: + vim["vim_url"] = auth_url + if tenant: + vim["vim-tenant-name"] = tenant + if account_type: + vim["vim_type"] = account_type + if description: + vim["description"] = description + if config: + vim["config"] = config ctx.obj.vim.update(name, vim, sdn_controller, sdn_port_mapping, wait=wait) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='vim-delete', short_help='deletes a VIM account') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it ' - 'until the operation is completed, or timeout') +@cli_osm.command(name="vim-delete", short_help="deletes a VIM account") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it " + "until the operation is completed, or timeout", +) @click.pass_context def vim_delete(ctx, name, force, wait): """deletes a VIM account NAME: name or ID of the VIM account to be deleted @@ -2550,218 +3211,259 @@ logger.debug("") # try: if not force: ctx.obj.vim.delete(name, wait=wait) else: - check_client_version(ctx.obj, '--force') + check_client_version(ctx.obj, "--force") ctx.obj.vim.delete(name, force, wait=wait) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='vim-list', short_help='list all VIM accounts') -#@click.option('--ro_update/--no_ro_update', +@cli_osm.command(name="vim-list", short_help="list all VIM accounts") +# @click.option('--ro_update/--no_ro_update', # default=False, # help='update list from RO') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the VIM accounts matching the filter') -@click.option('--long', is_flag=True, - help='get more details of the NS (project, vim, deployment status, configuration status.') +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the VIM accounts matching the filter", +) +@click.option( + "--long", + is_flag=True, + help="get more details of the NS (project, vim, deployment status, configuration status.", +) @click.pass_context def vim_list(ctx, filter, long): """list all VIM accounts""" logger.debug("") if filter: - filter='&'.join(filter) - check_client_version(ctx.obj, '--filter') -# if ro_update: -# check_client_version(ctx.obj, '--ro_update', 'v1') + filter = "&".join(filter) + check_client_version(ctx.obj, "--filter") + # if ro_update: + # check_client_version(ctx.obj, '--ro_update', 'v1') fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ - if fullclassname == 'osmclient.sol005.client.Client': + if fullclassname == "osmclient.sol005.client.Client": resp = ctx.obj.vim.list(filter) -# else: -# resp = ctx.obj.vim.list(ro_update) + # else: + # resp = ctx.obj.vim.list(ro_update) if long: - table = PrettyTable(['vim name', 'uuid', 'project', 'operational state', 'error details']) + table = PrettyTable( + ["vim name", "uuid", "project", "operational state", "error details"] + ) project_list = ctx.obj.project.list() else: - table = PrettyTable(['vim name', 'uuid', 'operational state']) + table = PrettyTable(["vim name", "uuid", "operational state"]) for vim in resp: if long: - if 'vim_password' in vim: - vim['vim_password']='********' - logger.debug('VIM details: {}'.format(yaml.safe_dump(vim))) - vim_state = vim['_admin'].get('operationalState', '-') - error_details = 'N/A' - if vim_state == 'ERROR': - error_details = vim['_admin'].get('detailed-status', 'Not found') + if "vim_password" in vim: + vim["vim_password"] = "********" + logger.debug("VIM details: {}".format(yaml.safe_dump(vim))) + vim_state = vim["_admin"].get("operationalState", "-") + error_details = "N/A" + if vim_state == "ERROR": + error_details = vim["_admin"].get("detailed-status", "Not found") project_id, project_name = get_project(project_list, vim) - #project_info = '{} ({})'.format(project_name, project_id) + # project_info = '{} ({})'.format(project_name, project_id) project_info = project_name - table.add_row([vim['name'], vim['uuid'], project_info, - vim_state, wrap_text(text=error_details, width=80)]) + table.add_row( + [ + vim["name"], + vim["uuid"], + project_info, + vim_state, + wrap_text(text=error_details, width=80), + ] + ) else: - table.add_row([vim['name'], vim['uuid'], vim['_admin'].get('operationalState', '-')]) - table.align = 'l' + table.add_row( + [vim["name"], vim["uuid"], vim["_admin"].get("operationalState", "-")] + ) + table.align = "l" print(table) -@cli_osm.command(name='vim-show', short_help='shows the details of a VIM account') -@click.argument('name') -@click.option('--filter', multiple=True, - help='restricts the information to the fields in the filter') +@cli_osm.command(name="vim-show", short_help="shows the details of a VIM account") +@click.argument("name") +@click.option( + "--filter", + multiple=True, + help="restricts the information to the fields in the filter", +) @click.pass_context def vim_show(ctx, name, filter): """shows the details of a VIM account NAME: name or ID of the VIM account """ logger.debug("") # try: resp = ctx.obj.vim.get(name) - if 'vim_password' in resp: - resp['vim_password']='********' - # except ClientException as e: - # print(str(e)) - # exit(1) - - table = PrettyTable(['key', 'attribute']) + if "vim_password" in resp: + resp["vim_password"] = "********" + # except ClientException as e: + # print(str(e)) + # exit(1) + + table = PrettyTable(["key", "attribute"]) for k, v in list(resp.items()): if not filter or k in filter: - table.add_row([k, wrap_text(text=json.dumps(v, indent=2),width=100)]) - table.align = 'l' + table.add_row([k, wrap_text(text=json.dumps(v, indent=2), width=100)]) + table.align = "l" print(table) #################### # WIM operations #################### -@cli_osm.command(name='wim-create', short_help='creates a new WIM account') -@click.option('--name', - prompt=True, - help='Name for the WIM account') -@click.option('--user', - help='WIM username') -@click.option('--password', - help='WIM password') -@click.option('--url', - prompt=True, - help='WIM url') + +@cli_osm.command(name="wim-create", short_help="creates a new WIM account") +@click.option("--name", prompt=True, help="Name for the WIM account") +@click.option("--user", help="WIM username") +@click.option("--password", help="WIM password") +@click.option("--url", prompt=True, help="WIM url") # @click.option('--tenant', # help='wIM tenant name') -@click.option('--config', - default=None, - help='WIM specific config parameters') -@click.option('--wim_type', - help='WIM type') -@click.option('--description', - default=None, - help='human readable description') -@click.option('--wim_port_mapping', default=None, - help="File describing the port mapping between DC edge (datacenters, switches, ports) and WAN edge " - "(WAN service endpoint id and info)") -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it ' - 'until the operation is completed, or timeout') -@click.pass_context -def wim_create(ctx, - name, - user, - password, - url, - # tenant, - config, - wim_type, - description, - wim_port_mapping, - wait): +@click.option("--config", default=None, help="WIM specific config parameters") +@click.option("--wim_type", help="WIM type") +@click.option("--description", default=None, help="human readable description") +@click.option( + "--wim_port_mapping", + default=None, + help="File describing the port mapping between DC edge (datacenters, switches, ports) and WAN edge " + "(WAN service endpoint id and info)", +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it " + "until the operation is completed, or timeout", +) +@click.pass_context +def wim_create( + ctx, + name, + user, + password, + url, + # tenant, + config, + wim_type, + description, + wim_port_mapping, + wait, +): """creates a new WIM account""" logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) # if sdn_controller: # check_client_version(ctx.obj, '--sdn_controller') # if sdn_port_mapping: # check_client_version(ctx.obj, '--sdn_port_mapping') wim = {} - if user: wim['user'] = user - if password: wim['password'] = password - if url: wim['wim_url'] = url + if user: + wim["user"] = user + if password: + wim["password"] = password + if url: + wim["wim_url"] = url # if tenant: wim['tenant'] = tenant - wim['wim_type'] = wim_type - if description: wim['description'] = description - if config: wim['config'] = config + wim["wim_type"] = wim_type + if description: + wim["description"] = description + if config: + wim["config"] = config ctx.obj.wim.create(name, wim, wim_port_mapping, wait=wait) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='wim-update', short_help='updates a WIM account') -@click.argument('name') -@click.option('--newname', help='New name for the WIM account') -@click.option('--user', help='WIM username') -@click.option('--password', help='WIM password') -@click.option('--url', help='WIM url') -@click.option('--config', help='WIM specific config parameters') -@click.option('--wim_type', help='WIM type') -@click.option('--description', help='human readable description') -@click.option('--wim_port_mapping', default=None, - help="File describing the port mapping between DC edge (datacenters, switches, ports) and WAN edge " - "(WAN service endpoint id and info)") -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it until the operation is completed, or timeout') -@click.pass_context -def wim_update(ctx, - name, - newname, - user, - password, - url, - config, - wim_type, - description, - wim_port_mapping, - wait): +@cli_osm.command(name="wim-update", short_help="updates a WIM account") +@click.argument("name") +@click.option("--newname", help="New name for the WIM account") +@click.option("--user", help="WIM username") +@click.option("--password", help="WIM password") +@click.option("--url", help="WIM url") +@click.option("--config", help="WIM specific config parameters") +@click.option("--wim_type", help="WIM type") +@click.option("--description", help="human readable description") +@click.option( + "--wim_port_mapping", + default=None, + help="File describing the port mapping between DC edge (datacenters, switches, ports) and WAN edge " + "(WAN service endpoint id and info)", +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it until the operation is completed, or timeout", +) +@click.pass_context +def wim_update( + ctx, + name, + newname, + user, + password, + url, + config, + wim_type, + description, + wim_port_mapping, + wait, +): """updates a WIM account NAME: name or ID of the WIM account """ logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) wim = {} - if newname: wim['name'] = newname - if user: wim['user'] = user - if password: wim['password'] = password - if url: wim['url'] = url + if newname: + wim["name"] = newname + if user: + wim["user"] = user + if password: + wim["password"] = password + if url: + wim["url"] = url # if tenant: wim['tenant'] = tenant - if wim_type: wim['wim_type'] = wim_type - if description: wim['description'] = description - if config: wim['config'] = config + if wim_type: + wim["wim_type"] = wim_type + if description: + wim["description"] = description + if config: + wim["config"] = config ctx.obj.wim.update(name, wim, wim_port_mapping, wait=wait) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='wim-delete', short_help='deletes a WIM account') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it until the operation is completed, or timeout') +@cli_osm.command(name="wim-delete", short_help="deletes a WIM account") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it until the operation is completed, or timeout", +) @click.pass_context def wim_delete(ctx, name, force, wait): """deletes a WIM account NAME: name or ID of the WIM account to be deleted @@ -2773,172 +3475,213 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='wim-list', short_help='list all WIM accounts') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the WIM accounts matching the filter') +@cli_osm.command(name="wim-list", short_help="list all WIM accounts") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the WIM accounts matching the filter", +) @click.pass_context def wim_list(ctx, filter): """list all WIM accounts""" logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) if filter: - filter='&'.join(filter) + filter = "&".join(filter) resp = ctx.obj.wim.list(filter) - table = PrettyTable(['wim name', 'uuid']) + table = PrettyTable(["wim name", "uuid"]) for wim in resp: - table.add_row([wim['name'], wim['uuid']]) - table.align = 'l' + table.add_row([wim["name"], wim["uuid"]]) + table.align = "l" print(table) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='wim-show', short_help='shows the details of a WIM account') -@click.argument('name') +@cli_osm.command(name="wim-show", short_help="shows the details of a WIM account") +@click.argument("name") @click.pass_context def wim_show(ctx, name): """shows the details of a WIM account NAME: name or ID of the WIM account """ logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) resp = ctx.obj.wim.get(name) - if 'password' in resp: - resp['wim_password']='********' - # except ClientException as e: - # print(str(e)) - # exit(1) - - table = PrettyTable(['key', 'attribute']) + if "password" in resp: + resp["wim_password"] = "********" + # except ClientException as e: + # print(str(e)) + # exit(1) + + table = PrettyTable(["key", "attribute"]) for k, v in list(resp.items()): table.add_row([k, json.dumps(v, indent=2)]) - table.align = 'l' + table.align = "l" print(table) #################### # SDN controller operations #################### -@cli_osm.command(name='sdnc-create', short_help='creates a new SDN controller') -@click.option('--name', - prompt=True, - help='Name to create sdn controller') -@click.option('--type', - prompt=True, - help='SDN controller type') -@click.option('--sdn_controller_version', # hidden=True, - help='Deprecated. Use --config {version: sdn_controller_version}') -@click.option('--url', - help='URL in format http[s]://HOST:IP/') -@click.option('--ip_address', # hidden=True, - help='Deprecated. Use --url') -@click.option('--port', # hidden=True, - help='Deprecated. Use --url') -@click.option('--switch_dpid', # hidden=True, - help='Deprecated. Use --config {switch_id: DPID}') -@click.option('--config', - help='Extra information for SDN in yaml format, as {switch_id: identity used for the plugin (e.g. DPID: ' - 'Openflow Datapath ID), version: version}') -@click.option('--user', - help='SDN controller username') -@click.option('--password', - hide_input=True, - confirmation_prompt=True, - help='SDN controller password') -@click.option('--description', default=None, help='human readable description') -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help="do not return the control immediately, but keep it until the operation is completed, or timeout") + +@cli_osm.command(name="sdnc-create", short_help="creates a new SDN controller") +@click.option("--name", prompt=True, help="Name to create sdn controller") +@click.option("--type", prompt=True, help="SDN controller type") +@click.option( + "--sdn_controller_version", # hidden=True, + help="Deprecated. Use --config {version: sdn_controller_version}", +) +@click.option("--url", help="URL in format http[s]://HOST:IP/") +@click.option("--ip_address", help="Deprecated. Use --url") # hidden=True, +@click.option("--port", help="Deprecated. Use --url") # hidden=True, +@click.option( + "--switch_dpid", help="Deprecated. Use --config {switch_id: DPID}" # hidden=True, +) +@click.option( + "--config", + help="Extra information for SDN in yaml format, as {switch_id: identity used for the plugin (e.g. DPID: " + "Openflow Datapath ID), version: version}", +) +@click.option("--user", help="SDN controller username") +@click.option( + "--password", + hide_input=True, + confirmation_prompt=True, + help="SDN controller password", +) +@click.option("--description", default=None, help="human readable description") +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it until the operation is completed, or timeout", +) @click.pass_context def sdnc_create(ctx, **kwargs): """creates a new SDN controller""" logger.debug("") - sdncontroller = {x: kwargs[x] for x in kwargs if kwargs[x] and - x not in ("wait", "ip_address", "port", "switch_dpid")} + sdncontroller = { + x: kwargs[x] + for x in kwargs + if kwargs[x] and x not in ("wait", "ip_address", "port", "switch_dpid") + } if kwargs.get("port"): print("option '--port' is deprecated, use '--url' instead") sdncontroller["port"] = int(kwargs["port"]) if kwargs.get("ip_address"): print("option '--ip_address' is deprecated, use '--url' instead") sdncontroller["ip"] = kwargs["ip_address"] if kwargs.get("switch_dpid"): - print("option '--switch_dpid' is deprecated, use '--config={switch_id: id|DPID}' instead") + print( + "option '--switch_dpid' is deprecated, use '--config={switch_id: id|DPID}' instead" + ) sdncontroller["dpid"] = kwargs["switch_dpid"] if kwargs.get("sdn_controller_version"): - print("option '--sdn_controller_version' is deprecated, use '--config={version: SDN_CONTROLLER_VERSION}'" - " instead") + print( + "option '--sdn_controller_version' is deprecated, use '--config={version: SDN_CONTROLLER_VERSION}'" + " instead" + ) # try: check_client_version(ctx.obj, ctx.command.name) ctx.obj.sdnc.create(kwargs["name"], sdncontroller, wait=kwargs["wait"]) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='sdnc-update', short_help='updates an SDN controller') -@click.argument('name') -@click.option('--newname', help='New name for the SDN controller') -@click.option('--description', default=None, help='human readable description') -@click.option('--type', help='SDN controller type') -@click.option('--url', help='URL in format http[s]://HOST:IP/') -@click.option('--config', help='Extra information for SDN in yaml format, as ' - '{switch_id: identity used for the plugin (e.g. DPID: ' - 'Openflow Datapath ID), version: version}') -@click.option('--user', help='SDN controller username') -@click.option('--password', help='SDN controller password') -@click.option('--ip_address', help='Deprecated. Use --url') # hidden=True -@click.option('--port', help='Deprecated. Use --url') # hidden=True -@click.option('--switch_dpid', help='Deprecated. Use --config {switch_dpid: DPID}') # hidden=True -@click.option('--sdn_controller_version', help='Deprecated. Use --config {version: VERSION}') # hidden=True -@click.option('--wait', required=False, default=False, is_flag=True, - help='do not return the control immediately, but keep it until the operation is completed, or timeout') + +@cli_osm.command(name="sdnc-update", short_help="updates an SDN controller") +@click.argument("name") +@click.option("--newname", help="New name for the SDN controller") +@click.option("--description", default=None, help="human readable description") +@click.option("--type", help="SDN controller type") +@click.option("--url", help="URL in format http[s]://HOST:IP/") +@click.option( + "--config", + help="Extra information for SDN in yaml format, as " + "{switch_id: identity used for the plugin (e.g. DPID: " + "Openflow Datapath ID), version: version}", +) +@click.option("--user", help="SDN controller username") +@click.option("--password", help="SDN controller password") +@click.option("--ip_address", help="Deprecated. Use --url") # hidden=True +@click.option("--port", help="Deprecated. Use --url") # hidden=True +@click.option( + "--switch_dpid", help="Deprecated. Use --config {switch_dpid: DPID}" +) # hidden=True +@click.option( + "--sdn_controller_version", help="Deprecated. Use --config {version: VERSION}" +) # hidden=True +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it until the operation is completed, or timeout", +) @click.pass_context def sdnc_update(ctx, **kwargs): """updates an SDN controller NAME: name or ID of the SDN controller """ logger.debug("") - sdncontroller = {x: kwargs[x] for x in kwargs if kwargs[x] and - x not in ("wait", "ip_address", "port", "switch_dpid", "new_name")} + sdncontroller = { + x: kwargs[x] + for x in kwargs + if kwargs[x] + and x not in ("wait", "ip_address", "port", "switch_dpid", "new_name") + } if kwargs.get("newname"): sdncontroller["name"] = kwargs["newname"] if kwargs.get("port"): print("option '--port' is deprecated, use '--url' instead") sdncontroller["port"] = int(kwargs["port"]) if kwargs.get("ip_address"): print("option '--ip_address' is deprecated, use '--url' instead") sdncontroller["ip"] = kwargs["ip_address"] if kwargs.get("switch_dpid"): - print("option '--switch_dpid' is deprecated, use '--config={switch_id: id|DPID}' instead") + print( + "option '--switch_dpid' is deprecated, use '--config={switch_id: id|DPID}' instead" + ) sdncontroller["dpid"] = kwargs["switch_dpid"] if kwargs.get("sdn_controller_version"): - print("option '--sdn_controller_version' is deprecated, use '---config={version: SDN_CONTROLLER_VERSION}'" - " instead") + print( + "option '--sdn_controller_version' is deprecated, use '---config={version: SDN_CONTROLLER_VERSION}'" + " instead" + ) # try: check_client_version(ctx.obj, ctx.command.name) ctx.obj.sdnc.update(kwargs["name"], sdncontroller, wait=kwargs["wait"]) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='sdnc-delete', short_help='deletes an SDN controller') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') -@click.option('--wait', required=False, default=False, is_flag=True, - help='do not return the control immediately, but keep it until the operation is completed, or timeout') +@cli_osm.command(name="sdnc-delete", short_help="deletes an SDN controller") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion bypassing pre-conditions" +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it until the operation is completed, or timeout", +) @click.pass_context def sdnc_delete(ctx, name, force, wait): """deletes an SDN controller NAME: name or ID of the SDN controller to be deleted @@ -2950,34 +3693,38 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='sdnc-list', short_help='list all SDN controllers') -@click.option('--filter', default=None, multiple=True, - help="restricts the list to the SDN controllers matching the filter with format: 'k[.k..]=v[&k[.k]=v2]'") +@cli_osm.command(name="sdnc-list", short_help="list all SDN controllers") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the SDN controllers matching the filter with format: 'k[.k..]=v[&k[.k]=v2]'", +) @click.pass_context def sdnc_list(ctx, filter): """list all SDN controllers""" logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) if filter: - filter='&'.join(filter) + filter = "&".join(filter) resp = ctx.obj.sdnc.list(filter) # except ClientException as e: # print(str(e)) # exit(1) - table = PrettyTable(['sdnc name', 'id']) + table = PrettyTable(["sdnc name", "id"]) for sdnc in resp: - table.add_row([sdnc['name'], sdnc['_id']]) - table.align = 'l' + table.add_row([sdnc["name"], sdnc["_id"]]) + table.align = "l" print(table) -@cli_osm.command(name='sdnc-show', short_help='shows the details of an SDN controller') -@click.argument('name') +@cli_osm.command(name="sdnc-show", short_help="shows the details of an SDN controller") +@click.argument("name") @click.pass_context def sdnc_show(ctx, name): """shows the details of an SDN controller NAME: name or ID of the SDN controller @@ -2988,131 +3735,140 @@ resp = ctx.obj.sdnc.get(name) # except ClientException as e: # print(str(e)) # exit(1) - table = PrettyTable(['key', 'attribute']) + table = PrettyTable(["key", "attribute"]) for k, v in list(resp.items()): table.add_row([k, json.dumps(v, indent=2)]) - table.align = 'l' + table.align = "l" print(table) ########################### # K8s cluster operations ########################### -@cli_osm.command(name='k8scluster-add', short_help='adds a K8s cluster to OSM') -@click.argument('name') -@click.option('--creds', - prompt=True, - help='credentials file, i.e. a valid `.kube/config` file') -@click.option('--version', - prompt=True, - help='Kubernetes version') -@click.option('--vim', - prompt=True, - help='VIM target, the VIM where the cluster resides') -@click.option('--k8s-nets', - prompt=True, - help='list of VIM networks, in JSON inline format, where the cluster is accessible via L3 routing, e.g. "{(k8s_net1:vim_network1) [,(k8s_net2:vim_network2) ...]}"') -@click.option('--description', - default=None, - help='human readable description') -@click.option('--namespace', - default='kube-system', - help='namespace to be used for its operation, defaults to `kube-system`') -@click.option('--cni', - default=None, - help='list of CNI plugins, in JSON inline format, used in the cluster') -#@click.option('--skip-init', + +@cli_osm.command(name="k8scluster-add", short_help="adds a K8s cluster to OSM") +@click.argument("name") +@click.option( + "--creds", prompt=True, help="credentials file, i.e. a valid `.kube/config` file" +) +@click.option("--version", prompt=True, help="Kubernetes version") +@click.option( + "--vim", prompt=True, help="VIM target, the VIM where the cluster resides" +) +@click.option( + "--k8s-nets", + prompt=True, + help='list of VIM networks, in JSON inline format, where the cluster is accessible via L3 routing, e.g. "{(k8s_net1:vim_network1) [,(k8s_net2:vim_network2) ...]}"', +) +@click.option("--description", default=None, help="human readable description") +@click.option( + "--namespace", + default="kube-system", + help="namespace to be used for its operation, defaults to `kube-system`", +) +@click.option( + "--cni", + default=None, + help="list of CNI plugins, in JSON inline format, used in the cluster", +) +# @click.option('--skip-init', # is_flag=True, # help='If set, K8s cluster is assumed to be ready for its use with OSM') -#@click.option('--wait', +# @click.option('--wait', # is_flag=True, # help='do not return the control immediately, but keep it until the operation is completed, or timeout') @click.pass_context -def k8scluster_add(ctx, - name, - creds, - version, - vim, - k8s_nets, - description, - namespace, - cni): +def k8scluster_add( + ctx, name, creds, version, vim, k8s_nets, description, namespace, cni +): """adds a K8s cluster to OSM NAME: name of the K8s cluster """ # try: check_client_version(ctx.obj, ctx.command.name) cluster = {} - cluster['name'] = name - with open(creds, 'r') as cf: - cluster['credentials'] = yaml.safe_load(cf.read()) - cluster['k8s_version'] = version - cluster['vim_account'] = vim - cluster['nets'] = yaml.safe_load(k8s_nets) + cluster["name"] = name + with open(creds, "r") as cf: + cluster["credentials"] = yaml.safe_load(cf.read()) + cluster["k8s_version"] = version + cluster["vim_account"] = vim + cluster["nets"] = yaml.safe_load(k8s_nets) if description: - cluster['description'] = description - if namespace: cluster['namespace'] = namespace - if cni: cluster['cni'] = yaml.safe_load(cni) + cluster["description"] = description + if namespace: + cluster["namespace"] = namespace + if cni: + cluster["cni"] = yaml.safe_load(cni) ctx.obj.k8scluster.create(name, cluster) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='k8scluster-update', short_help='updates a K8s cluster') -@click.argument('name') -@click.option('--newname', help='New name for the K8s cluster') -@click.option('--creds', help='credentials file, i.e. a valid `.kube/config` file') -@click.option('--version', help='Kubernetes version') -@click.option('--vim', help='VIM target, the VIM where the cluster resides') -@click.option('--k8s-nets', help='list of VIM networks, in JSON inline format, where the cluster is accessible via L3 routing, e.g. "{(k8s_net1:vim_network1) [,(k8s_net2:vim_network2) ...]}"') -@click.option('--description', help='human readable description') -@click.option('--namespace', help='namespace to be used for its operation, defaults to `kube-system`') -@click.option('--cni', help='list of CNI plugins, in JSON inline format, used in the cluster') -@click.pass_context -def k8scluster_update(ctx, - name, - newname, - creds, - version, - vim, - k8s_nets, - description, - namespace, - cni): +@cli_osm.command(name="k8scluster-update", short_help="updates a K8s cluster") +@click.argument("name") +@click.option("--newname", help="New name for the K8s cluster") +@click.option("--creds", help="credentials file, i.e. a valid `.kube/config` file") +@click.option("--version", help="Kubernetes version") +@click.option("--vim", help="VIM target, the VIM where the cluster resides") +@click.option( + "--k8s-nets", + help='list of VIM networks, in JSON inline format, where the cluster is accessible via L3 routing, e.g. "{(k8s_net1:vim_network1) [,(k8s_net2:vim_network2) ...]}"', +) +@click.option("--description", help="human readable description") +@click.option( + "--namespace", + help="namespace to be used for its operation, defaults to `kube-system`", +) +@click.option( + "--cni", help="list of CNI plugins, in JSON inline format, used in the cluster" +) +@click.pass_context +def k8scluster_update( + ctx, name, newname, creds, version, vim, k8s_nets, description, namespace, cni +): """updates a K8s cluster NAME: name or ID of the K8s cluster """ # try: check_client_version(ctx.obj, ctx.command.name) cluster = {} - if newname: cluster['name'] = newname + if newname: + cluster["name"] = newname if creds: - with open(creds, 'r') as cf: - cluster['credentials'] = yaml.safe_load(cf.read()) - if version: cluster['k8s_version'] = version - if vim: cluster['vim_account'] = vim - if k8s_nets: cluster['nets'] = yaml.safe_load(k8s_nets) - if description: cluster['description'] = description - if namespace: cluster['namespace'] = namespace - if cni: cluster['cni'] = yaml.safe_load(cni) + with open(creds, "r") as cf: + cluster["credentials"] = yaml.safe_load(cf.read()) + if version: + cluster["k8s_version"] = version + if vim: + cluster["vim_account"] = vim + if k8s_nets: + cluster["nets"] = yaml.safe_load(k8s_nets) + if description: + cluster["description"] = description + if namespace: + cluster["namespace"] = namespace + if cni: + cluster["cni"] = yaml.safe_load(cni) ctx.obj.k8scluster.update(name, cluster) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='k8scluster-delete', short_help='deletes a K8s cluster') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion from the DB (not recommended)') -#@click.option('--wait', +@cli_osm.command(name="k8scluster-delete", short_help="deletes a K8s cluster") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion from the DB (not recommended)" +) +# @click.option('--wait', # is_flag=True, # help='do not return the control immediately, but keep it until the operation is completed, or timeout') @click.pass_context def k8scluster_delete(ctx, name, force): """deletes a K8s cluster @@ -3125,69 +3881,104 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='k8scluster-list') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the K8s clusters matching the filter') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') -@click.option('--long', is_flag=True, help='get more details') +@cli_osm.command(name="k8scluster-list") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the K8s clusters matching the filter", +) +@click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.option("--long", is_flag=True, help="get more details") @click.pass_context def k8scluster_list(ctx, filter, literal, long): """list all K8s clusters""" # try: check_client_version(ctx.obj, ctx.command.name) if filter: - filter='&'.join(filter) + filter = "&".join(filter) resp = ctx.obj.k8scluster.list(filter) if literal: print(yaml.safe_dump(resp, indent=4, default_flow_style=False)) return if long: - table = PrettyTable(['Name', 'Id', 'Project', 'Version', 'VIM', 'K8s-nets', - 'Operational State', 'Op. state (details)', 'Description', 'Detailed status']) + table = PrettyTable( + [ + "Name", + "Id", + "Project", + "Version", + "VIM", + "K8s-nets", + "Operational State", + "Op. state (details)", + "Description", + "Detailed status", + ] + ) project_list = ctx.obj.project.list() else: - table = PrettyTable(['Name', 'Id', 'VIM', 'Operational State', 'Op. state details']) + table = PrettyTable( + ["Name", "Id", "VIM", "Operational State", "Op. state details"] + ) try: vim_list = ctx.obj.vim.list() except: vim_list = [] for cluster in resp: - logger.debug('Cluster details: {}'.format(yaml.safe_dump(cluster))) - vim_name = get_vim_name(vim_list, cluster['vim_account']) - #vim_info = '{} ({})'.format(vim_name,cluster['vim_account']) + logger.debug("Cluster details: {}".format(yaml.safe_dump(cluster))) + vim_name = get_vim_name(vim_list, cluster["vim_account"]) + # vim_info = '{} ({})'.format(vim_name,cluster['vim_account']) vim_info = vim_name op_state_details = "Helm: {}\nJuju: {}".format( - cluster["_admin"].get("helm-chart", {}).get("operationalState", "-"), - cluster["_admin"].get("juju-bundle", {}).get("operationalState", "-")) + cluster["_admin"].get("helm-chart", {}).get("operationalState", "-"), + cluster["_admin"].get("juju-bundle", {}).get("operationalState", "-"), + ) if long: project_id, project_name = get_project(project_list, cluster) - #project_info = '{} ({})'.format(project_name, project_id) + # project_info = '{} ({})'.format(project_name, project_id) project_info = project_name - detailed_status = cluster["_admin"].get("detailed-status","-") - table.add_row([cluster['name'], cluster['_id'], project_info, - cluster['k8s_version'], vim_info, - json.dumps(cluster['nets']), cluster["_admin"]["operationalState"], - op_state_details, trunc_text(cluster.get('description') or '', 40), - wrap_text(text=detailed_status, width=40)]) + detailed_status = cluster["_admin"].get("detailed-status", "-") + table.add_row( + [ + cluster["name"], + cluster["_id"], + project_info, + cluster["k8s_version"], + vim_info, + json.dumps(cluster["nets"]), + cluster["_admin"]["operationalState"], + op_state_details, + trunc_text(cluster.get("description") or "", 40), + wrap_text(text=detailed_status, width=40), + ] + ) else: - table.add_row([cluster['name'], cluster['_id'], vim_info, - cluster["_admin"]["operationalState"], op_state_details]) - table.align = 'l' + table.add_row( + [ + cluster["name"], + cluster["_id"], + vim_info, + cluster["_admin"]["operationalState"], + op_state_details, + ] + ) + table.align = "l" print(table) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='k8scluster-show', short_help='shows the details of a K8s cluster') -@click.argument('name') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') +@cli_osm.command( + name="k8scluster-show", short_help="shows the details of a K8s cluster" +) +@click.argument("name") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") @click.pass_context def k8scluster_show(ctx, name, literal): """shows the details of a K8s cluster NAME: name or ID of the K8s cluster @@ -3195,42 +3986,44 @@ # try: resp = ctx.obj.k8scluster.get(name) if literal: print(yaml.safe_dump(resp, indent=4, default_flow_style=False)) return - table = PrettyTable(['key', 'attribute']) + table = PrettyTable(["key", "attribute"]) for k, v in list(resp.items()): - table.add_row([k, wrap_text(text=json.dumps(v, indent=2),width=100)]) - table.align = 'l' + table.add_row([k, wrap_text(text=json.dumps(v, indent=2), width=100)]) + table.align = "l" print(table) # except ClientException as e: # print(str(e)) # exit(1) - ########################### # Repo operations ########################### -@cli_osm.command(name='repo-add', short_help='adds a repo to OSM') -@click.argument('name') -@click.argument('uri') -@click.option('--type', - type=click.Choice(['helm-chart', 'juju-bundle', 'osm']), - default='osm', - help='type of repo (helm-chart for Helm Charts, juju-bundle for Juju Bundles, osm for OSM Repositories)') -@click.option('--description', - default=None, - help='human readable description') -@click.option('--user', - default=None, - help='OSM repository: The username of the OSM repository') -@click.option('--password', - default=None, - help='OSM repository: The password of the OSM repository') -#@click.option('--wait', + +@cli_osm.command(name="repo-add", short_help="adds a repo to OSM") +@click.argument("name") +@click.argument("uri") +@click.option( + "--type", + type=click.Choice(["helm-chart", "juju-bundle", "osm"]), + default="osm", + help="type of repo (helm-chart for Helm Charts, juju-bundle for Juju Bundles, osm for OSM Repositories)", +) +@click.option("--description", default=None, help="human readable description") +@click.option( + "--user", default=None, help="OSM repository: The username of the OSM repository" +) +@click.option( + "--password", + default=None, + help="OSM repository: The password of the OSM repository", +) +# @click.option('--wait', # is_flag=True, # help='do not return the control immediately, but keep it until the operation is completed, or timeout') @click.pass_context def repo_add(ctx, **kwargs): """adds a repo to OSM @@ -3240,72 +4033,77 @@ """ # try: kwargs = {k: v for k, v in kwargs.items() if v is not None} repo = kwargs repo["url"] = repo.pop("uri") - if repo["type"] in ['helm-chart', 'juju-bundle']: - ctx.obj.repo.create(repo['name'], repo) + if repo["type"] in ["helm-chart", "juju-bundle"]: + ctx.obj.repo.create(repo["name"], repo) else: - ctx.obj.osmrepo.create(repo['name'], repo) - # except ClientException as e: - # print(str(e)) - # exit(1) - - -@cli_osm.command(name='repo-update', short_help='updates a repo in OSM') -@click.argument('name') -@click.option('--newname', help='New name for the repo') -@click.option('--uri', help='URI of the repo') -@click.option('--description', help='human readable description') -#@click.option('--wait', + ctx.obj.osmrepo.create(repo["name"], repo) + # except ClientException as e: + # print(str(e)) + # exit(1) + + +@cli_osm.command(name="repo-update", short_help="updates a repo in OSM") +@click.argument("name") +@click.option("--newname", help="New name for the repo") +@click.option("--uri", help="URI of the repo") +@click.option("--description", help="human readable description") +# @click.option('--wait', # is_flag=True, # help='do not return the control immediately, but keep it until the operation is completed, or timeout') @click.pass_context -def repo_update(ctx, - name, - newname, - uri, - description): +def repo_update(ctx, name, newname, uri, description): """updates a repo in OSM NAME: name of the repo """ # try: check_client_version(ctx.obj, ctx.command.name) repo = {} if newname: - repo['name'] = newname + repo["name"] = newname if uri: - repo['uri'] = uri - if description: repo['description'] = description + repo["uri"] = uri + if description: + repo["description"] = description try: ctx.obj.repo.update(name, repo) except NotFound: ctx.obj.osmrepo.update(name, repo) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='repo-index', short_help='Index a repository from a folder with artifacts') -@click.option('--origin', default='.', help='origin path where the artifacts are located') -@click.option('--destination', default='.', help='destination path where the index is deployed') +@cli_osm.command( + name="repo-index", short_help="Index a repository from a folder with artifacts" +) +@click.option( + "--origin", default=".", help="origin path where the artifacts are located" +) +@click.option( + "--destination", default=".", help="destination path where the index is deployed" +) @click.pass_context def repo_index(ctx, origin, destination): """Index a repository NAME: name or ID of the repo to be deleted """ check_client_version(ctx.obj, ctx.command.name) ctx.obj.osmrepo.repo_index(origin, destination) -@cli_osm.command(name='repo-delete', short_help='deletes a repo') -@click.argument('name') -@click.option('--force', is_flag=True, help='forces the deletion from the DB (not recommended)') -#@click.option('--wait', +@cli_osm.command(name="repo-delete", short_help="deletes a repo") +@click.argument("name") +@click.option( + "--force", is_flag=True, help="forces the deletion from the DB (not recommended)" +) +# @click.option('--wait', # is_flag=True, # help='do not return the control immediately, but keep it until the operation is completed, or timeout') @click.pass_context def repo_delete(ctx, name, force): """deletes a repo @@ -3320,44 +4118,54 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='repo-list') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the repos matching the filter') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') +@cli_osm.command(name="repo-list") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the repos matching the filter", +) +@click.option("--literal", is_flag=True, help="print literally, no pretty table") @click.pass_context def repo_list(ctx, filter, literal): """list all repos""" # try: # K8s Repositories check_client_version(ctx.obj, ctx.command.name) if filter: - filter='&'.join(filter) + filter = "&".join(filter) resp = ctx.obj.repo.list(filter) resp += ctx.obj.osmrepo.list(filter) if literal: print(yaml.safe_dump(resp, indent=4, default_flow_style=False)) return - table = PrettyTable(['Name', 'Id', 'Type', 'URI', 'Description']) + table = PrettyTable(["Name", "Id", "Type", "URI", "Description"]) for repo in resp: - #cluster['k8s-nets'] = json.dumps(yaml.safe_load(cluster['k8s-nets'])) - table.add_row([repo['name'], repo['_id'], repo['type'], repo['url'], trunc_text(repo.get('description') or '',40)]) - table.align = 'l' + # cluster['k8s-nets'] = json.dumps(yaml.safe_load(cluster['k8s-nets'])) + table.add_row( + [ + repo["name"], + repo["_id"], + repo["type"], + repo["url"], + trunc_text(repo.get("description") or "", 40), + ] + ) + table.align = "l" print(table) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='repo-show', short_help='shows the details of a repo') -@click.argument('name') -@click.option('--literal', is_flag=True, - help='print literally, no pretty table') +@cli_osm.command(name="repo-show", short_help="shows the details of a repo") +@click.argument("name") +@click.option("--literal", is_flag=True, help="print literally, no pretty table") @click.pass_context def repo_show(ctx, name, literal): """shows the details of a repo NAME: name or ID of the repo @@ -3369,53 +4177,56 @@ if literal: if resp: print(yaml.safe_dump(resp, indent=4, default_flow_style=False)) return - table = PrettyTable(['key', 'attribute']) + table = PrettyTable(["key", "attribute"]) if resp: for k, v in list(resp.items()): table.add_row([k, json.dumps(v, indent=2)]) - table.align = 'l' + table.align = "l" print(table) # except ClientException as e: # print(str(e)) # exit(1) - #################### # Project mgmt operations #################### -@cli_osm.command(name='project-create', short_help='creates a new project') -@click.argument('name') -#@click.option('--description', + +@cli_osm.command(name="project-create", short_help="creates a new project") +@click.argument("name") +# @click.option('--description', # default='no description', # help='human readable description') -@click.option('--domain-name', 'domain_name', - default=None, - help='assign to a domain') -@click.option('--quotas', 'quotas', multiple=True, default=None, - help="provide quotas. Can be used several times: 'quota1=number[,quota2=number,...]'. Quotas can be one " - "of vnfds, nsds, nsts, pdus, nsrs, nsis, vim_accounts, wim_accounts, sdns, k8sclusters, k8srepos") +@click.option("--domain-name", "domain_name", default=None, help="assign to a domain") +@click.option( + "--quotas", + "quotas", + multiple=True, + default=None, + help="provide quotas. Can be used several times: 'quota1=number[,quota2=number,...]'. Quotas can be one " + "of vnfds, nsds, nsts, pdus, nsrs, nsis, vim_accounts, wim_accounts, sdns, k8sclusters, k8srepos", +) @click.pass_context def project_create(ctx, name, domain_name, quotas): """Creates a new project NAME: name of the project DOMAIN_NAME: optional domain name for the project when keystone authentication is used QUOTAS: set quotas for the project """ logger.debug("") - project = {'name': name} + project = {"name": name} if domain_name: - project['domain_name'] = domain_name + project["domain_name"] = domain_name quotas_dict = _process_project_quotas(quotas) if quotas_dict: - project['quotas'] = quotas_dict + project["quotas"] = quotas_dict # try: check_client_version(ctx.obj, ctx.command.name) ctx.obj.project.create(name, project) # except ClientException as e: @@ -3429,19 +4240,21 @@ return quotas_dict try: for quota in quota_list: for single_quota in quota.split(","): k, v = single_quota.split("=") - quotas_dict[k] = None if v in ('None', 'null', '') else int(v) + quotas_dict[k] = None if v in ("None", "null", "") else int(v) except (ValueError, TypeError): - raise ClientException("invalid format for 'quotas'. Use 'k1=v1,v1=v2'. v must be a integer or null") + raise ClientException( + "invalid format for 'quotas'. Use 'k1=v1,v1=v2'. v must be a integer or null" + ) return quotas_dict -@cli_osm.command(name='project-delete', short_help='deletes a project') -@click.argument('name') -#@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') +@cli_osm.command(name="project-delete", short_help="deletes a project") +@click.argument("name") +# @click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') @click.pass_context def project_delete(ctx, name): """deletes a project NAME: name or ID of the project to be deleted @@ -3453,34 +4266,38 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='project-list', short_help='list all projects') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the projects matching the filter') +@cli_osm.command(name="project-list", short_help="list all projects") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the projects matching the filter", +) @click.pass_context def project_list(ctx, filter): """list all projects""" logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) if filter: - filter='&'.join(filter) + filter = "&".join(filter) resp = ctx.obj.project.list(filter) # except ClientException as e: # print(str(e)) # exit(1) - table = PrettyTable(['name', 'id']) + table = PrettyTable(["name", "id"]) for proj in resp: - table.add_row([proj['name'], proj['_id']]) - table.align = 'l' + table.add_row([proj["name"], proj["_id"]]) + table.align = "l" print(table) -@cli_osm.command(name='project-show', short_help='shows the details of a project') -@click.argument('name') +@cli_osm.command(name="project-show", short_help="shows the details of a project") +@click.argument("name") @click.pass_context def project_show(ctx, name): """shows the details of a project NAME: name or ID of the project @@ -3491,24 +4308,30 @@ resp = ctx.obj.project.get(name) # except ClientException as e: # print(str(e)) # exit(1) - table = PrettyTable(['key', 'attribute']) + table = PrettyTable(["key", "attribute"]) for k, v in resp.items(): table.add_row([k, json.dumps(v, indent=2)]) - table.align = 'l' + table.align = "l" print(table) -@cli_osm.command(name='project-update', short_help='updates a project (only the name can be updated)') -@click.argument('project') -@click.option('--name', default=None, - help='new name for the project') -@click.option('--quotas', 'quotas', multiple=True, default=None, - help="change quotas. Can be used several times: 'quota1=number|empty[,quota2=...]' " - "(use empty to reset quota to default") +@cli_osm.command( + name="project-update", short_help="updates a project (only the name can be updated)" +) +@click.argument("project") +@click.option("--name", default=None, help="new name for the project") +@click.option( + "--quotas", + "quotas", + multiple=True, + default=None, + help="change quotas. Can be used several times: 'quota1=number|empty[,quota2=...]' " + "(use empty to reset quota to default", +) @click.pass_context def project_update(ctx, project, name, quotas): """ Update a project name @@ -3519,14 +4342,14 @@ :return: """ logger.debug("") project_changes = {} if name: - project_changes['name'] = name + project_changes["name"] = name quotas_dict = _process_project_quotas(quotas) if quotas_dict: - project_changes['quotas'] = quotas_dict + project_changes["quotas"] = quotas_dict # try: check_client_version(ctx.obj, ctx.command.name) ctx.obj.project.update(project, project_changes) # except ClientException as e: @@ -3535,28 +4358,37 @@ #################### # User mgmt operations #################### -@cli_osm.command(name='user-create', short_help='creates a new user') -@click.argument('username') -@click.option('--password', - prompt=True, - hide_input=True, - confirmation_prompt=True, - help='user password') -@click.option('--projects', - # prompt="Comma separate list of projects", - multiple=True, - callback=lambda ctx, param, value: ''.join(value).split(',') if all(len(x)==1 for x in value) else value, - help='list of project ids that the user belongs to') -@click.option('--project-role-mappings', 'project_role_mappings', - default=None, multiple=True, - help="assign role(s) in a project. Can be used several times: 'project,role1[,role2,...]'") -@click.option('--domain-name', 'domain_name', - default=None, - help='assign to a domain') + +@cli_osm.command(name="user-create", short_help="creates a new user") +@click.argument("username") +@click.option( + "--password", + prompt=True, + hide_input=True, + confirmation_prompt=True, + help="user password", +) +@click.option( + "--projects", + # prompt="Comma separate list of projects", + multiple=True, + callback=lambda ctx, param, value: "".join(value).split(",") + if all(len(x) == 1 for x in value) + else value, + help="list of project ids that the user belongs to", +) +@click.option( + "--project-role-mappings", + "project_role_mappings", + default=None, + multiple=True, + help="assign role(s) in a project. Can be used several times: 'project,role1[,role2,...]'", +) +@click.option("--domain-name", "domain_name", default=None, help="assign to a domain") @click.pass_context def user_create(ctx, username, password, projects, project_role_mappings, domain_name): """Creates a new user \b @@ -3566,50 +4398,74 @@ PROJECT_ROLE_MAPPING: roles in projects assigned to user (keystone) DOMAIN_NAME: optional domain name for the user when keystone authentication is used """ logger.debug("") user = {} - user['username'] = username - user['password'] = password - user['projects'] = projects - user['project_role_mappings'] = project_role_mappings + user["username"] = username + user["password"] = password + user["projects"] = projects + user["project_role_mappings"] = project_role_mappings if domain_name: - user['domain_name'] = domain_name + user["domain_name"] = domain_name # try: check_client_version(ctx.obj, ctx.command.name) ctx.obj.user.create(username, user) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='user-update', short_help='updates user information') -@click.argument('username') -@click.option('--password', - # prompt=True, - # hide_input=True, - # confirmation_prompt=True, - help='user password') -@click.option('--set-username', 'set_username', - default=None, - help='change username') -@click.option('--set-project', 'set_project', - default=None, multiple=True, - help="create/replace the roles for this project: 'project,role1[,role2,...]'") -@click.option('--remove-project', 'remove_project', - default=None, multiple=True, - help="removes project from user: 'project'") -@click.option('--add-project-role', 'add_project_role', - default=None, multiple=True, - help="assign role(s) in a project. Can be used several times: 'project,role1[,role2,...]'") -@click.option('--remove-project-role', 'remove_project_role', - default=None, multiple=True, - help="remove role(s) in a project. Can be used several times: 'project,role1[,role2,...]'") -@click.pass_context -def user_update(ctx, username, password, set_username, set_project, remove_project, - add_project_role, remove_project_role): +@cli_osm.command(name="user-update", short_help="updates user information") +@click.argument("username") +@click.option( + "--password", + # prompt=True, + # hide_input=True, + # confirmation_prompt=True, + help="user password", +) +@click.option("--set-username", "set_username", default=None, help="change username") +@click.option( + "--set-project", + "set_project", + default=None, + multiple=True, + help="create/replace the roles for this project: 'project,role1[,role2,...]'", +) +@click.option( + "--remove-project", + "remove_project", + default=None, + multiple=True, + help="removes project from user: 'project'", +) +@click.option( + "--add-project-role", + "add_project_role", + default=None, + multiple=True, + help="assign role(s) in a project. Can be used several times: 'project,role1[,role2,...]'", +) +@click.option( + "--remove-project-role", + "remove_project_role", + default=None, + multiple=True, + help="remove role(s) in a project. Can be used several times: 'project,role1[,role2,...]'", +) +@click.pass_context +def user_update( + ctx, + username, + password, + set_username, + set_project, + remove_project, + add_project_role, + remove_project_role, +): """Update a user information \b USERNAME: name of the user PASSWORD: new password @@ -3619,28 +4475,28 @@ ADD_PROJECT_ROLE: adding mappings for project/role(s) REMOVE_PROJECT_ROLE: removing mappings for project/role(s) """ logger.debug("") user = {} - user['password'] = password - user['username'] = set_username - user['set-project'] = set_project - user['remove-project'] = remove_project - user['add-project-role'] = add_project_role - user['remove-project-role'] = remove_project_role - + user["password"] = password + user["username"] = set_username + user["set-project"] = set_project + user["remove-project"] = remove_project + user["add-project-role"] = add_project_role + user["remove-project-role"] = remove_project_role + # try: check_client_version(ctx.obj, ctx.command.name) ctx.obj.user.update(username, user) # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='user-delete', short_help='deletes a user') -@click.argument('name') -#@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') +@cli_osm.command(name="user-delete", short_help="deletes a user") +@click.argument("name") +# @click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') @click.pass_context def user_delete(ctx, name): """deletes a user \b @@ -3653,108 +4509,134 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='user-list', short_help='list all users') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the users matching the filter') +@cli_osm.command(name="user-list", short_help="list all users") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the users matching the filter", +) @click.pass_context def user_list(ctx, filter): """list all users""" # try: check_client_version(ctx.obj, ctx.command.name) if filter: - filter='&'.join(filter) + filter = "&".join(filter) resp = ctx.obj.user.list(filter) # except ClientException as e: # print(str(e)) # exit(1) - table = PrettyTable(['name', 'id']) + table = PrettyTable(["name", "id"]) for user in resp: - table.add_row([user['username'], user['_id']]) - table.align = 'l' + table.add_row([user["username"], user["_id"]]) + table.align = "l" print(table) -@cli_osm.command(name='user-show', short_help='shows the details of a user') -@click.argument('name') +@cli_osm.command(name="user-show", short_help="shows the details of a user") +@click.argument("name") @click.pass_context def user_show(ctx, name): """shows the details of a user NAME: name or ID of the user """ logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) resp = ctx.obj.user.get(name) - if 'password' in resp: - resp['password']='********' - # except ClientException as e: - # print(str(e)) - # exit(1) - - table = PrettyTable(['key', 'attribute']) + if "password" in resp: + resp["password"] = "********" + # except ClientException as e: + # print(str(e)) + # exit(1) + + table = PrettyTable(["key", "attribute"]) for k, v in resp.items(): table.add_row([k, json.dumps(v, indent=2)]) - table.align = 'l' + table.align = "l" print(table) #################### # Fault Management operations #################### -@cli_osm.command(name='ns-alarm-create') -@click.argument('name') -@click.option('--ns', prompt=True, help='NS instance id or name') -@click.option('--vnf', prompt=True, - help='VNF name (VNF member index as declared in the NSD)') -@click.option('--vdu', prompt=True, - help='VDU name (VDU name as declared in the VNFD)') -@click.option('--metric', prompt=True, - help='Name of the metric (e.g. cpu_utilization)') -@click.option('--severity', default='WARNING', - help='severity of the alarm (WARNING, MINOR, MAJOR, CRITICAL, INDETERMINATE)') -@click.option('--threshold_value', prompt=True, - help='threshold value that, when crossed, an alarm is triggered') -@click.option('--threshold_operator', prompt=True, - help='threshold operator describing the comparison (GE, LE, GT, LT, EQ)') -@click.option('--statistic', default='AVERAGE', - help='statistic (AVERAGE, MINIMUM, MAXIMUM, COUNT, SUM)') -@click.pass_context -def ns_alarm_create(ctx, name, ns, vnf, vdu, metric, severity, - threshold_value, threshold_operator, statistic): + +@cli_osm.command(name="ns-alarm-create") +@click.argument("name") +@click.option("--ns", prompt=True, help="NS instance id or name") +@click.option( + "--vnf", prompt=True, help="VNF name (VNF member index as declared in the NSD)" +) +@click.option("--vdu", prompt=True, help="VDU name (VDU name as declared in the VNFD)") +@click.option("--metric", prompt=True, help="Name of the metric (e.g. cpu_utilization)") +@click.option( + "--severity", + default="WARNING", + help="severity of the alarm (WARNING, MINOR, MAJOR, CRITICAL, INDETERMINATE)", +) +@click.option( + "--threshold_value", + prompt=True, + help="threshold value that, when crossed, an alarm is triggered", +) +@click.option( + "--threshold_operator", + prompt=True, + help="threshold operator describing the comparison (GE, LE, GT, LT, EQ)", +) +@click.option( + "--statistic", + default="AVERAGE", + help="statistic (AVERAGE, MINIMUM, MAXIMUM, COUNT, SUM)", +) +@click.pass_context +def ns_alarm_create( + ctx, + name, + ns, + vnf, + vdu, + metric, + severity, + threshold_value, + threshold_operator, + statistic, +): """creates a new alarm for a NS instance""" # TODO: Check how to validate threshold_value. # Should it be an integer (1-100), percentage, or decimal (0.01-1.00)? logger.debug("") # try: ns_instance = ctx.obj.ns.get(ns) alarm = {} - alarm['alarm_name'] = name - alarm['ns_id'] = ns_instance['_id'] - alarm['correlation_id'] = ns_instance['_id'] - alarm['vnf_member_index'] = vnf - alarm['vdu_name'] = vdu - alarm['metric_name'] = metric - alarm['severity'] = severity - alarm['threshold_value'] = int(threshold_value) - alarm['operation'] = threshold_operator - alarm['statistic'] = statistic + alarm["alarm_name"] = name + alarm["ns_id"] = ns_instance["_id"] + alarm["correlation_id"] = ns_instance["_id"] + alarm["vnf_member_index"] = vnf + alarm["vdu_name"] = vdu + alarm["metric_name"] = metric + alarm["severity"] = severity + alarm["threshold_value"] = int(threshold_value) + alarm["operation"] = threshold_operator + alarm["statistic"] = statistic check_client_version(ctx.obj, ctx.command.name) ctx.obj.ns.create_alarm(alarm) # except ClientException as e: # print(str(e)) # exit(1) -#@cli_osm.command(name='ns-alarm-delete') -#@click.argument('name') -#@click.pass_context -#def ns_alarm_delete(ctx, name): +# @cli_osm.command(name='ns-alarm-delete') +# @click.argument('name') +# @click.pass_context +# def ns_alarm_delete(ctx, name): # """deletes an alarm # # NAME: name of the alarm to be deleted # """ # try: @@ -3767,92 +4649,107 @@ #################### # Performance Management operations #################### -@cli_osm.command(name='ns-metric-export', short_help='exports a metric to the internal OSM bus, which can be read by other apps') -@click.option('--ns', prompt=True, help='NS instance id or name') -@click.option('--vnf', prompt=True, - help='VNF name (VNF member index as declared in the NSD)') -@click.option('--vdu', prompt=True, - help='VDU name (VDU name as declared in the VNFD)') -@click.option('--metric', prompt=True, - help='name of the metric (e.g. cpu_utilization)') -#@click.option('--period', default='1w', + +@cli_osm.command( + name="ns-metric-export", + short_help="exports a metric to the internal OSM bus, which can be read by other apps", +) +@click.option("--ns", prompt=True, help="NS instance id or name") +@click.option( + "--vnf", prompt=True, help="VNF name (VNF member index as declared in the NSD)" +) +@click.option("--vdu", prompt=True, help="VDU name (VDU name as declared in the VNFD)") +@click.option("--metric", prompt=True, help="name of the metric (e.g. cpu_utilization)") +# @click.option('--period', default='1w', # help='metric collection period (e.g. 20s, 30m, 2h, 3d, 1w)') -@click.option('--interval', help='periodic interval (seconds) to export metrics continuously') +@click.option( + "--interval", help="periodic interval (seconds) to export metrics continuously" +) @click.pass_context def ns_metric_export(ctx, ns, vnf, vdu, metric, interval): """exports a metric to the internal OSM bus, which can be read by other apps""" # TODO: Check how to validate interval. # Should it be an integer (seconds), or should a suffix (s,m,h,d,w) also be permitted? logger.debug("") # try: ns_instance = ctx.obj.ns.get(ns) metric_data = {} - metric_data['ns_id'] = ns_instance['_id'] - metric_data['correlation_id'] = ns_instance['_id'] - metric_data['vnf_member_index'] = vnf - metric_data['vdu_name'] = vdu - metric_data['metric_name'] = metric - metric_data['collection_unit'] = 'WEEK' - metric_data['collection_period'] = 1 + metric_data["ns_id"] = ns_instance["_id"] + metric_data["correlation_id"] = ns_instance["_id"] + metric_data["vnf_member_index"] = vnf + metric_data["vdu_name"] = vdu + metric_data["metric_name"] = metric + metric_data["collection_unit"] = "WEEK" + metric_data["collection_period"] = 1 check_client_version(ctx.obj, ctx.command.name) if not interval: - print('{}'.format(ctx.obj.ns.export_metric(metric_data))) + print("{}".format(ctx.obj.ns.export_metric(metric_data))) else: i = 1 while True: - print('{} {}'.format(ctx.obj.ns.export_metric(metric_data),i)) + print("{} {}".format(ctx.obj.ns.export_metric(metric_data), i)) time.sleep(int(interval)) - i+=1 + i += 1 # except ClientException as e: # print(str(e)) # exit(1) #################### # Other operations #################### -@cli_osm.command(name='version', short_help='shows client and server versions') + +@cli_osm.command(name="version", short_help="shows client and server versions") @click.pass_context def get_version(ctx): """shows client and server versions""" # try: check_client_version(ctx.obj, "version") - print ("Server version: {}".format(ctx.obj.get_version())) - print ("Client version: {}".format(pkg_resources.get_distribution("osmclient").version)) - # except ClientException as e: - # print(str(e)) - # exit(1) - -@cli_osm.command(name='upload-package', short_help='uploads a VNF package or NS package') -@click.argument('filename') -@click.option('--skip-charm-build', default=False, is_flag=True, - help='the charm will not be compiled, it is assumed to already exist') + print("Server version: {}".format(ctx.obj.get_version())) + print( + "Client version: {}".format(pkg_resources.get_distribution("osmclient").version) + ) + # except ClientException as e: + # print(str(e)) + # exit(1) + + +@cli_osm.command( + name="upload-package", short_help="uploads a VNF package or NS package" +) +@click.argument("filename") +@click.option( + "--skip-charm-build", + default=False, + is_flag=True, + help="the charm will not be compiled, it is assumed to already exist", +) @click.pass_context def upload_package(ctx, filename, skip_charm_build): """uploads a vnf package or ns package filename: vnf or ns package folder, or vnf or ns package file (tar.gz) """ logger.debug("") # try: ctx.obj.package.upload(filename, skip_charm_build=skip_charm_build) fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__ - if fullclassname != 'osmclient.sol005.client.Client': + if fullclassname != "osmclient.sol005.client.Client": ctx.obj.package.wait_for_upload(filename) # except ClientException as e: # print(str(e)) # exit(1) -#@cli_osm.command(name='ns-scaling-show') -#@click.argument('ns_name') -#@click.pass_context -#def show_ns_scaling(ctx, ns_name): +# @cli_osm.command(name='ns-scaling-show') +# @click.argument('ns_name') +# @click.pass_context +# def show_ns_scaling(ctx, ns_name): # """shows the status of a NS scaling operation # # NS_NAME: name of the NS instance being scaled # """ # try: @@ -3887,22 +4784,22 @@ # inst['vnfrs']]) # table.align = 'l' # print(table) -#@cli_osm.command(name='ns-scale') -#@click.argument('ns_name') -#@click.option('--ns_scale_group', prompt=True) -#@click.option('--index', prompt=True) -#@click.option('--wait', +# @cli_osm.command(name='ns-scale') +# @click.argument('ns_name') +# @click.option('--ns_scale_group', prompt=True) +# @click.option('--index', prompt=True) +# @click.option('--wait', # required=False, # default=False, # is_flag=True, # help='do not return the control immediately, but keep it \ # until the operation is completed, or timeout') -#@click.pass_context -#def ns_scale(ctx, ns_name, ns_scale_group, index, wait): +# @click.pass_context +# def ns_scale(ctx, ns_name, ns_scale_group, index, wait): # """scales NS # # NS_NAME: name of the NS instance to be scaled # """ # try: @@ -3911,13 +4808,13 @@ # except ClientException as e: # print(str(e)) # exit(1) -#@cli_osm.command(name='config-agent-list') -#@click.pass_context -#def config_agent_list(ctx): +# @cli_osm.command(name='config-agent-list') +# @click.pass_context +# def config_agent_list(ctx): # """list config agents""" # try: # check_client_version(ctx.obj, ctx.command.name, 'v1') # except ClientException as e: # print(str(e)) @@ -3930,14 +4827,14 @@ # account['juju']]) # table.align = 'l' # print(table) -#@cli_osm.command(name='config-agent-delete') -#@click.argument('name') -#@click.pass_context -#def config_agent_delete(ctx, name): +# @cli_osm.command(name='config-agent-delete') +# @click.argument('name') +# @click.pass_context +# def config_agent_delete(ctx, name): # """deletes a config agent # # NAME: name of the config agent to be deleted # """ # try: @@ -3946,137 +4843,164 @@ # except ClientException as e: # print(str(e)) # exit(1) -#@cli_osm.command(name='config-agent-add') -#@click.option('--name', +# @cli_osm.command(name='config-agent-add') +# @click.option('--name', # prompt=True) -#@click.option('--account_type', +# @click.option('--account_type', # prompt=True) -#@click.option('--server', +# @click.option('--server', # prompt=True) -#@click.option('--user', +# @click.option('--user', # prompt=True) -#@click.option('--secret', +# @click.option('--secret', # prompt=True, # hide_input=True, # confirmation_prompt=True) -#@click.pass_context -#def config_agent_add(ctx, name, account_type, server, user, secret): +# @click.pass_context +# def config_agent_add(ctx, name, account_type, server, user, secret): # """adds a config agent""" # try: # check_client_version(ctx.obj, ctx.command.name, 'v1') # ctx.obj.vca.create(name, account_type, server, user, secret) # except ClientException as e: # print(str(e)) # exit(1) -#@cli_osm.command(name='ro-dump') -#@click.pass_context -#def ro_dump(ctx): +# @cli_osm.command(name='ro-dump') +# @click.pass_context +# def ro_dump(ctx): # """shows RO agent information""" # check_client_version(ctx.obj, ctx.command.name, 'v1') # resp = ctx.obj.vim.get_resource_orchestrator() # table = PrettyTable(['key', 'attribute']) # for k, v in list(resp.items()): # table.add_row([k, json.dumps(v, indent=2)]) # table.align = 'l' # print(table) -#@cli_osm.command(name='vcs-list') -#@click.pass_context -#def vcs_list(ctx): +# @cli_osm.command(name='vcs-list') +# @click.pass_context +# def vcs_list(ctx): # check_client_version(ctx.obj, ctx.command.name, 'v1') # resp = ctx.obj.utils.get_vcs_info() # table = PrettyTable(['component name', 'state']) # for component in resp: # table.add_row([component['component_name'], component['state']]) # table.align = 'l' # print(table) -@cli_osm.command(name='ns-action', short_help='executes an action/primitive over a NS instance') -@click.argument('ns_name') -@click.option('--vnf_name', default=None, help='member-vnf-index if the target is a vnf instead of a ns)') -@click.option('--kdu_name', default=None, help='kdu-name if the target is a kdu)') -@click.option('--vdu_id', default=None, help='vdu-id if the target is a vdu') -@click.option('--vdu_count', default=None, type=int, help='number of vdu instance of this vdu_id') -@click.option('--action_name', prompt=True, help='action name') -@click.option('--params', default=None, help='action params in YAML/JSON inline string') -@click.option('--params_file', default=None, help='YAML/JSON file with action params') -@click.option('--timeout', required=False, default=None, type=int, help='timeout in seconds') -@click.option('--wait', - required=False, - default=False, - is_flag=True, - help='do not return the control immediately, but keep it until the operation is completed, or timeout') -@click.pass_context -def ns_action(ctx, - ns_name, - vnf_name, - kdu_name, - vdu_id, - vdu_count, - action_name, - params, - params_file, - timeout, - wait): +@cli_osm.command( + name="ns-action", short_help="executes an action/primitive over a NS instance" +) +@click.argument("ns_name") +@click.option( + "--vnf_name", + default=None, + help="member-vnf-index if the target is a vnf instead of a ns)", +) +@click.option("--kdu_name", default=None, help="kdu-name if the target is a kdu)") +@click.option("--vdu_id", default=None, help="vdu-id if the target is a vdu") +@click.option( + "--vdu_count", default=None, type=int, help="number of vdu instance of this vdu_id" +) +@click.option("--action_name", prompt=True, help="action name") +@click.option("--params", default=None, help="action params in YAML/JSON inline string") +@click.option("--params_file", default=None, help="YAML/JSON file with action params") +@click.option( + "--timeout", required=False, default=None, type=int, help="timeout in seconds" +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it until the operation is completed, or timeout", +) +@click.pass_context +def ns_action( + ctx, + ns_name, + vnf_name, + kdu_name, + vdu_id, + vdu_count, + action_name, + params, + params_file, + timeout, + wait, +): """executes an action/primitive over a NS instance NS_NAME: name or ID of the NS instance """ logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) op_data = {} if vnf_name: - op_data['member_vnf_index'] = vnf_name + op_data["member_vnf_index"] = vnf_name if kdu_name: - op_data['kdu_name'] = kdu_name + op_data["kdu_name"] = kdu_name if vdu_id: - op_data['vdu_id'] = vdu_id + op_data["vdu_id"] = vdu_id if vdu_count is not None: - op_data['vdu_count_index'] = vdu_count + op_data["vdu_count_index"] = vdu_count if timeout: - op_data['timeout_ns_action'] = timeout - op_data['primitive'] = action_name + op_data["timeout_ns_action"] = timeout + op_data["primitive"] = action_name if params_file: - with open(params_file, 'r') as pf: + with open(params_file, "r") as pf: params = pf.read() if params: - op_data['primitive_params'] = yaml.safe_load(params) + op_data["primitive_params"] = yaml.safe_load(params) else: - op_data['primitive_params'] = {} - print(ctx.obj.ns.exec_op(ns_name, op_name='action', op_data=op_data, wait=wait)) - - # except ClientException as e: - # print(str(e)) - # exit(1) - - -@cli_osm.command(name='vnf-scale', short_help='executes a VNF scale (adding/removing VDUs)') -@click.argument('ns_name') -@click.argument('vnf_name') -@click.option('--scaling-group', prompt=True, help="scaling-group-descriptor name to use") -@click.option('--scale-in', default=False, is_flag=True, help="performs a scale in operation") -@click.option('--scale-out', default=False, is_flag=True, help="performs a scale out operation (by default)") -@click.option('--timeout', required=False, default=None, type=int, help='timeout in seconds') -@click.option('--wait', required=False, default=False, is_flag=True, - help='do not return the control immediately, but keep it until the operation is completed, or timeout') -@click.pass_context -def vnf_scale(ctx, - ns_name, - vnf_name, - scaling_group, - scale_in, - scale_out, - timeout, - wait): + op_data["primitive_params"] = {} + print(ctx.obj.ns.exec_op(ns_name, op_name="action", op_data=op_data, wait=wait)) + + # except ClientException as e: + # print(str(e)) + # exit(1) + + +@cli_osm.command( + name="vnf-scale", short_help="executes a VNF scale (adding/removing VDUs)" +) +@click.argument("ns_name") +@click.argument("vnf_name") +@click.option( + "--scaling-group", prompt=True, help="scaling-group-descriptor name to use" +) +@click.option( + "--scale-in", default=False, is_flag=True, help="performs a scale in operation" +) +@click.option( + "--scale-out", + default=False, + is_flag=True, + help="performs a scale out operation (by default)", +) +@click.option( + "--timeout", required=False, default=None, type=int, help="timeout in seconds" +) +@click.option( + "--wait", + required=False, + default=False, + is_flag=True, + help="do not return the control immediately, but keep it until the operation is completed, or timeout", +) +@click.pass_context +def vnf_scale( + ctx, ns_name, vnf_name, scaling_group, scale_in, scale_out, timeout, wait +): """ Executes a VNF scale (adding/removing VDUs) \b NS_NAME: name or ID of the NS instance. @@ -4085,25 +5009,26 @@ logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) if not scale_in and not scale_out: scale_out = True - ctx.obj.ns.scale_vnf(ns_name, vnf_name, scaling_group, scale_in, scale_out, wait, timeout) + ctx.obj.ns.scale_vnf( + ns_name, vnf_name, scaling_group, scale_in, scale_out, wait, timeout + ) # except ClientException as e: # print(str(e)) # exit(1) ############################## # Role Management Operations # ############################## -@cli_osm.command(name='role-create', short_help='creates a new role') -@click.argument('name') -@click.option('--permissions', - default=None, - help='role permissions using a dictionary') + +@cli_osm.command(name="role-create", short_help="creates a new role") +@click.argument("name") +@click.option("--permissions", default=None, help="role permissions using a dictionary") @click.pass_context def role_create(ctx, name, permissions): """ Creates a new role. @@ -4118,24 +5043,22 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='role-update', short_help='updates a role') -@click.argument('name') -@click.option('--set-name', - default=None, - help='change name of rle') +@cli_osm.command(name="role-update", short_help="updates a role") +@click.argument("name") +@click.option("--set-name", default=None, help="change name of rle") # @click.option('--permissions', # default=None, # help='provide a yaml format dictionary with incremental changes. Values can be bool or None to delete') -@click.option('--add', - default=None, - help='yaml format dictionary with permission: True/False to access grant/denial') -@click.option('--remove', - default=None, - help='yaml format list to remove a permission') +@click.option( + "--add", + default=None, + help="yaml format dictionary with permission: True/False to access grant/denial", +) +@click.option("--remove", default=None, help="yaml format list to remove a permission") @click.pass_context def role_update(ctx, name, set_name, add, remove): """ Updates a role. @@ -4152,12 +5075,12 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='role-delete', short_help='deletes a role') -@click.argument('name') +@cli_osm.command(name="role-delete", short_help="deletes a role") +@click.argument("name") # @click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') @click.pass_context def role_delete(ctx, name): """ Deletes a role. @@ -4172,36 +5095,40 @@ # except ClientException as e: # print(str(e)) # exit(1) -@cli_osm.command(name='role-list', short_help='list all roles') -@click.option('--filter', default=None, multiple=True, - help='restricts the list to the projects matching the filter') +@cli_osm.command(name="role-list", short_help="list all roles") +@click.option( + "--filter", + default=None, + multiple=True, + help="restricts the list to the projects matching the filter", +) @click.pass_context def role_list(ctx, filter): """ List all roles. """ logger.debug("") # try: check_client_version(ctx.obj, ctx.command.name) if filter: - filter='&'.join(filter) + filter = "&".join(filter) resp = ctx.obj.role.list(filter) # except ClientException as e: # print(str(e)) # exit(1) - table = PrettyTable(['name', 'id']) + table = PrettyTable(["name", "id"]) for role in resp: - table.add_row([role['name'], role['_id']]) - table.align = 'l' + table.add_row([role["name"], role["_id"]]) + table.align = "l" print(table) -@cli_osm.command(name='role-show', short_help='show specific role') -@click.argument('name') +@cli_osm.command(name="role-show", short_help="show specific role") +@click.argument("name") @click.pass_context def role_show(ctx, name): """ Shows the details of a role. @@ -4214,79 +5141,95 @@ resp = ctx.obj.role.get(name) # except ClientException as e: # print(str(e)) # exit(1) - table = PrettyTable(['key', 'attribute']) + table = PrettyTable(["key", "attribute"]) for k, v in resp.items(): table.add_row([k, json.dumps(v, indent=2)]) - table.align = 'l' + table.align = "l" print(table) -@cli_osm.command(name='package-create', - short_help='Create empty NS package structure') -@click.argument('package-type') -@click.argument('package-name') -@click.option('--base-directory', - default='.', - help=('(NS/VNF/NST) Set the location for package creation. Default: "."')) -@click.option('--image', - default="image-name", - help='(VNF) Set the name of the vdu image. Default "image-name"') -@click.option('--vdus', - default=1, - help='(VNF) Set the number of vdus in a VNF. Default 1') -@click.option('--vcpu', - default=1, - help='(VNF) Set the number of virtual CPUs in a vdu. Default 1') -@click.option('--memory', - default=1024, - help='(VNF) Set the memory size (MB) of the vdu. Default 1024') -@click.option('--storage', - default=10, - help='(VNF) Set the disk size (GB) of the vdu. Default 10') -@click.option('--interfaces', - default=0, - help='(VNF) Set the number of additional interfaces apart from the management interface. Default 0') -@click.option('--vendor', - default="OSM", - help='(NS/VNF) Set the descriptor vendor. Default "OSM"') -@click.option('--override', - default=False, - is_flag=True, - help='(NS/VNF/NST) Flag for overriding the package if exists.') -@click.option('--detailed', - is_flag=True, - default=False, - help='(NS/VNF/NST) Flag for generating descriptor .yaml with all possible commented options') -@click.option('--netslice-subnets', - default=1, - help='(NST) Number of netslice subnets. Default 1') -@click.option('--netslice-vlds', - default=1, - help='(NST) Number of netslice vlds. Default 1') -@click.option( - "--old", default=False, is_flag=True, help="Support flag for old versions of the OSM IM (OSM<9)" -) -@click.pass_context -def package_create(ctx, - package_type, - base_directory, - package_name, - override, - image, - vdus, - vcpu, - memory, - storage, - interfaces, - vendor, - detailed, - netslice_subnets, - netslice_vlds, - old,): +@cli_osm.command(name="package-create", short_help="Create empty NS package structure") +@click.argument("package-type") +@click.argument("package-name") +@click.option( + "--base-directory", + default=".", + help=('(NS/VNF/NST) Set the location for package creation. Default: "."'), +) +@click.option( + "--image", + default="image-name", + help='(VNF) Set the name of the vdu image. Default "image-name"', +) +@click.option( + "--vdus", default=1, help="(VNF) Set the number of vdus in a VNF. Default 1" +) +@click.option( + "--vcpu", default=1, help="(VNF) Set the number of virtual CPUs in a vdu. Default 1" +) +@click.option( + "--memory", + default=1024, + help="(VNF) Set the memory size (MB) of the vdu. Default 1024", +) +@click.option( + "--storage", default=10, help="(VNF) Set the disk size (GB) of the vdu. Default 10" +) +@click.option( + "--interfaces", + default=0, + help="(VNF) Set the number of additional interfaces apart from the management interface. Default 0", +) +@click.option( + "--vendor", default="OSM", help='(NS/VNF) Set the descriptor vendor. Default "OSM"' +) +@click.option( + "--override", + default=False, + is_flag=True, + help="(NS/VNF/NST) Flag for overriding the package if exists.", +) +@click.option( + "--detailed", + is_flag=True, + default=False, + help="(NS/VNF/NST) Flag for generating descriptor .yaml with all possible commented options", +) +@click.option( + "--netslice-subnets", default=1, help="(NST) Number of netslice subnets. Default 1" +) +@click.option( + "--netslice-vlds", default=1, help="(NST) Number of netslice vlds. Default 1" +) +@click.option( + "--old", + default=False, + is_flag=True, + help="Support flag for old versions of the OSM IM (OSM<9)", +) +@click.pass_context +def package_create( + ctx, + package_type, + base_directory, + package_name, + override, + image, + vdus, + vcpu, + memory, + storage, + interfaces, + vendor, + detailed, + netslice_subnets, + netslice_vlds, + old, +): """ Creates an OSM NS, VNF, NST package \b PACKAGE_TYPE: Package to be created: NS, VNF or NST. @@ -4294,49 +5237,56 @@ """ # try: logger.debug("") check_client_version(ctx.obj, ctx.command.name) - print("Creating the {} structure: {}/{}".format(package_type.upper(), base_directory, package_name)) - resp = ctx.obj.package_tool.create(package_type, - base_directory, - package_name, - override=override, - image=image, - vdus=vdus, - vcpu=vcpu, - memory=memory, - storage=storage, - interfaces=interfaces, - vendor=vendor, - detailed=detailed, - netslice_subnets=netslice_subnets, - netslice_vlds=netslice_vlds, - old=old,) + print( + "Creating the {} structure: {}/{}".format( + package_type.upper(), base_directory, package_name + ) + ) + resp = ctx.obj.package_tool.create( + package_type, + base_directory, + package_name, + override=override, + image=image, + vdus=vdus, + vcpu=vcpu, + memory=memory, + storage=storage, + interfaces=interfaces, + vendor=vendor, + detailed=detailed, + netslice_subnets=netslice_subnets, + netslice_vlds=netslice_vlds, + old=old, + ) print(resp) # except ClientException as inst: # print("ERROR: {}".format(inst)) # exit(1) -@cli_osm.command(name='package-validate', - short_help='Validate descriptors given a base directory') -@click.argument('base-directory', - default=".", - required=False) -@click.option('--recursive/--no-recursive', - default=True, - help='The activated recursive option will validate the yaml files' - ' within the indicated directory and in its subdirectories') -@click.option('--old', - is_flag=True, - default=False, - help='Validates also the descriptors using the previous OSM format (pre SOL006)') -@click.pass_context -def package_validate(ctx, - base_directory, - recursive, - old): + +@cli_osm.command( + name="package-validate", short_help="Validate descriptors given a base directory" +) +@click.argument("base-directory", default=".", required=False) +@click.option( + "--recursive/--no-recursive", + default=True, + help="The activated recursive option will validate the yaml files" + " within the indicated directory and in its subdirectories", +) +@click.option( + "--old", + is_flag=True, + default=False, + help="Validates also the descriptors using the previous OSM format (pre SOL006)", +) +@click.pass_context +def package_validate(ctx, base_directory, recursive, old): """ Validate descriptors given a base directory. \b BASE_DIRECTORY: Base folder for NS, VNF or NST package. @@ -4347,99 +5297,121 @@ results = ctx.obj.package_tool.validate(base_directory, recursive, old) table = PrettyTable() table.field_names = ["TYPE", "PATH", "VALID", "ERROR"] # Print the dictionary generated by the validation function for result in results: - table.add_row([result["type"], result["path"], result["valid"], result["error"]]) + table.add_row( + [result["type"], result["path"], result["valid"], result["error"]] + ) table.sortby = "VALID" table.align["PATH"] = "l" table.align["TYPE"] = "l" table.align["ERROR"] = "l" print(table) # except ClientException as inst: # print("ERROR: {}".format(inst)) # exit(1) -@cli_osm.command(name='package-translate', - short_help='Translate descriptors given a base directory') -@click.argument('base-directory', - default=".", - required=False) -@click.option('--recursive/--no-recursive', - default=True, - help='The activated recursive option will translate the yaml files' - ' within the indicated directory and in its subdirectories') -@click.option('--dryrun', - is_flag=True, - default=False, - help='Do not translate yet, only make a dry-run to test translation') -@click.pass_context -def package_translate(ctx, - base_directory, - recursive, - dryrun): + +@cli_osm.command( + name="package-translate", short_help="Translate descriptors given a base directory" +) +@click.argument("base-directory", default=".", required=False) +@click.option( + "--recursive/--no-recursive", + default=True, + help="The activated recursive option will translate the yaml files" + " within the indicated directory and in its subdirectories", +) +@click.option( + "--dryrun", + is_flag=True, + default=False, + help="Do not translate yet, only make a dry-run to test translation", +) +@click.pass_context +def package_translate(ctx, base_directory, recursive, dryrun): """ Translate descriptors given a base directory. \b BASE_DIRECTORY: Stub folder for NS, VNF or NST package. """ logger.debug("") check_client_version(ctx.obj, ctx.command.name) results = ctx.obj.package_tool.translate(base_directory, recursive, dryrun) table = PrettyTable() - table.field_names = ["CURRENT TYPE", "NEW TYPE", "PATH", "VALID", "TRANSLATED", "ERROR"] + table.field_names = [ + "CURRENT TYPE", + "NEW TYPE", + "PATH", + "VALID", + "TRANSLATED", + "ERROR", + ] # Print the dictionary generated by the validation function for result in results: - table.add_row([result["current type"], result["new type"], result["path"], result["valid"], result["translated"], result["error"]]) + table.add_row( + [ + result["current type"], + result["new type"], + result["path"], + result["valid"], + result["translated"], + result["error"], + ] + ) table.sortby = "TRANSLATED" table.align["PATH"] = "l" table.align["TYPE"] = "l" table.align["ERROR"] = "l" print(table) # except ClientException as inst: # print("ERROR: {}".format(inst)) # exit(1) -@cli_osm.command(name='package-build', - short_help='Build the tar.gz of the package') -@click.argument('package-folder') -@click.option('--skip-validation', - default=False, - is_flag=True, - help='skip package validation') -@click.option('--skip-charm-build', default=False, is_flag=True, - help='the charm will not be compiled, it is assumed to already exist') -@click.pass_context -def package_build(ctx, - package_folder, - skip_validation, - skip_charm_build): + +@cli_osm.command(name="package-build", short_help="Build the tar.gz of the package") +@click.argument("package-folder") +@click.option( + "--skip-validation", default=False, is_flag=True, help="skip package validation" +) +@click.option( + "--skip-charm-build", + default=False, + is_flag=True, + help="the charm will not be compiled, it is assumed to already exist", +) +@click.pass_context +def package_build(ctx, package_folder, skip_validation, skip_charm_build): """ Build the package NS, VNF given the package_folder. \b PACKAGE_FOLDER: Folder of the NS, VNF or NST to be packaged """ # try: logger.debug("") check_client_version(ctx.obj, ctx.command.name) - results = ctx.obj.package_tool.build(package_folder, - skip_validation=skip_validation, - skip_charm_build=skip_charm_build) + results = ctx.obj.package_tool.build( + package_folder, + skip_validation=skip_validation, + skip_charm_build=skip_charm_build, + ) print(results) # except ClientException as inst: # print("ERROR: {}".format(inst)) # exit(1) -@cli_osm.command(name='descriptor-translate', - short_help='Translate input descriptor file from Rel EIGHT OSM descriptors to SOL006 and prints in standard output') -@click.argument('descriptor-file', - required=True) -@click.pass_context -def descriptor_translate(ctx, - descriptor_file): + +@cli_osm.command( + name="descriptor-translate", + short_help="Translate input descriptor file from Rel EIGHT OSM descriptors to SOL006 and prints in standard output", +) +@click.argument("descriptor-file", required=True) +@click.pass_context +def descriptor_translate(ctx, descriptor_file): """ Translate input descriptor. \b DESCRIPTOR_FILE: Descriptor file for NS, VNF or Network Slice. @@ -4454,11 +5426,13 @@ try: cli_osm() exit(0) except pycurl.error as exc: print(exc) - print('Maybe "--hostname" option or OSM_HOSTNAME environment variable needs to be specified') + print( + 'Maybe "--hostname" option or OSM_HOSTNAME environment variable needs to be specified' + ) except ClientException as exc: print("ERROR: {}".format(exc)) except (FileNotFoundError, PermissionError) as exc: print("Cannot open file: {}".format(exc)) except yaml.YAMLError as exc: @@ -4466,8 +5440,7 @@ exit(1) # TODO capture other controlled exceptions here # TODO remove the ClientException captures from all places, unless they do something different -if __name__ == '__main__': +if __name__ == "__main__": cli() - would reformat osmclient/scripts/osm.py Oh no! 💥 💔 💥 41 files would be reformatted, 7 files would be left unchanged. cover create: /tmp/.tox/cover cover installdeps: -r/opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/requirements.txt, -r/opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/requirements-dev.txt, -r/opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/requirements-test.txt cover develop-inst: /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0 cover installed: bitarray==2.3.4,certifi==2020.12.5,chardet==4.0.0,click==7.1.2,coverage==5.5,enum34==1.1.10,idna==2.10,importlib-metadata==4.8.2,Jinja2==2.11.3,lxml==4.7.1,MarkupSafe==1.1.1,mock==4.0.3,nose2==0.10.0,osm-im @ git+https://osm.etsi.org/gerrit/osm/IM.git@35517bbfdb9b9e5e26ca1909d9ecf6398a8bb062,-e git+https://osm.etsi.org/gerrit/osm/osmclient.git@1cbff09ebd242dcba9e0011c083e13e5623f1f5d#egg=osmclient,packaging==20.9,prettytable==2.1.0,pyang==2.5.2,pyangbind==0.8.1,pycurl==7.43.0.6,pyparsing==2.4.7,python-magic==0.4.22,PyYAML==5.4.1,regex==2021.11.10,requests==2.25.1,six==1.16.0,typing_extensions==4.0.1,urllib3==1.26.4,verboselogs==1.7,wcwidth==0.2.5,zipp==3.6.0 cover run-test-pre: PYTHONHASHSEED='1630188128' cover run-test: commands[0] | sh -c 'rm -f nosetests.xml' cover run-test: commands[1] | coverage erase cover run-test: commands[2] | nose2 -C --coverage osmclient ........................ ---------------------------------------------------------------------- Ran 24 tests in 10.068s OK Name Stmts Miss Cover ------------------------------------------------------------ osmclient/__init__.py 0 0 100% osmclient/client.py 32 32 0% osmclient/common/__init__.py 0 0 100% osmclient/common/exceptions.py 6 0 100% osmclient/common/http.py 67 39 42% osmclient/common/package_tool.py 344 304 12% osmclient/common/test/test_utils.py 36 0 100% osmclient/common/utils.py 62 39 37% osmclient/common/wait.py 84 84 0% osmclient/scripts/__init__.py 0 0 100% osmclient/scripts/osm.py 2002 2002 0% osmclient/sol005/__init__.py 0 0 100% osmclient/sol005/client.py 95 95 0% osmclient/sol005/http.py 151 151 0% osmclient/sol005/k8scluster.py 74 74 0% osmclient/sol005/ns.py 296 296 0% osmclient/sol005/nsd.py 123 123 0% osmclient/sol005/nsi.py 209 209 0% osmclient/sol005/nst.py 128 128 0% osmclient/sol005/osmrepo.py 309 259 16% osmclient/sol005/package.py 62 62 0% osmclient/sol005/pdud.py 80 80 0% osmclient/sol005/project.py 74 74 0% osmclient/sol005/repo.py 69 56 19% osmclient/sol005/role.py 117 117 0% osmclient/sol005/sdncontroller.py 97 97 0% osmclient/sol005/tests/test_osmrepo.py 13 0 100% osmclient/sol005/user.py 124 124 0% osmclient/sol005/vim.py 152 152 0% osmclient/sol005/vnf.py 56 56 0% osmclient/sol005/vnfd.py 194 194 0% osmclient/sol005/wim.py 142 142 0% osmclient/v1/__init__.py 0 0 100% osmclient/v1/client.py 55 9 84% osmclient/v1/key.py 18 18 0% osmclient/v1/ns.py 118 89 25% osmclient/v1/nsd.py 27 8 70% osmclient/v1/package.py 34 17 50% osmclient/v1/tests/test_ns.py 22 0 100% osmclient/v1/tests/test_nsd.py 20 1 95% osmclient/v1/tests/test_package.py 15 0 100% osmclient/v1/tests/test_vnf.py 26 0 100% osmclient/v1/tests/test_vnfd.py 20 1 95% osmclient/v1/utils.py 9 4 56% osmclient/v1/vca.py 27 18 33% osmclient/v1/vim.py 184 162 12% osmclient/v1/vnf.py 24 3 88% osmclient/v1/vnfd.py 25 6 76% ------------------------------------------------------------ TOTAL 5822 5325 9% cover run-test: commands[3] | coverage report '--omit=*tests*' Name Stmts Miss Cover --------------------------------------------------------- osmclient/__init__.py 0 0 100% osmclient/client.py 32 32 0% osmclient/common/__init__.py 0 0 100% osmclient/common/exceptions.py 6 0 100% osmclient/common/http.py 67 39 42% osmclient/common/package_tool.py 344 304 12% osmclient/common/test/test_utils.py 36 0 100% osmclient/common/utils.py 62 39 37% osmclient/common/wait.py 84 84 0% osmclient/scripts/__init__.py 0 0 100% osmclient/scripts/osm.py 2002 2002 0% osmclient/sol005/__init__.py 0 0 100% osmclient/sol005/client.py 95 95 0% osmclient/sol005/http.py 151 151 0% osmclient/sol005/k8scluster.py 74 74 0% osmclient/sol005/ns.py 296 296 0% osmclient/sol005/nsd.py 123 123 0% osmclient/sol005/nsi.py 209 209 0% osmclient/sol005/nst.py 128 128 0% osmclient/sol005/osmrepo.py 309 259 16% osmclient/sol005/package.py 62 62 0% osmclient/sol005/pdud.py 80 80 0% osmclient/sol005/project.py 74 74 0% osmclient/sol005/repo.py 69 56 19% osmclient/sol005/role.py 117 117 0% osmclient/sol005/sdncontroller.py 97 97 0% osmclient/sol005/user.py 124 124 0% osmclient/sol005/vim.py 152 152 0% osmclient/sol005/vnf.py 56 56 0% osmclient/sol005/vnfd.py 194 194 0% osmclient/sol005/wim.py 142 142 0% osmclient/v1/__init__.py 0 0 100% osmclient/v1/client.py 55 9 84% osmclient/v1/key.py 18 18 0% osmclient/v1/ns.py 118 89 25% osmclient/v1/nsd.py 27 8 70% osmclient/v1/package.py 34 17 50% osmclient/v1/utils.py 9 4 56% osmclient/v1/vca.py 27 18 33% osmclient/v1/vim.py 184 162 12% osmclient/v1/vnf.py 24 3 88% osmclient/v1/vnfd.py 25 6 76% --------------------------------------------------------- TOTAL 5706 5323 7% cover run-test: commands[4] | coverage html -d ./cover '--omit=*tests*' cover run-test: commands[5] | coverage xml -o coverage.xml '--omit=*tests*' flake8 create: /tmp/.tox/flake8 flake8 installdeps: flake8 flake8 develop-inst: /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0 flake8 installed: flake8==4.0.1,importlib-metadata==4.2.0,mccabe==0.6.1,-e git+https://osm.etsi.org/gerrit/osm/osmclient.git@1cbff09ebd242dcba9e0011c083e13e5623f1f5d#egg=osmclient,pycodestyle==2.8.0,pyflakes==2.4.0,typing_extensions==4.0.1,zipp==3.6.0 flake8 run-test-pre: PYTHONHASHSEED='1630188128' flake8 run-test: commands[0] | - flake8 osmclient/ setup.py osmclient/client.py:38:35: E231 missing whitespace after ',' verbose = kwargs.get('verbose',0) ^ osmclient/client.py:39:15: E225 missing whitespace around operator if verbose>0: ^ osmclient/client.py:41:9: E265 block comment should start with '# ' #handler = logging.StreamHandler() ^ osmclient/client.py:43:9: E265 block comment should start with '# ' #logger.addHandler(handler) ^ osmclient/client.py:44:19: E225 missing whitespace around operator if verbose==1: ^ osmclient/client.py:46:21: E225 missing whitespace around operator elif verbose==2: ^ osmclient/client.py:48:21: E225 missing whitespace around operator elif verbose>2: ^ osmclient/scripts/osm.py:40:1: E302 expected 2 blank lines, found 1 def wrap_text(text, width): ^ osmclient/scripts/osm.py:47:4: E111 indentation is not a multiple of 4 if len(text) > length: ^ osmclient/scripts/osm.py:48:8: E111 indentation is not a multiple of 4 return text[:(length - 3)] + '...' ^ osmclient/scripts/osm.py:49:4: E111 indentation is not a multiple of 4 else: ^ osmclient/scripts/osm.py:50:8: E111 indentation is not a multiple of 4 return text ^ osmclient/scripts/osm.py:100:44: W504 line break after binary operator help='hostname of server. ' + ^ osmclient/scripts/osm.py:102:1: E265 block comment should start with '# ' #@click.option('--sol005/--no-sol005', ^ osmclient/scripts/osm.py:110:49: W504 line break after binary operator help='user (defaults to admin). ' + ^ osmclient/scripts/osm.py:115:53: W504 line break after binary operator help='password (defaults to admin). ' + ^ osmclient/scripts/osm.py:120:52: W504 line break after binary operator help='project (defaults to admin). ' + ^ osmclient/scripts/osm.py:133:90: W504 line break after binary operator help='project domain name for keystone authentication (default to None). ' + ^ osmclient/scripts/osm.py:138:87: W504 line break after binary operator help='user domain name for keystone authentication (default to None). ' + ^ osmclient/scripts/osm.py:140:1: E265 block comment should start with '# ' #@click.option('--so-port', ^ osmclient/scripts/osm.py:145:1: E265 block comment should start with '# ' #@click.option('--so-project', ^ osmclient/scripts/osm.py:150:1: E265 block comment should start with '# ' #@click.option('--ro-hostname', ^ osmclient/scripts/osm.py:155:1: E265 block comment should start with '# ' #@click.option('--ro-port', ^ osmclient/scripts/osm.py:166:55: W504 line break after binary operator "either hostname option or OSM_HOSTNAME " + ^ osmclient/scripts/osm.py:253:9: E265 block comment should start with '# ' #Nets ^ osmclient/scripts/osm.py:259:42: E231 missing whitespace after ',' net_list = status_dict.get('nets',[]) ^ osmclient/scripts/osm.py:265:46: E225 missing whitespace around operator status_nets[net['status']] +=1 ^ osmclient/scripts/osm.py:267:14: E231 missing whitespace after ',' for k,v in status_nets.items(): ^ osmclient/scripts/osm.py:268:41: E231 missing whitespace after ',' message += "{}:{},".format(k,v) ^ osmclient/scripts/osm.py:271:9: E265 block comment should start with '# ' #VMs and VNFs ^ osmclient/scripts/osm.py:285:48: E225 missing whitespace around operator status_vms[vm['status']] +=1 ^ osmclient/scripts/osm.py:291:14: E231 missing whitespace after ',' for k,v in status_vms.items(): ^ osmclient/scripts/osm.py:292:41: E231 missing whitespace after ',' message += "{}:{},".format(k,v) ^ osmclient/scripts/osm.py:296:14: E231 missing whitespace after ',' for k,v in status_vnfs.items(): ^ osmclient/scripts/osm.py:299:19: E231 missing whitespace after ',' for k2,v2 in v.items(): ^ osmclient/scripts/osm.py:300:46: E231 missing whitespace after ',' message += "{}:{},".format(k2,v2) ^ osmclient/scripts/osm.py:326:22: E231 missing whitespace after ',' for k,v in status_ee[elementType].items(): ^ osmclient/scripts/osm.py:327:49: E231 missing whitespace after ',' message += "{}:{},".format(k,v) ^ osmclient/scripts/osm.py:337:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:343:9: E122 continuation line missing indentation or outdented ['ns instance name', ^ osmclient/scripts/osm.py:356:9: E722 do not use bare 'except' except: ^ osmclient/scripts/osm.py:360:9: E122 continuation line missing indentation or outdented ['ns instance name', ^ osmclient/scripts/osm.py:379:17: E265 block comment should start with '# ' #project = '{} ({})'.format(project_name, project_id) ^ osmclient/scripts/osm.py:384:17: E265 block comment should start with '# ' #vim = '{} ({})'.format(vim_name, vim_id) ^ osmclient/scripts/osm.py:387:77: E231 missing whitespace after ',' current_operation = "{} ({})".format(nsr['currentOperation'],nsr['currentOperationID']) ^ osmclient/scripts/osm.py:389:91: E231 missing whitespace after ',' current_operation = "{} ({})".format(nsr['_admin'].get('current-operation','-'), nsr['_admin']['nslcmop']) ^ osmclient/scripts/osm.py:411:18: E126 continuation line over-indented for hanging indent [nsr_name, ^ osmclient/scripts/osm.py:412:18: E128 continuation line under-indented for visual indent nsr_id, ^ osmclient/scripts/osm.py:413:18: E128 continuation line under-indented for visual indent date, ^ osmclient/scripts/osm.py:414:18: E128 continuation line under-indented for visual indent ns_state, ^ osmclient/scripts/osm.py:415:18: E128 continuation line under-indented for visual indent current_operation, ^ osmclient/scripts/osm.py:416:18: E128 continuation line under-indented for visual indent wrap_text(text=error_details,width=40), ^ osmclient/scripts/osm.py:416:46: E231 missing whitespace after ',' wrap_text(text=error_details,width=40), ^ osmclient/scripts/osm.py:417:18: E128 continuation line under-indented for visual indent project, ^ osmclient/scripts/osm.py:418:18: E128 continuation line under-indented for visual indent vim, ^ osmclient/scripts/osm.py:419:18: E128 continuation line under-indented for visual indent deployment_status, ^ osmclient/scripts/osm.py:420:18: E128 continuation line under-indented for visual indent config_status]) ^ osmclient/scripts/osm.py:423:18: E126 continuation line over-indented for hanging indent [nsr_name, ^ osmclient/scripts/osm.py:424:18: E128 continuation line under-indented for visual indent nsr_id, ^ osmclient/scripts/osm.py:425:18: E128 continuation line under-indented for visual indent date, ^ osmclient/scripts/osm.py:426:18: E128 continuation line under-indented for visual indent ns_state, ^ osmclient/scripts/osm.py:427:18: E128 continuation line under-indented for visual indent current_operation, ^ osmclient/scripts/osm.py:428:18: E128 continuation line under-indented for visual indent wrap_text(text=error_details,width=40)]) ^ osmclient/scripts/osm.py:428:46: E231 missing whitespace after ',' wrap_text(text=error_details,width=40)]) ^ osmclient/scripts/osm.py:434:1: E302 expected 2 blank lines, found 1 def nsd_list(ctx, filter, long): ^ osmclient/scripts/osm.py:438:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:453:64: E231 missing whitespace after ',' onb_state = nsd['_admin'].get('onboardingState','-') ^ osmclient/scripts/osm.py:454:64: E231 missing whitespace after ',' op_state = nsd['_admin'].get('operationalState','-') ^ osmclient/scripts/osm.py:455:61: E231 missing whitespace after ',' usage_state = nsd['_admin'].get('usageState','-') ^ osmclient/scripts/osm.py:498:46: E231 missing whitespace after ',' name = vnfd.get('id', vnfd.get('name','-')) ^ osmclient/scripts/osm.py:511:1: E302 expected 2 blank lines, found 1 def vnfd_list(ctx, nf_type, filter, long): ^ osmclient/scripts/osm.py:518:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:541:35: E127 continuation line over-indented for visual indent 'usage state', 'date', 'last update']) ^ osmclient/scripts/osm.py:545:50: E231 missing whitespace after ',' name = vnfd.get('id', vnfd.get('name','-')) ^ osmclient/scripts/osm.py:548:65: E231 missing whitespace after ',' onb_state = vnfd['_admin'].get('onboardingState','-') ^ osmclient/scripts/osm.py:549:65: E231 missing whitespace after ',' op_state = vnfd['_admin'].get('operationalState','-') ^ osmclient/scripts/osm.py:552:62: E231 missing whitespace after ',' usage_state = vnfd['_admin'].get('usageState','-') ^ osmclient/scripts/osm.py:555:129: E501 line too long (137 > 128 characters) table.add_row([name, vnfd['_id'], descriptor_type, vendor, version, onb_state, op_state, usage_state, date, last_update]) ^ osmclient/scripts/osm.py:619:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='nfpkg-repo-list', short_help='list all xNF from OSM repositories') ^ osmclient/scripts/osm.py:638:19: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:695:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='nsd-repo-list', short_help='list all NS from OSM repositories') ^ osmclient/scripts/osm.py:707:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='nspkg-repo-list', short_help='list all NS from OSM repositories') ^ osmclient/scripts/osm.py:719:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='nf-list', short_help='list all NF instances') ^ osmclient/scripts/osm.py:788:38: E225 missing whitespace around operator if params['lcmOperationType']=='instantiate': ^ osmclient/scripts/osm.py:793:40: E225 missing whitespace around operator elif params['lcmOperationType']=='action': ^ osmclient/scripts/osm.py:812:5: E265 block comment should start with '# ' #print(yaml.safe_dump(resp)) ^ osmclient/scripts/osm.py:815:34: E225 missing whitespace around operator if op['lcmOperationType']=='action': ^ osmclient/scripts/osm.py:825:43: E231 missing whitespace after ',' detail = op.get('errorMessage','-') ^ osmclient/scripts/osm.py:832:89: E231 missing whitespace after ',' wrap_text(text=json.dumps(formatParams(op['operationParams']),indent=2),width=50), ^ osmclient/scripts/osm.py:832:99: E231 missing whitespace after ',' wrap_text(text=json.dumps(formatParams(op['operationParams']),indent=2),width=50), ^ osmclient/scripts/osm.py:836:49: E231 missing whitespace after ',' wrap_text(text=detail,width=50)]) ^ osmclient/scripts/osm.py:839:83: E231 missing whitespace after ',' op['operationState'], date, wrap_text(text=detail or "",width=50)]) ^ osmclient/scripts/osm.py:850:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:904:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:966:129: E501 line too long (132 > 128 characters) @cli_osm.command(name='netslice-instance-op-list', short_help='shows the history of operations over a Network Slice Instance (NSI)') ^ osmclient/scripts/osm.py:988:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:1035:65: E231 missing whitespace after ',' table.add_row([k, wrap_text(text=json.dumps(v, indent=2),width=100)]) ^ osmclient/scripts/osm.py:1083:65: E231 missing whitespace after ',' table.add_row([k, wrap_text(text=json.dumps(v, indent=2),width=100)]) ^ osmclient/scripts/osm.py:1091:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:1140:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='vnfpkg-repo-show', short_help='shows the details of a NF package in an OSM repository') ^ osmclient/scripts/osm.py:1183:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='nspkg-repo-show', short_help='shows the details of a NS package in an OSM repository') ^ osmclient/scripts/osm.py:1268:69: E231 missing whitespace after ',' table.add_row([k, wrap_text(text=json.dumps(v, indent=2),width=100)]) ^ osmclient/scripts/osm.py:1276:68: E231 missing whitespace after ',' table.add_row([k, wrap_text(json.dumps(v, indent=2),width=100)]) ^ osmclient/scripts/osm.py:1300:13: E122 continuation line missing indentation or outdented if "namespace" in op_status and "info" in op_status and \ "last_deployed" in op_status["info"] and "status" in op_status["info"] and \ "code" in op_status["info"]["status"] and "resources" in op_status["info"]["status"] and \ "seconds" in op_status["info"]["last_deployed"]: ^ osmclient/scripts/osm.py:1301:13: E122 continuation line missing indentation or outdented if "namespace" in op_status and "info" in op_status and \ "last_deployed" in op_status["info"] and "status" in op_status["info"] and \ "code" in op_status["info"]["status"] and "resources" in op_status["info"]["status"] and \ "seconds" in op_status["info"]["last_deployed"]: ^ osmclient/scripts/osm.py:1302:13: E122 continuation line missing indentation or outdented if "namespace" in op_status and "info" in op_status and \ "last_deployed" in op_status["info"] and "status" in op_status["info"] and \ "code" in op_status["info"]["status"] and "resources" in op_status["info"]["status"] and \ "seconds" in op_status["info"]["last_deployed"]: ^ osmclient/scripts/osm.py:1303:129: E501 line too long (139 > 128 characters) last_deployed_time = datetime.fromtimestamp(op_status["info"]["last_deployed"]["seconds"]).strftime("%a %b %d %I:%M:%S %Y") ^ osmclient/scripts/osm.py:1307:55: E225 missing whitespace around operator if op_status["info"]["status"]["code"]==1: ^ osmclient/scripts/osm.py:1334:16: E225 missing whitespace around operator op_data={} ^ osmclient/scripts/osm.py:1341:16: E225 missing whitespace around operator while t<30: ^ osmclient/scripts/osm.py:1348:14: E211 whitespace before '(' print ("Could not determine KDU status") ^ osmclient/scripts/osm.py:1358:58: E231 missing whitespace after ',' table.add_row([k, wrap_text(text=json.dumps(v,indent=2),width=100)]) ^ osmclient/scripts/osm.py:1358:68: E231 missing whitespace after ',' table.add_row([k, wrap_text(text=json.dumps(v,indent=2),width=100)]) ^ osmclient/scripts/osm.py:1366:1: E265 block comment should start with '# ' #@cli_osm.command(name='vnf-monitoring-show') ^ osmclient/scripts/osm.py:1367:1: E265 block comment should start with '# ' #@click.argument('vnf_name') ^ osmclient/scripts/osm.py:1368:1: E265 block comment should start with '# ' #@click.pass_context ^ osmclient/scripts/osm.py:1369:1: E265 block comment should start with '# ' #def vnf_monitoring_show(ctx, vnf_name): ^ osmclient/scripts/osm.py:1389:1: E265 block comment should start with '# ' #@cli_osm.command(name='ns-monitoring-show') ^ osmclient/scripts/osm.py:1390:1: E265 block comment should start with '# ' #@click.argument('ns_name') ^ osmclient/scripts/osm.py:1391:1: E265 block comment should start with '# ' #@click.pass_context ^ osmclient/scripts/osm.py:1392:1: E265 block comment should start with '# ' #def ns_monitoring_show(ctx, ns_name): ^ osmclient/scripts/osm.py:1449:5: E265 block comment should start with '# ' #resp = ctx.obj.nst.get_individual(name) ^ osmclient/scripts/osm.py:1579:129: E501 line too long (130 > 128 characters) @cli_osm.command(name='netslice-instance-op-show', short_help='shows the info of an operation over a Network Slice Instance(NSI)') ^ osmclient/scripts/osm.py:1738:22: E231 missing whitespace after ',' repo,vendor, version): ^ osmclient/scripts/osm.py:1786:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='nfpkg-create', short_help='creates a new NFpkg') ^ osmclient/scripts/osm.py:1866:19: E225 missing whitespace around operator config=cf.read() ^ osmclient/scripts/osm.py:1932:19: E225 missing whitespace around operator config=cf.read() ^ osmclient/scripts/osm.py:1949:17: E127 continuation line over-indented for visual indent 'id: TEXT, vim_account: TEXT,\n' ^ osmclient/scripts/osm.py:1982:17: E127 continuation line over-indented for visual indent 'id: TEXT, vim_account: TEXT,\n' ^ osmclient/scripts/osm.py:2008:100: W504 line break after binary operator help='interface(s) of the PDU: name=,mgmt=,ip-address='+ ^ osmclient/scripts/osm.py:2008:100: E225 missing whitespace around operator help='interface(s) of the PDU: name=,mgmt=,ip-address='+ ^ osmclient/scripts/osm.py:2034:12: E701 multiple statements on one line (colon) if name: pdu["name"] = name ^ osmclient/scripts/osm.py:2035:16: E701 multiple statements on one line (colon) if pdu_type: pdu["type"] = pdu_type ^ osmclient/scripts/osm.py:2036:19: E701 multiple statements on one line (colon) if description: pdu["description"] = description ^ osmclient/scripts/osm.py:2037:19: E701 multiple statements on one line (colon) if vim_account: pdu["vim_accounts"] = vim_account ^ osmclient/scripts/osm.py:2041:22: E225 missing whitespace around operator new_iface={k:v for k,v in [i.split('=') for i in iface.split(',')]} ^ osmclient/scripts/osm.py:2041:25: E231 missing whitespace after ':' new_iface={k:v for k,v in [i.split('=') for i in iface.split(',')]} ^ osmclient/scripts/osm.py:2041:33: E231 missing whitespace after ',' new_iface={k:v for k,v in [i.split('=') for i in iface.split(',')]} ^ osmclient/scripts/osm.py:2042:54: E231 missing whitespace after ',' new_iface["mgmt"] = (new_iface.get("mgmt","false").lower() == "true") ^ osmclient/scripts/osm.py:2436:129: E501 line too long (136 > 128 characters) @click.option('--sdn_port_mapping', default=None, help="File describing the port mapping between compute nodes' ports and switch ports") ^ osmclient/scripts/osm.py:2492:129: E501 line too long (136 > 128 characters) @click.option('--sdn_port_mapping', default=None, help="File describing the port mapping between compute nodes' ports and switch ports") ^ osmclient/scripts/osm.py:2521:15: E701 multiple statements on one line (colon) if newname: vim['name'] = newname ^ osmclient/scripts/osm.py:2522:12: E701 multiple statements on one line (colon) if user: vim['vim_user'] = user ^ osmclient/scripts/osm.py:2523:16: E701 multiple statements on one line (colon) if password: vim['vim_password'] = password ^ osmclient/scripts/osm.py:2524:16: E701 multiple statements on one line (colon) if auth_url: vim['vim_url'] = auth_url ^ osmclient/scripts/osm.py:2525:14: E701 multiple statements on one line (colon) if tenant: vim['vim-tenant-name'] = tenant ^ osmclient/scripts/osm.py:2526:20: E701 multiple statements on one line (colon) if account_type: vim['vim_type'] = account_type ^ osmclient/scripts/osm.py:2527:19: E701 multiple statements on one line (colon) if description: vim['description'] = description ^ osmclient/scripts/osm.py:2528:14: E701 multiple statements on one line (colon) if config: vim['config'] = config ^ osmclient/scripts/osm.py:2563:1: E265 block comment should start with '# ' #@click.option('--ro_update/--no_ro_update', ^ osmclient/scripts/osm.py:2575:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:2592:36: E225 missing whitespace around operator vim['vim_password']='********' ^ osmclient/scripts/osm.py:2599:13: E265 block comment should start with '# ' #project_info = '{} ({})'.format(project_name, project_id) ^ osmclient/scripts/osm.py:2623:29: E225 missing whitespace around operator resp['vim_password']='********' ^ osmclient/scripts/osm.py:2631:69: E231 missing whitespace after ',' table.add_row([k, wrap_text(text=json.dumps(v, indent=2),width=100)]) ^ osmclient/scripts/osm.py:2691:12: E701 multiple statements on one line (colon) if user: wim['user'] = user ^ osmclient/scripts/osm.py:2692:16: E701 multiple statements on one line (colon) if password: wim['password'] = password ^ osmclient/scripts/osm.py:2693:11: E701 multiple statements on one line (colon) if url: wim['wim_url'] = url ^ osmclient/scripts/osm.py:2696:19: E701 multiple statements on one line (colon) if description: wim['description'] = description ^ osmclient/scripts/osm.py:2697:14: E701 multiple statements on one line (colon) if config: wim['config'] = config ^ osmclient/scripts/osm.py:2741:15: E701 multiple statements on one line (colon) if newname: wim['name'] = newname ^ osmclient/scripts/osm.py:2742:12: E701 multiple statements on one line (colon) if user: wim['user'] = user ^ osmclient/scripts/osm.py:2743:16: E701 multiple statements on one line (colon) if password: wim['password'] = password ^ osmclient/scripts/osm.py:2744:11: E701 multiple statements on one line (colon) if url: wim['url'] = url ^ osmclient/scripts/osm.py:2746:16: E701 multiple statements on one line (colon) if wim_type: wim['wim_type'] = wim_type ^ osmclient/scripts/osm.py:2747:19: E701 multiple statements on one line (colon) if description: wim['description'] = description ^ osmclient/scripts/osm.py:2748:14: E701 multiple statements on one line (colon) if config: wim['config'] = config ^ osmclient/scripts/osm.py:2788:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:2813:29: E225 missing whitespace around operator resp['wim_password']='********' ^ osmclient/scripts/osm.py:2848:14: E128 continuation line under-indented for visual indent 'Openflow Datapath ID), version: version}') ^ osmclient/scripts/osm.py:2865:64: W504 line break after binary operator sdncontroller = {x: kwargs[x] for x in kwargs if kwargs[x] and ^ osmclient/scripts/osm.py:2886:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='sdnc-update', short_help='updates an SDN controller') ^ osmclient/scripts/osm.py:2910:64: W504 line break after binary operator sdncontroller = {x: kwargs[x] for x in kwargs if kwargs[x] and ^ osmclient/scripts/osm.py:2965:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:3017:129: E501 line too long (178 > 128 characters) help='list of VIM networks, in JSON inline format, where the cluster is accessible via L3 routing, e.g. "{(k8s_net1:vim_network1) [,(k8s_net2:vim_network2) ...]}"') ^ osmclient/scripts/osm.py:3027:1: E265 block comment should start with '# ' #@click.option('--skip-init', ^ osmclient/scripts/osm.py:3030:1: E265 block comment should start with '# ' #@click.option('--wait', ^ osmclient/scripts/osm.py:3035:16: E128 continuation line under-indented for visual indent name, ^ osmclient/scripts/osm.py:3036:16: E128 continuation line under-indented for visual indent creds, ^ osmclient/scripts/osm.py:3037:16: E128 continuation line under-indented for visual indent version, ^ osmclient/scripts/osm.py:3038:16: E128 continuation line under-indented for visual indent vim, ^ osmclient/scripts/osm.py:3039:16: E128 continuation line under-indented for visual indent k8s_nets, ^ osmclient/scripts/osm.py:3040:16: E128 continuation line under-indented for visual indent description, ^ osmclient/scripts/osm.py:3041:16: E128 continuation line under-indented for visual indent namespace, ^ osmclient/scripts/osm.py:3042:16: E128 continuation line under-indented for visual indent cni): ^ osmclient/scripts/osm.py:3058:17: E701 multiple statements on one line (colon) if namespace: cluster['namespace'] = namespace ^ osmclient/scripts/osm.py:3059:11: E701 multiple statements on one line (colon) if cni: cluster['cni'] = yaml.safe_load(cni) ^ osmclient/scripts/osm.py:3072:129: E501 line too long (192 > 128 characters) @click.option('--k8s-nets', help='list of VIM networks, in JSON inline format, where the cluster is accessible via L3 routing, e.g. "{(k8s_net1:vim_network1) [,(k8s_net2:vim_network2) ...]}"') ^ osmclient/scripts/osm.py:3078:16: E128 continuation line under-indented for visual indent name, ^ osmclient/scripts/osm.py:3079:16: E128 continuation line under-indented for visual indent newname, ^ osmclient/scripts/osm.py:3080:16: E128 continuation line under-indented for visual indent creds, ^ osmclient/scripts/osm.py:3081:16: E128 continuation line under-indented for visual indent version, ^ osmclient/scripts/osm.py:3082:16: E128 continuation line under-indented for visual indent vim, ^ osmclient/scripts/osm.py:3083:16: E128 continuation line under-indented for visual indent k8s_nets, ^ osmclient/scripts/osm.py:3084:16: E128 continuation line under-indented for visual indent description, ^ osmclient/scripts/osm.py:3085:16: E128 continuation line under-indented for visual indent namespace, ^ osmclient/scripts/osm.py:3086:16: E128 continuation line under-indented for visual indent cni): ^ osmclient/scripts/osm.py:3094:15: E701 multiple statements on one line (colon) if newname: cluster['name'] = newname ^ osmclient/scripts/osm.py:3098:15: E701 multiple statements on one line (colon) if version: cluster['k8s_version'] = version ^ osmclient/scripts/osm.py:3099:11: E701 multiple statements on one line (colon) if vim: cluster['vim_account'] = vim ^ osmclient/scripts/osm.py:3100:16: E701 multiple statements on one line (colon) if k8s_nets: cluster['nets'] = yaml.safe_load(k8s_nets) ^ osmclient/scripts/osm.py:3101:19: E701 multiple statements on one line (colon) if description: cluster['description'] = description ^ osmclient/scripts/osm.py:3102:17: E701 multiple statements on one line (colon) if namespace: cluster['namespace'] = namespace ^ osmclient/scripts/osm.py:3103:11: E701 multiple statements on one line (colon) if cni: cluster['cni'] = yaml.safe_load(cni) ^ osmclient/scripts/osm.py:3113:1: E265 block comment should start with '# ' #@click.option('--wait', ^ osmclient/scripts/osm.py:3142:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:3155:5: E722 do not use bare 'except' except: ^ osmclient/scripts/osm.py:3160:9: E265 block comment should start with '# ' #vim_info = '{} ({})'.format(vim_name,cluster['vim_account']) ^ osmclient/scripts/osm.py:3167:13: E265 block comment should start with '# ' #project_info = '{} ({})'.format(project_name, project_id) ^ osmclient/scripts/osm.py:3169:70: E231 missing whitespace after ',' detailed_status = cluster["_admin"].get("detailed-status","-") ^ osmclient/scripts/osm.py:3202:65: E231 missing whitespace after ',' table.add_row([k, wrap_text(text=json.dumps(v, indent=2),width=100)]) ^ osmclient/scripts/osm.py:3211:1: E303 too many blank lines (3) ########################### ^ osmclient/scripts/osm.py:3215:1: E302 expected 2 blank lines, found 3 @cli_osm.command(name='repo-add', short_help='adds a repo to OSM') ^ osmclient/scripts/osm.py:3231:1: E265 block comment should start with '# ' #@click.option('--wait', ^ osmclient/scripts/osm.py:3259:1: E265 block comment should start with '# ' #@click.option('--wait', ^ osmclient/scripts/osm.py:3264:14: E128 continuation line under-indented for visual indent name, ^ osmclient/scripts/osm.py:3265:14: E128 continuation line under-indented for visual indent newname, ^ osmclient/scripts/osm.py:3266:14: E128 continuation line under-indented for visual indent uri, ^ osmclient/scripts/osm.py:3267:14: E128 continuation line under-indented for visual indent description): ^ osmclient/scripts/osm.py:3279:19: E701 multiple statements on one line (colon) if description: repo['description'] = description ^ osmclient/scripts/osm.py:3306:1: E265 block comment should start with '# ' #@click.option('--wait', ^ osmclient/scripts/osm.py:3337:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:3345:9: E265 block comment should start with '# ' #cluster['k8s-nets'] = json.dumps(yaml.safe_load(cluster['k8s-nets'])) ^ osmclient/scripts/osm.py:3346:118: E231 missing whitespace after ',' table.add_row([repo['name'], repo['_id'], repo['type'], repo['url'], trunc_text(repo.get('description') or '',40)]) ^ osmclient/scripts/osm.py:3387:1: E303 too many blank lines (3) #################### ^ osmclient/scripts/osm.py:3391:1: E302 expected 2 blank lines, found 3 @cli_osm.command(name='project-create', short_help='creates a new project') ^ osmclient/scripts/osm.py:3393:1: E265 block comment should start with '# ' #@click.option('--description', ^ osmclient/scripts/osm.py:3442:1: E265 block comment should start with '# ' #@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') ^ osmclient/scripts/osm.py:3468:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:3550:89: E225 missing whitespace around operator callback=lambda ctx, param, value: ''.join(value).split(',') if all(len(x)==1 for x in value) else value, ^ osmclient/scripts/osm.py:3641:1: E265 block comment should start with '# ' #@click.option('--force', is_flag=True, help='forces the deletion bypassing pre-conditions') ^ osmclient/scripts/osm.py:3667:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:3692:25: E225 missing whitespace around operator resp['password']='********' ^ osmclient/scripts/osm.py:3752:1: E265 block comment should start with '# ' #@cli_osm.command(name='ns-alarm-delete') ^ osmclient/scripts/osm.py:3753:1: E265 block comment should start with '# ' #@click.argument('name') ^ osmclient/scripts/osm.py:3754:1: E265 block comment should start with '# ' #@click.pass_context ^ osmclient/scripts/osm.py:3755:1: E265 block comment should start with '# ' #def ns_alarm_delete(ctx, name): ^ osmclient/scripts/osm.py:3772:129: E501 line too long (129 > 128 characters) @cli_osm.command(name='ns-metric-export', short_help='exports a metric to the internal OSM bus, which can be read by other apps') ^ osmclient/scripts/osm.py:3780:1: E265 block comment should start with '# ' #@click.option('--period', default='1w', ^ osmclient/scripts/osm.py:3805:71: E231 missing whitespace after ',' print('{} {}'.format(ctx.obj.ns.export_metric(metric_data),i)) ^ osmclient/scripts/osm.py:3807:14: E225 missing whitespace around operator i+=1 ^ osmclient/scripts/osm.py:3823:10: E211 whitespace before '(' print ("Server version: {}".format(ctx.obj.get_version())) ^ osmclient/scripts/osm.py:3824:10: E211 whitespace before '(' print ("Client version: {}".format(pkg_resources.get_distribution("osmclient").version)) ^ osmclient/scripts/osm.py:3829:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='upload-package', short_help='uploads a VNF package or NS package') ^ osmclient/scripts/osm.py:3850:1: E265 block comment should start with '# ' #@cli_osm.command(name='ns-scaling-show') ^ osmclient/scripts/osm.py:3851:1: E265 block comment should start with '# ' #@click.argument('ns_name') ^ osmclient/scripts/osm.py:3852:1: E265 block comment should start with '# ' #@click.pass_context ^ osmclient/scripts/osm.py:3853:1: E265 block comment should start with '# ' #def show_ns_scaling(ctx, ns_name): ^ osmclient/scripts/osm.py:3892:1: E265 block comment should start with '# ' #@cli_osm.command(name='ns-scale') ^ osmclient/scripts/osm.py:3893:1: E265 block comment should start with '# ' #@click.argument('ns_name') ^ osmclient/scripts/osm.py:3894:1: E265 block comment should start with '# ' #@click.option('--ns_scale_group', prompt=True) ^ osmclient/scripts/osm.py:3895:1: E265 block comment should start with '# ' #@click.option('--index', prompt=True) ^ osmclient/scripts/osm.py:3896:1: E265 block comment should start with '# ' #@click.option('--wait', ^ osmclient/scripts/osm.py:3902:1: E265 block comment should start with '# ' #@click.pass_context ^ osmclient/scripts/osm.py:3903:1: E265 block comment should start with '# ' #def ns_scale(ctx, ns_name, ns_scale_group, index, wait): ^ osmclient/scripts/osm.py:3916:1: E265 block comment should start with '# ' #@cli_osm.command(name='config-agent-list') ^ osmclient/scripts/osm.py:3917:1: E265 block comment should start with '# ' #@click.pass_context ^ osmclient/scripts/osm.py:3918:1: E265 block comment should start with '# ' #def config_agent_list(ctx): ^ osmclient/scripts/osm.py:3935:1: E265 block comment should start with '# ' #@cli_osm.command(name='config-agent-delete') ^ osmclient/scripts/osm.py:3936:1: E265 block comment should start with '# ' #@click.argument('name') ^ osmclient/scripts/osm.py:3937:1: E265 block comment should start with '# ' #@click.pass_context ^ osmclient/scripts/osm.py:3938:1: E265 block comment should start with '# ' #def config_agent_delete(ctx, name): ^ osmclient/scripts/osm.py:3951:1: E265 block comment should start with '# ' #@cli_osm.command(name='config-agent-add') ^ osmclient/scripts/osm.py:3952:1: E265 block comment should start with '# ' #@click.option('--name', ^ osmclient/scripts/osm.py:3954:1: E265 block comment should start with '# ' #@click.option('--account_type', ^ osmclient/scripts/osm.py:3956:1: E265 block comment should start with '# ' #@click.option('--server', ^ osmclient/scripts/osm.py:3958:1: E265 block comment should start with '# ' #@click.option('--user', ^ osmclient/scripts/osm.py:3960:1: E265 block comment should start with '# ' #@click.option('--secret', ^ osmclient/scripts/osm.py:3964:1: E265 block comment should start with '# ' #@click.pass_context ^ osmclient/scripts/osm.py:3965:1: E265 block comment should start with '# ' #def config_agent_add(ctx, name, account_type, server, user, secret): ^ osmclient/scripts/osm.py:3975:1: E265 block comment should start with '# ' #@cli_osm.command(name='ro-dump') ^ osmclient/scripts/osm.py:3976:1: E265 block comment should start with '# ' #@click.pass_context ^ osmclient/scripts/osm.py:3977:1: E265 block comment should start with '# ' #def ro_dump(ctx): ^ osmclient/scripts/osm.py:3988:1: E265 block comment should start with '# ' #@cli_osm.command(name='vcs-list') ^ osmclient/scripts/osm.py:3989:1: E265 block comment should start with '# ' #@click.pass_context ^ osmclient/scripts/osm.py:3990:1: E265 block comment should start with '# ' #def vcs_list(ctx): ^ osmclient/scripts/osm.py:4189:15: E225 missing whitespace around operator filter='&'.join(filter) ^ osmclient/scripts/osm.py:4227:14: E128 continuation line under-indented for visual indent short_help='Create empty NS package structure') ^ osmclient/scripts/osm.py:4320:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='package-validate', ^ osmclient/scripts/osm.py:4362:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='package-translate', ^ osmclient/scripts/osm.py:4377:22: E128 continuation line under-indented for visual indent base_directory, ^ osmclient/scripts/osm.py:4378:22: E128 continuation line under-indented for visual indent recursive, ^ osmclient/scripts/osm.py:4379:22: E128 continuation line under-indented for visual indent dryrun): ^ osmclient/scripts/osm.py:4393:129: E501 line too long (139 > 128 characters) table.add_row([result["current type"], result["new type"], result["path"], result["valid"], result["translated"], result["error"]]) ^ osmclient/scripts/osm.py:4403:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='package-build', ^ osmclient/scripts/osm.py:4404:14: E128 continuation line under-indented for visual indent short_help='Build the tar.gz of the package') ^ osmclient/scripts/osm.py:4434:1: E302 expected 2 blank lines, found 1 @cli_osm.command(name='descriptor-translate', ^ osmclient/scripts/osm.py:4435:129: E501 line too long (133 > 128 characters) short_help='Translate input descriptor file from Rel EIGHT OSM descriptors to SOL006 and prints in standard output') ^ osmclient/scripts/osm.py:4473:1: W391 blank line at end of file ^ osmclient/common/http.py:53:68: E231 missing whitespace after ',' self._logger.info("Request METHOD: {} URL: {}".format("GET",self._url + endpoint)) ^ osmclient/common/http.py:68:71: E231 missing whitespace after ',' self._logger.info("Request METHOD: {} URL: {}".format("DELETE",self._url + endpoint)) ^ osmclient/common/http.py:95:69: E231 missing whitespace after ',' self._logger.info("Request METHOD: {} URL: {}".format("POST",self._url + endpoint)) ^ osmclient/common/package_tool.py:117:25: E201 whitespace after '(' if ( desc_type=="vnfd" or desc_type=="nsd" ): ^ osmclient/common/package_tool.py:117:35: E225 missing whitespace around operator if ( desc_type=="vnfd" or desc_type=="nsd" ): ^ osmclient/common/package_tool.py:117:56: E225 missing whitespace around operator if ( desc_type=="vnfd" or desc_type=="nsd" ): ^ osmclient/common/package_tool.py:117:63: E202 whitespace before ')' if ( desc_type=="vnfd" or desc_type=="nsd" ): ^ osmclient/common/package_tool.py:118:129: E501 line too long (140 > 128 characters) print("OSM descriptor '{}' written in an unsupported format. Please update to ETSI SOL006 format".format(desc_path)) ^ osmclient/common/package_tool.py:154:25: E201 whitespace after '(' if not ( desc_type=="vnfd" or desc_type=="nsd" ): ^ osmclient/common/package_tool.py:154:35: E225 missing whitespace around operator if not ( desc_type=="vnfd" or desc_type=="nsd" ): ^ osmclient/common/package_tool.py:154:56: E225 missing whitespace around operator if not ( desc_type=="vnfd" or desc_type=="nsd" ): ^ osmclient/common/package_tool.py:154:63: E202 whitespace before ')' if not ( desc_type=="vnfd" or desc_type=="nsd" ): ^ osmclient/common/package_tool.py:155:129: E501 line too long (153 > 128 characters) table.append({"current type": desc_type, "new type": desc_type, "path": desc_path, "valid": "OK", "translated": "N/A", "error": "-"}) ^ osmclient/common/package_tool.py:159:129: E501 line too long (151 > 128 characters) sol006_model = yaml.safe_dump(im_translation.translate_im_model_to_sol006(descriptor_data), indent=4, default_flow_style=False) ^ osmclient/common/package_tool.py:165:129: E501 line too long (160 > 128 characters) table.append({"current type": desc_type, "new type": new_desc_type, "path": desc_path, "valid": "OK", "translated": "OK", "error": "-"}) ^ osmclient/common/package_tool.py:167:129: E501 line too long (211 > 128 characters) table.append({"current type": desc_type, "new type": new_desc_type, "path": desc_path, "valid": "OK", "translated": "ERROR", "error": "Error in the post-validation: {}".format(str(ve2))}) ^ osmclient/common/package_tool.py:169:129: E501 line too long (206 > 128 characters) table.append({"current type": desc_type, "new type": new_desc_type, "path": desc_path, "valid": "OK", "translated": "ERROR", "error": "Error in the translation: {}".format(str(e2))}) ^ osmclient/common/package_tool.py:171:129: E501 line too long (194 > 128 characters) table.append({"current type": desc_type, "new type": "N/A", "path": desc_path, "valid": "ERROR", "translated": "N/A", "error": "Error in the pre-validation: {}".format(str(ve))}) ^ osmclient/common/package_tool.py:173:129: E501 line too long (151 > 128 characters) table.append({"current type": desc_type, "new type": "N/A", "path": desc_path, "valid": "ERROR", "translated": "N/A", "error": str(e)}) ^ osmclient/common/package_tool.py:364:129: E501 line too long (146 > 128 characters) raise ClientException('Descriptor filename is not correct in: {}. It should end with "nfd.yaml" or "nsd.yaml"'.format(package_folder)) ^ osmclient/common/package_tool.py:522:13: E265 block comment should start with '# ' #self._logger.debug("\n"+yaml.safe_dump(descriptor_dict, indent=4, default_flow_style=False)) ^ osmclient/common/package_tool.py:524:17: E201 whitespace after '(' if ( (desc_type=="vnf" and ("vnfd:vnfd-catalog" in descriptor_dict or "vnfd-catalog" in descriptor_dict)) or ^ osmclient/common/package_tool.py:524:28: E225 missing whitespace around operator if ( (desc_type=="vnf" and ("vnfd:vnfd-catalog" in descriptor_dict or "vnfd-catalog" in descriptor_dict)) or ^ osmclient/common/package_tool.py:524:119: W504 line break after binary operator if ( (desc_type=="vnf" and ("vnfd:vnfd-catalog" in descriptor_dict or "vnfd-catalog" in descriptor_dict)) or ^ osmclient/common/package_tool.py:525:28: E225 missing whitespace around operator (desc_type=="ns" and ( "nsd:nsd-catalog" in descriptor_dict or "nsd-catalog" in descriptor_dict)) ): ^ osmclient/common/package_tool.py:525:40: E201 whitespace after '(' (desc_type=="ns" and ( "nsd:nsd-catalog" in descriptor_dict or "nsd-catalog" in descriptor_dict)) ): ^ osmclient/common/package_tool.py:525:115: E202 whitespace before ')' (desc_type=="ns" and ( "nsd:nsd-catalog" in descriptor_dict or "nsd-catalog" in descriptor_dict)) ): ^ osmclient/common/utils.py:62:46: W504 line break after binary operator if (re.match('.*.yaml', member.name) and ^ osmclient/v1/vnf.py:31:17: E128 continuation line under-indented for visual indent .format(self._client.so_rbac_project_path)) ^ osmclient/v1/vim.py:61:12: E114 indentation is not a multiple of 4 (comment) #'openstack' not in vim_access['vim-type']): ^ osmclient/v1/vim.py:61:12: E265 block comment should start with '# ' #'openstack' not in vim_access['vim-type']): ^ osmclient/v1/vim.py:69:12: E111 indentation is not a multiple of 4 vim_config = yaml.safe_load(vim_access['config']) ^ osmclient/v1/vim.py:84:5: E303 too many blank lines (2) def _update_ro_accounts(self): ^ osmclient/v1/vim.py:86:21: E128 continuation line under-indented for visual indent .format(self._client.so_rbac_project_path)) ^ osmclient/v1/vim.py:93:45: E126 continuation line over-indented for hanging indent "ro-account": account['name'], ^ osmclient/v1/vim.py:95:41: E126 continuation line over-indented for hanging indent } ^ osmclient/v1/vim.py:98:21: E128 continuation line under-indented for visual indent refresh_body) ^ osmclient/v1/vim.py:103:5: E303 too many blank lines (2) def update_vim_account_dict(self, vim_account, vim_access, vim_config): ^ osmclient/v1/vim.py:146:53: E127 continuation line over-indented for visual indent .format(vim_name)) ^ osmclient/v1/vim.py:160:21: E128 continuation line under-indented for visual indent .format(self._client.so_rbac_project_path)) ^ osmclient/v1/vim.py:173:25: E128 continuation line under-indented for visual indent if 'uuid' in datacenter else None}) ^ osmclient/v1/vim.py:198:63: E128 continuation line under-indented for visual indent tenant['uuid'])) ^ osmclient/v1/vim.py:233:21: E128 continuation line under-indented for visual indent .format(self._client.so_rbac_project_path)) ^ osmclient/v1/vim.py:270:17: E128 continuation line under-indented for visual indent .format(self._client.so_rbac_project_path)) ^ osmclient/v1/ns.py:38:17: E128 continuation line under-indented for visual indent .format(self._client.so_rbac_project_path)) ^ osmclient/v1/ns.py:147:15: E126 continuation line over-indented for hanging indent 'api/operational/{}ns-instance-opdata/nsr/{}?deep' ^ osmclient/v1/ns.py:171:21: E128 continuation line under-indented for visual indent .format(self._client.so_rbac_project_path, ns['id'])) ^ osmclient/v1/nsd.py:33:17: E128 continuation line under-indented for visual indent .format(self._client.so_rbac_project_path)) ^ osmclient/v1/vnfd.py:33:17: E128 continuation line under-indented for visual indent .format(self._client.so_rbac_project_path)) ^ osmclient/v1/vca.py:32:17: E128 continuation line under-indented for visual indent .format(self._client.so_rbac_project_path)) ^ osmclient/v1/vca.py:58:33: E128 continuation line under-indented for visual indent .format(self._client.so_rbac_project_path), postdata): ^ osmclient/v1/client.py:75:17: E126 continuation line over-indented for hanging indent self._host, ^ osmclient/v1/client.py:128:1: W391 blank line at end of file ^ osmclient/sol005/vnf.py:26:1: E302 expected 2 blank lines, found 1 class Vnf(object): ^ osmclient/sol005/vnf.py:52:66: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) ^ osmclient/sol005/vnf.py:53:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/vnf.py:84:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/wim.py:87:13: E265 block comment should start with '# ' #wim_account['config'] = json.dumps(wim_config) ^ osmclient/sol005/wim.py:90:40: E128 continuation line under-indented for visual indent postfields_dict=wim_account) ^ osmclient/sol005/wim.py:91:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/wim.py:92:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/wim.py:93:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/wim.py:103:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/wim.py:119:41: E225 missing whitespace around operator if wim_account.get('config')=="" and (wim_port_mapping): ^ osmclient/sol005/wim.py:121:41: E225 missing whitespace around operator if wim_account.get('config')=="": ^ osmclient/sol005/wim.py:129:9: E265 block comment should start with '# ' #wim_account['config'] = json.dumps(wim_config) ^ osmclient/sol005/wim.py:130:85: E231 missing whitespace after ',' http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase,wim['_id']), ^ osmclient/sol005/wim.py:131:40: E128 continuation line under-indented for visual indent postfields_dict=wim_account) ^ osmclient/sol005/wim.py:132:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/wim.py:133:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/wim.py:134:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/wim.py:143:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/wim.py:182:42: E128 continuation line under-indented for visual indent wim_id, querystring)) ^ osmclient/sol005/wim.py:201:26: E271 multiple spaces after keyword msg = resp or "" ^ osmclient/sol005/wim.py:217:66: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) ^ osmclient/sol005/wim.py:223:25: E128 continuation line under-indented for visual indent if '_id' in datacenter else None}) ^ osmclient/sol005/wim.py:235:71: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase,wim_id)) ^ osmclient/sol005/wim.py:237:23: E222 multiple spaces after operator resp = json.loads(resp) ^ osmclient/sol005/wim.py:243:1: W391 blank line at end of file ^ osmclient/sol005/vim.py:75:13: E265 block comment should start with '# ' #'openstack' not in vim_access['vim-type']): ^ osmclient/sol005/vim.py:93:13: E265 block comment should start with '# ' #vim_account['config'] = json.dumps(vim_config) ^ osmclient/sol005/vim.py:96:40: E128 continuation line under-indented for visual indent postfields_dict=vim_account) ^ osmclient/sol005/vim.py:97:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/vim.py:98:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/vim.py:99:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/vim.py:109:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/vim.py:125:41: E225 missing whitespace around operator if vim_account.get('config')=="" and (sdn_controller or sdn_port_mapping): ^ osmclient/sol005/vim.py:127:41: E225 missing whitespace around operator if vim_account.get('config')=="": ^ osmclient/sol005/vim.py:142:9: E265 block comment should start with '# ' #vim_account['config'] = json.dumps(vim_config) ^ osmclient/sol005/vim.py:143:85: E231 missing whitespace after ',' http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase,vim['_id']), ^ osmclient/sol005/vim.py:144:40: E128 continuation line under-indented for visual indent postfields_dict=vim_account) ^ osmclient/sol005/vim.py:147:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/vim.py:156:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/vim.py:194:42: E128 continuation line under-indented for visual indent vim_id, querystring)) ^ osmclient/sol005/vim.py:195:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/vim.py:196:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/vim.py:228:66: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) ^ osmclient/sol005/vim.py:245:71: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase,vim_id)) ^ osmclient/sol005/vim.py:253:1: W391 blank line at end of file ^ osmclient/sol005/k8scluster.py:24:1: E302 expected 2 blank lines, found 1 class K8scluster(object): ^ osmclient/sol005/k8scluster.py:45:40: E128 continuation line under-indented for visual indent postfields_dict=k8s_cluster) ^ osmclient/sol005/k8scluster.py:46:9: E265 block comment should start with '# ' #print 'HTTP CODE: {}'.format(http_code) ^ osmclient/sol005/k8scluster.py:47:9: E265 block comment should start with '# ' #print 'RESP: {}'.format(resp) ^ osmclient/sol005/k8scluster.py:48:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/k8scluster.py:54:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/k8scluster.py:66:83: E231 missing whitespace after ',' http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,cluster['_id']), ^ osmclient/sol005/k8scluster.py:67:40: E128 continuation line under-indented for visual indent postfields_dict=k8s_cluster) ^ osmclient/sol005/k8scluster.py:70:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/k8scluster.py:72:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/k8scluster.py:98:42: E128 continuation line under-indented for visual indent cluster_id, querystring)) ^ osmclient/sol005/k8scluster.py:99:9: E265 block comment should start with '# ' #print 'HTTP CODE: {}'.format(http_code) ^ osmclient/sol005/k8scluster.py:100:9: E265 block comment should start with '# ' #print 'RESP: {}'.format(resp) ^ osmclient/sol005/k8scluster.py:121:66: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) ^ osmclient/sol005/k8scluster.py:134:71: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase,cluster_id)) ^ osmclient/sol005/k8scluster.py:142:1: W391 blank line at end of file ^ osmclient/sol005/ns.py:66:66: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) ^ osmclient/sol005/ns.py:97:13: E265 block comment should start with '# ' #resp = self._http.get_cmd('{}/{}/nsd_content'.format(self._apiBase, ns_id)) ^ osmclient/sol005/ns.py:98:13: E265 block comment should start with '# ' #print(yaml.safe_dump(resp)) ^ osmclient/sol005/ns.py:130:50: E128 continuation line under-indented for visual indent ns['_id'], querystring)) ^ osmclient/sol005/ns.py:192:9: E265 block comment should start with '# ' #ns['userdata'] = {} ^ osmclient/sol005/ns.py:193:9: E265 block comment should start with '# ' #ns['userdata']['key1']='value1' ^ osmclient/sol005/ns.py:194:9: E265 block comment should start with '# ' #ns['userdata']['key2']='value2' ^ osmclient/sol005/ns.py:235:42: E128 continuation line under-indented for visual indent "'member-vnf-index'") ^ osmclient/sol005/ns.py:252:47: E231 missing whitespace after ',' http_header = ['{}: {}'.format(key,val) ^ osmclient/sol005/ns.py:253:27: E128 continuation line under-indented for visual indent for (key,val) in list(headers.items())] ^ osmclient/sol005/ns.py:253:35: E231 missing whitespace after ',' for (key,val) in list(headers.items())] ^ osmclient/sol005/ns.py:256:36: E128 continuation line under-indented for visual indent postfields_dict=ns) ^ osmclient/sol005/ns.py:259:13: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/ns.py:270:13: E265 block comment should start with '# ' #else: ^ osmclient/sol005/ns.py:279:20: E225 missing whitespace around operator message="failed to create ns: {} nsd: {}\nerror:\n{}".format( ^ osmclient/sol005/ns.py:293:39: E128 continuation line under-indented for visual indent self._apiVersion, self._apiResource) ^ osmclient/sol005/ns.py:296:18: E111 indentation is not a multiple of 4 filter_string = '&{}'.format(filter) ^ osmclient/sol005/ns.py:296:18: E117 over-indented filter_string = '&{}'.format(filter) ^ osmclient/sol005/ns.py:298:56: E126 continuation line over-indented for hanging indent self._apiBase, ns['_id'], ^ osmclient/sol005/ns.py:299:70: E202 whitespace before ')' filter_string) ) ^ osmclient/sol005/ns.py:300:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/ns.py:301:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/ns.py:318:20: E225 missing whitespace around operator message="failed to get operation list of NS {}:\nerror:\n{}".format( ^ osmclient/sol005/ns.py:331:39: E128 continuation line under-indented for visual indent self._apiVersion, self._apiResource) ^ osmclient/sol005/ns.py:333:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/ns.py:334:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/ns.py:351:20: E225 missing whitespace around operator message="failed to get status of operation {}:\nerror:\n{}".format( ^ osmclient/sol005/ns.py:367:13: E265 block comment should start with '# ' #print('OP_NAME: {}'.format(op_name)) ^ osmclient/sol005/ns.py:368:13: E265 block comment should start with '# ' #print('OP_DATA: {}'.format(json.dumps(op_data))) ^ osmclient/sol005/ns.py:370:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/ns.py:371:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/ns.py:372:13: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/ns.py:377:35: E126 continuation line over-indented for hanging indent resp)) ^ osmclient/sol005/ns.py:383:13: E265 block comment should start with '# ' #else: ^ osmclient/sol005/ns.py:392:20: E225 missing whitespace around operator message="failed to exec operation {}:\nerror:\n{}".format( ^ osmclient/sol005/ns.py:403:20: E225 missing whitespace around operator op_data={} ^ osmclient/sol005/ns.py:421:20: E225 missing whitespace around operator message="failed to scale vnf {} of ns {}:\nerror:\n{}".format( ^ osmclient/sol005/ns.py:433:40: E128 continuation line under-indented for visual indent postfields_dict=data) ^ osmclient/sol005/ns.py:434:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/ns.py:435:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/ns.py:439:13: E265 block comment should start with '# ' #else: ^ osmclient/sol005/ns.py:449:20: E225 missing whitespace around operator message="failed to create alarm: alarm {}\n{}".format( ^ osmclient/sol005/ns.py:463:40: E128 continuation line under-indented for visual indent postfields_dict=data) ^ osmclient/sol005/ns.py:464:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/ns.py:465:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/ns.py:469:13: E265 block comment should start with '# ' #else: ^ osmclient/sol005/ns.py:479:20: E225 missing whitespace around operator message="failed to delete alarm: alarm {}\n{}".format( ^ osmclient/sol005/ns.py:491:40: E128 continuation line under-indented for visual indent postfields_dict=data) ^ osmclient/sol005/ns.py:492:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/ns.py:493:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/ns.py:497:13: E265 block comment should start with '# ' #else: ^ osmclient/sol005/ns.py:507:20: E225 missing whitespace around operator message="failed to export metric: metric {}\n{}".format( ^ osmclient/sol005/ns.py:523:1: W391 blank line at end of file ^ osmclient/sol005/pdud.py:46:66: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) ^ osmclient/sol005/pdud.py:73:9: E265 block comment should start with '# ' #print(yaml.safe_dump(resp)) ^ osmclient/sol005/pdud.py:85:42: E128 continuation line under-indented for visual indent pdud['_id'], querystring)) ^ osmclient/sol005/pdud.py:86:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/pdud.py:87:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/pdud.py:104:16: E225 missing whitespace around operator headers= self._client._headers ^ osmclient/sol005/pdud.py:106:43: E231 missing whitespace after ',' http_header = ['{}: {}'.format(key,val) ^ osmclient/sol005/pdud.py:107:23: E128 continuation line under-indented for visual indent for (key,val) in list(headers.items())] ^ osmclient/sol005/pdud.py:107:31: E231 missing whitespace after ',' for (key,val) in list(headers.items())] ^ osmclient/sol005/pdud.py:113:13: E265 block comment should start with '# ' #endpoint = '{}{}'.format(self._apiBase,ow_string) ^ osmclient/sol005/pdud.py:115:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/pdud.py:116:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/pdud.py:117:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/pdud.py:124:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/pdud.py:138:1: W391 blank line at end of file ^ osmclient/sol005/user.py:68:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/user.py:69:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/user.py:70:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/user.py:77:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/user.py:147:46: E128 continuation line under-indented for visual indent postfields_dict=update_user, skip_query_admin=True) ^ osmclient/sol005/user.py:159:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/user.py:178:42: E128 continuation line under-indented for visual indent user['_id'], querystring), skip_query_admin=True) ^ osmclient/sol005/user.py:179:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/user.py:180:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/user.py:204:66: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string), skip_query_admin=True) ^ osmclient/sol005/user.py:205:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/user.py:225:1: W391 blank line at end of file ^ osmclient/sol005/sdncontroller.py:76:40: E128 continuation line under-indented for visual indent postfields_dict=sdn_controller) ^ osmclient/sol005/sdncontroller.py:77:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/sdncontroller.py:78:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/sdncontroller.py:79:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/sdncontroller.py:89:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/sdncontroller.py:105:85: E231 missing whitespace after ',' http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase,sdnc['_id']), ^ osmclient/sol005/sdncontroller.py:109:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/sdncontroller.py:118:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/sdncontroller.py:166:66: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) ^ osmclient/sol005/sdncontroller.py:167:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/sdncontroller.py:186:1: W391 blank line at end of file ^ osmclient/sol005/role.py:72:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/role.py:79:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/role.py:165:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/role.py:190:66: E127 continuation line over-indented for visual indent skip_query_admin=True) ^ osmclient/sol005/role.py:220:82: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase, filter_string),skip_query_admin=True) ^ osmclient/sol005/role.py:245:1: W391 blank line at end of file ^ osmclient/sol005/nst.py:28:1: E265 block comment should start with '# ' #from os import stat ^ osmclient/sol005/nst.py:29:1: E265 block comment should start with '# ' #from os.path import basename ^ osmclient/sol005/nst.py:31:1: E302 expected 2 blank lines, found 1 class Nst(object): ^ osmclient/sol005/nst.py:50:9: E265 block comment should start with '# ' #print(yaml.safe_dump(resp)) ^ osmclient/sol005/nst.py:75:13: E265 block comment should start with '# ' #print(yaml.safe_dump(resp)) ^ osmclient/sol005/nst.py:91:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/nst.py:92:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/nst.py:93:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/nst.py:95:13: E265 block comment should start with '# ' #store in a file ^ osmclient/sol005/nst.py:97:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/nst.py:125:42: E128 continuation line under-indented for visual indent nst['_id'], querystring)) ^ osmclient/sol005/nst.py:126:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/nst.py:127:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/nst.py:163:26: E126 continuation line over-indented for hanging indent "Unexpected MIME type for file {}: MIME type {}".format( ^ osmclient/sol005/nst.py:165:23: E126 continuation line over-indented for hanging indent ) ^ osmclient/sol005/nst.py:166:20: E225 missing whitespace around operator headers= self._client._headers ^ osmclient/sol005/nst.py:171:17: E265 block comment should start with '# ' #headers['Content-Type'] = 'application/binary' ^ osmclient/sol005/nst.py:173:17: E265 block comment should start with '# ' #headers['Content-Filename'] = basename(filename) ^ osmclient/sol005/nst.py:174:17: E265 block comment should start with '# ' #file_size = stat(filename).st_size ^ osmclient/sol005/nst.py:175:17: E265 block comment should start with '# ' #headers['Content-Range'] = 'bytes 0-{}/{}'.format(file_size - 1, file_size) ^ osmclient/sol005/nst.py:178:26: E126 continuation line over-indented for hanging indent "Unexpected MIME type for file {}: MIME type {}".format( ^ osmclient/sol005/nst.py:180:23: E126 continuation line over-indented for hanging indent ) ^ osmclient/sol005/nst.py:182:47: E231 missing whitespace after ',' http_header = ['{}: {}'.format(key,val) ^ osmclient/sol005/nst.py:183:27: E128 continuation line under-indented for visual indent for (key,val) in list(headers.items())] ^ osmclient/sol005/nst.py:183:35: E231 missing whitespace after ',' for (key,val) in list(headers.items())] ^ osmclient/sol005/nst.py:194:55: E231 missing whitespace after ',' endpoint = '{}{}'.format(self._apiBase,ow_string) ^ osmclient/sol005/nst.py:196:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/nst.py:197:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/nst.py:218:1: W391 blank line at end of file ^ osmclient/sol005/vnfd.py:212:50: E127 continuation line over-indented for visual indent cpu_override_string = "virtual-compute-desc.{}.virtual-cpu={};"\ .format(vcd_number, quote(yaml.safe_dump(virtual_cpu))) ^ osmclient/sol005/vnfd.py:214:47: E127 continuation line over-indented for visual indent memory_override_string = "virtual-compute-desc.{}.virtual-memory={};"\ .format(vcd_number, quote(yaml.safe_dump(virtual_memory))) ^ osmclient/sol005/vnfd.py:228:50: E127 continuation line over-indented for visual indent cpu_override_string = "virtual-compute-desc.{}.virtual-cpu={};"\ .format(vcd_number, quote(yaml.safe_dump(virtual_cpu))) ^ osmclient/sol005/vnfd.py:230:47: E127 continuation line over-indented for visual indent memory_override_string = "virtual-compute-desc.{}.virtual-memory={};"\ .format(vcd_number, quote(yaml.safe_dump(virtual_memory))) ^ osmclient/sol005/nsi.py:67:66: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) ^ osmclient/sol005/nsi.py:98:13: E265 block comment should start with '# ' #resp = self._http.get_cmd('{}/{}/nsd_content'.format(self._apiBase, nsi_id)) ^ osmclient/sol005/nsi.py:99:13: E265 block comment should start with '# ' #print(yaml.safe_dump(resp)) ^ osmclient/sol005/nsi.py:113:42: E128 continuation line under-indented for visual indent nsi['_id'], querystring)) ^ osmclient/sol005/nsi.py:161:9: E265 block comment should start with '# ' #nsi['userdata'] = {} ^ osmclient/sol005/nsi.py:162:9: E265 block comment should start with '# ' #nsi['userdata']['key1']='value1' ^ osmclient/sol005/nsi.py:163:9: E265 block comment should start with '# ' #nsi['userdata']['key2']='value2' ^ osmclient/sol005/nsi.py:230:47: E231 missing whitespace after ',' http_header = ['{}: {}'.format(key,val) ^ osmclient/sol005/nsi.py:231:27: E128 continuation line under-indented for visual indent for (key,val) in list(headers.items())] ^ osmclient/sol005/nsi.py:231:35: E231 missing whitespace after ',' for (key,val) in list(headers.items())] ^ osmclient/sol005/nsi.py:234:36: E128 continuation line under-indented for visual indent postfields_dict=nsi) ^ osmclient/sol005/nsi.py:235:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/nsi.py:236:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/nsi.py:237:13: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/nsi.py:242:35: E126 continuation line over-indented for hanging indent resp)) ^ osmclient/sol005/nsi.py:247:13: E265 block comment should start with '# ' #else: ^ osmclient/sol005/nsi.py:256:20: E225 missing whitespace around operator message="failed to create nsi: {} nst: {}\nerror:\n{}".format( ^ osmclient/sol005/nsi.py:270:39: E128 continuation line under-indented for visual indent self._apiVersion, self._apiResource) ^ osmclient/sol005/nsi.py:275:56: E126 continuation line over-indented for hanging indent self._apiBase, nsi['_id'], ^ osmclient/sol005/nsi.py:276:70: E202 whitespace before ')' filter_string) ) ^ osmclient/sol005/nsi.py:277:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/nsi.py:278:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/nsi.py:279:13: E265 block comment should start with '# ' #if http_code == 200: ^ osmclient/sol005/nsi.py:284:18: E111 indentation is not a multiple of 4 raise ClientException('unexpected response from server') ^ osmclient/sol005/nsi.py:284:18: E117 over-indented raise ClientException('unexpected response from server') ^ osmclient/sol005/nsi.py:285:13: E265 block comment should start with '# ' #else: ^ osmclient/sol005/nsi.py:295:20: E225 missing whitespace around operator message="failed to get operation list of NSI {}:\nerror:\n{}".format( ^ osmclient/sol005/nsi.py:308:39: E128 continuation line under-indented for visual indent self._apiVersion, self._apiResource) ^ osmclient/sol005/nsi.py:310:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/nsi.py:311:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/nsi.py:312:13: E265 block comment should start with '# ' #if http_code == 200: ^ osmclient/sol005/nsi.py:318:13: E265 block comment should start with '# ' #else: ^ osmclient/sol005/nsi.py:328:20: E225 missing whitespace around operator message="failed to get status of operation {}:\nerror:\n{}".format( ^ osmclient/sol005/nsi.py:343:13: E265 block comment should start with '# ' #print('OP_NAME: {}'.format(op_name)) ^ osmclient/sol005/nsi.py:344:13: E265 block comment should start with '# ' #print('OP_DATA: {}'.format(json.dumps(op_data))) ^ osmclient/sol005/nsi.py:346:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/nsi.py:347:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/nsi.py:348:13: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/nsi.py:353:35: E126 continuation line over-indented for hanging indent resp)) ^ osmclient/sol005/nsi.py:355:13: E265 block comment should start with '# ' #else: ^ osmclient/sol005/nsi.py:364:20: E225 missing whitespace around operator message="failed to exec operation {}:\nerror:\n{}".format( ^ osmclient/sol005/nsi.py:368:1: W391 blank line at end of file ^ osmclient/sol005/osmrepo.py:147:108: W504 line break after binary operator if ((pkgtype == 'vnf' and (pkg_descriptor.get('vnfd') or pkg_descriptor.get('vnfd:vnfd_catalog'))) or ^ osmclient/sol005/project.py:48:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/project.py:49:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/project.py:50:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/project.py:57:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/project.py:73:46: E128 continuation line under-indented for visual indent postfields_dict=project_changes, ^ osmclient/sol005/project.py:74:46: E128 continuation line under-indented for visual indent skip_query_admin=True) ^ osmclient/sol005/project.py:86:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/project.py:107:9: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/project.py:108:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/project.py:132:66: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string), ^ osmclient/sol005/project.py:133:53: E127 continuation line over-indented for visual indent skip_query_admin=True) ^ osmclient/sol005/project.py:134:9: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/project.py:153:1: W391 blank line at end of file ^ osmclient/sol005/package.py:21:1: E265 block comment should start with '# ' #from os import stat ^ osmclient/sol005/package.py:22:1: E265 block comment should start with '# ' #from os.path import basename ^ osmclient/sol005/package.py:93:13: E265 block comment should start with '# ' #endpoint = '/nsds' if pkg_type['type'] == 'nsd' else '/vnfds' ^ osmclient/sol005/package.py:94:13: E265 block comment should start with '# ' #print('Endpoint: {}'.format(endpoint)) ^ osmclient/sol005/package.py:97:13: E265 block comment should start with '# ' #headers['Content-Type'] = 'application/binary' ^ osmclient/sol005/package.py:99:13: E265 block comment should start with '# ' #headers['Content-Filename'] = basename(filename) ^ osmclient/sol005/package.py:100:13: E265 block comment should start with '# ' #file_size = stat(filename).st_size ^ osmclient/sol005/package.py:101:13: E265 block comment should start with '# ' #headers['Content-Range'] = 'bytes 0-{}/{}'.format(file_size - 1, file_size) ^ osmclient/sol005/package.py:103:47: E231 missing whitespace after ',' http_header = ['{}: {}'.format(key,val) ^ osmclient/sol005/package.py:104:27: E128 continuation line under-indented for visual indent for (key,val) in list(headers.items())] ^ osmclient/sol005/package.py:104:35: E231 missing whitespace after ',' for (key,val) in list(headers.items())] ^ osmclient/sol005/package.py:107:13: E265 block comment should start with '# ' #print('HTTP CODE: {}'.format(http_code)) ^ osmclient/sol005/package.py:108:13: E265 block comment should start with '# ' #print('RESP: {}'.format(resp)) ^ osmclient/sol005/package.py:109:13: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/package.py:114:40: E126 continuation line over-indented for hanging indent resp)) ^ osmclient/sol005/repo.py:24:1: E302 expected 2 blank lines, found 1 class Repo(object): ^ osmclient/sol005/repo.py:37:40: E128 continuation line under-indented for visual indent postfields_dict=repo) ^ osmclient/sol005/repo.py:38:9: E265 block comment should start with '# ' #print 'HTTP CODE: {}'.format(http_code) ^ osmclient/sol005/repo.py:39:9: E265 block comment should start with '# ' #print 'RESP: {}'.format(resp) ^ osmclient/sol005/repo.py:40:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/repo.py:47:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/repo.py:59:83: E231 missing whitespace after ',' http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,repo_dict['_id']), ^ osmclient/sol005/repo.py:60:40: E128 continuation line under-indented for visual indent postfields_dict=repo) ^ osmclient/sol005/repo.py:63:9: E265 block comment should start with '# ' #if http_code in (200, 201, 202, 204): ^ osmclient/sol005/repo.py:65:9: E265 block comment should start with '# ' #else: ^ osmclient/sol005/repo.py:92:42: E128 continuation line under-indented for visual indent repo_id, querystring)) ^ osmclient/sol005/repo.py:93:9: E265 block comment should start with '# ' #print 'HTTP CODE: {}'.format(http_code) ^ osmclient/sol005/repo.py:94:9: E265 block comment should start with '# ' #print 'RESP: {}'.format(resp) ^ osmclient/sol005/repo.py:115:66: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}{}'.format(self._apiBase,filter_string)) ^ osmclient/sol005/repo.py:128:71: E231 missing whitespace after ',' _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase,repo_id)) ^ osmclient/sol005/repo.py:136:1: W391 blank line at end of file ^ osmclient/sol005/client.py:21:1: E265 block comment should start with '# ' #from osmclient.v1 import vca ^ osmclient/sol005/client.py:74:50: E231 missing whitespace after ',' 'https://{}:{}/osm'.format(self._host,self._so_port), **kwargs) ^ osmclient/sol005/client.py:132:9: E265 block comment should start with '# ' #print(http_code, resp) ^ osmclient/sol005/client.py:144:17: E711 comparison to None should be 'if cond is not None:' if host != None: ^ osmclient/sol005/client.py:145:23: E225 missing whitespace around operator self._host=host ^ osmclient/sol005/client.py:146:13: E221 multiple spaces before operator port = kwargs.pop('port', None) ^ osmclient/sol005/client.py:147:17: E711 comparison to None should be 'if cond is not None:' if port != None: ^ osmclient/sol005/client.py:148:26: E225 missing whitespace around operator self._so_port=port ^ pylint create: /tmp/.tox/pylint pylint installdeps: -r/opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/requirements.txt, -r/opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/requirements-dev.txt, -r/opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/requirements-test.txt, pylint pylint develop-inst: /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0 pylint installed: astroid==2.9.0,bitarray==2.3.4,certifi==2020.12.5,chardet==4.0.0,click==7.1.2,coverage==5.5,enum34==1.1.10,idna==2.10,importlib-metadata==4.8.2,isort==5.10.1,Jinja2==2.11.3,lazy-object-proxy==1.6.0,lxml==4.7.1,MarkupSafe==1.1.1,mccabe==0.6.1,mock==4.0.3,nose2==0.10.0,osm-im @ git+https://osm.etsi.org/gerrit/osm/IM.git@35517bbfdb9b9e5e26ca1909d9ecf6398a8bb062,-e git+https://osm.etsi.org/gerrit/osm/osmclient.git@1cbff09ebd242dcba9e0011c083e13e5623f1f5d#egg=osmclient,packaging==20.9,platformdirs==2.4.0,prettytable==2.1.0,pyang==2.5.2,pyangbind==0.8.1,pycurl==7.43.0.6,pylint==2.12.2,pyparsing==2.4.7,python-magic==0.4.22,PyYAML==5.4.1,regex==2021.11.10,requests==2.25.1,six==1.16.0,toml==0.10.2,typed-ast==1.5.1,typing_extensions==4.0.1,urllib3==1.26.4,verboselogs==1.7,wcwidth==0.2.5,wrapt==1.13.3,zipp==3.6.0 pylint run-test-pre: PYTHONHASHSEED='1630188128' pylint run-test: commands[0] | - pylint -E osmclient ************* Module osmclient.client osmclient/client.py:47:34: E1101: Module 'logging' has no 'VERBOSE' member (no-member) ************* Module osmclient.scripts.osm osmclient/scripts/osm.py:4455:8: E1120: No value for argument 'ctx' in function call (no-value-for-parameter) ************* Module osmclient.common.http osmclient/common/http.py:53:8: E1101: Instance of 'Http' has no '_logger' member (no-member) osmclient/common/http.py:56:8: E1101: Instance of 'Http' has no '_logger' member (no-member) osmclient/common/http.py:59:12: E1101: Instance of 'Http' has no '_logger' member (no-member) osmclient/common/http.py:68:8: E1101: Instance of 'Http' has no '_logger' member (no-member) osmclient/common/http.py:71:8: E1101: Instance of 'Http' has no '_logger' member (no-member) osmclient/common/http.py:74:12: E1101: Instance of 'Http' has no '_logger' member (no-member) osmclient/common/http.py:95:8: E1101: Instance of 'Http' has no '_logger' member (no-member) osmclient/common/http.py:98:8: E1101: Instance of 'Http' has no '_logger' member (no-member) osmclient/common/http.py:101:12: E1101: Instance of 'Http' has no '_logger' member (no-member) ************* Module osmclient.sol005.pdud osmclient/sol005/pdud.py:137:8: E1123: Unexpected keyword argument 'filename' in method call (unexpected-keyword-arg) osmclient/sol005/pdud.py:137:8: E1120: No value for argument 'pdu' in method call (no-value-for-parameter) safety create: /tmp/.tox/safety safety installdeps: -r/opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/requirements.txt, safety safety develop-inst: /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0 safety installed: certifi==2020.12.5,chardet==4.0.0,click==7.1.2,dparse==0.5.1,idna==2.10,importlib-metadata==4.8.2,Jinja2==2.11.3,MarkupSafe==1.1.1,-e git+https://osm.etsi.org/gerrit/osm/osmclient.git@1cbff09ebd242dcba9e0011c083e13e5623f1f5d#egg=osmclient,packaging==20.9,prettytable==2.1.0,pycurl==7.43.0.6,pyparsing==2.4.7,python-magic==0.4.22,PyYAML==5.4.1,requests==2.25.1,safety==1.10.3,toml==0.10.2,typing_extensions==4.0.1,urllib3==1.26.4,verboselogs==1.7,wcwidth==0.2.5,zipp==3.6.0 safety run-test-pre: PYTHONHASHSEED='1630188128' safety run-test: commands[0] | - safety check --full-report +==============================================================================+ | | | /$$$$$$ /$$ | | /$$__ $$ | $$ | | /$$$$$$$ /$$$$$$ | $$ \__//$$$$$$ /$$$$$$ /$$ /$$ | | /$$_____/ |____ $$| $$$$ /$$__ $$|_ $$_/ | $$ | $$ | | | $$$$$$ /$$$$$$$| $$_/ | $$$$$$$$ | $$ | $$ | $$ | | \____ $$ /$$__ $$| $$ | $$_____/ | $$ /$$| $$ | $$ | | /$$$$$$$/| $$$$$$$| $$ | $$$$$$$ | $$$$/| $$$$$$$ | | |_______/ \_______/|__/ \_______/ \___/ \____ $$ | | /$$ | $$ | | | $$$$$$/ | | by pyup.io \______/ | | | +==============================================================================+ | REPORT | | checked 26 packages, using free DB (updated once a month) | +==============================================================================+ | No known security vulnerabilities found. | +==============================================================================+ ___________________________________ summary ____________________________________ black: commands succeeded cover: commands succeeded flake8: commands succeeded pylint: commands succeeded safety: commands succeeded congratulations :) [Pipeline] fileExists [Pipeline] step [Cobertura] Publishing Cobertura coverage report... [Cobertura] Publishing Cobertura coverage results... [Cobertura] Cobertura coverage report found. [Pipeline] fileExists [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Build) [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + runuser jenkins -c devops-stages/stage-build.sh [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Archive) [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + runuser jenkins -c mkdir -p changelog [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + runuser jenkins -c devops/tools/generatechangelog-pipeline.sh > changelog/changelog-osmclient.html [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + runuser jenkins -c devops-stages/stage-archive.sh devops-stages/stage-archive.sh: 7: devops-stages/stage-archive.sh: apt-ftparchive: not found [Pipeline] getArtifactoryServer [Pipeline] newBuildInfo [Pipeline] artifactoryUpload [consumer_0] Deploying artifact: https://artifactory-osm.etsi.org/artifactory/osm-osmclient/v9.0/28/dists/unstable/osmclient/binary-amd64/Packages.gz [consumer_1] Deploying artifact: https://artifactory-osm.etsi.org/artifactory/osm-osmclient/v9.0/28/dists/unstable/osmclient/binary-amd64/Packages [consumer_2] Deploying artifact: https://artifactory-osm.etsi.org/artifactory/osm-osmclient/v9.0/28/pool/osmclient/python3-osmclient_9.1.5%2Bg1cbff09-1_all.deb [consumer_0] Deploying artifact: https://artifactory-osm.etsi.org/artifactory/osm-osmclient/v9.0/28/changelog/changelog-osmclient.html [Pipeline] publishBuildInfo Deploying build info to: https://artifactory-osm.etsi.org/artifactory/api/build Deploying build descriptor to: https://artifactory-osm.etsi.org/artifactory/api/build Build successfully deployed. Browse it in Artifactory under https://artifactory-osm.etsi.org/artifactory/webapp/builds/osmclient-stage_2-merge%20::%20v9.0/28 [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + env [Pipeline] step Archiving artifacts Recording fingerprints [Pipeline] } [Pipeline] // stage [Pipeline] } $ docker stop --time=1 798e624997b2e17e8952987961dcc04acde0cad8763379b1f2ac208cf6fef054 $ docker rm -f 798e624997b2e17e8952987961dcc04acde0cad8763379b1f2ac208cf6fef054 [Pipeline] // withDockerContainer [Pipeline] fileExists [Pipeline] stage [Pipeline] { (Snap build) [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + docker pull snapcore/snapcraft:stable stable: Pulling from snapcore/snapcraft Digest: sha256:6d771575c134569e28a590f173f7efae8bf7f4d1746ad8a474c98e02f4a3f627 Status: Image is up to date for snapcore/snapcraft:stable [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + sudo rm -rf /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/stage/ /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/parts/ /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/prime/ /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/*.snap [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + sudo snapcraft clean --use-lxd Running with 'sudo' may cause permission errors and is discouraged. Use 'sudo' when cleaning. [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + snapcraft --use-lxd Launching a container. Waiting for container to be ready Created symlink /etc/systemd/system/dbus-org.freedesktop.network1.service → /lib/systemd/system/systemd-networkd.service. Waiting for network to be ready... Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] Get:2 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB] Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Get:4 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [1983 kB] Get:5 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [355 kB] Get:6 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [20.9 kB] Get:7 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [4732 B] Get:8 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [535 kB] Get:9 http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en [72.4 kB] Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1157 kB] Get:11 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [266 kB] Get:12 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1019 kB] Get:13 http://archive.ubuntu.com/ubuntu bionic/main Translation-en [516 kB] Get:14 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [151 kB] Get:15 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en [108 kB] Get:16 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [9184 B] Get:17 http://archive.ubuntu.com/ubuntu bionic/restricted Translation-en [3584 B] Get:18 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [8570 kB] Get:19 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en [4941 kB] Get:20 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [2328 kB] Get:21 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [448 kB] Get:22 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [27.3 kB] Get:23 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [6808 B] Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [559 kB] Get:25 http://archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [76.4 kB] Get:26 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1771 kB] Get:27 http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [383 kB] Fetched 25.7 MB in 9s (2942 kB/s) Reading package lists... Reading package lists... Building dependency tree... Reading state information... The following additional packages will be installed: gpg gpg-agent gpgconf libasn1-8-heimdal libfuse2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal libkrb5-26-heimdal libksba8 libldap-2.4-2 libldap-common libroken18-heimdal libsasl2-2 libsasl2-modules-db libudev1 libwind0-heimdal Suggested packages: dbus-user-session libpam-systemd pinentry-gnome3 tor scdaemon Recommended packages: gnupg libsasl2-modules The following NEW packages will be installed: dirmngr fuse libasn1-8-heimdal libfuse2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal libkrb5-26-heimdal libksba8 libldap-2.4-2 libldap-common libroken18-heimdal libsasl2-2 libsasl2-modules-db libwind0-heimdal udev The following packages will be upgraded: gpg gpg-agent gpgconf libudev1 4 upgraded, 18 newly installed, 0 to remove and 108 not upgraded. Need to get 3527 kB of archives. After this operation, 13.3 MB of additional disk space will be used. Get:1 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libsasl2-modules-db amd64 2.1.27~101-g0780600+dfsg-3ubuntu2.3 [15.0 kB] Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libudev1 amd64 237-3ubuntu10.52 [55.8 kB] Get:3 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libsasl2-2 amd64 2.1.27~101-g0780600+dfsg-3ubuntu2.3 [49.2 kB] Get:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 udev amd64 237-3ubuntu10.52 [1102 kB] Get:5 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libldap-common all 2.4.45+dfsg-1ubuntu1.10 [15.8 kB] Get:6 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libldap-2.4-2 amd64 2.4.45+dfsg-1ubuntu1.10 [154 kB] Get:7 http://archive.ubuntu.com/ubuntu bionic/main amd64 libfuse2 amd64 2.9.7-1ubuntu1 [80.9 kB] Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 fuse amd64 2.9.7-1ubuntu1 [24.5 kB] Get:9 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpg amd64 2.2.4-1ubuntu1.4 [467 kB] Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpgconf amd64 2.2.4-1ubuntu1.4 [123 kB] Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpg-agent amd64 2.2.4-1ubuntu1.4 [227 kB] Get:12 http://archive.ubuntu.com/ubuntu bionic/main amd64 libksba8 amd64 1.3.5-2 [92.6 kB] Get:13 http://archive.ubuntu.com/ubuntu bionic/main amd64 libroken18-heimdal amd64 7.5.0+dfsg-1 [41.3 kB] Get:14 http://archive.ubuntu.com/ubuntu bionic/main amd64 libasn1-8-heimdal amd64 7.5.0+dfsg-1 [175 kB] Get:15 http://archive.ubuntu.com/ubuntu bionic/main amd64 libheimbase1-heimdal amd64 7.5.0+dfsg-1 [29.3 kB] Get:16 http://archive.ubuntu.com/ubuntu bionic/main amd64 libhcrypto4-heimdal amd64 7.5.0+dfsg-1 [85.9 kB] Get:17 http://archive.ubuntu.com/ubuntu bionic/main amd64 libwind0-heimdal amd64 7.5.0+dfsg-1 [47.8 kB] Get:18 http://archive.ubuntu.com/ubuntu bionic/main amd64 libhx509-5-heimdal amd64 7.5.0+dfsg-1 [107 kB] Get:19 http://archive.ubuntu.com/ubuntu bionic/main amd64 libkrb5-26-heimdal amd64 7.5.0+dfsg-1 [206 kB] Get:20 http://archive.ubuntu.com/ubuntu bionic/main amd64 libheimntlm0-heimdal amd64 7.5.0+dfsg-1 [14.8 kB] Get:21 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgssapi3-heimdal amd64 7.5.0+dfsg-1 [96.5 kB] Get:22 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 dirmngr amd64 2.2.4-1ubuntu1.4 [316 kB] debconf: delaying package configuration, since apt-utils is not installed Fetched 3527 kB in 0s (8998 kB/s) (Reading database ... 12511 files and directories currently installed.) Preparing to unpack .../libudev1_237-3ubuntu10.52_amd64.deb ... Unpacking libudev1:amd64 (237-3ubuntu10.52) over (237-3ubuntu10) ... Setting up libudev1:amd64 (237-3ubuntu10.52) ... Selecting previously unselected package udev. (Reading database ... 12511 files and directories currently installed.) Preparing to unpack .../00-udev_237-3ubuntu10.52_amd64.deb ... Unpacking udev (237-3ubuntu10.52) ... Selecting previously unselected package libfuse2:amd64. Preparing to unpack .../01-libfuse2_2.9.7-1ubuntu1_amd64.deb ... Unpacking libfuse2:amd64 (2.9.7-1ubuntu1) ... Selecting previously unselected package fuse. Preparing to unpack .../02-fuse_2.9.7-1ubuntu1_amd64.deb ... Unpacking fuse (2.9.7-1ubuntu1) ... Preparing to unpack .../03-gpg_2.2.4-1ubuntu1.4_amd64.deb ... Unpacking gpg (2.2.4-1ubuntu1.4) over (2.2.4-1ubuntu1) ... Preparing to unpack .../04-gpgconf_2.2.4-1ubuntu1.4_amd64.deb ... Unpacking gpgconf (2.2.4-1ubuntu1.4) over (2.2.4-1ubuntu1) ... Preparing to unpack .../05-gpg-agent_2.2.4-1ubuntu1.4_amd64.deb ... Unpacking gpg-agent (2.2.4-1ubuntu1.4) over (2.2.4-1ubuntu1) ... Selecting previously unselected package libksba8:amd64. Preparing to unpack .../06-libksba8_1.3.5-2_amd64.deb ... Unpacking libksba8:amd64 (1.3.5-2) ... Selecting previously unselected package libroken18-heimdal:amd64. Preparing to unpack .../07-libroken18-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libroken18-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libasn1-8-heimdal:amd64. Preparing to unpack .../08-libasn1-8-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libasn1-8-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libheimbase1-heimdal:amd64. Preparing to unpack .../09-libheimbase1-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libheimbase1-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libhcrypto4-heimdal:amd64. Preparing to unpack .../10-libhcrypto4-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libhcrypto4-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libwind0-heimdal:amd64. Preparing to unpack .../11-libwind0-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libwind0-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libhx509-5-heimdal:amd64. Preparing to unpack .../12-libhx509-5-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libhx509-5-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libkrb5-26-heimdal:amd64. Preparing to unpack .../13-libkrb5-26-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libkrb5-26-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libheimntlm0-heimdal:amd64. Preparing to unpack .../14-libheimntlm0-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libheimntlm0-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libgssapi3-heimdal:amd64. Preparing to unpack .../15-libgssapi3-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libgssapi3-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libsasl2-modules-db:amd64. Preparing to unpack .../16-libsasl2-modules-db_2.1.27~101-g0780600+dfsg-3ubuntu2.3_amd64.deb ... Unpacking libsasl2-modules-db:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2.3) ... Selecting previously unselected package libsasl2-2:amd64. Preparing to unpack .../17-libsasl2-2_2.1.27~101-g0780600+dfsg-3ubuntu2.3_amd64.deb ... Unpacking libsasl2-2:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2.3) ... Selecting previously unselected package libldap-common. Preparing to unpack .../18-libldap-common_2.4.45+dfsg-1ubuntu1.10_all.deb ... Unpacking libldap-common (2.4.45+dfsg-1ubuntu1.10) ... Selecting previously unselected package libldap-2.4-2:amd64. Preparing to unpack .../19-libldap-2.4-2_2.4.45+dfsg-1ubuntu1.10_amd64.deb ... Unpacking libldap-2.4-2:amd64 (2.4.45+dfsg-1ubuntu1.10) ... Selecting previously unselected package dirmngr. Preparing to unpack .../20-dirmngr_2.2.4-1ubuntu1.4_amd64.deb ... Unpacking dirmngr (2.2.4-1ubuntu1.4) ... Setting up libldap-common (2.4.45+dfsg-1ubuntu1.10) ... Setting up gpgconf (2.2.4-1ubuntu1.4) ... Setting up libfuse2:amd64 (2.9.7-1ubuntu1) ... Setting up libsasl2-modules-db:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2.3) ... Setting up libsasl2-2:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2.3) ... Setting up gpg-agent (2.2.4-1ubuntu1.4) ... Setting up libroken18-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libksba8:amd64 (1.3.5-2) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Setting up udev (237-3ubuntu10.52) ... invoke-rc.d: policy-rc.d denied execution of start. Setting up libheimbase1-heimdal:amd64 (7.5.0+dfsg-1) ... Processing triggers for systemd (237-3ubuntu10) ... Setting up fuse (2.9.7-1ubuntu1) ... Setting up gpg (2.2.4-1ubuntu1.4) ... Setting up libwind0-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libasn1-8-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libhcrypto4-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libhx509-5-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libkrb5-26-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libheimntlm0-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libgssapi3-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libldap-2.4-2:amd64 (2.4.45+dfsg-1ubuntu1.10) ... Setting up dirmngr (2.2.4-1ubuntu1.4) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... The unit files have no installation config (WantedBy, RequiredBy, Also, Alias settings in the [Install] section, and DefaultInstance for template units). This means they are not meant to be enabled using systemctl. Possible reasons for having this kind of units are: 1) A unit may be statically enabled by being symlinked from another unit's .wants/ or .requires/ directory. 2) A unit's purpose may be to act as a helper for some other unit which has a requirement dependency on it. 3) A unit may be started when needed via activation (socket, path, timer, D-Bus, udev, scripted systemctl call, ...). 4) In case of template units, the unit is meant to be enabled with some instance name specified. Reading package lists... Building dependency tree... Reading state information... The following additional packages will be installed: apparmor apt libapt-pkg5.0 libbsd0 libedit2 libexpat1 libgssapi-krb5-2 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 liblzo2-2 libmpdec2 libpython3-stdlib libpython3.6-minimal libpython3.6-stdlib libssl1.0.0 libssl1.1 libsystemd0 mime-support multiarch-support openssh-client python3 python3-minimal python3.6 python3.6-minimal squashfs-tools systemd Suggested packages: apparmor-profiles-extra apparmor-utils apt-doc aptitude | synaptic | wajig gnupg | gnupg2 | gnupg1 powermgmt-base krb5-doc krb5-user keychain libpam-ssh monkeysphere ssh-askpass python3-doc python3-tk python3-venv python3.6-venv python3.6-doc binfmt-support zenity | kdialog systemd-container policykit-1 Recommended packages: krb5-locales file xauth gnupg libpam-systemd dbus networkd-dispatcher The following NEW packages will be installed: apparmor libbsd0 libedit2 libexpat1 libgssapi-krb5-2 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 liblzo2-2 libmpdec2 libpython3-stdlib libpython3.6-minimal libpython3.6-stdlib libssl1.0.0 mime-support multiarch-support openssh-client python3 python3-minimal python3.6 python3.6-minimal snapd squashfs-tools sudo The following packages will be upgraded: apt libapt-pkg5.0 libssl1.1 libsystemd0 systemd 5 upgraded, 25 newly installed, 0 to remove and 103 not upgraded. Need to get 36.8 MB of archives. After this operation, 147 MB of additional disk space will be used. Get:1 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libpython3.6-minimal amd64 3.6.9-1~18.04ubuntu1.4 [534 kB] Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 systemd amd64 237-3ubuntu10.52 [2913 kB] Get:3 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libexpat1 amd64 2.2.5-3ubuntu0.2 [80.5 kB] Get:4 http://security.ubuntu.com/ubuntu bionic-security/main amd64 python3.6-minimal amd64 3.6.9-1~18.04ubuntu1.4 [1610 kB] Get:5 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libpython3.6-stdlib amd64 3.6.9-1~18.04ubuntu1.4 [1712 kB] Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libsystemd0 amd64 237-3ubuntu10.52 [206 kB] Get:7 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libapt-pkg5.0 amd64 1.6.14 [809 kB] Get:8 http://security.ubuntu.com/ubuntu bionic-security/main amd64 python3.6 amd64 3.6.9-1~18.04ubuntu1.4 [203 kB] Get:9 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libbsd0 amd64 0.8.7-1ubuntu0.1 [41.6 kB] Get:10 http://security.ubuntu.com/ubuntu bionic-security/main amd64 sudo amd64 1.8.21p2-3ubuntu1.4 [428 kB] Get:11 http://security.ubuntu.com/ubuntu bionic-security/main amd64 apparmor amd64 2.12-4ubuntu5.1 [487 kB] Get:12 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libkrb5support0 amd64 1.16-2ubuntu0.2 [30.8 kB] Get:13 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libk5crypto3 amd64 1.16-2ubuntu0.2 [85.5 kB] Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 apt amd64 1.6.14 [1207 kB] Get:15 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libkrb5-3 amd64 1.16-2ubuntu0.2 [279 kB] Get:16 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libgssapi-krb5-2 amd64 1.16-2ubuntu0.2 [122 kB] Get:17 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libssl1.0.0 amd64 1.0.2n-1ubuntu5.7 [1089 kB] Get:18 http://security.ubuntu.com/ubuntu bionic-security/main amd64 openssh-client amd64 1:7.6p1-4ubuntu0.5 [612 kB] Get:19 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libssl1.1 amd64 1.1.1-1ubuntu2.1~18.04.14 [1302 kB] Get:20 http://security.ubuntu.com/ubuntu bionic-security/main amd64 squashfs-tools amd64 1:4.3-6ubuntu0.18.04.4 [111 kB] Get:21 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-minimal amd64 3.6.7-1~18.04 [23.7 kB] Get:22 http://archive.ubuntu.com/ubuntu bionic/main amd64 mime-support all 3.60ubuntu1 [30.1 kB] Get:23 http://archive.ubuntu.com/ubuntu bionic/main amd64 libmpdec2 amd64 2.4.2-1ubuntu1 [84.1 kB] Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3-stdlib amd64 3.6.7-1~18.04 [7240 B] Get:25 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3 amd64 3.6.7-1~18.04 [47.2 kB] Get:26 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 multiarch-support amd64 2.27-3ubuntu1.4 [6944 B] Get:27 http://archive.ubuntu.com/ubuntu bionic/main amd64 liblzo2-2 amd64 2.08-1.2 [48.7 kB] Get:28 http://archive.ubuntu.com/ubuntu bionic/main amd64 libedit2 amd64 3.1-20170329-1 [76.9 kB] Get:29 http://archive.ubuntu.com/ubuntu bionic/main amd64 libkeyutils1 amd64 1.5.9-9.2ubuntu2 [8720 B] Get:30 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 snapd amd64 2.51.1+18.04 [22.6 MB] debconf: delaying package configuration, since apt-utils is not installed Fetched 36.8 MB in 1s (26.9 MB/s) (Reading database ... 12757 files and directories currently installed.) Preparing to unpack .../systemd_237-3ubuntu10.52_amd64.deb ... Unpacking systemd (237-3ubuntu10.52) over (237-3ubuntu10) ... Preparing to unpack .../libsystemd0_237-3ubuntu10.52_amd64.deb ... Unpacking libsystemd0:amd64 (237-3ubuntu10.52) over (237-3ubuntu10) ... Setting up libsystemd0:amd64 (237-3ubuntu10.52) ... (Reading database ... 12757 files and directories currently installed.) Preparing to unpack .../libapt-pkg5.0_1.6.14_amd64.deb ... Unpacking libapt-pkg5.0:amd64 (1.6.14) over (1.6.1) ... Setting up libapt-pkg5.0:amd64 (1.6.14) ... (Reading database ... 12757 files and directories currently installed.) Preparing to unpack .../archives/apt_1.6.14_amd64.deb ... Unpacking apt (1.6.14) over (1.6.1) ... Setting up apt (1.6.14) ... Installing new version of config file /etc/apt/apt.conf.d/01autoremove ... /usr/sbin/policy-rc.d returned 101, not running 'restart apt-daily-upgrade.timer apt-daily.timer' (Reading database ... 12764 files and directories currently installed.) Preparing to unpack .../libssl1.1_1.1.1-1ubuntu2.1~18.04.14_amd64.deb ... Unpacking libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.14) over (1.1.0g-2ubuntu4) ... Selecting previously unselected package libpython3.6-minimal:amd64. Preparing to unpack .../libpython3.6-minimal_3.6.9-1~18.04ubuntu1.4_amd64.deb ... Unpacking libpython3.6-minimal:amd64 (3.6.9-1~18.04ubuntu1.4) ... Selecting previously unselected package libexpat1:amd64. Preparing to unpack .../libexpat1_2.2.5-3ubuntu0.2_amd64.deb ... Unpacking libexpat1:amd64 (2.2.5-3ubuntu0.2) ... Selecting previously unselected package python3.6-minimal. Preparing to unpack .../python3.6-minimal_3.6.9-1~18.04ubuntu1.4_amd64.deb ... Unpacking python3.6-minimal (3.6.9-1~18.04ubuntu1.4) ... Setting up libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.14) ... Checking for services that may need to be restarted...done. Checking for services that may need to be restarted...done. Setting up libpython3.6-minimal:amd64 (3.6.9-1~18.04ubuntu1.4) ... Setting up libexpat1:amd64 (2.2.5-3ubuntu0.2) ... Setting up python3.6-minimal (3.6.9-1~18.04ubuntu1.4) ... Selecting previously unselected package python3-minimal. (Reading database ... 13012 files and directories currently installed.) Preparing to unpack .../0-python3-minimal_3.6.7-1~18.04_amd64.deb ... Unpacking python3-minimal (3.6.7-1~18.04) ... Selecting previously unselected package mime-support. Preparing to unpack .../1-mime-support_3.60ubuntu1_all.deb ... Unpacking mime-support (3.60ubuntu1) ... Selecting previously unselected package libmpdec2:amd64. Preparing to unpack .../2-libmpdec2_2.4.2-1ubuntu1_amd64.deb ... Unpacking libmpdec2:amd64 (2.4.2-1ubuntu1) ... Selecting previously unselected package libpython3.6-stdlib:amd64. Preparing to unpack .../3-libpython3.6-stdlib_3.6.9-1~18.04ubuntu1.4_amd64.deb ... Unpacking libpython3.6-stdlib:amd64 (3.6.9-1~18.04ubuntu1.4) ... Selecting previously unselected package python3.6. Preparing to unpack .../4-python3.6_3.6.9-1~18.04ubuntu1.4_amd64.deb ... Unpacking python3.6 (3.6.9-1~18.04ubuntu1.4) ... Selecting previously unselected package libpython3-stdlib:amd64. Preparing to unpack .../5-libpython3-stdlib_3.6.7-1~18.04_amd64.deb ... Unpacking libpython3-stdlib:amd64 (3.6.7-1~18.04) ... Setting up python3-minimal (3.6.7-1~18.04) ... Selecting previously unselected package python3. (Reading database ... 13442 files and directories currently installed.) Preparing to unpack .../python3_3.6.7-1~18.04_amd64.deb ... Unpacking python3 (3.6.7-1~18.04) ... Selecting previously unselected package multiarch-support. Preparing to unpack .../multiarch-support_2.27-3ubuntu1.4_amd64.deb ... Unpacking multiarch-support (2.27-3ubuntu1.4) ... Setting up multiarch-support (2.27-3ubuntu1.4) ... Selecting previously unselected package liblzo2-2:amd64. (Reading database ... 13479 files and directories currently installed.) Preparing to unpack .../00-liblzo2-2_2.08-1.2_amd64.deb ... Unpacking liblzo2-2:amd64 (2.08-1.2) ... Selecting previously unselected package libbsd0:amd64. Preparing to unpack .../01-libbsd0_0.8.7-1ubuntu0.1_amd64.deb ... Unpacking libbsd0:amd64 (0.8.7-1ubuntu0.1) ... Selecting previously unselected package sudo. Preparing to unpack .../02-sudo_1.8.21p2-3ubuntu1.4_amd64.deb ... Unpacking sudo (1.8.21p2-3ubuntu1.4) ... Selecting previously unselected package apparmor. Preparing to unpack .../03-apparmor_2.12-4ubuntu5.1_amd64.deb ... Unpacking apparmor (2.12-4ubuntu5.1) ... Selecting previously unselected package libedit2:amd64. Preparing to unpack .../04-libedit2_3.1-20170329-1_amd64.deb ... Unpacking libedit2:amd64 (3.1-20170329-1) ... Selecting previously unselected package libkrb5support0:amd64. Preparing to unpack .../05-libkrb5support0_1.16-2ubuntu0.2_amd64.deb ... Unpacking libkrb5support0:amd64 (1.16-2ubuntu0.2) ... Selecting previously unselected package libk5crypto3:amd64. Preparing to unpack .../06-libk5crypto3_1.16-2ubuntu0.2_amd64.deb ... Unpacking libk5crypto3:amd64 (1.16-2ubuntu0.2) ... Selecting previously unselected package libkeyutils1:amd64. Preparing to unpack .../07-libkeyutils1_1.5.9-9.2ubuntu2_amd64.deb ... Unpacking libkeyutils1:amd64 (1.5.9-9.2ubuntu2) ... Selecting previously unselected package libkrb5-3:amd64. Preparing to unpack .../08-libkrb5-3_1.16-2ubuntu0.2_amd64.deb ... Unpacking libkrb5-3:amd64 (1.16-2ubuntu0.2) ... Selecting previously unselected package libgssapi-krb5-2:amd64. Preparing to unpack .../09-libgssapi-krb5-2_1.16-2ubuntu0.2_amd64.deb ... Unpacking libgssapi-krb5-2:amd64 (1.16-2ubuntu0.2) ... Selecting previously unselected package libssl1.0.0:amd64. Preparing to unpack .../10-libssl1.0.0_1.0.2n-1ubuntu5.7_amd64.deb ... Unpacking libssl1.0.0:amd64 (1.0.2n-1ubuntu5.7) ... Selecting previously unselected package openssh-client. Preparing to unpack .../11-openssh-client_1%3a7.6p1-4ubuntu0.5_amd64.deb ... Unpacking openssh-client (1:7.6p1-4ubuntu0.5) ... Selecting previously unselected package squashfs-tools. Preparing to unpack .../12-squashfs-tools_1%3a4.3-6ubuntu0.18.04.4_amd64.deb ... Unpacking squashfs-tools (1:4.3-6ubuntu0.18.04.4) ... Selecting previously unselected package snapd. Preparing to unpack .../13-snapd_2.51.1+18.04_amd64.deb ... Unpacking snapd (2.51.1+18.04) ... Setting up libedit2:amd64 (3.1-20170329-1) ... Setting up libssl1.0.0:amd64 (1.0.2n-1ubuntu5.7) ... Setting up mime-support (3.60ubuntu1) ... Setting up sudo (1.8.21p2-3ubuntu1.4) ... Setting up libbsd0:amd64 (0.8.7-1ubuntu0.1) ... Setting up libkrb5support0:amd64 (1.16-2ubuntu0.2) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Setting up systemd (237-3ubuntu10.52) ... Installing new version of config file /etc/dhcp/dhclient-enter-hooks.d/resolved ... Setting up libkeyutils1:amd64 (1.5.9-9.2ubuntu2) ... Setting up libmpdec2:amd64 (2.4.2-1ubuntu1) ... Setting up liblzo2-2:amd64 (2.08-1.2) ... Setting up libpython3.6-stdlib:amd64 (3.6.9-1~18.04ubuntu1.4) ... Setting up libk5crypto3:amd64 (1.16-2ubuntu0.2) ... Setting up python3.6 (3.6.9-1~18.04ubuntu1.4) ... Setting up squashfs-tools (1:4.3-6ubuntu0.18.04.4) ... Setting up libkrb5-3:amd64 (1.16-2ubuntu0.2) ... Setting up libpython3-stdlib:amd64 (3.6.7-1~18.04) ... Setting up python3 (3.6.7-1~18.04) ... running python rtupdate hooks for python3.6... running python post-rtupdate hooks for python3.6... Setting up apparmor (2.12-4ubuntu5.1) ... Created symlink /etc/systemd/system/sysinit.target.wants/apparmor.service → /lib/systemd/system/apparmor.service. Setting up libgssapi-krb5-2:amd64 (1.16-2ubuntu0.2) ... Setting up openssh-client (1:7.6p1-4ubuntu0.5) ... Setting up snapd (2.51.1+18.04) ... Created symlink /etc/systemd/system/multi-user.target.wants/snapd.apparmor.service → /lib/systemd/system/snapd.apparmor.service. Created symlink /etc/systemd/system/multi-user.target.wants/snapd.autoimport.service → /lib/systemd/system/snapd.autoimport.service. Created symlink /etc/systemd/system/multi-user.target.wants/snapd.core-fixup.service → /lib/systemd/system/snapd.core-fixup.service. Created symlink /etc/systemd/system/multi-user.target.wants/snapd.recovery-chooser-trigger.service → /lib/systemd/system/snapd.recovery-chooser-trigger.service. Created symlink /etc/systemd/system/multi-user.target.wants/snapd.seeded.service → /lib/systemd/system/snapd.seeded.service. Created symlink /etc/systemd/system/cloud-final.service.wants/snapd.seeded.service → /lib/systemd/system/snapd.seeded.service. Created symlink /etc/systemd/system/multi-user.target.wants/snapd.service → /lib/systemd/system/snapd.service. Created symlink /etc/systemd/system/timers.target.wants/snapd.snap-repair.timer → /lib/systemd/system/snapd.snap-repair.timer. Created symlink /etc/systemd/system/sockets.target.wants/snapd.socket → /lib/systemd/system/snapd.socket. Created symlink /etc/systemd/system/final.target.wants/snapd.system-shutdown.service → /lib/systemd/system/snapd.system-shutdown.service. /usr/sbin/policy-rc.d returned 101, not running 'start snapd.apparmor.service snapd.autoimport.service snapd.core-fixup.service snapd.failure.service snapd.recovery-chooser-trigger.service snapd.seeded.service snapd.service snapd.snap-repair.service snapd.snap-repair.timer snapd.socket snapd.system-shutdown.service' Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for systemd (237-3ubuntu10.52) ... Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Fetched 177 kB in 1s (185 kB/s) Reading package lists... Reading package lists... Building dependency tree... Reading state information... Calculating upgrade... The following packages will be upgraded: advancecomp base-files bash binutils binutils-common binutils-x86-64-linux-gnu bsdutils bzip2 ca-certificates cpp cpp-7 debconf dpkg dpkg-dev e2fsprogs fdisk g++ g++-7 gcc gcc-7 gcc-7-base gcc-8-base gpgv grep gzip libapparmor1 libasan4 libatomic1 libaudit-common libaudit1 libbinutils libblkid1 libbz2-1.0 libc-bin libc-dev-bin libc6 libc6-dev libcc1-0 libcilkrts5 libcom-err2 libcryptsetup12 libdb5.3 libdevmapper1.02.1 libdpkg-perl libext2fs2 libfdisk1 libgcc-7-dev libgcc1 libgcrypt20 libgnutls30 libgomp1 libhogweed4 libidn11 libidn2-0 libitm1 libjson-c3 libkmod2 liblsan0 liblz4-1 libmount1 libmpx2 libncurses5 libncursesw5 libnettle6 libp11-kit0 libpam-modules libpam-modules-bin libpam-runtime libpam0g libperl5.26 libpng16-16 libprocps6 libquadmath0 libseccomp2 libsmartcols1 libsqlite3-0 libss2 libstdc++-7-dev libstdc++6 libtinfo5 libtsan0 libubsan0 libunistring2 libuuid1 libzstd1 linux-libc-dev login mount ncurses-base ncurses-bin openssl passwd patch perl perl-base perl-modules-5.26 pkgbinarymangler procps systemd-sysv tar tzdata ubuntu-keyring util-linux 103 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 64.2 MB of archives. After this operation, 5154 kB of additional disk space will be used. Get:1 http://security.ubuntu.com/ubuntu bionic-security/main amd64 linux-libc-dev amd64 4.15.0-163.171 [994 kB] Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libc6-dev amd64 2.27-3ubuntu1.4 [2585 kB] Get:3 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libtsan0 amd64 8.4.0-1ubuntu1~18.04 [288 kB] Get:4 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libquadmath0 amd64 8.4.0-1ubuntu1~18.04 [134 kB] Get:5 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libmpx2 amd64 8.4.0-1ubuntu1~18.04 [11.6 kB] Get:6 http://security.ubuntu.com/ubuntu bionic-security/main amd64 liblsan0 amd64 8.4.0-1ubuntu1~18.04 [133 kB] Get:7 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libitm1 amd64 8.4.0-1ubuntu1~18.04 [27.9 kB] Get:8 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libgomp1 amd64 8.4.0-1ubuntu1~18.04 [76.5 kB] Get:9 http://security.ubuntu.com/ubuntu bionic-security/main amd64 gcc-8-base amd64 8.4.0-1ubuntu1~18.04 [18.7 kB] Get:10 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libgcc1 amd64 1:8.4.0-1ubuntu1~18.04 [40.6 kB] Get:11 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libcc1-0 amd64 8.4.0-1ubuntu1~18.04 [39.4 kB] Get:12 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libatomic1 amd64 8.4.0-1ubuntu1~18.04 [9192 B] Get:13 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libstdc++6 amd64 8.4.0-1ubuntu1~18.04 [400 kB] Get:14 http://security.ubuntu.com/ubuntu bionic-security/main amd64 bsdutils amd64 1:2.31.1-0.4ubuntu3.7 [60.2 kB] Get:15 http://security.ubuntu.com/ubuntu bionic-security/main amd64 tar amd64 1.29b-2ubuntu0.2 [234 kB] Get:16 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libext2fs2 amd64 1.44.1-1ubuntu1.3 [157 kB] Get:17 http://security.ubuntu.com/ubuntu bionic-security/main amd64 e2fsprogs amd64 1.44.1-1ubuntu1.3 [391 kB] Get:18 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libperl5.26 amd64 5.26.1-6ubuntu0.5 [3534 kB] Get:19 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libc-dev-bin amd64 2.27-3ubuntu1.4 [71.8 kB] Get:20 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libc6 amd64 2.27-3ubuntu1.4 [2832 kB] Get:21 http://security.ubuntu.com/ubuntu bionic-security/main amd64 perl amd64 5.26.1-6ubuntu0.5 [201 kB] Get:22 http://security.ubuntu.com/ubuntu bionic-security/main amd64 perl-base amd64 5.26.1-6ubuntu0.5 [1391 kB] Get:23 http://security.ubuntu.com/ubuntu bionic-security/main amd64 perl-modules-5.26 all 5.26.1-6ubuntu0.5 [2762 kB] Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 base-files amd64 10.1ubuntu2.11 [60.4 kB] Get:25 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 bash amd64 4.4.18-2ubuntu1.2 [614 kB] Get:26 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 dpkg amd64 1.19.0.5ubuntu2.3 [1136 kB] Get:27 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 grep amd64 3.1-2build1 [159 kB] Get:28 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gzip amd64 1.6-5ubuntu1.1 [89.8 kB] Get:29 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 login amd64 1:4.5-1ubuntu2 [308 kB] Get:30 http://security.ubuntu.com/ubuntu bionic-security/main amd64 bzip2 amd64 1.0.6-8.1ubuntu0.2 [33.9 kB] Get:31 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libbz2-1.0 amd64 1.0.6-8.1ubuntu0.2 [31.2 kB] Get:32 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libdb5.3 amd64 5.3.28-13.1ubuntu1.1 [672 kB] Get:33 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 ncurses-bin amd64 6.1-1ubuntu1.18.04 [163 kB] Get:34 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libncurses5 amd64 6.1-1ubuntu1.18.04 [95.1 kB] Get:35 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libtinfo5 amd64 6.1-1ubuntu1.18.04 [80.3 kB] Get:36 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libncursesw5 amd64 6.1-1ubuntu1.18.04 [117 kB] Get:37 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libuuid1 amd64 2.31.1-0.4ubuntu3.7 [20.1 kB] Get:38 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libc-bin amd64 2.27-3ubuntu1.4 [643 kB] Get:39 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libblkid1 amd64 2.31.1-0.4ubuntu3.7 [124 kB] Get:40 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libfdisk1 amd64 2.31.1-0.4ubuntu3.7 [164 kB] Get:41 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libmount1 amd64 2.31.1-0.4ubuntu3.7 [136 kB] Get:42 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libsmartcols1 amd64 2.31.1-0.4ubuntu3.7 [83.8 kB] Get:43 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 ncurses-base all 6.1-1ubuntu1.18.04 [17.8 kB] Get:44 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 debconf all 1.5.66ubuntu1 [124 kB] Get:45 http://security.ubuntu.com/ubuntu bionic-security/main amd64 fdisk amd64 2.31.1-0.4ubuntu3.7 [108 kB] Get:46 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libaudit-common all 1:2.8.2-1ubuntu1.1 [4068 B] Get:47 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libaudit1 amd64 1:2.8.2-1ubuntu1.1 [38.7 kB] Get:48 http://security.ubuntu.com/ubuntu bionic-security/main amd64 util-linux amd64 2.31.1-0.4ubuntu3.7 [904 kB] Get:49 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpam0g amd64 1.1.8-3.6ubuntu2.18.04.3 [55.0 kB] Get:50 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpam-modules-bin amd64 1.1.8-3.6ubuntu2.18.04.3 [40.3 kB] Get:51 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpam-modules amd64 1.1.8-3.6ubuntu2.18.04.3 [252 kB] Get:52 http://security.ubuntu.com/ubuntu bionic-security/main amd64 mount amd64 2.31.1-0.4ubuntu3.7 [107 kB] Get:53 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libcom-err2 amd64 1.44.1-1ubuntu1.3 [8848 B] Get:54 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libgcrypt20 amd64 1.8.1-4ubuntu1.3 [418 kB] Get:55 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 systemd-sysv amd64 237-3ubuntu10.52 [13.6 kB] Get:56 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpam-runtime all 1.1.8-3.6ubuntu2.18.04.3 [37.1 kB] Get:57 http://security.ubuntu.com/ubuntu bionic-security/main amd64 liblz4-1 amd64 0.0~r131-2ubuntu3.1 [48.5 kB] Get:58 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libss2 amd64 1.44.1-1ubuntu1.3 [11.1 kB] Get:59 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 passwd amd64 1:4.5-1ubuntu2 [816 kB] Get:60 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libzstd1 amd64 1.3.3+dfsg-2ubuntu1.2 [189 kB] Get:61 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libnettle6 amd64 3.4.1-0ubuntu0.18.04.1 [111 kB] Get:62 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpgv amd64 2.2.4-1ubuntu1.4 [198 kB] Get:63 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libhogweed4 amd64 3.4.1-0ubuntu0.18.04.1 [140 kB] Get:64 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libunistring2 amd64 0.9.9-0ubuntu2 [368 kB] Get:65 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libgnutls30 amd64 3.5.18-1ubuntu1.5 [646 kB] Get:66 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libidn2-0 amd64 2.0.4-1.1ubuntu0.2 [48.7 kB] Get:67 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libp11-kit0 amd64 0.23.9-2ubuntu0.1 [187 kB] Get:68 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libseccomp2 amd64 2.5.1-1ubuntu1~18.04.2 [43.0 kB] Get:69 http://security.ubuntu.com/ubuntu bionic-security/main amd64 ca-certificates all 20210119~18.04.2 [145 kB] Get:70 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 ubuntu-keyring all 2018.09.18.1~18.04.2 [22.3 kB] Get:71 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libprocps6 amd64 2:3.3.12-3ubuntu1.2 [31.8 kB] Get:72 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 procps amd64 2:3.3.12-3ubuntu1.2 [225 kB] Get:73 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libapparmor1 amd64 2.12-4ubuntu5.1 [31.3 kB] Get:74 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssl amd64 1.1.1-1ubuntu2.1~18.04.14 [613 kB] Get:75 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libjson-c3 amd64 0.12.1-1.3ubuntu0.3 [21.7 kB] Get:76 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libsqlite3-0 amd64 3.22.0-1ubuntu0.4 [499 kB] Get:77 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libdevmapper1.02.1 amd64 2:1.02.145-4.1ubuntu3.18.04.3 [127 kB] Get:78 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcryptsetup12 amd64 2:2.0.2-1ubuntu1.2 [134 kB] Get:79 http://security.ubuntu.com/ubuntu bionic-security/main amd64 tzdata all 2021e-0ubuntu0.18.04 [189 kB] Get:80 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libidn11 amd64 1.33-2.1ubuntu1.2 [46.6 kB] Get:81 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libkmod2 amd64 24-1ubuntu3.5 [40.2 kB] Get:82 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 dpkg-dev all 1.19.0.5ubuntu2.3 [607 kB] Get:83 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libpng16-16 amd64 1.6.34-1ubuntu0.18.04.2 [176 kB] Get:84 http://security.ubuntu.com/ubuntu bionic-security/main amd64 advancecomp amd64 2.1-1ubuntu0.18.04.1 [200 kB] Get:85 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libdpkg-perl all 1.19.0.5ubuntu2.3 [211 kB] Get:86 http://security.ubuntu.com/ubuntu bionic-security/main amd64 binutils-x86-64-linux-gnu amd64 2.30-21ubuntu1~18.04.7 [1839 kB] Get:87 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 pkgbinarymangler all 138.18.04.1 [53.2 kB] Get:88 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libbinutils amd64 2.30-21ubuntu1~18.04.7 [489 kB] Get:89 http://security.ubuntu.com/ubuntu bionic-security/main amd64 binutils amd64 2.30-21ubuntu1~18.04.7 [3388 B] Get:90 http://security.ubuntu.com/ubuntu bionic-security/main amd64 binutils-common amd64 2.30-21ubuntu1~18.04.7 [197 kB] Get:91 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libubsan0 amd64 7.5.0-3ubuntu1~18.04 [126 kB] Get:92 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libasan4 amd64 7.5.0-3ubuntu1~18.04 [358 kB] Get:93 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libcilkrts5 amd64 7.5.0-3ubuntu1~18.04 [42.5 kB] Get:94 http://security.ubuntu.com/ubuntu bionic-security/main amd64 g++-7 amd64 7.5.0-3ubuntu1~18.04 [9697 kB] Get:95 http://security.ubuntu.com/ubuntu bionic-security/main amd64 gcc-7 amd64 7.5.0-3ubuntu1~18.04 [9381 kB] Get:96 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libstdc++-7-dev amd64 7.5.0-3ubuntu1~18.04 [1471 kB] Get:97 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libgcc-7-dev amd64 7.5.0-3ubuntu1~18.04 [2378 kB] Get:98 http://security.ubuntu.com/ubuntu bionic-security/main amd64 cpp-7 amd64 7.5.0-3ubuntu1~18.04 [8591 kB] Get:99 http://security.ubuntu.com/ubuntu bionic-security/main amd64 gcc-7-base amd64 7.5.0-3ubuntu1~18.04 [18.3 kB] Get:100 http://security.ubuntu.com/ubuntu bionic-security/main amd64 cpp amd64 4:7.4.0-1ubuntu2.3 [27.7 kB] Get:101 http://security.ubuntu.com/ubuntu bionic-security/main amd64 patch amd64 2.7.6-2ubuntu1.1 [102 kB] Get:102 http://security.ubuntu.com/ubuntu bionic-security/main amd64 gcc amd64 4:7.4.0-1ubuntu2.3 [5184 B] Get:103 http://security.ubuntu.com/ubuntu bionic-security/main amd64 g++ amd64 4:7.4.0-1ubuntu2.3 [1568 B] debconf: delaying package configuration, since apt-utils is not installed Fetched 64.2 MB in 2s (38.1 MB/s) (Reading database ... 13914 files and directories currently installed.) Preparing to unpack .../0-libc6-dev_2.27-3ubuntu1.4_amd64.deb ... Unpacking libc6-dev:amd64 (2.27-3ubuntu1.4) over (2.27-3ubuntu1) ... Preparing to unpack .../1-libc-dev-bin_2.27-3ubuntu1.4_amd64.deb ... Unpacking libc-dev-bin (2.27-3ubuntu1.4) over (2.27-3ubuntu1) ... Preparing to unpack .../2-linux-libc-dev_4.15.0-163.171_amd64.deb ... Unpacking linux-libc-dev:amd64 (4.15.0-163.171) over (4.15.0-20.21) ... Preparing to unpack .../3-libtsan0_8.4.0-1ubuntu1~18.04_amd64.deb ... Unpacking libtsan0:amd64 (8.4.0-1ubuntu1~18.04) over (8-20180414-1ubuntu2) ... Preparing to unpack .../4-libquadmath0_8.4.0-1ubuntu1~18.04_amd64.deb ... Unpacking libquadmath0:amd64 (8.4.0-1ubuntu1~18.04) over (8-20180414-1ubuntu2) ... Preparing to unpack .../5-libmpx2_8.4.0-1ubuntu1~18.04_amd64.deb ... Unpacking libmpx2:amd64 (8.4.0-1ubuntu1~18.04) over (8-20180414-1ubuntu2) ... Preparing to unpack .../6-liblsan0_8.4.0-1ubuntu1~18.04_amd64.deb ... Unpacking liblsan0:amd64 (8.4.0-1ubuntu1~18.04) over (8-20180414-1ubuntu2) ... Preparing to unpack .../7-libitm1_8.4.0-1ubuntu1~18.04_amd64.deb ... Unpacking libitm1:amd64 (8.4.0-1ubuntu1~18.04) over (8-20180414-1ubuntu2) ... Preparing to unpack .../8-libgomp1_8.4.0-1ubuntu1~18.04_amd64.deb ... Unpacking libgomp1:amd64 (8.4.0-1ubuntu1~18.04) over (8-20180414-1ubuntu2) ... Preparing to unpack .../9-gcc-8-base_8.4.0-1ubuntu1~18.04_amd64.deb ... Unpacking gcc-8-base:amd64 (8.4.0-1ubuntu1~18.04) over (8-20180414-1ubuntu2) ... Setting up gcc-8-base:amd64 (8.4.0-1ubuntu1~18.04) ... (Reading database ... 13914 files and directories currently installed.) Preparing to unpack .../libgcc1_1%3a8.4.0-1ubuntu1~18.04_amd64.deb ... Unpacking libgcc1:amd64 (1:8.4.0-1ubuntu1~18.04) over (1:8-20180414-1ubuntu2) ... Setting up libgcc1:amd64 (1:8.4.0-1ubuntu1~18.04) ... (Reading database ... 13914 files and directories currently installed.) Preparing to unpack .../libcc1-0_8.4.0-1ubuntu1~18.04_amd64.deb ... Unpacking libcc1-0:amd64 (8.4.0-1ubuntu1~18.04) over (8-20180414-1ubuntu2) ... Preparing to unpack .../libatomic1_8.4.0-1ubuntu1~18.04_amd64.deb ... Unpacking libatomic1:amd64 (8.4.0-1ubuntu1~18.04) over (8-20180414-1ubuntu2) ... Preparing to unpack .../libstdc++6_8.4.0-1ubuntu1~18.04_amd64.deb ... Unpacking libstdc++6:amd64 (8.4.0-1ubuntu1~18.04) over (8-20180414-1ubuntu2) ... Setting up libstdc++6:amd64 (8.4.0-1ubuntu1~18.04) ... (Reading database ... 13914 files and directories currently installed.) Preparing to unpack .../libc6_2.27-3ubuntu1.4_amd64.deb ... Unpacking libc6:amd64 (2.27-3ubuntu1.4) over (2.27-3ubuntu1) ... Setting up libc6:amd64 (2.27-3ubuntu1.4) ... (Reading database ... 13914 files and directories currently installed.) Preparing to unpack .../base-files_10.1ubuntu2.11_amd64.deb ... /usr/sbin/policy-rc.d returned 101, not running 'stop motd-news.service' /usr/sbin/policy-rc.d returned 101, not running 'stop motd-news.timer' Unpacking base-files (10.1ubuntu2.11) over (10.1ubuntu2) ... Setting up base-files (10.1ubuntu2.11) ... Installing new version of config file /etc/issue ... Installing new version of config file /etc/issue.net ... Installing new version of config file /etc/lsb-release ... Installing new version of config file /etc/update-motd.d/50-motd-news ... /usr/sbin/policy-rc.d returned 101, not running 'start motd-news.timer' /usr/sbin/policy-rc.d returned 101, not running 'start motd-news.service' Removing obsolete conffile /etc/default/motd-news ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../bash_4.4.18-2ubuntu1.2_amd64.deb ... Unpacking bash (4.4.18-2ubuntu1.2) over (4.4.18-2ubuntu1) ... Setting up bash (4.4.18-2ubuntu1.2) ... update-alternatives: using /usr/share/man/man7/bash-builtins.7.gz to provide /usr/share/man/man7/builtins.7.gz (builtins.7.gz) in auto mode (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../bsdutils_1%3a2.31.1-0.4ubuntu3.7_amd64.deb ... Unpacking bsdutils (1:2.31.1-0.4ubuntu3.7) over (1:2.31.1-0.4ubuntu3) ... Setting up bsdutils (1:2.31.1-0.4ubuntu3.7) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../tar_1.29b-2ubuntu0.2_amd64.deb ... Unpacking tar (1.29b-2ubuntu0.2) over (1.29b-2) ... Setting up tar (1.29b-2ubuntu0.2) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../dpkg_1.19.0.5ubuntu2.3_amd64.deb ... Unpacking dpkg (1.19.0.5ubuntu2.3) over (1.19.0.5ubuntu2) ... Setting up dpkg (1.19.0.5ubuntu2.3) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../libext2fs2_1.44.1-1ubuntu1.3_amd64.deb ... Unpacking libext2fs2:amd64 (1.44.1-1ubuntu1.3) over (1.44.1-1) ... Setting up libext2fs2:amd64 (1.44.1-1ubuntu1.3) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../e2fsprogs_1.44.1-1ubuntu1.3_amd64.deb ... Unpacking e2fsprogs (1.44.1-1ubuntu1.3) over (1.44.1-1) ... Setting up e2fsprogs (1.44.1-1ubuntu1.3) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../grep_3.1-2build1_amd64.deb ... Unpacking grep (3.1-2build1) over (3.1-2) ... Setting up grep (3.1-2build1) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../gzip_1.6-5ubuntu1.1_amd64.deb ... Unpacking gzip (1.6-5ubuntu1.1) over (1.6-5ubuntu1) ... Setting up gzip (1.6-5ubuntu1.1) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../login_1%3a4.5-1ubuntu2_amd64.deb ... Unpacking login (1:4.5-1ubuntu2) over (1:4.5-1ubuntu1) ... Setting up login (1:4.5-1ubuntu2) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../ncurses-bin_6.1-1ubuntu1.18.04_amd64.deb ... Unpacking ncurses-bin (6.1-1ubuntu1.18.04) over (6.1-1ubuntu1) ... Setting up ncurses-bin (6.1-1ubuntu1.18.04) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../libperl5.26_5.26.1-6ubuntu0.5_amd64.deb ... Unpacking libperl5.26:amd64 (5.26.1-6ubuntu0.5) over (5.26.1-6) ... Preparing to unpack .../perl_5.26.1-6ubuntu0.5_amd64.deb ... Unpacking perl (5.26.1-6ubuntu0.5) over (5.26.1-6) ... Preparing to unpack .../perl-base_5.26.1-6ubuntu0.5_amd64.deb ... Unpacking perl-base (5.26.1-6ubuntu0.5) over (5.26.1-6) ... Setting up perl-base (5.26.1-6ubuntu0.5) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../perl-modules-5.26_5.26.1-6ubuntu0.5_all.deb ... Unpacking perl-modules-5.26 (5.26.1-6ubuntu0.5) over (5.26.1-6) ... Preparing to unpack .../bzip2_1.0.6-8.1ubuntu0.2_amd64.deb ... Unpacking bzip2 (1.0.6-8.1ubuntu0.2) over (1.0.6-8.1) ... Preparing to unpack .../libbz2-1.0_1.0.6-8.1ubuntu0.2_amd64.deb ... Unpacking libbz2-1.0:amd64 (1.0.6-8.1ubuntu0.2) over (1.0.6-8.1) ... Setting up libbz2-1.0:amd64 (1.0.6-8.1ubuntu0.2) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../libdb5.3_5.3.28-13.1ubuntu1.1_amd64.deb ... Unpacking libdb5.3:amd64 (5.3.28-13.1ubuntu1.1) over (5.3.28-13.1ubuntu1) ... Setting up libdb5.3:amd64 (5.3.28-13.1ubuntu1.1) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../libuuid1_2.31.1-0.4ubuntu3.7_amd64.deb ... Unpacking libuuid1:amd64 (2.31.1-0.4ubuntu3.7) over (2.31.1-0.4ubuntu3) ... Setting up libuuid1:amd64 (2.31.1-0.4ubuntu3.7) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../libblkid1_2.31.1-0.4ubuntu3.7_amd64.deb ... Unpacking libblkid1:amd64 (2.31.1-0.4ubuntu3.7) over (2.31.1-0.4ubuntu3) ... Setting up libblkid1:amd64 (2.31.1-0.4ubuntu3.7) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../libfdisk1_2.31.1-0.4ubuntu3.7_amd64.deb ... Unpacking libfdisk1:amd64 (2.31.1-0.4ubuntu3.7) over (2.31.1-0.4ubuntu3) ... Setting up libfdisk1:amd64 (2.31.1-0.4ubuntu3.7) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../libmount1_2.31.1-0.4ubuntu3.7_amd64.deb ... Unpacking libmount1:amd64 (2.31.1-0.4ubuntu3.7) over (2.31.1-0.4ubuntu3) ... Setting up libmount1:amd64 (2.31.1-0.4ubuntu3.7) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../libncurses5_6.1-1ubuntu1.18.04_amd64.deb ... Unpacking libncurses5:amd64 (6.1-1ubuntu1.18.04) over (6.1-1ubuntu1) ... Preparing to unpack .../libtinfo5_6.1-1ubuntu1.18.04_amd64.deb ... Unpacking libtinfo5:amd64 (6.1-1ubuntu1.18.04) over (6.1-1ubuntu1) ... Setting up libtinfo5:amd64 (6.1-1ubuntu1.18.04) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../libncursesw5_6.1-1ubuntu1.18.04_amd64.deb ... Unpacking libncursesw5:amd64 (6.1-1ubuntu1.18.04) over (6.1-1ubuntu1) ... Setting up libncursesw5:amd64 (6.1-1ubuntu1.18.04) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../libsmartcols1_2.31.1-0.4ubuntu3.7_amd64.deb ... Unpacking libsmartcols1:amd64 (2.31.1-0.4ubuntu3.7) over (2.31.1-0.4ubuntu3) ... Setting up libsmartcols1:amd64 (2.31.1-0.4ubuntu3.7) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../fdisk_2.31.1-0.4ubuntu3.7_amd64.deb ... Unpacking fdisk (2.31.1-0.4ubuntu3.7) over (2.31.1-0.4ubuntu3) ... Setting up fdisk (2.31.1-0.4ubuntu3.7) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../util-linux_2.31.1-0.4ubuntu3.7_amd64.deb ... Unpacking util-linux (2.31.1-0.4ubuntu3.7) over (2.31.1-0.4ubuntu3) ... Setting up util-linux (2.31.1-0.4ubuntu3.7) ... /usr/sbin/policy-rc.d returned 101, not running 'restart fstrim.timer' /usr/sbin/policy-rc.d returned 101, not running 'try-restart fstrim.service fstrim.timer' (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../libc-bin_2.27-3ubuntu1.4_amd64.deb ... Unpacking libc-bin (2.27-3ubuntu1.4) over (2.27-3ubuntu1) ... Setting up libc-bin (2.27-3ubuntu1.4) ... (Reading database ... 13915 files and directories currently installed.) Preparing to unpack .../ncurses-base_6.1-1ubuntu1.18.04_all.deb ... Unpacking ncurses-base (6.1-1ubuntu1.18.04) over (6.1-1ubuntu1) ... Setting up ncurses-base (6.1-1ubuntu1.18.04) ... (Reading database ... 13917 files and directories currently installed.) Preparing to unpack .../debconf_1.5.66ubuntu1_all.deb ... Unpacking debconf (1.5.66ubuntu1) over (1.5.66) ... Setting up debconf (1.5.66ubuntu1) ... (Reading database ... 13917 files and directories currently installed.) Preparing to unpack .../libaudit-common_1%3a2.8.2-1ubuntu1.1_all.deb ... Unpacking libaudit-common (1:2.8.2-1ubuntu1.1) over (1:2.8.2-1ubuntu1) ... Setting up libaudit-common (1:2.8.2-1ubuntu1.1) ... (Reading database ... 13917 files and directories currently installed.) Preparing to unpack .../libaudit1_1%3a2.8.2-1ubuntu1.1_amd64.deb ... Unpacking libaudit1:amd64 (1:2.8.2-1ubuntu1.1) over (1:2.8.2-1ubuntu1) ... Setting up libaudit1:amd64 (1:2.8.2-1ubuntu1.1) ... (Reading database ... 13917 files and directories currently installed.) Preparing to unpack .../libpam0g_1.1.8-3.6ubuntu2.18.04.3_amd64.deb ... Unpacking libpam0g:amd64 (1.1.8-3.6ubuntu2.18.04.3) over (1.1.8-3.6ubuntu2) ... Setting up libpam0g:amd64 (1.1.8-3.6ubuntu2.18.04.3) ... (Reading database ... 13917 files and directories currently installed.) Preparing to unpack .../libpam-modules-bin_1.1.8-3.6ubuntu2.18.04.3_amd64.deb ... Unpacking libpam-modules-bin (1.1.8-3.6ubuntu2.18.04.3) over (1.1.8-3.6ubuntu2) ... Setting up libpam-modules-bin (1.1.8-3.6ubuntu2.18.04.3) ... (Reading database ... 13919 files and directories currently installed.) Preparing to unpack .../libpam-modules_1.1.8-3.6ubuntu2.18.04.3_amd64.deb ... Unpacking libpam-modules:amd64 (1.1.8-3.6ubuntu2.18.04.3) over (1.1.8-3.6ubuntu2) ... Setting up libpam-modules:amd64 (1.1.8-3.6ubuntu2.18.04.3) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../mount_2.31.1-0.4ubuntu3.7_amd64.deb ... Unpacking mount (2.31.1-0.4ubuntu3.7) over (2.31.1-0.4ubuntu3) ... Preparing to unpack .../systemd-sysv_237-3ubuntu10.52_amd64.deb ... Unpacking systemd-sysv (237-3ubuntu10.52) over (237-3ubuntu10) ... Preparing to unpack .../libcom-err2_1.44.1-1ubuntu1.3_amd64.deb ... Unpacking libcom-err2:amd64 (1.44.1-1ubuntu1.3) over (1.44.1-1) ... Setting up libcom-err2:amd64 (1.44.1-1ubuntu1.3) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../libgcrypt20_1.8.1-4ubuntu1.3_amd64.deb ... Unpacking libgcrypt20:amd64 (1.8.1-4ubuntu1.3) over (1.8.1-4ubuntu1) ... Setting up libgcrypt20:amd64 (1.8.1-4ubuntu1.3) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../liblz4-1_0.0~r131-2ubuntu3.1_amd64.deb ... Unpacking liblz4-1:amd64 (0.0~r131-2ubuntu3.1) over (0.0~r131-2ubuntu3) ... Setting up liblz4-1:amd64 (0.0~r131-2ubuntu3.1) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../libpam-runtime_1.1.8-3.6ubuntu2.18.04.3_all.deb ... Unpacking libpam-runtime (1.1.8-3.6ubuntu2.18.04.3) over (1.1.8-3.6ubuntu2) ... Setting up libpam-runtime (1.1.8-3.6ubuntu2.18.04.3) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../libss2_1.44.1-1ubuntu1.3_amd64.deb ... Unpacking libss2:amd64 (1.44.1-1ubuntu1.3) over (1.44.1-1) ... Setting up libss2:amd64 (1.44.1-1ubuntu1.3) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../libzstd1_1.3.3+dfsg-2ubuntu1.2_amd64.deb ... Unpacking libzstd1:amd64 (1.3.3+dfsg-2ubuntu1.2) over (1.3.3+dfsg-2ubuntu1) ... Setting up libzstd1:amd64 (1.3.3+dfsg-2ubuntu1.2) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../passwd_1%3a4.5-1ubuntu2_amd64.deb ... Unpacking passwd (1:4.5-1ubuntu2) over (1:4.5-1ubuntu1) ... Setting up passwd (1:4.5-1ubuntu2) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../gpgv_2.2.4-1ubuntu1.4_amd64.deb ... Unpacking gpgv (2.2.4-1ubuntu1.4) over (2.2.4-1ubuntu1) ... Setting up gpgv (2.2.4-1ubuntu1.4) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../libnettle6_3.4.1-0ubuntu0.18.04.1_amd64.deb ... Unpacking libnettle6:amd64 (3.4.1-0ubuntu0.18.04.1) over (3.4-1) ... Setting up libnettle6:amd64 (3.4.1-0ubuntu0.18.04.1) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../libhogweed4_3.4.1-0ubuntu0.18.04.1_amd64.deb ... Unpacking libhogweed4:amd64 (3.4.1-0ubuntu0.18.04.1) over (3.4-1) ... Setting up libhogweed4:amd64 (3.4.1-0ubuntu0.18.04.1) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../libunistring2_0.9.9-0ubuntu2_amd64.deb ... Unpacking libunistring2:amd64 (0.9.9-0ubuntu2) over (0.9.9-0ubuntu1) ... Setting up libunistring2:amd64 (0.9.9-0ubuntu2) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../libidn2-0_2.0.4-1.1ubuntu0.2_amd64.deb ... Unpacking libidn2-0:amd64 (2.0.4-1.1ubuntu0.2) over (2.0.4-1.1build2) ... Setting up libidn2-0:amd64 (2.0.4-1.1ubuntu0.2) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../libp11-kit0_0.23.9-2ubuntu0.1_amd64.deb ... Unpacking libp11-kit0:amd64 (0.23.9-2ubuntu0.1) over (0.23.9-2) ... Setting up libp11-kit0:amd64 (0.23.9-2ubuntu0.1) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../libgnutls30_3.5.18-1ubuntu1.5_amd64.deb ... Unpacking libgnutls30:amd64 (3.5.18-1ubuntu1.5) over (3.5.18-1ubuntu1) ... Setting up libgnutls30:amd64 (3.5.18-1ubuntu1.5) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../libseccomp2_2.5.1-1ubuntu1~18.04.2_amd64.deb ... Unpacking libseccomp2:amd64 (2.5.1-1ubuntu1~18.04.2) over (2.3.1-2.1ubuntu4) ... Setting up libseccomp2:amd64 (2.5.1-1ubuntu1~18.04.2) ... (Reading database ... 13923 files and directories currently installed.) Preparing to unpack .../ubuntu-keyring_2018.09.18.1~18.04.2_all.deb ... Unpacking ubuntu-keyring (2018.09.18.1~18.04.2) over (2018.02.28) ... Setting up ubuntu-keyring (2018.09.18.1~18.04.2) ... (Reading database ... 13924 files and directories currently installed.) Preparing to unpack .../00-libprocps6_2%3a3.3.12-3ubuntu1.2_amd64.deb ... Unpacking libprocps6:amd64 (2:3.3.12-3ubuntu1.2) over (2:3.3.12-3ubuntu1) ... Preparing to unpack .../01-procps_2%3a3.3.12-3ubuntu1.2_amd64.deb ... Unpacking procps (2:3.3.12-3ubuntu1.2) over (2:3.3.12-3ubuntu1) ... Preparing to unpack .../02-openssl_1.1.1-1ubuntu2.1~18.04.14_amd64.deb ... Unpacking openssl (1.1.1-1ubuntu2.1~18.04.14) over (1.1.0g-2ubuntu4) ... Preparing to unpack .../03-ca-certificates_20210119~18.04.2_all.deb ... Unpacking ca-certificates (20210119~18.04.2) over (20180409) ... Preparing to unpack .../04-libapparmor1_2.12-4ubuntu5.1_amd64.deb ... Unpacking libapparmor1:amd64 (2.12-4ubuntu5.1) over (2.12-4ubuntu5) ... Preparing to unpack .../05-libdevmapper1.02.1_2%3a1.02.145-4.1ubuntu3.18.04.3_amd64.deb ... Unpacking libdevmapper1.02.1:amd64 (2:1.02.145-4.1ubuntu3.18.04.3) over (2:1.02.145-4.1ubuntu3) ... Preparing to unpack .../06-libjson-c3_0.12.1-1.3ubuntu0.3_amd64.deb ... Unpacking libjson-c3:amd64 (0.12.1-1.3ubuntu0.3) over (0.12.1-1.3) ... Preparing to unpack .../07-libcryptsetup12_2%3a2.0.2-1ubuntu1.2_amd64.deb ... Unpacking libcryptsetup12:amd64 (2:2.0.2-1ubuntu1.2) over (2:2.0.2-1ubuntu1) ... Preparing to unpack .../08-libidn11_1.33-2.1ubuntu1.2_amd64.deb ... Unpacking libidn11:amd64 (1.33-2.1ubuntu1.2) over (1.33-2.1ubuntu1) ... Preparing to unpack .../09-libkmod2_24-1ubuntu3.5_amd64.deb ... Unpacking libkmod2:amd64 (24-1ubuntu3.5) over (24-1ubuntu3) ... Preparing to unpack .../10-libsqlite3-0_3.22.0-1ubuntu0.4_amd64.deb ... Unpacking libsqlite3-0:amd64 (3.22.0-1ubuntu0.4) over (3.22.0-1) ... Preparing to unpack .../11-tzdata_2021e-0ubuntu0.18.04_all.deb ... Unpacking tzdata (2021e-0ubuntu0.18.04) over (2018d-1) ... Preparing to unpack .../12-libpng16-16_1.6.34-1ubuntu0.18.04.2_amd64.deb ... Unpacking libpng16-16:amd64 (1.6.34-1ubuntu0.18.04.2) over (1.6.34-1) ... Preparing to unpack .../13-advancecomp_2.1-1ubuntu0.18.04.1_amd64.deb ... Unpacking advancecomp (2.1-1ubuntu0.18.04.1) over (2.1-1) ... Preparing to unpack .../14-binutils-x86-64-linux-gnu_2.30-21ubuntu1~18.04.7_amd64.deb ... Unpacking binutils-x86-64-linux-gnu (2.30-21ubuntu1~18.04.7) over (2.30-15ubuntu1) ... Preparing to unpack .../15-libbinutils_2.30-21ubuntu1~18.04.7_amd64.deb ... Unpacking libbinutils:amd64 (2.30-21ubuntu1~18.04.7) over (2.30-15ubuntu1) ... Preparing to unpack .../16-binutils_2.30-21ubuntu1~18.04.7_amd64.deb ... Unpacking binutils (2.30-21ubuntu1~18.04.7) over (2.30-15ubuntu1) ... Preparing to unpack .../17-binutils-common_2.30-21ubuntu1~18.04.7_amd64.deb ... Unpacking binutils-common:amd64 (2.30-21ubuntu1~18.04.7) over (2.30-15ubuntu1) ... Preparing to unpack .../18-libubsan0_7.5.0-3ubuntu1~18.04_amd64.deb ... Unpacking libubsan0:amd64 (7.5.0-3ubuntu1~18.04) over (7.3.0-16ubuntu3) ... Preparing to unpack .../19-libasan4_7.5.0-3ubuntu1~18.04_amd64.deb ... Unpacking libasan4:amd64 (7.5.0-3ubuntu1~18.04) over (7.3.0-16ubuntu3) ... Preparing to unpack .../20-libcilkrts5_7.5.0-3ubuntu1~18.04_amd64.deb ... Unpacking libcilkrts5:amd64 (7.5.0-3ubuntu1~18.04) over (7.3.0-16ubuntu3) ... Preparing to unpack .../21-g++-7_7.5.0-3ubuntu1~18.04_amd64.deb ... Unpacking g++-7 (7.5.0-3ubuntu1~18.04) over (7.3.0-16ubuntu3) ... Preparing to unpack .../22-gcc-7_7.5.0-3ubuntu1~18.04_amd64.deb ... Unpacking gcc-7 (7.5.0-3ubuntu1~18.04) over (7.3.0-16ubuntu3) ... Preparing to unpack .../23-libstdc++-7-dev_7.5.0-3ubuntu1~18.04_amd64.deb ... Unpacking libstdc++-7-dev:amd64 (7.5.0-3ubuntu1~18.04) over (7.3.0-16ubuntu3) ... Preparing to unpack .../24-libgcc-7-dev_7.5.0-3ubuntu1~18.04_amd64.deb ... Unpacking libgcc-7-dev:amd64 (7.5.0-3ubuntu1~18.04) over (7.3.0-16ubuntu3) ... Preparing to unpack .../25-cpp-7_7.5.0-3ubuntu1~18.04_amd64.deb ... Unpacking cpp-7 (7.5.0-3ubuntu1~18.04) over (7.3.0-16ubuntu3) ... Preparing to unpack .../26-gcc-7-base_7.5.0-3ubuntu1~18.04_amd64.deb ... Unpacking gcc-7-base:amd64 (7.5.0-3ubuntu1~18.04) over (7.3.0-16ubuntu3) ... Preparing to unpack .../27-cpp_4%3a7.4.0-1ubuntu2.3_amd64.deb ... Unpacking cpp (4:7.4.0-1ubuntu2.3) over (4:7.3.0-3ubuntu2) ... Preparing to unpack .../28-dpkg-dev_1.19.0.5ubuntu2.3_all.deb ... Unpacking dpkg-dev (1.19.0.5ubuntu2.3) over (1.19.0.5ubuntu2) ... Preparing to unpack .../29-libdpkg-perl_1.19.0.5ubuntu2.3_all.deb ... Unpacking libdpkg-perl (1.19.0.5ubuntu2.3) over (1.19.0.5ubuntu2) ... Preparing to unpack .../30-patch_2.7.6-2ubuntu1.1_amd64.deb ... Unpacking patch (2.7.6-2ubuntu1.1) over (2.7.6-2ubuntu1) ... Preparing to unpack .../31-gcc_4%3a7.4.0-1ubuntu2.3_amd64.deb ... Unpacking gcc (4:7.4.0-1ubuntu2.3) over (4:7.3.0-3ubuntu2) ... Preparing to unpack .../32-g++_4%3a7.4.0-1ubuntu2.3_amd64.deb ... Unpacking g++ (4:7.4.0-1ubuntu2.3) over (4:7.3.0-3ubuntu2) ... Preparing to unpack .../33-pkgbinarymangler_138.18.04.1_all.deb ... Unpacking pkgbinarymangler (138.18.04.1) over (138) ... Setting up libquadmath0:amd64 (8.4.0-1ubuntu1~18.04) ... Setting up libncurses5:amd64 (6.1-1ubuntu1.18.04) ... Setting up libgomp1:amd64 (8.4.0-1ubuntu1~18.04) ... Setting up libatomic1:amd64 (8.4.0-1ubuntu1~18.04) ... Setting up libcc1-0:amd64 (8.4.0-1ubuntu1~18.04) ... Setting up libpng16-16:amd64 (1.6.34-1ubuntu0.18.04.2) ... Setting up libjson-c3:amd64 (0.12.1-1.3ubuntu0.3) ... Setting up tzdata (2021e-0ubuntu0.18.04) ... Current default time zone: 'Etc/UTC' Local time is now: Tue Dec 14 17:00:28 UTC 2021. Universal Time is now: Tue Dec 14 17:00:28 UTC 2021. Run 'dpkg-reconfigure tzdata' if you wish to change it. Setting up systemd-sysv (237-3ubuntu10.52) ... Setting up libtsan0:amd64 (8.4.0-1ubuntu1~18.04) ... Setting up linux-libc-dev:amd64 (4.15.0-163.171) ... Setting up mount (2.31.1-0.4ubuntu3.7) ... Setting up advancecomp (2.1-1ubuntu0.18.04.1) ... Setting up libdevmapper1.02.1:amd64 (2:1.02.145-4.1ubuntu3.18.04.3) ... Setting up perl-modules-5.26 (5.26.1-6ubuntu0.5) ... Setting up libprocps6:amd64 (2:3.3.12-3ubuntu1.2) ... Setting up libkmod2:amd64 (24-1ubuntu3.5) ... Setting up bzip2 (1.0.6-8.1ubuntu0.2) ... Setting up liblsan0:amd64 (8.4.0-1ubuntu1~18.04) ... Setting up procps (2:3.3.12-3ubuntu1.2) ... Setting up gcc-7-base:amd64 (7.5.0-3ubuntu1~18.04) ... Setting up binutils-common:amd64 (2.30-21ubuntu1~18.04.7) ... Setting up libmpx2:amd64 (8.4.0-1ubuntu1~18.04) ... Setting up patch (2.7.6-2ubuntu1.1) ... Setting up libperl5.26:amd64 (5.26.1-6ubuntu0.5) ... Setting up libapparmor1:amd64 (2.12-4ubuntu5.1) ... Setting up openssl (1.1.1-1ubuntu2.1~18.04.14) ... Installing new version of config file /etc/ssl/openssl.cnf ... Setting up libsqlite3-0:amd64 (3.22.0-1ubuntu0.4) ... Setting up libc-dev-bin (2.27-3ubuntu1.4) ... Setting up ca-certificates (20210119~18.04.2) ... Updating certificates in /etc/ssl/certs... 23 added, 28 removed; done. Setting up libc6-dev:amd64 (2.27-3ubuntu1.4) ... Setting up libitm1:amd64 (8.4.0-1ubuntu1~18.04) ... Setting up libidn11:amd64 (1.33-2.1ubuntu1.2) ... Setting up libcryptsetup12:amd64 (2:2.0.2-1ubuntu1.2) ... Setting up pkgbinarymangler (138.18.04.1) ... Setting up libasan4:amd64 (7.5.0-3ubuntu1~18.04) ... Setting up libbinutils:amd64 (2.30-21ubuntu1~18.04.7) ... Setting up libcilkrts5:amd64 (7.5.0-3ubuntu1~18.04) ... Setting up libubsan0:amd64 (7.5.0-3ubuntu1~18.04) ... Setting up libgcc-7-dev:amd64 (7.5.0-3ubuntu1~18.04) ... Setting up cpp-7 (7.5.0-3ubuntu1~18.04) ... Setting up libstdc++-7-dev:amd64 (7.5.0-3ubuntu1~18.04) ... Setting up perl (5.26.1-6ubuntu0.5) ... Setting up binutils-x86-64-linux-gnu (2.30-21ubuntu1~18.04.7) ... Setting up cpp (4:7.4.0-1ubuntu2.3) ... Setting up libdpkg-perl (1.19.0.5ubuntu2.3) ... Setting up binutils (2.30-21ubuntu1~18.04.7) ... Setting up gcc-7 (7.5.0-3ubuntu1~18.04) ... Setting up g++-7 (7.5.0-3ubuntu1~18.04) ... Setting up gcc (4:7.4.0-1ubuntu2.3) ... Setting up dpkg-dev (1.19.0.5ubuntu2.3) ... Setting up g++ (4:7.4.0-1ubuntu2.3) ... Processing triggers for libc-bin (2.27-3ubuntu1.4) ... Processing triggers for systemd (237-3ubuntu10.52) ... Processing triggers for mime-support (3.60ubuntu1) ... Processing triggers for ca-certificates (20210119~18.04.2) ... Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. Reading package lists... Building dependency tree... Reading state information... The following NEW packages will be installed: apt-transport-https 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 4348 B of archives. After this operation, 154 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 apt-transport-https all 1.6.14 [4348 B] debconf: delaying package configuration, since apt-utils is not installed Fetched 4348 B in 0s (40.0 kB/s) Selecting previously unselected package apt-transport-https. (Reading database ... 13931 files and directories currently installed.) Preparing to unpack .../apt-transport-https_1.6.14_all.deb ... Unpacking apt-transport-https (1.6.14) ... Setting up apt-transport-https (1.6.14) ... Waiting for network to be ready... 2021-12-14T17:01:19Z INFO Waiting for automatic snapd restart... snapd 2.53.4 from Canonical* installed "snapd" switched to the "latest/stable" channel core18 20211028 from Canonical* installed "core18" switched to the "latest/stable" channel core20 20211129 from Canonical* installed "core20" switched to the "latest/stable" channel snapcraft 6.0 from Canonical* installed "snapcraft" switched to the "latest/stable" channel Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease Reading package lists... Installing build dependencies: git=1:2.17.1-1ubuntu0.9 git-man=1:2.17.1-1ubuntu0.9 libcurl3-gnutls=7.58.0-2ubuntu3.16 libcurl4=7.58.0-2ubuntu3.16 libcurl4-openssl-dev=7.58.0-2ubuntu3.16 liberror-perl=0.17025-1 libnghttp2-14=1.30.0-1ubuntu1 libpsl5=0.19.1-5build1 librtmp1=2.4+20151223.gitfa8646d.1-1 libssl-dev=1.1.1-1ubuntu2.1~18.04.14 wget=1.19.4-1ubuntu2.2 Reading package lists... Building dependency tree... Reading state information... Suggested packages: gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn libcurl4-doc libidn11-dev libkrb5-dev libldap2-dev librtmp-dev libssh2-1-dev pkg-config zlib1g-dev libssl-doc Recommended packages: less publicsuffix The following NEW packages will be installed: git git-man libcurl3-gnutls libcurl4 libcurl4-openssl-dev liberror-perl libnghttp2-14 libpsl5 librtmp1 libssl-dev wget 0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded. Need to get 7546 kB of archives. After this operation, 45.9 MB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 libpsl5 amd64 0.19.1-5build1 [41.8 kB] Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 libnghttp2-14 amd64 1.30.0-1ubuntu1 [77.8 kB] Get:3 http://archive.ubuntu.com/ubuntu bionic/main amd64 librtmp1 amd64 2.4+20151223.gitfa8646d.1-1 [54.2 kB] Get:4 http://archive.ubuntu.com/ubuntu bionic/main amd64 liberror-perl all 0.17025-1 [22.8 kB] Get:5 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libssl-dev amd64 1.1.1-1ubuntu2.1~18.04.14 [1568 kB] Get:6 http://security.ubuntu.com/ubuntu bionic-security/main amd64 wget amd64 1.19.4-1ubuntu2.2 [316 kB] Get:7 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libcurl3-gnutls amd64 7.58.0-2ubuntu3.16 [218 kB] Get:8 http://security.ubuntu.com/ubuntu bionic-security/main amd64 git-man all 1:2.17.1-1ubuntu0.9 [803 kB] Get:9 http://security.ubuntu.com/ubuntu bionic-security/main amd64 git amd64 1:2.17.1-1ubuntu0.9 [3923 kB] Get:10 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libcurl4 amd64 7.58.0-2ubuntu3.16 [220 kB] Get:11 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libcurl4-openssl-dev amd64 7.58.0-2ubuntu3.16 [301 kB] debconf: delaying package configuration, since apt-utils is not installed Fetched 7546 kB in 1s (6011 kB/s) Selecting previously unselected package libpsl5:amd64. (Reading database ... 13935 files and directories currently installed.) Preparing to unpack .../00-libpsl5_0.19.1-5build1_amd64.deb ... Unpacking libpsl5:amd64 (0.19.1-5build1) ... Selecting previously unselected package wget. Preparing to unpack .../01-wget_1.19.4-1ubuntu2.2_amd64.deb ... Unpacking wget (1.19.4-1ubuntu2.2) ... Selecting previously unselected package libnghttp2-14:amd64. Preparing to unpack .../02-libnghttp2-14_1.30.0-1ubuntu1_amd64.deb ... Unpacking libnghttp2-14:amd64 (1.30.0-1ubuntu1) ... Selecting previously unselected package librtmp1:amd64. Preparing to unpack .../03-librtmp1_2.4+20151223.gitfa8646d.1-1_amd64.deb ... Unpacking librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1) ... Selecting previously unselected package libcurl3-gnutls:amd64. Preparing to unpack .../04-libcurl3-gnutls_7.58.0-2ubuntu3.16_amd64.deb ... Unpacking libcurl3-gnutls:amd64 (7.58.0-2ubuntu3.16) ... Selecting previously unselected package liberror-perl. Preparing to unpack .../05-liberror-perl_0.17025-1_all.deb ... Unpacking liberror-perl (0.17025-1) ... Selecting previously unselected package git-man. Preparing to unpack .../06-git-man_1%3a2.17.1-1ubuntu0.9_all.deb ... Unpacking git-man (1:2.17.1-1ubuntu0.9) ... Selecting previously unselected package git. Preparing to unpack .../07-git_1%3a2.17.1-1ubuntu0.9_amd64.deb ... Unpacking git (1:2.17.1-1ubuntu0.9) ... Selecting previously unselected package libcurl4:amd64. Preparing to unpack .../08-libcurl4_7.58.0-2ubuntu3.16_amd64.deb ... Unpacking libcurl4:amd64 (7.58.0-2ubuntu3.16) ... Selecting previously unselected package libcurl4-openssl-dev:amd64. Preparing to unpack .../09-libcurl4-openssl-dev_7.58.0-2ubuntu3.16_amd64.deb ... Unpacking libcurl4-openssl-dev:amd64 (7.58.0-2ubuntu3.16) ... Selecting previously unselected package libssl-dev:amd64. Preparing to unpack .../10-libssl-dev_1.1.1-1ubuntu2.1~18.04.14_amd64.deb ... Unpacking libssl-dev:amd64 (1.1.1-1ubuntu2.1~18.04.14) ... Setting up git-man (1:2.17.1-1ubuntu0.9) ... Setting up libnghttp2-14:amd64 (1.30.0-1ubuntu1) ... Setting up liberror-perl (0.17025-1) ... Setting up libpsl5:amd64 (0.19.1-5build1) ... Setting up libssl-dev:amd64 (1.1.1-1ubuntu2.1~18.04.14) ... Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1) ... Setting up wget (1.19.4-1ubuntu2.2) ... Setting up libcurl3-gnutls:amd64 (7.58.0-2ubuntu3.16) ... Setting up libcurl4:amd64 (7.58.0-2ubuntu3.16) ... Setting up libcurl4-openssl-dev:amd64 (7.58.0-2ubuntu3.16) ... Setting up git (1:2.17.1-1ubuntu0.9) ... Processing triggers for libc-bin (2.27-3ubuntu1.4) ... git set to automatically installed. git-man set to automatically installed. libcurl3-gnutls set to automatically installed. libcurl4 set to automatically installed. libcurl4-openssl-dev set to automatically installed. liberror-perl set to automatically installed. libnghttp2-14 set to automatically installed. libpsl5 set to automatically installed. librtmp1 set to automatically installed. libssl-dev set to automatically installed. wget set to automatically installed. snapd is not logged in, snap install commands will use sudo snap "core18" has no updates available Get:1 libgssapi3-heimdal_7.5.0+dfsg-1_amd64.deb [96.5 kB] Fetched 96.5 kB in 0s (0 B/s) Get:1 python3-dev_3.6.7-1~18.04_amd64.deb [1288 B] Fetched 1288 B in 0s (0 B/s) Get:1 libkrb5-3_1.16-2ubuntu0.2_amd64.deb [279 kB] Fetched 279 kB in 0s (0 B/s) Get:1 libgssapi-krb5-2_1.16-2ubuntu0.2_amd64.deb [122 kB] Fetched 122 kB in 0s (0 B/s) Get:1 libpython3.6-minimal_3.6.9-1~18.04ubuntu1.4_amd64.deb [534 kB] Fetched 534 kB in 0s (0 B/s) Get:1 libnghttp2-14_1.30.0-1ubuntu1_amd64.deb [77.8 kB] Fetched 77.8 kB in 0s (0 B/s) Get:1 libcom-err2_1.44.1-1ubuntu1.3_amd64.deb [8848 B] Fetched 8848 B in 0s (0 B/s) Get:1 libwind0-heimdal_7.5.0+dfsg-1_amd64.deb [47.8 kB] Fetched 47.8 kB in 0s (0 B/s) Get:1 python3-distutils_3.6.9-1~18.04_all.deb [144 kB] Fetched 144 kB in 0s (0 B/s) Get:1 libsasl2-modules-db_2.1.27~101-g0780600+dfsg-3ubuntu2.3_amd64.deb [15.0 kB] Fetched 15.0 kB in 0s (0 B/s) Get:1 linux-libc-dev_4.15.0-163.171_amd64.deb [994 kB] Fetched 994 kB in 0s (0 B/s) Get:1 libcurl4_7.58.0-2ubuntu3.16_amd64.deb [220 kB] Fetched 220 kB in 0s (0 B/s) Get:1 libldap-2.4-2_2.4.45+dfsg-1ubuntu1.10_amd64.deb [154 kB] Fetched 154 kB in 0s (0 B/s) Get:1 openssl_1.1.1-1ubuntu2.1~18.04.14_amd64.deb [613 kB] Fetched 613 kB in 0s (0 B/s) Get:1 libc6-dev_2.27-3ubuntu1.4_amd64.deb [2585 kB] Fetched 2585 kB in 0s (0 B/s) Get:1 libpython3.6-dev_3.6.9-1~18.04ubuntu1.4_amd64.deb [44.9 MB] Fetched 44.9 MB in 0s (0 B/s) Get:1 libexpat1-dev_2.2.5-3ubuntu0.2_amd64.deb [122 kB] Fetched 122 kB in 0s (0 B/s) Get:1 libheimntlm0-heimdal_7.5.0+dfsg-1_amd64.deb [14.8 kB] Fetched 14.8 kB in 0s (0 B/s) Get:1 libpsl5_0.19.1-5build1_amd64.deb [41.8 kB] Fetched 41.8 kB in 0s (0 B/s) Get:1 libsqlite3-0_3.22.0-1ubuntu0.4_amd64.deb [499 kB] Fetched 499 kB in 0s (0 B/s) Get:1 libpython3.6-stdlib_3.6.9-1~18.04ubuntu1.4_amd64.deb [1712 kB] Fetched 1712 kB in 0s (0 B/s) Get:1 libgmp10_6.1.2+dfsg-2_amd64.deb [240 kB] Fetched 240 kB in 0s (0 B/s) Get:1 python3-pip_9.0.1-2.3~ubuntu1.18.04.5_all.deb [114 kB] Fetched 114 kB in 0s (0 B/s) Get:1 libheimbase1-heimdal_7.5.0+dfsg-1_amd64.deb [29.3 kB] Fetched 29.3 kB in 0s (0 B/s) Get:1 libpython3.6_3.6.9-1~18.04ubuntu1.4_amd64.deb [1414 kB] Fetched 1414 kB in 0s (0 B/s) Get:1 python3.6_3.6.9-1~18.04ubuntu1.4_amd64.deb [203 kB] Fetched 203 kB in 0s (0 B/s) Get:1 python3_3.6.7-1~18.04_amd64.deb [47.2 kB] Fetched 47.2 kB in 0s (0 B/s) Get:1 libk5crypto3_1.16-2ubuntu0.2_amd64.deb [85.5 kB] Fetched 85.5 kB in 0s (0 B/s) Get:1 mime-support_3.60ubuntu1_all.deb [30.1 kB] Fetched 30.1 kB in 0s (0 B/s) Get:1 libsasl2-2_2.1.27~101-g0780600+dfsg-3ubuntu2.3_amd64.deb [49.2 kB] Fetched 49.2 kB in 0s (0 B/s) Get:1 libmagic1_5.32-2ubuntu0.4_amd64.deb [68.6 kB] Fetched 68.6 kB in 0s (0 B/s) Get:1 libmpdec2_2.4.2-1ubuntu1_amd64.deb [84.1 kB] Fetched 84.1 kB in 0s (0 B/s) Get:1 libexpat1_2.2.5-3ubuntu0.2_amd64.deb [80.5 kB] Fetched 80.5 kB in 0s (0 B/s) Get:1 python3-pycurl_7.43.0.1-0.2_amd64.deb [42.5 kB] Fetched 42.5 kB in 0s (0 B/s) Get:1 python3.6-minimal_3.6.9-1~18.04ubuntu1.4_amd64.deb [1610 kB] Fetched 1610 kB in 0s (0 B/s) Get:1 python3-minimal_3.6.7-1~18.04_amd64.deb [23.7 kB] Fetched 23.7 kB in 0s (0 B/s) Get:1 librtmp1_2.4+20151223.gitfa8646d.1-1_amd64.deb [54.2 kB] Fetched 54.2 kB in 0s (0 B/s) Get:1 libmagic-mgc_5.32-2ubuntu0.4_amd64.deb [184 kB] Fetched 184 kB in 0s (0 B/s) Get:1 libkrb5support0_1.16-2ubuntu0.2_amd64.deb [30.8 kB] Fetched 30.8 kB in 0s (0 B/s) Get:1 libpython3-stdlib_3.6.7-1~18.04_amd64.deb [7240 B] Fetched 7240 B in 0s (0 B/s) Get:1 libldap-common_2.4.45+dfsg-1ubuntu1.10_all.deb [15.8 kB] Fetched 15.8 kB in 0s (0 B/s) Get:1 libhcrypto4-heimdal_7.5.0+dfsg-1_amd64.deb [85.9 kB] Fetched 85.9 kB in 0s (0 B/s) Get:1 libkeyutils1_1.5.9-9.2ubuntu2_amd64.deb [8720 B] Fetched 8720 B in 0s (0 B/s) Get:1 python3-lib2to3_3.6.9-1~18.04_all.deb [77.4 kB] Fetched 77.4 kB in 0s (0 B/s) Get:1 python3-pkg-resources_39.0.1-2_all.deb [98.8 kB] Fetched 98.8 kB in 0s (0 B/s) Get:1 dh-python_3.20180325ubuntu2_all.deb [89.2 kB] Fetched 89.2 kB in 0s (0 B/s) Get:1 libhogweed4_3.4.1-0ubuntu0.18.04.1_amd64.deb [140 kB] Fetched 140 kB in 0s (0 B/s) Get:1 libreadline7_7.0-3_amd64.deb [124 kB] Fetched 124 kB in 0s (0 B/s) Get:1 libnettle6_3.4.1-0ubuntu0.18.04.1_amd64.deb [111 kB] Fetched 111 kB in 0s (0 B/s) Get:1 libc-dev-bin_2.27-3ubuntu1.4_amd64.deb [71.8 kB] Fetched 71.8 kB in 0s (0 B/s) Get:1 libgnutls30_3.5.18-1ubuntu1.5_amd64.deb [646 kB] Fetched 646 kB in 0s (0 B/s) Get:1 libroken18-heimdal_7.5.0+dfsg-1_amd64.deb [41.3 kB] Fetched 41.3 kB in 0s (0 B/s) Get:1 ca-certificates_20210119~18.04.2_all.deb [145 kB] Fetched 145 kB in 0s (0 B/s) Get:1 libffi6_3.2.1-8_amd64.deb [17.9 kB] Fetched 17.9 kB in 0s (0 B/s) Get:1 libunistring2_0.9.9-0ubuntu2_amd64.deb [368 kB] Fetched 368 kB in 0s (0 B/s) Get:1 libp11-kit0_0.23.9-2ubuntu0.1_amd64.deb [187 kB] Fetched 187 kB in 0s (0 B/s) Get:1 libasn1-8-heimdal_7.5.0+dfsg-1_amd64.deb [175 kB] Fetched 175 kB in 0s (0 B/s) Get:1 libkrb5-26-heimdal_7.5.0+dfsg-1_amd64.deb [206 kB] Fetched 206 kB in 0s (0 B/s) Get:1 libpython3-dev_3.6.7-1~18.04_amd64.deb [7328 B] Fetched 7328 B in 0s (0 B/s) Get:1 libssl1.1_1.1.1-1ubuntu2.1~18.04.14_amd64.deb [1302 kB] Fetched 1302 kB in 0s (0 B/s) Get:1 libtasn1-6_4.13-2_amd64.deb [36.2 kB] Fetched 36.2 kB in 0s (0 B/s) Get:1 python3.6-dev_3.6.9-1~18.04ubuntu1.4_amd64.deb [508 kB] Fetched 508 kB in 0s (0 B/s) Get:1 libhx509-5-heimdal_7.5.0+dfsg-1_amd64.deb [107 kB] Fetched 107 kB in 0s (0 B/s) Get:1 python-pip-whl_9.0.1-2.3~ubuntu1.18.04.5_all.deb [1653 kB] Fetched 1653 kB in 0s (0 B/s) Get:1 libidn2-0_2.0.4-1.1ubuntu0.2_amd64.deb [48.7 kB] Fetched 48.7 kB in 0s (0 B/s) Get:1 libcurl3-gnutls_7.58.0-2ubuntu3.16_amd64.deb [218 kB] Fetched 218 kB in 0s (0 B/s) Get:1 python3-setuptools_39.0.1-2_all.deb [248 kB] Fetched 248 kB in 0s (0 B/s) Pulling client + snapcraftctl pull Building client + /root/parts/client/install/usr/bin/pip3 install wheel Collecting wheel Downloading https://files.pythonhosted.org/packages/04/80/cad93b40262f5d09f6de82adbee452fd43cdff60830b56a74c5930f7e277/wheel-0.37.0-py2.py3-none-any.whl Installing collected packages: wheel Successfully installed wheel-0.37.0 + /root/parts/client/install/usr/bin/pip3 install pyang Collecting pyang Downloading https://files.pythonhosted.org/packages/c4/3a/dbefc004ae5c283409e42bcb3e93791741ff54640b9e75b5590695276836/pyang-2.5.2-py2.py3-none-any.whl (595kB) Collecting lxml (from pyang) Downloading https://files.pythonhosted.org/packages/03/ca/92b3459e6a26a71854be6c80811398440fcbceae1fd81d5dd6a1892b1dd7/lxml-4.7.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (5.6MB) Installing collected packages: lxml, pyang Successfully installed lxml-4.7.1 pyang-2.5.2 + /root/parts/client/install/usr/bin/pip3 install pyangbind Collecting pyangbind Downloading https://files.pythonhosted.org/packages/2e/20/7b3f2de320d120e845bce141148a23522fccb089b76ae0c76b5d5623d515/pyangbind-0.8.1.tar.gz (48kB) Collecting bitarray (from pyangbind) Downloading https://files.pythonhosted.org/packages/ac/b1/4e36d785d478bb7b5d02028a88e8627a10e810793d660b2b7aedd1cd146e/bitarray-2.3.4.tar.gz (88kB) Collecting enum34 (from pyangbind) Downloading https://files.pythonhosted.org/packages/63/f6/ccb1c83687756aeabbf3ca0f213508fcfb03883ff200d201b3a4c60cedcc/enum34-1.1.10-py3-none-any.whl Requirement already satisfied: lxml in /root/parts/client/install/usr/local/lib/python3.6/dist-packages (from pyangbind) Requirement already satisfied: pyang in /root/parts/client/install/usr/local/lib/python3.6/dist-packages (from pyangbind) Collecting regex (from pyangbind) Downloading https://files.pythonhosted.org/packages/93/57/277ac1dc8b7e49f48c6fb74929dd32d27ea5e3c504a766f4420d28a673ef/regex-2021.11.10-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (670kB) Collecting six (from pyangbind) Downloading https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl Building wheels for collected packages: pyangbind, bitarray Running setup.py bdist_wheel for pyangbind: started Running setup.py bdist_wheel for pyangbind: finished with status 'done' Stored in directory: /root/.cache/pip/wheels/2b/c9/b5/a80fdc73a61af741c3e181da1461b2588788229407c4d90147 Running setup.py bdist_wheel for bitarray: started Running setup.py bdist_wheel for bitarray: finished with status 'done' Stored in directory: /root/.cache/pip/wheels/97/e5/7a/2be8b8b9dfc24c4e6540cad5d83f5b3cdae7e21ae41da712c5 Successfully built pyangbind bitarray Installing collected packages: bitarray, enum34, regex, six, pyangbind Successfully installed bitarray-2.3.4 enum34-1.1.10 pyangbind-0.8.1 regex-2021.11.10 six-1.16.0 + PATH=/root/stage/usr/sbin:/root/stage/usr/bin:/root/stage/sbin:/root/stage/bin:/root/parts/client/install/usr/sbin:/root/parts/client/install/usr/bin:/root/parts/client/install/sbin:/root/parts/client/install/bin:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/snapcraft/6954/bin/scriptlet-bin:/root/parts/client/install/usr/local/bin:/root/parts/client/install/usr/local/bin + git symbolic-ref -q --short HEAD + git describe --tags --exact-match + BRANCH_OR_TAG=v9.1.5 + git clone https://osm.etsi.org/gerrit/osm/IM.git Cloning into 'IM'... + cd IM/ + git checkout v9.1.5 Note: checking out 'v9.1.5'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b HEAD is now at 35517bb Fix bug 1699 to add persistent-storage type to vdu + /root/parts/client/install/usr/bin/pip3 install . Processing /root/parts/client/build/IM Installing collected packages: osm-im Running setup.py install for osm-im: started Running setup.py install for osm-im: finished with status 'done' Successfully installed osm-im-9.1.5+g35517bb + cd ../ + rm -rf IM/ + /root/parts/client/install/usr/bin/pip3 install -r requirements.txt Collecting certifi==2020.12.5 (from -r requirements.txt (line 1)) Downloading https://files.pythonhosted.org/packages/5e/a0/5f06e1e1d463903cf0c0eebeb751791119ed7a4b3737fdc9a77f1cdfb51f/certifi-2020.12.5-py2.py3-none-any.whl (147kB) Collecting chardet==4.0.0 (from -r requirements.txt (line 3)) Downloading https://files.pythonhosted.org/packages/19/c7/fa589626997dd07bd87d9269342ccb74b1720384a4d739a1872bd84fbe68/chardet-4.0.0-py2.py3-none-any.whl (178kB) Collecting click==7.1.2 (from -r requirements.txt (line 5)) Downloading https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82kB) Collecting idna==2.10 (from -r requirements.txt (line 7)) Downloading https://files.pythonhosted.org/packages/a2/38/928ddce2273eaa564f6f50de919327bf3a00f091b5baba8dfa9460f3a8a8/idna-2.10-py2.py3-none-any.whl (58kB) Collecting jinja2==2.11.3 (from -r requirements.txt (line 9)) Downloading https://files.pythonhosted.org/packages/7e/c2/1eece8c95ddbc9b1aeb64f5783a9e07a286de42191b7204d67b7496ddf35/Jinja2-2.11.3-py2.py3-none-any.whl (125kB) Collecting markupsafe==1.1.1 (from -r requirements.txt (line 11)) Downloading https://files.pythonhosted.org/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl Collecting packaging==20.9 (from -r requirements.txt (line 13)) Downloading https://files.pythonhosted.org/packages/3e/89/7ea760b4daa42653ece2380531c90f64788d979110a2ab51049d92f408af/packaging-20.9-py2.py3-none-any.whl (40kB) Collecting prettytable==2.1.0 (from -r requirements.txt (line 15)) Downloading https://files.pythonhosted.org/packages/26/1b/42b59a4038bc0442e3a0085bc0de385658131eef8a88946333f870559b09/prettytable-2.1.0-py3-none-any.whl Collecting pycurl==7.43.0.6 (from -r requirements.txt (line 17)) Downloading https://files.pythonhosted.org/packages/50/1a/35b1d8b8e4e23a234f1b17a8a40299fd550940b16866c9a1f2d47a04b969/pycurl-7.43.0.6.tar.gz (222kB) Collecting pyparsing==2.4.7 (from -r requirements.txt (line 19)) Downloading https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl (67kB) Collecting python-magic==0.4.22 (from -r requirements.txt (line 21)) Downloading https://files.pythonhosted.org/packages/ba/7c/1d1d4bdda29bfec662b9b50951dee2dddf7747d3cbf7777f3d1c63372bd0/python_magic-0.4.22-py2.py3-none-any.whl Collecting pyyaml==5.4.1 (from -r requirements.txt (line 23)) Downloading https://files.pythonhosted.org/packages/7a/5b/bc0b5ab38247bba158504a410112b6c03f153c652734ece1849749e5f518/PyYAML-5.4.1-cp36-cp36m-manylinux1_x86_64.whl (640kB) Collecting requests==2.25.1 (from -r requirements.txt (line 25)) Downloading https://files.pythonhosted.org/packages/29/c1/24814557f1d22c56d50280771a17307e6bf87b70727d975fd6b2ce6b014a/requests-2.25.1-py2.py3-none-any.whl (61kB) Collecting urllib3==1.26.4 (from -r requirements.txt (line 27)) Downloading https://files.pythonhosted.org/packages/09/c6/d3e3abe5b4f4f16cf0dfc9240ab7ce10c2baa0e268989a4e3ec19e90c84e/urllib3-1.26.4-py2.py3-none-any.whl (153kB) Collecting verboselogs==1.7 (from -r requirements.txt (line 29)) Downloading https://files.pythonhosted.org/packages/b8/9d/c5c3cb0093642042fd604b53928ac65e7650fdc5a8a97814288e29beab84/verboselogs-1.7-py2.py3-none-any.whl Collecting wcwidth==0.2.5 (from -r requirements.txt (line 31)) Downloading https://files.pythonhosted.org/packages/59/7c/e39aca596badaf1b78e8f547c807b04dae603a433d3e7a7e04d67f2ef3e5/wcwidth-0.2.5-py2.py3-none-any.whl Collecting importlib-metadata; python_version < "3.8" (from prettytable==2.1.0->-r requirements.txt (line 15)) Downloading https://files.pythonhosted.org/packages/c4/1f/e2238896149df09953efcc53bdcc7d23597d6c53e428c30e572eda5ec6eb/importlib_metadata-4.8.2-py3-none-any.whl Collecting zipp>=0.5 (from importlib-metadata; python_version < "3.8"->prettytable==2.1.0->-r requirements.txt (line 15)) Downloading https://files.pythonhosted.org/packages/bd/df/d4a4974a3e3957fd1c1fa3082366d7fff6e428ddb55f074bf64876f8e8ad/zipp-3.6.0-py3-none-any.whl Collecting typing-extensions>=3.6.4; python_version < "3.8" (from importlib-metadata; python_version < "3.8"->prettytable==2.1.0->-r requirements.txt (line 15)) Downloading https://files.pythonhosted.org/packages/05/e4/baf0031e39cf545f0c9edd5b1a2ea12609b7fcba2d58e118b11753d68cf0/typing_extensions-4.0.1-py3-none-any.whl Building wheels for collected packages: pycurl Running setup.py bdist_wheel for pycurl: started Running setup.py bdist_wheel for pycurl: finished with status 'done' Stored in directory: /root/.cache/pip/wheels/d9/a1/7b/2894883fd5c69a3ba684a49d255466d1e924b3cf58cedc1ade Successfully built pycurl Installing collected packages: certifi, chardet, click, idna, markupsafe, jinja2, pyparsing, packaging, zipp, typing-extensions, importlib-metadata, wcwidth, prettytable, pycurl, python-magic, pyyaml, urllib3, requests, verboselogs Found existing installation: pycurl 7.43.0.1 Not uninstalling pycurl at /root/parts/client/install/usr/lib/python3/dist-packages, outside environment /root/parts/client/install/usr Successfully installed certifi-2020.12.5 chardet-4.0.0 click-7.1.2 idna-2.10 importlib-metadata-4.8.2 jinja2-2.11.3 markupsafe-1.1.1 packaging-20.9 prettytable-2.1.0 pycurl-7.43.0.6 pyparsing-2.4.7 python-magic-0.4.22 pyyaml-5.4.1 requests-2.25.1 typing-extensions-4.0.1 urllib3-1.26.4 verboselogs-1.7 wcwidth-0.2.5 zipp-3.6.0 + /root/parts/client/install/usr/bin/pip3 install . Processing /root/parts/client/build Installing collected packages: osmclient Running setup.py install for osmclient: started Running setup.py install for osmclient: finished with status 'done' Successfully installed osmclient-9.1.5+g1cbff09 + rm -rf .tox + git describe --match v* --tags --dirty + snapcraftctl set-version v9.1.5 + snapcraftctl build Staging client + snapcraftctl stage Priming client + snapcraftctl prime Snapping... Snapped osmclient_v9.1.5_amd64.snap [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + mv /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/osmclient_v9.1.5_amd64.snap /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/osmclient.snap [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + sudo rm -rf /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/stage/ /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/parts/ /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/prime/ [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + sudo docker run -v /home/jenkins/.snapcraft:/snapcraft -v /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0:/build -w /build snapcore/snapcraft:stable /bin/bash -c snapcraft login --with /snapcraft/config ; snapcraft push --release=9.0/edge osmclient.snap Login successful. You now have these capabilities: snaps: No restriction channels: No restriction permissions: ['package_access', 'package_manage', 'package_metrics', 'package_push', 'package_register', 'package_release', 'package_update'] expires: 2022-08-24T01:12:17.731625 DEPRECATED: The 'push' set of commands have been replaced with 'upload'. See http://snapcraft.io/docs/deprecation-notices/dn11 for more information. Preparing to upload 'osmclient.snap'. After uploading, the resulting snap revision will be released to '9.0/edge' when it passes the Snap Store review. Install the review-tools from the Snap Store for enhanced checks before uploading this snap. Pushing 'osmclient.snap' [ ] 0% Pushing 'osmclient.snap' [ ] 1% Pushing 'osmclient.snap' [ ] 2% Pushing 'osmclient.snap' [= ] 3% Pushing 'osmclient.snap' [= ] 4% Pushing 'osmclient.snap' [== ] 5% Pushing 'osmclient.snap' [== ] 6% Pushing 'osmclient.snap' [=== ] 7% Pushing 'osmclient.snap' [=== ] 8% Pushing 'osmclient.snap' [==== ] 9% Pushing 'osmclient.snap' [==== ] 10% Pushing 'osmclient.snap' [===== ] 11% Pushing 'osmclient.snap' [===== ] 12% Pushing 'osmclient.snap' [====== ] 13% Pushing 'osmclient.snap' [====== ] 14% Pushing 'osmclient.snap' [======= ] 15% Pushing 'osmclient.snap' [======= ] 16% Pushing 'osmclient.snap' [======== ] 17% Pushing 'osmclient.snap' [======== ] 18% Pushing 'osmclient.snap' [======== ] 19% Pushing 'osmclient.snap' [========= ] 20% Pushing 'osmclient.snap' [========= ] 21% Pushing 'osmclient.snap' [========== ] 22% Pushing 'osmclient.snap' [========== ] 23% Pushing 'osmclient.snap' [=========== ] 24% Pushing 'osmclient.snap' [=========== ] 25% Pushing 'osmclient.snap' [============ ] 26% Pushing 'osmclient.snap' [============ ] 27% Pushing 'osmclient.snap' [============= ] 28% Pushing 'osmclient.snap' [============= ] 29% Pushing 'osmclient.snap' [============== ] 30% Pushing 'osmclient.snap' [============== ] 31% Pushing 'osmclient.snap' [=============== ] 32% Pushing 'osmclient.snap' [=============== ] 33% Pushing 'osmclient.snap' [================ ] 34% Pushing 'osmclient.snap' [================ ] 35% Pushing 'osmclient.snap' [================ ] 36% Pushing 'osmclient.snap' [================= ] 37% Pushing 'osmclient.snap' [================= ] 38% Pushing 'osmclient.snap' [================== ] 39% Pushing 'osmclient.snap' [================== ] 40% Pushing 'osmclient.snap' [=================== ] 41% Pushing 'osmclient.snap' [=================== ] 42% Pushing 'osmclient.snap' [==================== ] 43% Pushing 'osmclient.snap' [==================== ] 44% Pushing 'osmclient.snap' [===================== ] 45% Pushing 'osmclient.snap' [===================== ] 46% Pushing 'osmclient.snap' [====================== ] 47% Pushing 'osmclient.snap' [====================== ] 48% Pushing 'osmclient.snap' [======================= ] 49% Pushing 'osmclient.snap' [======================= ] 50% Pushing 'osmclient.snap' [======================== ] 51% Pushing 'osmclient.snap' [======================== ] 52% Pushing 'osmclient.snap' [======================== ] 53% Pushing 'osmclient.snap' [========================= ] 54% Pushing 'osmclient.snap' [========================= ] 55% Pushing 'osmclient.snap' [========================== ] 56% Pushing 'osmclient.snap' [========================== ] 57% Pushing 'osmclient.snap' [=========================== ] 58% Pushing 'osmclient.snap' [=========================== ] 59% Pushing 'osmclient.snap' [============================ ] 60% Pushing 'osmclient.snap' [============================ ] 61% Pushing 'osmclient.snap' [============================= ] 62% Pushing 'osmclient.snap' [============================= ] 63% Pushing 'osmclient.snap' [============================== ] 64% Pushing 'osmclient.snap' [============================== ] 65% Pushing 'osmclient.snap' [=============================== ] 66% Pushing 'osmclient.snap' [=============================== ] 67% Pushing 'osmclient.snap' [================================ ] 68% Pushing 'osmclient.snap' [================================ ] 69% Pushing 'osmclient.snap' [================================= ] 70% Pushing 'osmclient.snap' [================================= ] 71% Pushing 'osmclient.snap' [================================= ] 72% Pushing 'osmclient.snap' [================================== ] 73% Pushing 'osmclient.snap' [================================== ] 74% Pushing 'osmclient.snap' [=================================== ] 75% Pushing 'osmclient.snap' [=================================== ] 76% Pushing 'osmclient.snap' [==================================== ] 77% Pushing 'osmclient.snap' [==================================== ] 78% Pushing 'osmclient.snap' [===================================== ] 79% Pushing 'osmclient.snap' [===================================== ] 80% Pushing 'osmclient.snap' [====================================== ] 81% Pushing 'osmclient.snap' [====================================== ] 82% Pushing 'osmclient.snap' [======================================= ] 83% Pushing 'osmclient.snap' [======================================= ] 84% Pushing 'osmclient.snap' [======================================== ] 85% Pushing 'osmclient.snap' [======================================== ] 86% Pushing 'osmclient.snap' [========================================= ] 87% Pushing 'osmclient.snap' [========================================= ] 88% Pushing 'osmclient.snap' [========================================= ] 89% Pushing 'osmclient.snap' [========================================== ] 90% Pushing 'osmclient.snap' [========================================== ] 91% Pushing 'osmclient.snap' [=========================================== ] 92% Pushing 'osmclient.snap' [=========================================== ] 93% Pushing 'osmclient.snap' [============================================ ] 94% Pushing 'osmclient.snap' [============================================ ] 95% Pushing 'osmclient.snap' [============================================= ] 96% Pushing 'osmclient.snap' [============================================= ] 97% Pushing 'osmclient.snap' [============================================== ] 98% Pushing 'osmclient.snap' [============================================== ] 99% Pushing 'osmclient.snap' [===============================================] 100% Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| released Revision 327 of 'osmclient' created. Track Arch Channel Version Revision Expires at latest amd64 stable v11.0.0-0-g928173c 326 candidate v11.0.0-0-g928173c 326 beta v9.0.0-dev-16-g45100df 317 edge v9.0.0-dev-16-g45100df 317 edge/refs-changes-04-11304-9 v9.0.0-dev-14-gc98c138 307 2021-12-17T20:26:31Z edge/refs-changes-04-11304-12 v9.0.0-dev-14-g2844f75 310 2021-12-19T22:07:13Z edge/refs-changes-04-11304-11 v9.0.0-dev-14-gb255e4a 309 2021-12-19T13:23:22Z edge/refs-changes-02-11402-2 v9.0.0-dev-16-g7c3e3ca 314 2021-12-23T22:13:57Z edge/refs-changes-02-11402-1 v9.0.0-dev-16-g7bbd0e5 313 2021-12-23T21:27:07Z edge/refs-changes-00-11400-2 v9.0.0-dev-15-g5e9e1fb 316 2021-12-23T23:43:35Z 7.0 amd64 stable 0+git.4ab46a0 45 candidate ↑ ↑ beta ↑ ↑ edge ↑ ↑ 7.1 amd64 stable v7.1.0+git4.a4af86f-dirty 46 candidate v7.1.0+git4.a4af86f-dirty 46 beta v7.1.0+git4.a4af86f-dirty 46 edge v7.1.0+git4.a4af86f-dirty 46 8.0 amd64 stable v8.0.0rc3+git1.f31a6d1 48 candidate v8.0.0rc3+git1.f31a6d1 48 beta v8.0.0rc2+git6.4d92e2d 53 edge v8.0.0rc2+git6.4d92e2d 53 9.0 amd64 stable v9.1.4 275 candidate v9.1.3 235 beta v9.1.4 275 edge v9.1.5 327 10.0 amd64 stable v10.0.3-0-gc0a69f8 287 candidate v10.0.3-0-gc0a69f8 287 beta v10.0.3-0-gc0a69f8 287 edge v10.0.3-0-gc0a69f8 287 11.0 amd64 stable v11.0.0-0-g928173c 326 candidate v11.0.0-0-g928173c 326 beta v11.0.0-0-g928173c 326 edge v11.0.0-0-g928173c 326 edge/refs-changes-22-11422-1 v11.0.0rc1-2-g928173c 321 2021-12-26T18:17:32Z edge/refs-changes-21-11421-1 v11.0.0rc1-1-gc86b1c6 320 2021-12-26T16:54:55Z Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...- Processing...\ Processing...| Processing.../ Processing...| [Pipeline] sh [osmclient-stage_2-merge_v9.0] Running shell script + sudo rm -rf /opt/jenkins/workspace/osmclient-stage_2-merge_v9.0/osmclient.snap [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS