aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordyh <dengyuanhong@chinamobile.com>2020-04-20 16:28:21 +0800
committerdyh <dengyuanhong@chinamobile.com>2020-04-20 16:30:56 +0800
commit3ff968b21a477944ed66b4261f5d9c9a182eb954 (patch)
tree5d889f4761ff6d591a0da490f8cbc9dfcdc3ff0f
parent9d63f079341419d875ac5e697cefde920d26c802 (diff)
1. fix the url of links in VNF
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>
-rw-r--r--catalog/packages/biz/notificationsutil.py22
-rw-r--r--catalog/packages/biz/vnf_package.py6
-rw-r--r--catalog/packages/tests/test_vnf_package.py27
-rw-r--r--catalog/pub/config/config.py4
4 files changed, 33 insertions, 26 deletions
diff --git a/catalog/packages/biz/notificationsutil.py b/catalog/packages/biz/notificationsutil.py
index a13eae9..4b8f736 100644
--- a/catalog/packages/biz/notificationsutil.py
+++ b/catalog/packages/biz/notificationsutil.py
@@ -12,21 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import json
import logging
+import traceback
import uuid
+
import requests
-import json
-from rest_framework import status
+from django.db.models import Q
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
-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.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__)
@@ -109,9 +111,9 @@ class NotificationsUtil(object):
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)
+ else:
+ logger.error("Sending notification to %s failed: %s" % (callbackuri, resp))
except:
logger.error("Post notification failed.")
logger.error(traceback.format_exc())
diff --git a/catalog/packages/biz/vnf_package.py b/catalog/packages/biz/vnf_package.py
index 1073879..20741a5 100644
--- a/catalog/packages/biz/vnf_package.py
+++ b/catalog/packages/biz/vnf_package.py
@@ -15,7 +15,6 @@
import json
import logging
import os
-
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.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
@@ -280,7 +279,8 @@ def fill_artifacts_data(vnf_pkg_id):
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)
diff --git a/catalog/packages/tests/test_vnf_package.py b/catalog/packages/tests/test_vnf_package.py
index 0b78cbd..289b600 100644
--- a/catalog/packages/tests/test_vnf_package.py
+++ b/catalog/packages/tests/test_vnf_package.py
@@ -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.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
@@ -150,9 +151,11 @@ class TestVnfPackage(TestCase):
"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)
@@ -206,13 +209,13 @@ class TestVnfPackage(TestCase):
"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": {
- "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": {
- "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"},
- "_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': {
- '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)
@@ -474,13 +477,13 @@ class TestVnfPackage(TestCase):
"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": {
- "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": {
- "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"
}
}
}
diff --git a/catalog/pub/config/config.py b/catalog/pub/config/config.py
index 3b8a59e..a4a8ce5 100644
--- a/catalog/pub/config/config.py
+++ b/catalog/pub/config/config.py
@@ -13,8 +13,10 @@
# limitations under the License.
# [MSB]
+MSB_SERVICE_PROTOCOL = 'https'
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'
@@ -92,7 +94,7 @@ CATALOG_URL_PATH = None
# [sdc config]
SDC_BASE_URL = "https://msb-iag/api"
-SDC_USER = "aai"
+SDC_USER = "modeling"
SDC_PASSWD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"
VNFD_SCHEMA_VERSION_DEFAULT = "base"