modify fetch vnf pkg aritfacts 45/87145/1
authorhewei-cmss <hewei@cmss.chinamobile.com>
Tue, 7 May 2019 12:53:57 +0000 (20:53 +0800)
committerhewei-cmss <hewei@cmss.chinamobile.com>
Tue, 7 May 2019 12:53:57 +0000 (20:53 +0800)
Close file and add exception

Issue-ID: VFC-1377

Change-Id: I0f60bb6a268069fd5db4367cd0b45bc7b116eeb2
Signed-off-by: hewei-cmss <hewei@cmss.chinamobile.com>
catalog/packages/biz/vnf_pkg_artifacts.py

index d8a7748..bb79624 100644 (file)
@@ -36,5 +36,8 @@ class FetchVnfPkgArtifact(object):
             artifact_path = fileutil.get_artifact_path(vnf_extract_path, artifactPath)
             if not artifact_path:
                 raise ArtifactNotFoundException("Couldn't artifact %s" % artifactPath)
-        file_content = open(artifact_path, 'rb').read()
+            with open(artifact_path, 'rb') as f:
+                file_content = f.read()
+        else:
+            raise ArtifactNotFoundException("NF Package format is not csar or zip")
         return file_content