summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-10-17 11:32:58 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-10-17 11:32:58 +0800
commit0bb97fffee35f0cda747b27ce2637bab8ce30df5 (patch)
tree97fda18bd52c350feae84dc5f8404bfc5074ba4a
parent4fab8bda58bbcfb5b93e6f1797844fe4a98e160b (diff)
Fix del vnf package logic
Change-Id: Icaeb5650207cab85c76ea36831ec6866570758aa Issue-ID: VFC-1151 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--catalog/packages/biz/vnf_package.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/catalog/packages/biz/vnf_package.py b/catalog/packages/biz/vnf_package.py
index 0444e989..be8edba4 100644
--- a/catalog/packages/biz/vnf_package.py
+++ b/catalog/packages/biz/vnf_package.py
@@ -23,7 +23,7 @@ import uuid
from catalog.packages.biz.common import parse_file_range, read, save
from catalog.pub.config.config import CATALOG_ROOT_PATH
-from catalog.pub.database.models import VnfPackageModel
+from catalog.pub.database.models import VnfPackageModel, NSPackageModel
from catalog.pub.exceptions import CatalogException, ResourceNotFoundException
from catalog.pub.utils.values import ignore_case_get
from catalog.pub.utils import fileutil, toscaparser
@@ -84,6 +84,17 @@ class VnfPackage(object):
if vnf_pkg[0].usageState != PKG_STATUS.NOT_IN_USE:
raise CatalogException("The VNF package (%s) is in use" % vnf_pkg_id)
'''
+ del_vnfd_id = vnf_pkg[0].vnfdId
+ ns_pkgs = NSPackageModel.objects.all()
+ for ns_pkg in ns_pkgs:
+ nsd_model = None
+ if ns_pkg.nsdModel:
+ nsd_model = json.JSONDecoder().decode(ns_pkg.nsdModel)
+ if not nsd_model:
+ continue
+ for vnf in nsd_model['vnfs']:
+ if del_vnfd_id == vnf["properties"]["id"]:
+ raise CatalogException('VNFD(%s) is referenced.' % del_vnfd_id)
vnf_pkg.delete()
vnf_pkg_path = os.path.join(CATALOG_ROOT_PATH, vnf_pkg_id)
fileutil.delete_dirs(vnf_pkg_path)