From 08282ff847cb3ed059aa0334b7e69d97bc45476b Mon Sep 17 00:00:00 2001 From: laili Date: Thu, 23 Aug 2018 13:59:20 +0800 Subject: Ns descriptor related stuffs. Modify the biz of deletion and query. Change-Id: I8162130946da2ca2a5d12f4796bba238e9e7c4c7 Issue-ID: VFC-1037 Signed-off-by: laili --- catalog/packages/biz/ns_descriptor.py | 20 ++++++-------------- catalog/packages/serializers/pnfd_infos.py | 0 2 files changed, 6 insertions(+), 14 deletions(-) create mode 100644 catalog/packages/serializers/pnfd_infos.py diff --git a/catalog/packages/biz/ns_descriptor.py b/catalog/packages/biz/ns_descriptor.py index b69b8e4e..ee0b005b 100644 --- a/catalog/packages/biz/ns_descriptor.py +++ b/catalog/packages/biz/ns_descriptor.py @@ -102,7 +102,7 @@ def query_single(nsd_info_id): 'vnfPkgIds': [], 'pnfdInfoIds': [], # TODO 'nestedNsdInfoIds': [], # TODO - 'nsdOnboardingState': 'CREATED', + 'nsdOnboardingState': ns_pkgs[0].onboardingState, 'onboardingFailureDetails': None, # TODO 'nsdOperationalState': ns_pkgs[0].operationalState, 'nsdUsageState': ns_pkgs[0].usageState, @@ -110,14 +110,6 @@ def query_single(nsd_info_id): '_links': None # TODO } - if ns_pkgs[0].nsdModel: - ns_pkgs[0]['nsdOnboardingState'] = 'ONBOARDED' - elif ns_pkgs[0].localFilePath: # TODO: strip() - ns_pkgs[0]['nsdOnboardingState'] = 'PROCESSING' - elif ns_pkgs[0].nsdId: - ns_pkgs[0]['nsdOnboardingState'] = 'UPLOADING' - ns_pkgs[0]['nsdOnboardingState'] = 'CREATED' - if ns_pkgs[0].nsdModel: nsd_model = json.JSONDecoder().decode(ns_pkgs[0].nsdModel) vnf_pkg_ids = [] @@ -138,13 +130,13 @@ def query_single(nsd_info_id): def delete_single(nsd_info_id): ns_pkgs = NSPackageModel.objects.filter(nsPackageId=nsd_info_id) if not ns_pkgs.exists(): - raise CatalogException('The NS descriptor (%s) does not exist.' % nsd_info_id) - if not ns_pkgs[0].nsdModel: - raise CatalogException('The NS descriptor (%s) is not ONBOARDED.' % nsd_info_id) + return + if ns_pkgs[0].onboardingState == 'ONBOARDED': + raise CatalogException('The NS descriptor (%s) shall be non-ONBOARDED.' % nsd_info_id) if ns_pkgs[0].operationalState != 'DISABLED': - raise CatalogException('The NS descriptor (%s) is not DISABLED.' % nsd_info_id) + raise CatalogException('The NS descriptor (%s) shall be DISABLED.' % nsd_info_id) if ns_pkgs[0].usageState != 'NOT_IN_USE': - raise CatalogException('The NS descriptor (%s) is not NOT_IN_USE.' % nsd_info_id) + raise CatalogException('The NS descriptor (%s) shall be NOT_IN_USE.' % nsd_info_id) ns_pkgs.delete() diff --git a/catalog/packages/serializers/pnfd_infos.py b/catalog/packages/serializers/pnfd_infos.py new file mode 100644 index 00000000..e69de29b -- cgit 1.2.3-korg