vnflcm upgrade from python2 to python3
[vfc/gvnfm/vnflcm.git] / lcm / lcm / pub / utils / notificationsutil.py
index 0a0e1f2..2eb820f 100644 (file)
@@ -46,7 +46,7 @@ class NotificationsUtil(object):
             "operationState": "operation_states",
             "operation": "operation_types"
         }
-        subscriptions_filter = {v + "__contains": notification[k] for k, v in filters.iteritems()}
+        subscriptions_filter = {v + "__contains": notification[k] for k, v in list(filters.items())}
 
         subscriptions = SubscriptionModel.objects.filter(**subscriptions_filter)
         if not subscriptions.exists():
@@ -65,7 +65,7 @@ class NotificationsUtil(object):
                 try:
                     self.post_notification(callbackUri, auth_info, notification)
                 except Exception as e:
-                    logger.error("Failed to post notification: %s", e.message)
+                    logger.error("Failed to post notification: %s", e.args[0])
 
     def post_notification(self, callbackUri, auth_info, notification):
         params = auth_info.get("paramsBasic", {})
@@ -136,7 +136,7 @@ def set_ext_connectivity(ext_connectivity, nfinstid):
             },
             'cpInstanceId': port.portid  # TODO: port.cpinstanceid is not initiated when create port resource.
         })
-    for network_id, ext_link_ports in ext_connectivity_map.items():
+    for network_id, ext_link_ports in list(ext_connectivity_map.items()):
         networks = NetworkInstModel.objects.filter(networkid=network_id)
         net_name = networks[0].name if networks else network_id
         network_resource = {
@@ -171,10 +171,9 @@ def set_affected_vss(affected_vss, nfinstid, changetype):
 
 
 def get_notification_status(operation_state):
-    notification_status = const.LCM_NOTIFICATION_STATUS.START
-    if operation_state in const.RESULT_RANGE:
-        notification_status = const.LCM_NOTIFICATION_STATUS.RESULT
-    return notification_status
+    if operation_state == const.OPERATION_STATE_TYPE.STARTING:
+        return const.LCM_NOTIFICATION_STATUS.START
+    return const.LCM_NOTIFICATION_STATUS.RESULT
 
 
 def prepare_notification(nfinstid, jobid, operation, operation_state):