Modify code of getting nsd model file path 51/10151/1
authorfengyuanxing <feng.yuanxing@zte.com.cn>
Mon, 4 Sep 2017 06:45:32 +0000 (14:45 +0800)
committerfengyuanxing <feng.yuanxing@zte.com.cn>
Mon, 4 Sep 2017 06:45:32 +0000 (14:45 +0800)
Change-Id: I68e820cb6b0d09087bd1d3ebea4d5cd6892983a0
Issue-Id: VFC-254
Signed-off-by: fengyuanxing <feng.yuanxing@zte.com.cn>
catalog/packages/ns_package.py
catalog/packages/tests.py

index fec97d0..451e9f2 100644 (file)
@@ -91,13 +91,9 @@ def parser_nsdmodel(csar_id,inputs):
 
         if nf_pkg:
             for pkg in nf_pkg:
-                csarid = pkg.nsd_id
-                csar_path = os.path.join(os.path.dirname(__file__), pkg.nsd_path)
-                f = file(csar_path)
-                line = f.readline(1)
-                f.close()
+                csar_path = pkg.nsd_path
+                ret={"model":toscaparser.parse_nsd(csar_path,inputs)}
                 continue
-            ret={"model":toscaparser.parse_nsd(csar_path,inputs)}
     except CatalogException as e:
         return [1, e.message]
     except:
index 23801f0..5c4f4ab 100644 (file)
@@ -14,6 +14,7 @@
 
 import unittest
 import mock
+import os
 import catalog.pub.utils.restcall
 import json
 from catalog.packages.ns_package import NsPackage
@@ -586,14 +587,16 @@ class PackageTest(unittest.TestCase):
     @mock.patch.object(NsPackage,'get_nsd')
     def test_ns_distribute(self, mock_get_nsd,mock_get_vnfd):
         # First distribute a VNF
-        local_file_name = "/resource/resource-TestFyx-template.yml"
+        template_file_name = "resource-TestFyx-template.yml"
+        local_file_name = os.path.join(os.path.dirname(__file__), template_file_name)
         vnfd = json.JSONEncoder().encode(self.vnfd_json)
         mock_get_vnfd.return_value = self.vnfd_json,local_file_name,vnfd
         NfDistributeThread(str(self.nf_csarId), ["1"], "1", "4").run()
         self.assert_nfmodel_result(str(self.nf_csarId), 1)
 
         # Then distribute a NS associated with the below VNF
-        local_file_name = "service-TestServiceFyx-template.yml"
+        template_file_name = "service-TestServiceFyx-template.yml"
+        local_file_name = os.path.join(os.path.dirname(__file__), template_file_name)
         nsd = json.JSONEncoder().encode(self.nsd_json)
         mock_get_nsd.return_value = self.nsd_json,local_file_name,nsd
         response = self.client.post("/api/catalog/v1/nspackages",self.nsdata)