diff options
author | Fu Jinhua <fu.jinhua@zte.com.cn> | 2018-08-23 07:38:38 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-08-23 07:38:38 +0000 |
commit | 3e7ac8b04ce74558dfae5c8deaeb175ae4b28ba1 (patch) | |
tree | eccd478aa0b034c8b3437965ccd83d1dcbaebc89 | |
parent | 431872934bc9126a44ef65ab59106cca9932b5f7 (diff) | |
parent | f7b64998e97d296daf10c6cc699a8305a6557177 (diff) |
Merge "Deal with nfPackage"
-rw-r--r-- | catalog/packages/biz/vnf_package.py | 17 | ||||
-rw-r--r-- | catalog/packages/views/vnf_package_views.py | 4 |
2 files changed, 17 insertions, 4 deletions
diff --git a/catalog/packages/biz/vnf_package.py b/catalog/packages/biz/vnf_package.py index 1b77d577..a98336d3 100644 --- a/catalog/packages/biz/vnf_package.py +++ b/catalog/packages/biz/vnf_package.py @@ -24,6 +24,7 @@ from catalog.pub.config.config import CATALOG_ROOT_PATH from catalog.pub.database.models import VnfPackageModel from catalog.pub.exceptions import CatalogException from catalog.pub.utils.values import ignore_case_get +from catalog.pub.utils import fileutil logger = logging.getLogger(__name__) @@ -82,8 +83,20 @@ def query_single(vnfPkgId): return pkg_info -def delete_single(vnfPkgId): - return None +def delete_vnf_pkg(vnfPkgId): + vnf_pkg = VnfPackageModel.objects.filter(vnfPackageId=vnfPkgId) + if not vnf_pkg.exists(): + logger.debug('VNF package(%s) is deleted.' % vnfPkgId) + return + if vnf_pkg[0].onboardingState != "CREATED": + raise CatalogException("The VNF package (%s) is not on-boarded" % vnfPkgId) + if vnf_pkg[0].operationalState != "DISABLED": + raise CatalogException("The VNF package (%s) is not disabled" % vnfPkgId) + if vnf_pkg[0].usageState != "NOT_IN_USE": + raise CatalogException("The VNF package (%s) is in use" % vnfPkgId) + vnf_pkg.delete() + vnf_pkg_path = os.path.join(CATALOG_ROOT_PATH, vnfPkgId) + fileutil.delete_dirs(vnf_pkg_path) class VnfpkgUploadThread(threading.Thread): diff --git a/catalog/packages/views/vnf_package_views.py b/catalog/packages/views/vnf_package_views.py index 4915f20c..16596613 100644 --- a/catalog/packages/views/vnf_package_views.py +++ b/catalog/packages/views/vnf_package_views.py @@ -27,7 +27,7 @@ from catalog.packages.serializers.create_vnf_pkg_info_req import CreateVnfPkgInf from catalog.packages.serializers.vnf_pkg_info import VnfPkgInfoSerializer from catalog.packages.serializers.vnf_pkg_infos import VnfPkgInfosSerializer from catalog.packages.biz.vnf_package import create_vnf_pkg, query_multiple, VnfpkgUploadThread, \ - query_single, delete_single + query_single, delete_vnf_pkg logger = logging.getLogger(__name__) @@ -181,7 +181,7 @@ def vnf_package_rd(request, vnfPkgId): if request.method == 'DELETE': logger.debug("Delete an individual VNF package> %s" % request.data) try: - delete_single(vnfPkgId) + delete_vnf_pkg(vnfPkgId) return Response(data=None, status=status.HTTP_204_NO_CONTENT) except CatalogException: logger.error(traceback.format_exc()) |