Update python2 to python3
[vfc/nfvo/lcm.git] / lcm / ns_vnfs / views / vnf_views.py
index a672ed5..593ac76 100644 (file)
@@ -11,6 +11,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
 import logging
 import traceback
 
@@ -20,9 +21,9 @@ from rest_framework.response import Response
 from rest_framework.views import APIView
 
 from lcm.ns_vnfs.biz.grant_vnf import GrantVnf
-from lcm.ns_vnfs.biz.handle_notification import HandleVnfLcmOocNotification, HandleVnfIdentifierCreationNotification, HandleVnfIdentifierDeletionNotification
 from lcm.ns_vnfs.serializers.grant_vnf_serializer import GrantRequestSerializer
 from lcm.ns_vnfs.serializers.grant_vnf_serializer import GrantSerializer
+from lcm.ns_vnfs.biz.handle_notification import HandleVnfLcmOocNotification, HandleVnfIdentifierCreationNotification, HandleVnfIdentifierDeletionNotification
 from lcm.ns_vnfs.serializers.grant_vnf_serializer import VnfLcmOperationOccurrenceNotificationSerializer, VnfIdentifierCreationNotificationSerializer, VnfIdentifierDeletionNotificationSerializer
 
 logger = logging.getLogger(__name__)
@@ -54,8 +55,8 @@ class VnfGrantView(APIView):
             return Response(data=resp_serializer.data, status=status.HTTP_201_CREATED)
         except Exception as e:
             logger.error(traceback.format_exc())
-            logger.error("Exception in VnfGrant: %s", e.message)
-            return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+            logger.error("Exception in VnfGrant: %s", e.args[0])
+            return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
 
 class VnfNotifyView(APIView):
@@ -76,17 +77,17 @@ class VnfNotifyView(APIView):
             if notification_type == 'VnfLcmOperationOccurrenceNotification':
                 notification = VnfLcmOperationOccurrenceNotificationSerializer(data=request.data)
                 if not notification.is_valid():
-                    raise Exception(notification.errors)
+                    logger.warn(notification.errors)
                 HandleVnfLcmOocNotification(vnfmId, vnfInstanceId, notification.data).do_biz()
             elif notification_type == 'VnfIdentifierCreationNotification':
                 notification = VnfIdentifierCreationNotificationSerializer(data=request.data)
                 if not notification.is_valid():
-                    raise Exception(notification.errors)
+                    logger.warn(notification.errors)
                 HandleVnfIdentifierCreationNotification(vnfmId, vnfInstanceId, notification.data).do_biz()
             elif notification_type == 'VnfIdentifierDeletionNotification':
                 notification = VnfIdentifierDeletionNotificationSerializer(data=request.data)
                 if not notification.is_valid():
-                    raise Exception(notification.errors)
+                    logger.warn(notification.errors)
                 HandleVnfIdentifierDeletionNotification(vnfmId, vnfInstanceId, notification.data).do_biz()
             else:
                 raise Exception('Unexpected noitifcation type value.')