1. Remove the mandatory dependency on MSB 45/110945/2
authordyh <dengyuanhong@chinamobile.com>
Thu, 6 Aug 2020 01:20:55 +0000 (09:20 +0800)
committerdyh <dengyuanhong@chinamobile.com>
Fri, 7 Aug 2020 07:37:08 +0000 (15:37 +0800)
2. Refactor config file

Change-Id: I8317ee0e1440e177a54e5510c6393529b6a3a5fe
Issue-ID: MODELING-411
Signed-off-by: dyh <dengyuanhong@chinamobile.com>
13 files changed:
catalog/packages/biz/notificationsutil.py
catalog/packages/biz/nsdm_subscription.py
catalog/packages/biz/vnf_package.py
catalog/packages/biz/vnf_pkg_subscription.py
catalog/packages/tests/test_nsdm_subscription.py
catalog/packages/tests/test_vnf_package.py
catalog/packages/tests/test_vnf_pkg_subscription.py
catalog/packages/tests/test_vnfpackage.py
catalog/pub/config/config.py
catalog/pub/msapi/sdc_controller.py
catalog/pub/utils/restcall.py
catalog/settings.py
catalog/urls.py

index 31760cc..93c26c7 100644 (file)
@@ -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.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
 
 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'] = {
             # 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
             """
             }
             callbackuri = sub.callback_uri
             """
@@ -149,7 +148,7 @@ class PkgNotifications(NotificationsUtil):
             'vnfdId': vnfd_id,
             '_links': {
                 'vnfPackage': {
             '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': {
             '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': {
             '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)
                 }
             }
         }
                 }
             }
         }
index a551c2c..564e936 100644 (file)
@@ -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.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__)
 
 
 logger = logging.getLogger(__name__)
 
