From: tierno Date: Wed, 28 Aug 2019 13:36:34 +0000 (+0000) Subject: change imports with osm_nbi prefix X-Git-Tag: v6.0.2rc1~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=23acf4001306e92a587de566be4bab00931104ba;p=osm%2FNBI.git change imports with osm_nbi prefix Change-Id: I4dcbfc71d900269f28ceec6669fe4127bc6a29fc Signed-off-by: tierno --- diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index 7d1e85d..e21120e 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -18,16 +18,13 @@ from uuid import uuid4 from hashlib import sha256 from http import HTTPStatus from time import time -from validation import user_new_schema, user_edit_schema, project_new_schema, project_edit_schema -from validation import vim_account_new_schema, vim_account_edit_schema, sdn_new_schema, sdn_edit_schema -from validation import wim_account_new_schema, wim_account_edit_schema, roles_new_schema, roles_edit_schema -from validation import validate_input -from validation import ValidationError -from validation import is_valid_uuid # To check that User/Project Names don't look like UUIDs -from base_topic import BaseTopic, EngineException +from osm_nbi.validation import user_new_schema, user_edit_schema, project_new_schema, project_edit_schema, \ + vim_account_new_schema, vim_account_edit_schema, sdn_new_schema, sdn_edit_schema, \ + wim_account_new_schema, wim_account_edit_schema, roles_new_schema, roles_edit_schema, \ + validate_input, ValidationError, is_valid_uuid # To check that User/Project Names don't look like UUIDs +from osm_nbi.base_topic import BaseTopic, EngineException +from osm_nbi.authconn import AuthconnNotFoundException, AuthconnConflictException from osm_common.dbbase import deep_update_rfc7396 -from authconn import AuthconnNotFoundException, AuthconnConflictException -# from authconn_keystone import AuthconnKeystone __author__ = "Alfonso Tierno " diff --git a/osm_nbi/authconn.py b/osm_nbi/authconn.py index 1727590..ef4d75c 100644 --- a/osm_nbi/authconn.py +++ b/osm_nbi/authconn.py @@ -23,11 +23,12 @@ Authconn implements an Abstract class for the Auth backend connector plugins with the definition of the methods to be implemented. """ -__author__ = "Eduardo Sousa " +__author__ = "Eduardo Sousa , " \ + "Pedro de la Cruz Ramos " __date__ = "$27-jul-2018 23:59:59$" from http import HTTPStatus -from base_topic import BaseTopic +from osm_nbi.base_topic import BaseTopic class AuthException(Exception): @@ -190,8 +191,14 @@ class Authconn: :return: returns a list of users. """ - def get_user(self, id, fail=True): - filt = {BaseTopic.id_field("users", id): id} + def get_user(self, _id, fail=True): + """ + Get one user + :param _id: id or name + :param fail: True to raise exception on not found. False to return None on not found + :return: dictionary with the user information + """ + filt = {BaseTopic.id_field("users", _id): _id} users = self.get_user_list(filt) if not users: if fail: @@ -227,8 +234,14 @@ class Authconn: """ raise AuthconnNotImplementedException("Should have implemented this") - def get_role(self, id, fail=True): - filt = {BaseTopic.id_field("roles", id): id} + def get_role(self, _id, fail=True): + """ + Get one role + :param _id: id or name + :param fail: True to raise exception on not found. False to return None on not found + :return: dictionary with the role information + """ + filt = {BaseTopic.id_field("roles", _id): _id} roles = self.get_role_list(filt) if not roles: if fail: @@ -273,8 +286,14 @@ class Authconn: """ raise AuthconnNotImplementedException("Should have implemented this") - def get_project(self, id, fail=True): - filt = {BaseTopic.id_field("projects", id): id} + def get_project(self, _id, fail=True): + """ + Get one project + :param _id: id or name + :param fail: True to raise exception on not found. False to return None on not found + :return: dictionary with the project information + """ + filt = {BaseTopic.id_field("projects", _id): _id} projs = self.get_project_list(filt) if not projs: if fail: diff --git a/osm_nbi/authconn_internal.py b/osm_nbi/authconn_internal.py index 2d2ddab..da5e543 100644 --- a/osm_nbi/authconn_internal.py +++ b/osm_nbi/authconn_internal.py @@ -24,12 +24,13 @@ AuthconnInternal implements implements the connector for OSM Internal Authentication Backend and leverages the RBAC model """ -__author__ = "Pedro de la Cruz Ramos " +__author__ = "Pedro de la Cruz Ramos , " \ + "Alfonso Tierno " __date__ = "$27-jul-2018 23:59:59$" -from authconn import Authconn, AuthException, AuthconnOperationException, AuthconnNotFoundException, \ +from osm_nbi.authconn import Authconn, AuthException, AuthconnOperationException, AuthconnNotFoundException, \ AuthconnConflictException import logging @@ -40,7 +41,7 @@ from keystoneauth1.exceptions.base import ClientException from keystoneauth1.exceptions.http import Conflict from keystoneclient.v3 import client from http import HTTPStatus -from validation import is_valid_uuid +from osm_nbi.validation import is_valid_uuid class AuthconnKeystone(Authconn): diff --git a/osm_nbi/base_topic.py b/osm_nbi/base_topic.py index 4fb84a5..9688f60 100644 --- a/osm_nbi/base_topic.py +++ b/osm_nbi/base_topic.py @@ -18,7 +18,7 @@ from uuid import uuid4 from http import HTTPStatus from time import time from osm_common.dbbase import deep_update_rfc7396 -from validation import validate_input, ValidationError, is_valid_uuid +from osm_nbi.validation import validate_input, ValidationError, is_valid_uuid __author__ = "Alfonso Tierno " @@ -27,7 +27,7 @@ class EngineException(Exception): def __init__(self, message, http_code=HTTPStatus.BAD_REQUEST): self.http_code = http_code - Exception.__init__(self, message) + super(Exception, self).__init__(message) def get_iterable(input_var): diff --git a/osm_nbi/descriptor_topics.py b/osm_nbi/descriptor_topics.py index eb6a46d..27b51a1 100644 --- a/osm_nbi/descriptor_topics.py +++ b/osm_nbi/descriptor_topics.py @@ -20,8 +20,8 @@ import json from hashlib import md5 from osm_common.dbbase import DbException, deep_update_rfc7396 from http import HTTPStatus -from validation import ValidationError, pdu_new_schema, pdu_edit_schema -from base_topic import BaseTopic, EngineException, get_iterable +from osm_nbi.validation import ValidationError, pdu_new_schema, pdu_edit_schema +from osm_nbi.base_topic import BaseTopic, EngineException, get_iterable from osm_im.vnfd import vnfd as vnfd_im from osm_im.nsd import nsd as nsd_im from osm_im.nst import nst as nst_im diff --git a/osm_nbi/engine.py b/osm_nbi/engine.py index ccfd7d3..8233c90 100644 --- a/osm_nbi/engine.py +++ b/osm_nbi/engine.py @@ -21,14 +21,14 @@ from osm_common.fsbase import FsException from osm_common.msgbase import MsgException from http import HTTPStatus -from authconn_keystone import AuthconnKeystone -from authconn_internal import AuthconnInternal -from base_topic import EngineException, versiontuple -from admin_topics import VimAccountTopic, WimAccountTopic, SdnTopic -from admin_topics import UserTopicAuth, ProjectTopicAuth, RoleTopicAuth -from descriptor_topics import VnfdTopic, NsdTopic, PduTopic, NstTopic -from instance_topics import NsrTopic, VnfrTopic, NsLcmOpTopic, NsiTopic, NsiLcmOpTopic -from pmjobs_topics import PmJobsTopic +from osm_nbi.authconn_keystone import AuthconnKeystone +from osm_nbi.authconn_internal import AuthconnInternal +from osm_nbi.base_topic import EngineException, versiontuple +from osm_nbi.admin_topics import VimAccountTopic, WimAccountTopic, SdnTopic +from osm_nbi.admin_topics import UserTopicAuth, ProjectTopicAuth, RoleTopicAuth +from osm_nbi.descriptor_topics import VnfdTopic, NsdTopic, PduTopic, NstTopic +from osm_nbi.instance_topics import NsrTopic, VnfrTopic, NsLcmOpTopic, NsiTopic, NsiLcmOpTopic +from osm_nbi.pmjobs_topics import PmJobsTopic from base64 import b64encode from os import urandom, path from threading import Lock diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index 809578e..4b3f04b 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -18,8 +18,8 @@ from uuid import uuid4 from http import HTTPStatus from time import time from copy import copy, deepcopy -from validation import validate_input, ValidationError, ns_instantiate, ns_action, ns_scale, nsi_instantiate -from base_topic import BaseTopic, EngineException, get_iterable +from osm_nbi.validation import validate_input, ValidationError, ns_instantiate, ns_action, ns_scale, nsi_instantiate +from osm_nbi.base_topic import BaseTopic, EngineException, get_iterable # from descriptor_topics import DescriptorTopic from yaml import safe_dump from osm_common.dbbase import DbException diff --git a/osm_nbi/pmjobs_topics.py b/osm_nbi/pmjobs_topics.py index 5123cdc..08b0b1d 100644 --- a/osm_nbi/pmjobs_topics.py +++ b/osm_nbi/pmjobs_topics.py @@ -16,7 +16,7 @@ import asyncio import aiohttp -from base_topic import EngineException +from osm_nbi.base_topic import EngineException __author__ = "Vijay R S " diff --git a/osm_nbi/subscriptions.py b/osm_nbi/subscriptions.py index 156f466..39eed76 100644 --- a/osm_nbi/subscriptions.py +++ b/osm_nbi/subscriptions.py @@ -27,7 +27,7 @@ from http import HTTPStatus from osm_common import dbmongo, dbmemory, msglocal, msgkafka from osm_common.dbbase import DbException from osm_common.msgbase import MsgException -from engine import EngineException +from osm_nbi.engine import EngineException __author__ = "Alfonso Tierno " diff --git a/requirements.txt b/requirements.txt index 469ec46..712bfe4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,6 +14,7 @@ CherryPy==18.0.0 jsonschema PyYAML==3.* python-keystoneclient +requests git+https://osm.etsi.org/gerrit/osm/common.git#egg=osm-common git+https://osm.etsi.org/gerrit/osm/IM.git#egg=osm-im