Deal with nfPackage 91/61791/1
authorbiancunkang <bian.cunkang@zte.com.cn>
Wed, 22 Aug 2018 07:40:00 +0000 (15:40 +0800)
committerbiancunkang <bian.cunkang@zte.com.cn>
Wed, 22 Aug 2018 07:40:00 +0000 (15:40 +0800)
Change-Id: Iee6b610f740864fe56873678159b25c663e02cc1
Issue-ID: VFC-1038
Signed-off-by: biancunkang <bian.cunkang@zte.com.cn>
catalog/packages/biz/nf_package.py
catalog/packages/serializers/vnf_pkg_info.py

index 9f0eae0..b660d07 100644 (file)
@@ -19,6 +19,7 @@ import sys
 import threading
 import traceback
 import urllib2
+import uuid
 
 from catalog.pub.config.config import CATALOG_ROOT_PATH, CATALOG_URL_PATH, MSB_SERVICE_IP
 from catalog.pub.config.config import REG_TO_MSB_REG_PARAM
@@ -78,6 +79,23 @@ def parse_vnfd(csar_id, inputs):
     return [0, ret]
 
 
+def create_vnf_pkg(data):
+    user_defined_data = ignore_case_get(data, "userDefinedData")
+    vnfPkgId = str(uuid.uuid4())
+    VnfPackageModel.objects.create(
+        vnfPackageId=vnfPkgId
+    )
+    data = {
+        "id": vnfPkgId,
+        "onboardingState": "CREATED",
+        "operationalState": "DISABLED",
+        "usageState": "NOT_IN_USE",
+        "userDefinedData": user_defined_data,
+        "_links": None
+    }
+    return data
+
+
 class NfDistributeThread(threading.Thread):
     """
     Sdc NF Package Distribute
index c6f7273..4c63a46 100644 (file)
@@ -103,5 +103,5 @@ class VnfPkgInfoSerializer(serializers.Serializer):
     _links = _LinkSerializer(
         help_text='Links to resources related to this resource.',
         required=True,
-        allow_null=False
+        allow_null=True  # TODO supposed to be False
     )