1. fix the url of links in VNF 49/106249/1
authordyh <dengyuanhong@chinamobile.com>
Mon, 20 Apr 2020 08:28:21 +0000 (16:28 +0800)
committerdyh <dengyuanhong@chinamobile.com>
Mon, 20 Apr 2020 08:30:56 +0000 (16:30 +0800)
2. fix the log of notification
3. fix the SDC_USER

Issue-ID: MODELING-356
Change-Id: I7c664768f42df91ef154c37b80521e40b875da9a
Signed-off-by: dyh <dengyuanhong@chinamobile.com>
catalog/packages/biz/notificationsutil.py
catalog/packages/biz/vnf_package.py
catalog/packages/tests/test_vnf_package.py
catalog/pub/config/config.py

index a13eae9..4b8f736 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 json
 import logging
 import logging
+import traceback
 import uuid
 import uuid
+
 import requests
 import requests
-import json
-from rest_framework import status
+from django.db.models import Q
 from requests.auth import HTTPBasicAuth
 from requests.auth import HTTPBasicAuth
-from catalog.packages import const
-from catalog.pub.database.models import VnfPackageModel, VnfPkgSubscriptionModel, NsdmSubscriptionModel
+from rest_framework import status
+
 import catalog.pub.utils.timeutil
 import catalog.pub.utils.timeutil
-from catalog.pub.utils.values import remove_none_key
-from catalog.pub.config import config as pub_config
-import traceback
-from django.db.models import Q
+from catalog.packages import const
 from catalog.packages.serializers.vnf_pkg_notifications import PkgChangeNotificationSerializer, \
     PkgOnboardingNotificationSerializer
 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
 
 logger = logging.getLogger(__name__)
 
 
 logger = logging.getLogger(__name__)
 
@@ -109,9 +111,9 @@ class NotificationsUtil(object):
                                      verify=False)
 
             if resp.status_code == status.HTTP_204_NO_CONTENT:
                                      verify=False)
 
             if resp.status_code == status.HTTP_204_NO_CONTENT:
-                logger.error("Sending notification to %s failed: %s" % (callbackuri, resp))
-            else:
                 logger.info("Sending notification to %s successfully.", callbackuri)
                 logger.info("Sending notification to %s successfully.", callbackuri)
+            else:
+                logger.error("Sending notification to %s failed: %s" % (callbackuri, resp))
         except:
             logger.error("Post notification failed.")
             logger.error(traceback.format_exc())
         except:
             logger.error("Post notification failed.")
             logger.error(traceback.format_exc())
index 1073879..20741a5 100644 (file)
@@ -15,7 +15,6 @@
 import json
 import logging
 import os
 import json
 import logging
 import os
-
 import threading
 import traceback
 import urllib
 import threading
 import traceback
 import urllib
@@ -25,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_SERVICE_IP, MSB_SERVICE_PORT
+from catalog.pub.config.config import CATALOG_ROOT_PATH, MSB_SERVICE_IP, MSB_SERVICE_PORT, MSB_SERVICE_PROTOCOL
 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
@@ -280,7 +279,8 @@ 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 = "http://%s:%s/api/vnfpkgm/v1/vnf_packages/%s" % (
+    self_href = "%s://%s:%s/api/vnfpkgm/v1/vnf_packages/%s" % (
+        MSB_SERVICE_PROTOCOL,
         MSB_SERVICE_IP,
         MSB_SERVICE_PORT,
         pkg_id)
         MSB_SERVICE_IP,
         MSB_SERVICE_PORT,
         pkg_id)
index 0b78cbd..289b600 100644 (file)
@@ -26,6 +26,7 @@ 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
@@ -150,9 +151,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': 'http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/222'},
-                       'vnfd': {'href': 'http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/222/vnfd'},
-                       'packageContent': {'href': 'http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/222/package_content'}
+            "_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'},
+                       'packageContent': {
+                           'href': config.MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/222/package_content'}
                        }
         }
         self.assertEqual(response.data, expect_data)
                        }
         }
         self.assertEqual(response.data, expect_data)
@@ -206,13 +209,13 @@ class TestVnfPackage(TestCase):
                 "userDefinedData": {"a": "A"},
                 "_links": {
                     "self": {
                 "userDefinedData": {"a": "A"},
                 "_links": {
                     "self": {
-                        "href": "http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/111"
+                        "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/111"
                     },
                     "vnfd": {
                     },
                     "vnfd": {
-                        "href": "http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/111/vnfd"
+                        "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/111/vnfd"
                     },
                     "packageContent": {
                     },
                     "packageContent": {
-                        "href": "http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/111/package_content"
+                        "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/111/package_content"
                     }
                 }
             },
                     }
                 }
             },
@@ -229,10 +232,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': 'http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/222'},
-                           'vnfd': {'href': 'http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/222/vnfd'},
+                "_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'},
                            'packageContent': {
                            'packageContent': {
-                               'href': 'http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/222/package_content'}}
+                               'href': config.MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/222/package_content'}}
             }
         ]
         self.assertEqual(response.data, expect_data)
             }
         ]
         self.assertEqual(response.data, expect_data)
@@ -474,13 +477,13 @@ class TestVnfPackage(TestCase):
             "usageState": "NOT_IN_USE",
             "_links": {
                 "self": {
             "usageState": "NOT_IN_USE",
             "_links": {
                 "self": {
-                    "href": "http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/222"
+                    "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/222"
                 },
                 "vnfd": {
                 },
                 "vnfd": {
-                    "href": "http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/222/vnfd"
+                    "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/222/vnfd"
                 },
                 "packageContent": {
                 },
                 "packageContent": {
-                    "href": "http://127.0.0.1:80/api/vnfpkgm/v1/vnf_packages/222/package_content"
+                    "href": config.MSB_BASE_URL + "/api/vnfpkgm/v1/vnf_packages/222/package_content"
                 }
             }
         }
                 }
             }
         }
index 3b8a59e..a4a8ce5 100644 (file)
 # limitations under the License.
 
 # [MSB]
 # limitations under the License.
 
 # [MSB]
+MSB_SERVICE_PROTOCOL = 'https'
 MSB_SERVICE_IP = '127.0.0.1'
 MSB_SERVICE_PORT = '80'
 MSB_SERVICE_IP = '127.0.0.1'
 MSB_SERVICE_PORT = '80'
+MSB_BASE_URL = "%s://%s:%s" % (MSB_SERVICE_PROTOCOL, MSB_SERVICE_IP, MSB_SERVICE_PORT)
 
 # [REDIS]
 # REDIS_HOST = '127.0.0.1'
 
 # [REDIS]
 # REDIS_HOST = '127.0.0.1'
@@ -92,7 +94,7 @@ CATALOG_URL_PATH = None
 
 # [sdc config]
 SDC_BASE_URL = "https://msb-iag/api"
 
 # [sdc config]
 SDC_BASE_URL = "https://msb-iag/api"
-SDC_USER = "aai"
+SDC_USER = "modeling"
 SDC_PASSWD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"
 
 VNFD_SCHEMA_VERSION_DEFAULT = "base"
 SDC_PASSWD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"
 
 VNFD_SCHEMA_VERSION_DEFAULT = "base"