summaryrefslogtreecommitdiffstats
path: root/catalog/packages
diff options
context:
space:
mode:
authordengyh <dengyuanhong@chinamobile.com>2020-07-29 17:03:15 +0800
committerdengyh <dengyuanhong@chinamobile.com>2020-07-29 17:13:59 +0800
commit246df561b466d1202a40ece1c133a4bf70ab958f (patch)
treee70c39f22467a1ea0f826c5ca438d7d178535dc4 /catalog/packages
parent7a0c2aa47bc5297a7977e7b7d1a362768efa1e17 (diff)
Unity MSB address
Change-Id: Ie1ded953213ed156ff7a1f4d884851ddd93c18e5 Issue-ID: MODELING-405 Signed-off-by: dengyh <dengyuanhong@chinamobile.com>
Diffstat (limited to 'catalog/packages')
-rw-r--r--catalog/packages/biz/notificationsutil.py22
-rw-r--r--catalog/packages/biz/nsdm_subscription.py4
-rw-r--r--catalog/packages/biz/vnf_package.py8
-rw-r--r--catalog/packages/biz/vnf_pkg_subscription.py4
-rw-r--r--catalog/packages/tests/test_nsdm_subscription.py35
-rw-r--r--catalog/packages/tests/test_vnf_pkg_subscription.py25
-rw-r--r--catalog/packages/tests/test_vnfpackage.py22
7 files changed, 32 insertions, 88 deletions
diff --git a/catalog/packages/biz/notificationsutil.py b/catalog/packages/biz/notificationsutil.py
index 4b8f736..31760cc 100644
--- a/catalog/packages/biz/notificationsutil.py
+++ b/catalog/packages/biz/notificationsutil.py
@@ -61,10 +61,7 @@ class NotificationsUtil(object):
# set subscription id
notification["subscriptionId"] = sub.get_subscription_id()
notification['_links']['subscription'] = {
- 'href': 'http://%s:%s/%s%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- self.subscription_root_uri,
- notification["subscriptionId"])
+ 'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, self.subscription_root_uri, notification["subscriptionId"])
}
callbackuri = sub.callback_uri
"""
@@ -152,10 +149,7 @@ class PkgNotifications(NotificationsUtil):
'vnfdId': vnfd_id,
'_links': {
'vnfPackage': {
- 'href': 'http://%s:%s/%s/vnf_packages/%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.PKG_URL_PREFIX,
- self.vnf_pkg_id)
+ 'href': '%s/%s/vnf_packages/%s' % (pub_config.MSB_BASE_URL, const.PKG_URL_PREFIX, self.vnf_pkg_id)
}
}
}
@@ -198,10 +192,7 @@ class NsdNotifications(NotificationsUtil):
'nsdId': self.nsd_id,
'_links': {
'nsdInfo': {
- 'href': 'http://%s:%s/%s/ns_descriptors/%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.NSD_URL_PREFIX,
- self.nsd_info_id)
+ 'href': '%s/%s/ns_descriptors/%s' % (pub_config.MSB_BASE_URL, const.NSD_URL_PREFIX, self.nsd_info_id)
}
}
}
@@ -241,10 +232,9 @@ class PnfNotifications(NotificationsUtil):
'pnfdId': self.pnfd_id,
'_links': {
'pnfdInfo': {
- 'href': 'http://%s:%s/%s/pnf_descriptors/%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.NSD_URL_PREFIX,
- self.pnfd_info_id)
+ 'href': '%s/%s/pnf_descriptors/%s' % (pub_config.MSB_BASE_URL,
+ 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 84bacde..a551c2c 100644
--- a/catalog/packages/biz/nsdm_subscription.py
+++ b/catalog/packages/biz/nsdm_subscription.py
@@ -26,7 +26,7 @@ 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_SERVICE_IP, MSB_SERVICE_PORT
+from catalog.pub.config.config import MSB_BASE_URL
logger = logging.getLogger(__name__)
@@ -194,7 +194,7 @@ class NsdmSubscription:
"Subscription has already existed with the "
"same callbackUri and filter:%s" % links)
raise NsdmDuplicateSubscriptionException(
- "https://%s:%s/%s" % (MSB_SERVICE_IP, MSB_SERVICE_PORT, links["self"]["href"]))
+ "%s/%s" % (MSB_BASE_URL, 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 20741a5..e202674 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_SERVICE_IP, MSB_SERVICE_PORT, MSB_SERVICE_PROTOCOL
+from catalog.pub.config.config import CATALOG_ROOT_PATH, MSB_BASE_URL
from catalog.pub.database.models import VnfPackageModel, NSPackageModel
from catalog.pub.exceptions import CatalogException, ResourceNotFoundException
from catalog.pub.utils import fileutil, toscaparser
@@ -279,11 +279,7 @@ def fill_artifacts_data(vnf_pkg_id):
def fill_links(pkg_id, is_onboarded=False):
- self_href = "%s://%s:%s/api/vnfpkgm/v1/vnf_packages/%s" % (
- MSB_SERVICE_PROTOCOL,
- MSB_SERVICE_IP,
- MSB_SERVICE_PORT,
- pkg_id)
+ self_href = "%s/api/vnfpkgm/v1/vnf_packages/%s" % (MSB_BASE_URL, 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 fef90b4..2b2e245 100644
--- a/catalog/packages/biz/vnf_pkg_subscription.py
+++ b/catalog/packages/biz/vnf_pkg_subscription.py
@@ -27,7 +27,7 @@ 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_SERVICE_IP, MSB_SERVICE_PORT
+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(
- "https://%s:%s/%s" % (MSB_SERVICE_IP, MSB_SERVICE_PORT, links["self"]["href"]))
+ "%s/%s" % (MSB_BASE_URL, links["self"]["href"]))
return True
diff --git a/catalog/packages/tests/test_nsdm_subscription.py b/catalog/packages/tests/test_nsdm_subscription.py
index b992b2d..61c8ce6 100644
--- a/catalog/packages/tests/test_nsdm_subscription.py
+++ b/catalog/packages/tests/test_nsdm_subscription.py
@@ -29,7 +29,7 @@ from catalog.pub.config import config as pub_config
import catalog.pub.utils.timeutil
from catalog.packages.tests.const import nsd_data
from catalog.pub.database.models import NSPackageModel, VnfPackageModel, PnfPackageModel
-from catalog.pub.config.config import CATALOG_ROOT_PATH, MSB_SERVICE_IP, MSB_SERVICE_PORT
+from catalog.pub.config.config import CATALOG_ROOT_PATH, MSB_BASE_URL
from catalog.pub.utils import toscaparser
@@ -180,8 +180,7 @@ class TestNsdmSubscription(TestCase):
response = self.client.post("/api/nsd/v1/subscriptions",
data=self.subscription, format='json')
self.assertEqual(303, response.status_code)
- redirect_addr = "https://%s:%s/%s" % (MSB_SERVICE_IP, MSB_SERVICE_PORT,
- os.path.join(const.NSDM_SUBSCRIPTION_ROOT_URI, subscriptionid))
+ redirect_addr = "%s/%s" % (MSB_BASE_URL, os.path.join(const.NSDM_SUBSCRIPTION_ROOT_URI, subscriptionid))
self.assertEqual(redirect_addr, response["Location"])
@mock.patch("requests.get")
@@ -627,15 +626,9 @@ class TestNsdmSubscription(TestCase):
'nsdId': "b632bddc-bccd-4180-bd8d-4e8a9578eff7",
'_links': {
'nsdInfo': {
- 'href': 'http://%s:%s/%s/ns_descriptors/%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.NSD_URL_PREFIX,
- "d0ea5ec3-0b98-438a-9bea-488230cff174")},
+ 'href': '%s/%s/ns_descriptors/%s' % (pub_config.MSB_BASE_URL, const.NSD_URL_PREFIX, "d0ea5ec3-0b98-438a-9bea-488230cff174")},
'subscription': {
- 'href': 'http://%s:%s/%s%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.NSDM_SUBSCRIPTION_ROOT_URI,
- "1111")}
+ 'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.NSDM_SUBSCRIPTION_ROOT_URI, "1111")}
},
"subscriptionId": "1111"
@@ -682,16 +675,10 @@ class NotificationTest(TestCase):
'nsdId': "nsdid1",
'_links': {
'nsdInfo': {
- 'href': 'http://%s:%s/%s/ns_descriptors/%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.NSD_URL_PREFIX,
- "nsdinfoid1")
+ 'href': '%s/%s/ns_descriptors/%s' % (pub_config.MSB_BASE_URL, const.NSD_URL_PREFIX, "nsdinfoid1")
},
'subscription': {
- 'href': 'http://%s:%s/%s%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.NSDM_SUBSCRIPTION_ROOT_URI,
- "1")}
+ 'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.NSDM_SUBSCRIPTION_ROOT_URI, "1")}
},
'onboardingFailureDetails': "NSD(nsdid1) already exists.",
"subscriptionId": "1"
@@ -724,16 +711,10 @@ class NotificationTest(TestCase):
'pnfdId': "pnfdId1",
'_links': {
'pnfdInfo': {
- 'href': 'http://%s:%s/%s/pnf_descriptors/%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.NSD_URL_PREFIX,
- "pnfdInfoIds1")
+ 'href': '%s/%s/pnf_descriptors/%s' % (pub_config.MSB_BASE_URL, const.NSD_URL_PREFIX, "pnfdInfoIds1")
},
'subscription': {
- 'href': 'http://%s:%s/%s%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.NSDM_SUBSCRIPTION_ROOT_URI,
- "1")},
+ 'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.NSDM_SUBSCRIPTION_ROOT_URI, "1")},
},
"subscriptionId": "1",
}
diff --git a/catalog/packages/tests/test_vnf_pkg_subscription.py b/catalog/packages/tests/test_vnf_pkg_subscription.py
index 28edd64..f9f6ff2 100644
--- a/catalog/packages/tests/test_vnf_pkg_subscription.py
+++ b/catalog/packages/tests/test_vnf_pkg_subscription.py
@@ -27,7 +27,7 @@ from catalog.packages import const
from catalog.packages.biz.notificationsutil import PkgNotifications
from catalog.packages.biz.vnf_pkg_subscription import QuerySubscription, TerminateSubscription
from catalog.pub.config import config as pub_config
-from catalog.pub.config.config import CATALOG_ROOT_PATH, MSB_SERVICE_IP, MSB_SERVICE_PORT
+from catalog.pub.config.config import CATALOG_ROOT_PATH, MSB_BASE_URL
from catalog.pub.database.models import VnfPkgSubscriptionModel, VnfPackageModel
from catalog.pub.exceptions import SubscriptionDoesNotExistsException
from .const import vnf_subscription_data
@@ -92,8 +92,7 @@ class TestNfPackageSubscription(TestCase):
format='json'
)
self.assertEqual(303, response.status_code)
- redirect_addr = "https://%s:%s/%s" % (MSB_SERVICE_IP, MSB_SERVICE_PORT,
- os.path.join(const.VNFPKG_SUBSCRIPTION_ROOT_URI, temp_uuid))
+ redirect_addr = "%s/%s" % (MSB_BASE_URL, os.path.join(const.VNFPKG_SUBSCRIPTION_ROOT_URI, temp_uuid))
self.assertEqual(redirect_addr, response["Location"])
@mock.patch("requests.get")
@@ -260,16 +259,10 @@ class TestNfPackageSubscription(TestCase):
'vnfdId': uuid_vnfdid,
'_links': {
'vnfPackage': {
- 'href': 'http://%s:%s/%s/vnf_packages/%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.PKG_URL_PREFIX,
- uuid_vnfPackageId)
+ 'href': '%s/%s/vnf_packages/%s' % (pub_config.MSB_BASE_URL, const.PKG_URL_PREFIX, uuid_vnfPackageId)
},
'subscription': {
- 'href': 'http://%s:%s/%s%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.VNFPKG_SUBSCRIPTION_ROOT_URI,
- uuid_subscriptid)}
+ 'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.VNFPKG_SUBSCRIPTION_ROOT_URI, uuid_subscriptid)}
},
"subscriptionId": uuid_subscriptid
}
@@ -333,16 +326,10 @@ class NotificationTest(TestCase):
'vnfdId': "vnfdid1",
'_links': {
'vnfPackage': {
- 'href': 'http://%s:%s/%s/vnf_packages/%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.PKG_URL_PREFIX,
- "vnfpkgid1")
+ 'href': '%s/%s/vnf_packages/%s' % (pub_config.MSB_BASE_URL, const.PKG_URL_PREFIX, "vnfpkgid1")
},
'subscription': {
- 'href': 'http://%s:%s/%s%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.VNFPKG_SUBSCRIPTION_ROOT_URI,
- "1")}
+ 'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.VNFPKG_SUBSCRIPTION_ROOT_URI, "1")}
},
'changeType': const.PKG_CHANGE_TYPE.OP_STATE_CHANGE,
'operationalState': None,
diff --git a/catalog/packages/tests/test_vnfpackage.py b/catalog/packages/tests/test_vnfpackage.py
index df27212..e4f292c 100644
--- a/catalog/packages/tests/test_vnfpackage.py
+++ b/catalog/packages/tests/test_vnfpackage.py
@@ -326,15 +326,9 @@ class TestNfPackage(TestCase):
'vnfdId': "b1bb0ce7-2222-4fa7-95ed-4840d70a1177",
'_links': {
'vnfPackage': {
- 'href': 'http://%s:%s/%s/vnf_packages/%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.PKG_URL_PREFIX,
- uuid_csarid)},
+ 'href': '%s/%s/vnf_packages/%s' % (pub_config.MSB_BASE_URL, const.PKG_URL_PREFIX, uuid_csarid)},
'subscription': {
- 'href': 'http://%s:%s/%s%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.VNFPKG_SUBSCRIPTION_ROOT_URI,
- uuid_subscriptid)}
+ 'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.VNFPKG_SUBSCRIPTION_ROOT_URI, uuid_subscriptid)}
},
"subscriptionId": uuid_subscriptid
@@ -356,15 +350,11 @@ class TestNfPackage(TestCase):
'vnfdId': "b1bb0ce7-2222-4fa7-95ed-4840d70a1177",
'_links': {
'vnfPackage': {
- 'href': 'http://%s:%s/%s/vnf_packages/%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.PKG_URL_PREFIX,
- uuid_csarid)},
+ 'href': '%s/%s/vnf_packages/%s' % (pub_config.MSB_BASE_URL, const.PKG_URL_PREFIX,
+ uuid_csarid)},
'subscription': {
- 'href': 'http://%s:%s/%s%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- const.VNFPKG_SUBSCRIPTION_ROOT_URI,
- uuid_subscriptid)}
+ 'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.VNFPKG_SUBSCRIPTION_ROOT_URI,
+ uuid_subscriptid)}
},
'changeType': const.PKG_CHANGE_TYPE.PKG_DELETE,