@@ -194,7 +193,7 @@ class NsdmSubscription:
                     "Subscription has already existed with the "
                     "same callbackUri and filter:%s" % links)
                 raise NsdmDuplicateSubscriptionException(
                     "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 "
 
     def save_db(self):
         logger.debug("Create Subscription --> Saving the subscription "
index e202674..a906cb9 100644 (file)
@@ -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.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
 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):
 
 
 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")},
     links = {
         "self": {"href": self_href},
         "vnfd": {"href": "%s/%s" % (self_href, "vnfd")},
index 2b2e245..5609403 100644 (file)
@@ -16,18 +16,18 @@ import ast
 import json
 import logging
 import os
 import json
 import logging
 import os
-import requests
 import uuid
 import uuid
-
 from collections import Counter
 from collections import Counter
-from rest_framework import status
+
+import requests
 from requests.auth import HTTPBasicAuth
 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.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__)
 
 
 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(
                 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
 
 
         return True
 
index 61c8ce6..41c8648 100644 (file)
 # limitations under the License.
 
 import json
 # limitations under the License.
 
 import json
-import mock
-import uuid
 import os
 import os
+import uuid
+
+import mock
 from django.test import TestCase
 from django.test import TestCase
-from rest_framework.test import APIClient
-from rest_framework import status
 from requests.auth import HTTPBasicAuth
 from requests.auth import HTTPBasicAuth
+from rest_framework import status
+from rest_framework.test import APIClient
 
 
-from catalog.packages.biz.nsdm_subscription import NsdmSubscription
-from catalog.pub.database.models import NsdmSubscriptionModel
-from catalog.packages.biz.notificationsutil import NsdNotifications, PnfNotifications
-from catalog.packages import const
-from catalog.pub.config import config as pub_config
 import catalog.pub.utils.timeutil
 import catalog.pub.utils.timeutil
+from catalog.packages import const
+from catalog.packages.biz.notificationsutil import NsdNotifications, PnfNotifications
+from catalog.packages.biz.nsdm_subscription import NsdmSubscription
 from catalog.packages.tests.const import nsd_data
 from catalog.packages.tests.const import nsd_data
+from catalog.pub.config.config import CATALOG_ROOT_PATH
 from catalog.pub.database.models import NSPackageModel, VnfPackageModel, PnfPackageModel
 from catalog.pub.database.models import NSPackageModel, VnfPackageModel, PnfPackageModel
-from catalog.pub.config.config import CATALOG_ROOT_PATH, MSB_BASE_URL
+from catalog.pub.database.models import NsdmSubscriptionModel
 from catalog.pub.utils import toscaparser
 
 
 from catalog.pub.utils import toscaparser
 
 
@@ -180,7 +180,7 @@ class TestNsdmSubscription(TestCase):
         response = self.client.post("/api/nsd/v1/subscriptions",
                                     data=self.subscription, format='json')
         self.assertEqual(303, response.status_code)
         response = self.client.post("/api/nsd/v1/subscriptions",
                                     data=self.subscription, format='json')
         self.assertEqual(303, response.status_code)
-        redirect_addr = "%s/%s" % (MSB_BASE_URL, os.path.join(const.NSDM_SUBSCRIPTION_ROOT_URI, subscriptionid))
+        redirect_addr = "/%s" % (os.path.join(const.NSDM_SUBSCRIPTION_ROOT_URI, subscriptionid))
         self.assertEqual(redirect_addr, response["Location"])
 
     @mock.patch("requests.get")
         self.assertEqual(redirect_addr, response["Location"])
 
     @mock.patch("requests.get")
@@ -626,9 +626,10 @@ class TestNsdmSubscription(TestCase):
             'nsdId': "b632bddc-bccd-4180-bd8d-4e8a9578eff7",
             '_links': {
                 'nsdInfo': {
             'nsdId': "b632bddc-bccd-4180-bd8d-4e8a9578eff7",
             '_links': {
                 'nsdInfo': {
-                    'href': '%s/%s/ns_descriptors/%s' % (pub_config.MSB_BASE_URL, const.NSD_URL_PREFIX, "d0ea5ec3-0b98-438a-9bea-488230cff174")},
+                    'href': '/%s/ns_descriptors/%s' % (
+                        const.NSD_URL_PREFIX, "d0ea5ec3-0b98-438a-9bea-488230cff174")},
                 'subscription': {
                 'subscription': {
-                    'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.NSDM_SUBSCRIPTION_ROOT_URI, "1111")}
+                    'href': '/%s%s' % (const.NSDM_SUBSCRIPTION_ROOT_URI, "1111")}
 
             },
             "subscriptionId": "1111"
 
             },
             "subscriptionId": "1111"
@@ -675,10 +676,10 @@ class NotificationTest(TestCase):
             'nsdId': "nsdid1",
             '_links': {
                 'nsdInfo': {
             'nsdId': "nsdid1",
             '_links': {
                 'nsdInfo': {
-                    'href': '%s/%s/ns_descriptors/%s' % (pub_config.MSB_BASE_URL, const.NSD_URL_PREFIX, "nsdinfoid1")
+                    'href': '/%s/ns_descriptors/%s' % (const.NSD_URL_PREFIX, "nsdinfoid1")
                 },
                 'subscription': {
                 },
                 'subscription': {
-                    'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.NSDM_SUBSCRIPTION_ROOT_URI, "1")}
+                    'href': '/%s%s' % (const.NSDM_SUBSCRIPTION_ROOT_URI, "1")}
             },
             'onboardingFailureDetails': "NSD(nsdid1) already exists.",
             "subscriptionId": "1"
             },
             'onboardingFailureDetails': "NSD(nsdid1) already exists.",
             "subscriptionId": "1"
@@ -711,10 +712,10 @@ class NotificationTest(TestCase):
             'pnfdId': "pnfdId1",
             '_links': {
                 'pnfdInfo': {
             'pnfdId': "pnfdId1",
             '_links': {
                 'pnfdInfo': {
-                    'href': '%s/%s/pnf_descriptors/%s' % (pub_config.MSB_BASE_URL, const.NSD_URL_PREFIX, "pnfdInfoIds1")
+                    'href': '/%s/pnf_descriptors/%s' % (const.NSD_URL_PREFIX, "pnfdInfoIds1")
                 },
                 'subscription': {
                 },
                 'subscription': {
-                    'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.NSDM_SUBSCRIPTION_ROOT_URI, "1")},
+                    'href': '/%s%s' % (const.NSDM_SUBSCRIPTION_ROOT_URI, "1")},
             },
             "subscriptionId": "1",
         }
             },
             "subscriptionId": "1",
         }
index 289b600..b2675a8 100644 (file)
@@ -26,7 +26,6 @@ from rest_framework.test import APIClient
 from catalog.packages.biz.vnf_package import VnfPackage, VnfPkgUploadThread
 from catalog.packages.const import PKG_STATUS
 from catalog.packages.tests.const import vnfd_data
 from catalog.packages.biz.vnf_package import VnfPackage, VnfPkgUploadThread
 from catalog.packages.const import PKG_STATUS
 from catalog.packages.tests.const import vnfd_data
-from catalog.pub.config import config
 from catalog.pub.config.config import CATALOG_ROOT_PATH
 from catalog.pub.database.models import VnfPackageModel
 from catalog.pub.utils import toscaparser
 from catalog.pub.config.config import CATALOG_ROOT_PATH
 from catalog.pub.database.models import VnfPackageModel
 from catalog.pub.utils import toscaparser
@@ -151,11 +150,11 @@ class TestVnfPackage(TestCase):
             "operationalState": "DISABLED",
             "usageState": "NOT_IN_USE",
             "userDefinedData": {"a": "A"},
             "operationalState": "DISABLED",
             "usageState": "NOT_IN_USE",
             "userDefinedData": {"a": "A"},
-            "_links": {'self': {'href': config.MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/222'},
+            "_links": {'self': {'href': '/api/vnfpkgm/v1/vnf_packages/222'},
                        'vnfd': {
                        'vnfd': {
-                           'href': config.MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/222/vnfd'},
+                           'href': '/api/vnfpkgm/v1/vnf_packages/222/vnfd'},
                        'packageContent': {
                        'packageContent': {
-                           'href': config.MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/222/package_content'}
+                           'href': '/api/vnfpkgm/v1/vnf_packages/222/package_content'}
                        }
         }
         self.assertEqual(response.data, expect_data)
                        }
         }
         self.assertEqual(response.data, expect_data)
@@ -209,13 +208,13 @@ class TestVnfPackage(TestCase):
                 "userDefinedData": {"a": "A"},
                 "_links": {
                     "self": {
                 "userDefinedData": {"a": "A"},
                 "_links": {
                     "self": {
-                        "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/111"
+                        "href": "/api/vnfpkgm/v1/vnf_packages/111"
                     },
                     "vnfd": {
                     },
                     "vnfd": {
-                        "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/111/vnfd"
+                        "href": "/api/vnfpkgm/v1/vnf_packages/111/vnfd"
                     },
                     "packageContent": {
                     },
                     "packageContent": {
-                        "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/111/package_content"
+                        "href": "/api/vnfpkgm/v1/vnf_packages/111/package_content"
                     }
                 }
             },
                     }
                 }
             },
@@ -232,10 +231,10 @@ class TestVnfPackage(TestCase):
                 "operationalState": "DISABLED",
                 "usageState": "NOT_IN_USE",
                 "userDefinedData": {"a": "A"},
                 "operationalState": "DISABLED",
                 "usageState": "NOT_IN_USE",
                 "userDefinedData": {"a": "A"},
-                "_links": {'self': {'href': config.MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/222'},
-                           'vnfd': {'href': config.MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/222/vnfd'},
+                "_links": {'self': {'href': '/api/vnfpkgm/v1/vnf_packages/222'},
+                           'vnfd': {'href': '/api/vnfpkgm/v1/vnf_packages/222/vnfd'},
                            'packageContent': {
                            'packageContent': {
-                               'href': config.MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/222/package_content'}}
+                               'href': '/api/vnfpkgm/v1/vnf_packages/222/package_content'}}
             }
         ]
         self.assertEqual(response.data, expect_data)
             }
         ]
         self.assertEqual(response.data, expect_data)
@@ -477,13 +476,13 @@ class TestVnfPackage(TestCase):
             "usageState": "NOT_IN_USE",
             "_links": {
                 "self": {
             "usageState": "NOT_IN_USE",
             "_links": {
                 "self": {
-                    "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/222"
+                    "href": "/api/vnfpkgm/v1/vnf_packages/222"
                 },
                 "vnfd": {
                 },
                 "vnfd": {
-                    "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/222/vnfd"
+                    "href": "/api/vnfpkgm/v1/vnf_packages/222/vnfd"
                 },
                 "packageContent": {
                 },
                 "packageContent": {
-                    "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/222/package_content"
+                    "href": "/api/vnfpkgm/v1/vnf_packages/222/package_content"
                 }
             }
         }
                 }
             }
         }
