diff options
author | dyh <dengyuanhong@chinamobile.com> | 2020-08-06 09:20:55 +0800 |
---|---|---|
committer | dyh <dengyuanhong@chinamobile.com> | 2020-08-07 15:37:08 +0800 |
commit | 46bd3041d522ddce28ae3450e98c9c49b44b02cc (patch) | |
tree | 765a04f0a0bc4531d8bb6a0b4aba2304e894a34c /catalog/packages/biz | |
parent | 824413f6f354330f868b38a2ec8cb93b3c8d2808 (diff) |
1. Remove the mandatory dependency on MSB
2. Refactor config file
Change-Id: I8317ee0e1440e177a54e5510c6393529b6a3a5fe
Issue-ID: MODELING-411
Signed-off-by: dyh <dengyuanhong@chinamobile.com>
Diffstat (limited to 'catalog/packages/biz')
-rw-r--r-- | catalog/packages/biz/notificationsutil.py | 13 | ||||
-rw-r--r-- | catalog/packages/biz/nsdm_subscription.py | 3 | ||||
-rw-r--r-- | catalog/packages/biz/vnf_package.py | 4 | ||||
-rw-r--r-- | catalog/packages/biz/vnf_pkg_subscription.py | 10 |
4 files changed, 14 insertions, 16 deletions
diff --git a/catalog/packages/biz/notificationsutil.py b/catalog/packages/biz/notificationsutil.py index 31760cc..93c26c7 100644 --- a/catalog/packages/biz/notificationsutil.py +++ b/catalog/packages/biz/notificationsutil.py @@ -26,7 +26,6 @@ import catalog.pub.utils.timeutil from catalog.packages import const from catalog.packages.serializers.vnf_pkg_notifications import PkgChangeNotificationSerializer, \ PkgOnboardingNotificationSerializer -from catalog.pub.config import config as pub_config from catalog.pub.database.models import VnfPackageModel, VnfPkgSubscriptionModel, NsdmSubscriptionModel from catalog.pub.utils.values import remove_none_key @@ -61,7 +60,7 @@ class NotificationsUtil(object): # set subscription id notification["subscriptionId"] = sub.get_subscription_id() notification['_links']['subscription'] = { - 'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, self.subscription_root_uri, notification["subscriptionId"]) + 'href': '/%s%s' % (self.subscription_root_uri, notification["subscriptionId"]) } callbackuri = sub.callback_uri """ @@ -149,7 +148,7 @@ class PkgNotifications(NotificationsUtil): 'vnfdId': vnfd_id, '_links': { 'vnfPackage': { - 'href': '%s/%s/vnf_packages/%s' % (pub_config.MSB_BASE_URL, const.PKG_URL_PREFIX, self.vnf_pkg_id) + 'href': '/%s/vnf_packages/%s' % (const.PKG_URL_PREFIX, self.vnf_pkg_id) } } } @@ -192,7 +191,8 @@ class NsdNotifications(NotificationsUtil): 'nsdId': self.nsd_id, '_links': { 'nsdInfo': { - 'href': '%s/%s/ns_descriptors/%s' % (pub_config.MSB_BASE_URL, const.NSD_URL_PREFIX, self.nsd_info_id) + 'href': '/%s/ns_descriptors/%s' % ( + const.NSD_URL_PREFIX, self.nsd_info_id) } } } @@ -232,9 +232,8 @@ class PnfNotifications(NotificationsUtil): 'pnfdId': self.pnfd_id, '_links': { 'pnfdInfo': { - 'href': '%s/%s/pnf_descriptors/%s' % (pub_config.MSB_BASE_URL, - const.NSD_URL_PREFIX, - self.pnfd_info_id) + 'href': '/%s/pnf_descriptors/%s' % (const.NSD_URL_PREFIX, + self.pnfd_info_id) } } } diff --git a/catalog/packages/biz/nsdm_subscription.py b/catalog/packages/biz/nsdm_subscription.py index a551c2c..564e936 100644 --- a/catalog/packages/biz/nsdm_subscription.py +++ b/catalog/packages/biz/nsdm_subscription.py @@ -26,7 +26,6 @@ from catalog.pub.database.models import NsdmSubscriptionModel from catalog.pub.exceptions import CatalogException, \ NsdmBadRequestException, NsdmDuplicateSubscriptionException, SubscriptionDoesNotExistsException from catalog.pub.utils.values import ignore_case_get -from catalog.pub.config.config import MSB_BASE_URL logger = logging.getLogger(__name__) @@ -194,7 +193,7 @@ class NsdmSubscription: "Subscription has already existed with the " "same callbackUri and filter:%s" % links) raise NsdmDuplicateSubscriptionException( - "%s/%s" % (MSB_BASE_URL, links["self"]["href"])) + "/%s" % (links["self"]["href"])) def save_db(self): logger.debug("Create Subscription --> Saving the subscription " diff --git a/catalog/packages/biz/vnf_package.py b/catalog/packages/biz/vnf_package.py index e202674..a906cb9 100644 --- a/catalog/packages/biz/vnf_package.py +++ b/catalog/packages/biz/vnf_package.py @@ -24,7 +24,7 @@ import zipfile from catalog.packages import const from catalog.packages.biz.common import parse_file_range, read, save from catalog.packages.biz.notificationsutil import PkgNotifications -from catalog.pub.config.config import CATALOG_ROOT_PATH, MSB_BASE_URL +from catalog.pub.config.config import CATALOG_ROOT_PATH from catalog.pub.database.models import VnfPackageModel, NSPackageModel from catalog.pub.exceptions import CatalogException, ResourceNotFoundException from catalog.pub.utils import fileutil, toscaparser @@ -279,7 +279,7 @@ def fill_artifacts_data(vnf_pkg_id): def fill_links(pkg_id, is_onboarded=False): - self_href = "%s/api/vnfpkgm/v1/vnf_packages/%s" % (MSB_BASE_URL, pkg_id) + self_href = "/api/vnfpkgm/v1/vnf_packages/%s" % (pkg_id) links = { "self": {"href": self_href}, "vnfd": {"href": "%s/%s" % (self_href, "vnfd")}, diff --git a/catalog/packages/biz/vnf_pkg_subscription.py b/catalog/packages/biz/vnf_pkg_subscription.py index 2b2e245..5609403 100644 --- a/catalog/packages/biz/vnf_pkg_subscription.py +++ b/catalog/packages/biz/vnf_pkg_subscription.py @@ -16,18 +16,18 @@ import ast import json import logging import os -import requests import uuid - from collections import Counter -from rest_framework import status + +import requests from requests.auth import HTTPBasicAuth +from rest_framework import status + from catalog.packages import const from catalog.pub.database.models import VnfPkgSubscriptionModel from catalog.pub.exceptions import VnfPkgSubscriptionException, \ VnfPkgDuplicateSubscriptionException, SubscriptionDoesNotExistsException from catalog.pub.utils.values import ignore_case_get -from catalog.pub.config.config import MSB_BASE_URL logger = logging.getLogger(__name__) @@ -133,7 +133,7 @@ class CreateSubscription(object): links = json.loads(subscription.links) logger.error("Subscriptions has already exists with the same callbackUri and filter:%s" % links) raise VnfPkgDuplicateSubscriptionException( - "%s/%s" % (MSB_BASE_URL, links["self"]["href"])) + "/%s" % (links["self"]["href"])) return True |