diff options
author | biancunkang <bian.cunkang@zte.com.cn> | 2018-08-27 10:45:34 +0800 |
---|---|---|
committer | biancunkang <bian.cunkang@zte.com.cn> | 2018-08-27 10:45:34 +0800 |
commit | d58f1c71fb1571671a0a7c83ee0d09b068440d32 (patch) | |
tree | e0642e22cda82ff6f4f8b8097fa6111b8311fe3f | |
parent | 083f361ccba199c8df0aba4a9033b59fa4594bed (diff) |
Deal with nfPackage
Code refactoring
Change-Id: I27847d2c2f53a6674e2d634b3c887f4b205e6c1c
Issue-ID: VFC-1038
Signed-off-by: biancunkang <bian.cunkang@zte.com.cn>
-rw-r--r-- | catalog/packages/biz/vnf_package.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/catalog/packages/biz/vnf_package.py b/catalog/packages/biz/vnf_package.py index d63df9ae..71ec697e 100644 --- a/catalog/packages/biz/vnf_package.py +++ b/catalog/packages/biz/vnf_package.py @@ -58,30 +58,16 @@ def query_multiple(): if not nf_pkgs.exists(): raise CatalogException('VNF packages do not exist.') for nf_pkg in nf_pkgs: - ret = query_single(nf_pkg.vnfPackageId) + ret = fill_response_data(nf_pkg) pkgs_info.append(ret) return pkgs_info def query_single(vnf_pkg_id): - pkg_info = {} nf_pkg = VnfPackageModel.objects.filter(vnfPackageId=vnf_pkg_id) if not nf_pkg.exists(): raise CatalogException('VNF package(%s) does not exist.' % vnf_pkg_id) - pkg_info["id"] = nf_pkg[0].vnfPackageId - pkg_info["vnfdId"] = nf_pkg[0].vnfdId - pkg_info["vnfProductName"] = nf_pkg[0].vnfdProductName - pkg_info["vnfSoftwareVersion"] = nf_pkg[0].vnfSoftwareVersion - pkg_info["vnfdVersion"] = nf_pkg[0].vnfdVersion - pkg_info["checksum"] = json.JSONDecoder().decode(nf_pkg[0].checksum) - pkg_info["softwareImages"] = None # TODO - pkg_info["additionalArtifacts"] = None # TODO - pkg_info["onboardingState"] = nf_pkg[0].onboardingState - pkg_info["operationalState"] = nf_pkg[0].operationalState - pkg_info["usageState"] = nf_pkg[0].usageState - pkg_info["userDefinedData"] = json.JSONDecoder().decode(nf_pkg[0].userDefinedData) - pkg_info["_links"] = None # TODO - return pkg_info + return fill_response_data(nf_pkg) def delete_vnf_pkg(vnf_pkg_id): @@ -160,3 +146,21 @@ class VnfPkgUploadThread(threading.Thread): save_file.write(req.read()) save_file.close() req.close() + + +def fill_response_data(nf_pkg): + pkg_info = {} + pkg_info["id"] = nf_pkg[0].vnfPackageId + pkg_info["vnfdId"] = nf_pkg[0].vnfdId + pkg_info["vnfProductName"] = nf_pkg[0].vnfdProductName + pkg_info["vnfSoftwareVersion"] = nf_pkg[0].vnfSoftwareVersion + pkg_info["vnfdVersion"] = nf_pkg[0].vnfdVersion + pkg_info["checksum"] = json.JSONDecoder().decode(nf_pkg[0].checksum) + pkg_info["softwareImages"] = None # TODO + pkg_info["additionalArtifacts"] = None # TODO + pkg_info["onboardingState"] = nf_pkg[0].onboardingState + pkg_info["operationalState"] = nf_pkg[0].operationalState + pkg_info["usageState"] = nf_pkg[0].usageState + pkg_info["userDefinedData"] = json.JSONDecoder().decode(nf_pkg[0].userDefinedData) + pkg_info["_links"] = None # TODO + return pkg_info |