index f9f6ff2..f989b17 100644 (file)
@@ -18,21 +18,20 @@ import uuid
 
 import mock
 from django.test import TestCase
 
 import mock
 from django.test import TestCase
+from requests.auth import HTTPBasicAuth
 from rest_framework import status
 from rest_framework.test import APIClient
 from rest_framework import status
 from rest_framework.test import APIClient
-from requests.auth import HTTPBasicAuth
 
 import catalog.pub.utils.timeutil
 from catalog.packages import const
 from catalog.packages.biz.notificationsutil import PkgNotifications
 from catalog.packages.biz.vnf_pkg_subscription import QuerySubscription, TerminateSubscription
 
 import catalog.pub.utils.timeutil
 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_BASE_URL
+from catalog.packages.tests.const import vnfd_data
+from catalog.pub.config.config import CATALOG_ROOT_PATH
 from catalog.pub.database.models import VnfPkgSubscriptionModel, VnfPackageModel
 from catalog.pub.exceptions import SubscriptionDoesNotExistsException
 from catalog.pub.database.models import VnfPkgSubscriptionModel, VnfPackageModel
 from catalog.pub.exceptions import SubscriptionDoesNotExistsException
-from .const import vnf_subscription_data
 from catalog.pub.utils import toscaparser
 from catalog.pub.utils import toscaparser
