Optimize ns instant.
[vfc/nfvo/lcm.git] / lcm / ns / serializers / sol / affected_nss.py
index c35b083..d4d6170 100644 (file)
@@ -1,4 +1,5 @@
 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+# Copyright (c) 2019, ZTE Corporation.
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 
 from rest_framework import serializers
 
-from lcm.ns import const
-
-
-CHANGE_TYPE = [
-    const.CHANGE_TYPES.ADD,
-    const.CHANGE_TYPES.REMOVE,
-    const.CHANGE_TYPES.INSTANTIATE,
-    const.CHANGE_TYPES.SCALE,
-    const.CHANGE_TYPES.UPDATE,
-    const.CHANGE_TYPES.HEAL,
-    const.CHANGE_TYPES.TERMINATE
-]
-
-CHANGE_RESULT = [
-    const.CHANGE_RESULTS.COMPLETED,
-    const.CHANGE_RESULTS.ROLLED_BACK,
-    const.CHANGE_RESULTS.FAILED,
-    const.CHANGE_RESULTS.PARTIALLY_COMPLETED
-]
+from lcm.ns.enum import CHANGE_TYPE, CHANGE_RESULT
+from lcm.pub.utils.enumutil import enum_to_list
 
 
 class AffectedNssSerializer(serializers.Serializer):
@@ -48,10 +32,10 @@ class AffectedNssSerializer(serializers.Serializer):
     changeType = serializers.ChoiceField(
         help_text="Signals the type of change",
         required=True,
-        choices=CHANGE_TYPE
+        choices=enum_to_list(CHANGE_TYPE)
     )
     changeResult = serializers.ChoiceField(
         help_text="Signals the result of change identified by the 'changeType' attribute.",
         required=True,
-        choices=CHANGE_RESULT
+        choices=enum_to_list(CHANGE_RESULT)
     )