Code Review
/
modeling
/
etsicatalog.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
1. Remove the mandatory dependency on MSB
[modeling/etsicatalog.git]
/
catalog
/
packages
/
biz
/
notificationsutil.py
diff --git
a/catalog/packages/biz/notificationsutil.py
b/catalog/packages/biz/notificationsutil.py
index
a13eae9
..
93c26c7
100644
(file)
--- a/
catalog/packages/biz/notificationsutil.py
+++ b/
catalog/packages/biz/notificationsutil.py
@@
-12,21
+12,22
@@
# 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.database.models import VnfPackageModel, VnfPkgSubscriptionModel, NsdmSubscriptionModel
+from catalog.pub.utils.values import remove_none_key
logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
@@
-59,10
+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': 'http://%s:%s/%s%s' % (pub_config.MSB_SERVICE_IP,
- pub_config.MSB_SERVICE_PORT,
- self.subscription_root_uri,
- notification["subscriptionId"])
+ 'href': '/%s%s' % (self.subscription_root_uri, notification["subscriptionId"])
}
callbackuri = sub.callback_uri
"""
}
callbackuri = sub.callback_uri
"""
@@
-109,9
+107,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())
@@
-150,10
+148,7
@@
class PkgNotifications(NotificationsUtil):
'vnfdId': vnfd_id,
'_links': {
'vnfPackage': {
'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/vnf_packages/%s' % (const.PKG_URL_PREFIX, self.vnf_pkg_id)
}
}
}
}
}
}
@@
-196,10
+191,8
@@
class NsdNotifications(NotificationsUtil):
'nsdId': self.nsd_id,
'_links': {
'nsdInfo': {
'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/ns_descriptors/%s' % (
+ const.NSD_URL_PREFIX, self.nsd_info_id)
}
}
}
}
}
}
@@
-239,10
+232,8
@@
class PnfNotifications(NotificationsUtil):
'pnfdId': self.pnfd_id,
'_links': {
'pnfdInfo': {
'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/pnf_descriptors/%s' % (const.NSD_URL_PREFIX,
+ self.pnfd_info_id)
}
}
}
}
}
}