-from catalog.packages.tests.const import vnfd_data
+from .const import vnf_subscription_data
 
 
 class TestNfPackageSubscription(TestCase):
 
 
 class TestNfPackageSubscription(TestCase):
@@ -92,7 +91,7 @@ class TestNfPackageSubscription(TestCase):
             format='json'
         )
         self.assertEqual(303, response.status_code)
             format='json'
         )
         self.assertEqual(303, response.status_code)
-        redirect_addr = "%s/%s" % (MSB_BASE_URL, os.path.join(const.VNFPKG_SUBSCRIPTION_ROOT_URI, temp_uuid))
+        redirect_addr = "/%s" % (os.path.join(const.VNFPKG_SUBSCRIPTION_ROOT_URI, temp_uuid))
         self.assertEqual(redirect_addr, response["Location"])
 
     @mock.patch("requests.get")
         self.assertEqual(redirect_addr, response["Location"])
 
     @mock.patch("requests.get")
@@ -259,14 +258,15 @@ class TestNfPackageSubscription(TestCase):
             'vnfdId': uuid_vnfdid,
             '_links': {
                 'vnfPackage': {
             'vnfdId': uuid_vnfdid,
             '_links': {
                 'vnfPackage': {
-                    'href': '%s/%s/vnf_packages/%s' % (pub_config.MSB_BASE_URL, const.PKG_URL_PREFIX, uuid_vnfPackageId)
+                    'href': '/%s/vnf_packages/%s' % (const.PKG_URL_PREFIX, uuid_vnfPackageId)
                 },
                 'subscription': {
                 },
                 'subscription': {
-                    'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.VNFPKG_SUBSCRIPTION_ROOT_URI, uuid_subscriptid)}
+                    'href': '/%s%s' % (const.VNFPKG_SUBSCRIPTION_ROOT_URI, uuid_subscriptid)}
             },
             "subscriptionId": uuid_subscriptid
         }
             },
             "subscriptionId": uuid_subscriptid
         }
