aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfengyuanxing <feng.yuanxing@zte.com.cn>2017-09-04 14:45:32 +0800
committerfengyuanxing <feng.yuanxing@zte.com.cn>2017-09-04 14:45:32 +0800
commitc5fd5f6016b8bef47b00eed0dbaebeced7265f7d (patch)
treeb4ee209d39530ddad0b10199bfd54659cfdbc9fe
parent91a2fb71a0b340ad9cbe508a2ca3043c21bfb034 (diff)
Modify code of getting nsd model file path
Change-Id: I68e820cb6b0d09087bd1d3ebea4d5cd6892983a0 Issue-Id: VFC-254 Signed-off-by: fengyuanxing <feng.yuanxing@zte.com.cn>
-rw-r--r--catalog/packages/ns_package.py8
-rw-r--r--catalog/packages/tests.py7
2 files changed, 7 insertions, 8 deletions
diff --git a/catalog/packages/ns_package.py b/catalog/packages/ns_package.py
index fec97d04..451e9f20 100644
--- a/catalog/packages/ns_package.py
+++ b/catalog/packages/ns_package.py
@@ -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:
diff --git a/catalog/packages/tests.py b/catalog/packages/tests.py
index 23801f02..5c4f4ab0 100644
--- a/catalog/packages/tests.py
+++ b/catalog/packages/tests.py
@@ -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)