-        mock_requests_post.assert_called_with(vnf_subscription_data["callbackUri"], data=json.dumps(expect_notification),
+        mock_requests_post.assert_called_with(vnf_subscription_data["callbackUri"],
+                                              data=json.dumps(expect_notification),
                                               headers={'Connection': 'close',
                                                        'content-type': 'application/json',
                                                        'accept': 'application/json'},
                                               headers={'Connection': 'close',
                                                        'content-type': 'application/json',
                                                        'accept': 'application/json'},
@@ -326,10 +326,10 @@ class NotificationTest(TestCase):
             'vnfdId': "vnfdid1",
             '_links': {
                 'vnfPackage': {
             'vnfdId': "vnfdid1",
             '_links': {
                 'vnfPackage': {
-                    'href': '%s/%s/vnf_packages/%s' % (pub_config.MSB_BASE_URL, const.PKG_URL_PREFIX, "vnfpkgid1")
+                    'href': '/%s/vnf_packages/%s' % (const.PKG_URL_PREFIX, "vnfpkgid1")
                 },
                 'subscription': {
                 },
                 'subscription': {
-                    'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.VNFPKG_SUBSCRIPTION_ROOT_URI, "1")}
+                    'href': '/%s%s' % (const.VNFPKG_SUBSCRIPTION_ROOT_URI, "1")}
             },
             'changeType': const.PKG_CHANGE_TYPE.OP_STATE_CHANGE,
             'operationalState': None,
             },
             'changeType': const.PKG_CHANGE_TYPE.OP_STATE_CHANGE,
             'operationalState': None,
index e4f292c..2478dca 100644 (file)
 # limitations under the License.
 
 import json
 # limitations under the License.
 
 import json
-import mock
 import os
 import os
-import catalog.pub.utils.timeutil
-from requests.auth import HTTPBasicAuth
 
 
+import mock
 from django.test import TestCase
 from django.test import TestCase
+from requests.auth import HTTPBasicAuth
 from rest_framework import status
 from rest_framework.test import APIClient
 
 from rest_framework import status
 from rest_framework.test import APIClient
 
+import catalog.pub.utils.timeutil
+from catalog.packages import const
 from catalog.packages.biz.sdc_vnf_package import NfDistributeThread, NfPkgDeleteThread
 from catalog.packages.biz.sdc_vnf_package import NfDistributeThread, NfPkgDeleteThread
+from catalog.pub.config.config import CATALOG_ROOT_PATH
 from catalog.pub.database.models import JobStatusModel, JobModel
 from catalog.pub.database.models import VnfPackageModel
 from catalog.pub.msapi import sdc
 from catalog.pub.utils import restcall, toscaparser
 from .const import vnfd_data
 from catalog.pub.database.models import JobStatusModel, JobModel
 from catalog.pub.database.models import VnfPackageModel
 from catalog.pub.msapi import sdc
 from catalog.pub.utils import restcall, toscaparser
 from .const import vnfd_data
-from catalog.pub.config.config import CATALOG_ROOT_PATH
-from catalog.packages import const
-from catalog.pub.config import config as pub_config
 
 
 class TestNfPackage(TestCase):
 
 
 class TestNfPackage(TestCase):
@@ -326,9 +325,9 @@ class TestNfPackage(TestCase):
             'vnfdId': "b1bb0ce7-2222-4fa7-95ed-4840d70a1177",
             '_links': {
                 'vnfPackage': {
             'vnfdId': "b1bb0ce7-2222-4fa7-95ed-4840d70a1177",
             '_links': {
                 'vnfPackage': {
-                    'href': '%s/%s/vnf_packages/%s' % (pub_config.MSB_BASE_URL, const.PKG_URL_PREFIX, uuid_csarid)},
+                    'href': '/%s/vnf_packages/%s' % (const.PKG_URL_PREFIX, uuid_csarid)},
                 'subscription': {
                 'subscription': {
-                    'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.VNFPKG_SUBSCRIPTION_ROOT_URI, uuid_subscriptid)}
+                    'href': '/%s%s' % (const.VNFPKG_SUBSCRIPTION_ROOT_URI, uuid_subscriptid)}
 
             },
             "subscriptionId": uuid_subscriptid
 
             },
             "subscriptionId": uuid_subscriptid
@@ -350,11 +349,11 @@ class TestNfPackage(TestCase):
             'vnfdId': "b1bb0ce7-2222-4fa7-95ed-4840d70a1177",
             '_links': {
                 'vnfPackage': {
             'vnfdId': "b1bb0ce7-2222-4fa7-95ed-4840d70a1177",
             '_links': {
                 'vnfPackage': {
-                    'href': '%s/%s/vnf_packages/%s' % (pub_config.MSB_BASE_URL, const.PKG_URL_PREFIX,
-                                                       uuid_csarid)},
-                    'subscription': {
-                        'href': '%s/%s%s' % (pub_config.MSB_BASE_URL, const.VNFPKG_SUBSCRIPTION_ROOT_URI,
-                                             uuid_subscriptid)}
+                    'href': '/%s/vnf_packages/%s' % (const.PKG_URL_PREFIX,
+                                                     uuid_csarid)},
+                'subscription': {
+                    'href': '/%s%s' % (const.VNFPKG_SUBSCRIPTION_ROOT_URI,
+                                       uuid_subscriptid)}
 
             },
             'changeType': const.PKG_CHANGE_TYPE.PKG_DELETE,
 
             },
             'changeType': const.PKG_CHANGE_TYPE.PKG_DELETE,
index 2c42c7a..49d1d84 100644 (file)
 # limitations under the License.
 
 import os
 # limitations under the License.
 
 import os
-env_dict = os.environ
 
 # [MSB]
 
 # [MSB]
-MSB_SERVICE_PROTOCOL = env_dict.get("MSB_PROTO", "http")
-MSB_SERVICE_IP = env_dict.get("MSB_ADDR", "127.0.0.1:80").split(':')[0]
-MSB_SERVICE_PORT = env_dict.get("MSB_ADDR", "127.0.0.1:80").split(':')[1]
-MSB_BASE_URL = "%s://%s:%s" % (MSB_SERVICE_PROTOCOL, MSB_SERVICE_IP, MSB_SERVICE_PORT)
+MSB_BASE_URL = os.getenv("MSB_ADDR", "http://127.0.0.1:80")
+MSB_ENABLED = os.getenv("MSB_ENABLED", "true")
+
+# [SDC config]
+if MSB_ENABLED == "true":
+    SDC_BASE_URL = MSB_BASE_URL + "/api"
+else:
+    SDC_BASE_URL = os.getenv("SDC_ADDR")
+SDC_USER = "modeling"
+SDC_PASSWD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"
+
+SERVICE_IP = os.getenv("SERVICE_IP", "127.0.0.1")
+
+# [DMAAP config]
+DMAAP_ENABLED = os.getenv("DMAAP_ENABLED", False)
+DMAAP_MR_BASE_URL = os.getenv("DMAAP_ADDR")
+CONSUMER_GROUP = "consumerGroup"
+CONSUMER_ID = "consumerId"
+POLLING_INTERVAL = 15
 
 # [mysql]
 
 # [mysql]
-DB_IP = env_dict.get("MYSQL_ADDR", "127.0.0.1:3306").split(':')[0]
-DB_PORT = env_dict.get("MYSQL_ADDR", "127.0.0.1:3306").split(':')[1]
+DB_IP = os.getenv("DB_IP", "127.0.0.1")
+DB_PORT = os.getenv("DB_PORT", "3306")
 DB_NAME = "etsicatalog"
 DB_NAME = "etsicatalog"
-DB_USER = "etsicatalog"
-DB_PASSWD = "etsicatalog"
+DB_USER = os.getenv("DB_USER", "etsicatalog")
+DB_PASSWD = os.getenv("DB_PASSWD", "etsicatalog")
 
 # [MDC]
 SERVICE_NAME = "catalog"
 
 # [MDC]
 SERVICE_NAME = "catalog"
@@ -34,59 +48,54 @@ FORWARDED_FOR_FIELDS = ["HTTP_X_FORWARDED_FOR", "HTTP_X_FORWARDED_HOST",
                         "HTTP_X_FORWARDED_SERVER"]
 
 # [register]
                         "HTTP_X_FORWARDED_SERVER"]
 
 # [register]
-REG_TO_MSB_WHEN_START = True
+REG_TO_MSB_WHEN_START = False
 REG_TO_MSB_REG_URL = "/api/microservices/v1/services"
 REG_TO_MSB_REG_URL = "/api/microservices/v1/services"
-SSL_ENABLED = env_dict.get("SSL_ENABLED", "true")
-if SSL_ENABLED == "true":
-    enable_ssl = "true"
-else:
-    enable_ssl = "false"
-svc_ip = env_dict.get("SERVICE_IP", "127.0.0.1")
+SSL_ENABLED = os.getenv("SSL_ENABLED", "false")
 REG_TO_MSB_REG_PARAM = [{
     "serviceName": "catalog",
     "version": "v1",
 REG_TO_MSB_REG_PARAM = [{
     "serviceName": "catalog",
     "version": "v1",
-    "enable_ssl": enable_ssl,
+    "enable_ssl": SSL_ENABLED,
     "url": "/api/catalog/v1",
     "protocol": "REST",
     "visualRange": "1",
     "nodes": [{
     "url": "/api/catalog/v1",
     "protocol": "REST",
     "visualRange": "1",
     "nodes": [{
-        "ip": svc_ip,
+        "ip": SERVICE_IP,
         "port": "8806",
         "ttl": 0
     }]
 }, {
     "serviceName": "nsd",
     "version": "v1",
         "port": "8806",
         "ttl": 0
     }]
 }, {
     "serviceName": "nsd",
     "version": "v1",
-    "enable_ssl": enable_ssl,
+    "enable_ssl": SSL_ENABLED,
     "url": "/api/nsd/v1",
     "protocol": "REST",
     "visualRange": "1",
     "nodes": [{
     "url": "/api/nsd/v1",
     "protocol": "REST",
     "visualRange": "1",
     "nodes": [{
-        "ip": svc_ip,
+        "ip": SERVICE_IP,
         "port": "8806",
         "ttl": 0
     }]
 }, {
     "serviceName": "vnfpkgm",
     "version": "v1",
         "port": "8806",
         "ttl": 0
     }]
 }, {
     "serviceName": "vnfpkgm",
     "version": "v1",
-    "enable_ssl": enable_ssl,
+    "enable_ssl": SSL_ENABLED,
     "url": "/api/vnfpkgm/v1",
     "protocol": "REST",
     "visualRange": "1",
     "nodes": [{
     "url": "/api/vnfpkgm/v1",
     "protocol": "REST",
     "visualRange": "1",
     "nodes": [{
-        "ip": svc_ip,
+        "ip": SERVICE_IP,
         "port": "8806",
         "ttl": 0
     }]
 }, {
     "serviceName": "parser",
     "version": "v1",
         "port": "8806",
         "ttl": 0
     }]
 }, {
     "serviceName": "parser",
     "version": "v1",
-    "enable_ssl": enable_ssl,
+    "enable_ssl": SSL_ENABLED,
     "url": "/api/parser/v1",
     "protocol": "REST",
     "visualRange": "1",
     "nodes": [{
     "url": "/api/parser/v1",
     "protocol": "REST",
     "visualRange": "1",
     "nodes": [{
-        "ip": svc_ip,
+        "ip": SERVICE_IP,
         "port": "8806",
         "ttl": 0
     }]
         "port": "8806",
         "ttl": 0
     }]
@@ -100,16 +109,4 @@ MSB_SVC_PARSER_URL = "/api/microservices/v1/services/parser/version/v1"
 CATALOG_ROOT_PATH = None
 CATALOG_URL_PATH = None
 
 CATALOG_ROOT_PATH = None
 CATALOG_URL_PATH = None
 
-# [sdc config]
-SDC_BASE_URL = MSB_BASE_URL + "/api"
-SDC_USER = "modeling"
-SDC_PASSWD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"
-
-# [dmaap config]
-DMAAP_MR_IP = MSB_SERVICE_IP
-DMAAP_MR_PORT = '30226'
-CONSUMER_GROUP = "consumerGroup"
-CONSUMER_ID = "consumerId"
-POLLING_INTERVAL = 15
-
 VNFD_SCHEMA_VERSION_DEFAULT = "base"
 VNFD_SCHEMA_VERSION_DEFAULT = "base"
index 505443a..74a5ae8 100644 (file)
@@ -12,13 +12,11 @@ from apscheduler.scheduler import Scheduler
 from catalog.pub.Dmaap_lib.dmaap.consumer import ConsumerClient
 from catalog.pub.Dmaap_lib.dmaap.identity import IdentityClient
 from catalog.pub.Dmaap_lib.dmaap.publisher import BatchPublisherClient
 from catalog.pub.Dmaap_lib.dmaap.consumer import ConsumerClient
 from catalog.pub.Dmaap_lib.dmaap.identity import IdentityClient
 from catalog.pub.Dmaap_lib.dmaap.publisher import BatchPublisherClient
-from catalog.pub.config.config import CONSUMER_GROUP, CONSUMER_ID, POLLING_INTERVAL, DMAAP_MR_IP, \
-    DMAAP_MR_PORT
+from catalog.pub.config.config import CONSUMER_GROUP, CONSUMER_ID, POLLING_INTERVAL, DMAAP_MR_BASE_URL
 from catalog.pub.msapi import sdc
 
 logger = logging.getLogger(__name__)
 
 from catalog.pub.msapi import sdc
 
 logger = logging.getLogger(__name__)
 
-DMAAP_MR_BASE_URL = "https://%s:%s" % (DMAAP_MR_IP, DMAAP_MR_PORT)
 ARTIFACT_TYPES_LIST = ["TOSCA_TEMPLATE", "TOSCA_CSAR"]
 
 
 ARTIFACT_TYPES_LIST = ["TOSCA_TEMPLATE", "TOSCA_CSAR"]
 
 
index 4d40068..6dbab78 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import base64
+import logging
 import sys
 import traceback
 import sys
 import traceback
-import logging
 import urllib
 import uuid
 import urllib
 import uuid
+
 import httplib2
 import httplib2
-import base64
 
 from catalog.pub.config.config import MSB_BASE_URL
 
 
 from catalog.pub.config.config import MSB_BASE_URL
 
index cbb90d7..81127b8 100644 (file)
 # limitations under the License.
 
 import os
 # limitations under the License.
 
 import os
-import sys
 import platform
 import platform
+import sys
+from logging import config as log_config
 
 
-# import catalog.pub.redisco
+from onaplogging import monkey
 
 
-# from catalog.pub.config.config import REDIS_HOST, REDIS_PORT, REDIS_PASSWD
-from catalog.pub.config.config import DB_NAME, DB_IP, DB_USER, DB_PASSWD, DB_PORT
 from catalog.pub.config import config as pub_config
 from catalog.pub.config import config as pub_config
-from logging import config as log_config
-from onaplogging import monkey
+from catalog.pub.config.config import DB_NAME, DB_IP, DB_USER, DB_PASSWD, DB_PORT
 
 monkey.patch_all()
 
 
 monkey.patch_all()
 
@@ -139,7 +137,6 @@ STATICFILES_DIRS = [
 
 pub_config.CATALOG_ROOT_PATH = os.path.join(STATICFILES_DIRS[0], "catalog")
 pub_config.CATALOG_URL_PATH = "static/catalog"
 
 pub_config.CATALOG_ROOT_PATH = os.path.join(STATICFILES_DIRS[0], "catalog")
 pub_config.CATALOG_URL_PATH = "static/catalog"
-pub_config.SDC_BASE_URL = "https://%s:%s/api" % (pub_config.MSB_SERVICE_IP, pub_config.MSB_SERVICE_PORT)
 
 if platform.system() == 'Windows' or 'test' in sys.argv:
     LOGGING = {
 
 if platform.system() == 'Windows' or 'test' in sys.argv:
     LOGGING = {
index f149716..9429e5d 100644 (file)
@@ -16,7 +16,7 @@ from django.conf.urls import include, url
 from django.contrib import admin
 
 from catalog.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG_TO_MSB_REG_PARAM, \
 from django.contrib import admin
 
 from catalog.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG_TO_MSB_REG_PARAM, \
-    MSB_SVC_CALALOG_URL, MSB_SVC_NSD_URL, MSB_SVC_VNFPKGM_URL, MSB_SVC_PARSER_URL
+    MSB_SVC_CALALOG_URL, MSB_SVC_NSD_URL, MSB_SVC_VNFPKGM_URL, MSB_SVC_PARSER_URL, DMAAP_ENABLED
 from catalog.pub.msapi.sdc_controller import SDCController
 
 urlpatterns = [
 from catalog.pub.msapi.sdc_controller import SDCController
 
 urlpatterns = [
@@ -39,4 +39,5 @@ if REG_TO_MSB_WHEN_START:
     for reg_param in REG_TO_MSB_REG_PARAM:
         req_by_msb(REG_TO_MSB_REG_URL, "POST", json.JSONEncoder().encode(reg_param))
 
     for reg_param in REG_TO_MSB_REG_PARAM:
         req_by_msb(REG_TO_MSB_REG_URL, "POST", json.JSONEncoder().encode(reg_param))
 
-SDCController().start()
+if DMAAP_ENABLED:
+    SDCController().start()