diff options
author | 2017-09-22 18:43:56 +0800 | |
---|---|---|
committer | 2017-09-22 18:43:56 +0800 | |
commit | b428f80a98ad7d83269589ab9dca0cc190764106 (patch) | |
tree | ac16550a42f9b1652637d6b6cf49b2a5ec8ff693 | |
parent | ab74a293bea69753b37a08e48c191173327e176a (diff) |
Update return value of ns pkg list
Change-Id: I695ea58d0c4e7f132406e14167078b7c29dc011d
Issue-Id: VFC-433
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r-- | catalog/packages/ns_package.py | 9 | ||||
-rw-r--r-- | catalog/packages/tests/test_ns.py | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/catalog/packages/ns_package.py b/catalog/packages/ns_package.py index 37b3cc51..318c0952 100644 --- a/catalog/packages/ns_package.py +++ b/catalog/packages/ns_package.py @@ -112,8 +112,9 @@ class NsPackage(object): artifact = sdc.get_artifact(sdc.ASSETTYPE_SERVICES, csar_id) local_path = os.path.join(CATALOG_ROOT_PATH, csar_id) + csar_name = "%s.csar" % artifact.get("name", csar_id) local_file_name = sdc.download_artifacts(artifact["toscaModelURL"], - local_path, "%s.csar" % artifact.get("name", csar_id)) + local_path, csar_name) nsd_json = toscaparser.parse_nsd(local_file_name) nsd = json.JSONDecoder().decode(nsd_json) @@ -135,7 +136,7 @@ class NsPackage(object): nsdDesginer=nsd["metadata"].get("vendor", "undefined"), nsdDescription=nsd["metadata"].get("description", ""), nsdVersion=nsd["metadata"].get("version", "undefined"), - nsPackageUri=local_file_name, + nsPackageUri="%s/%s" % (csar_id, csar_name), sdcCsarId=csar_id, localFilePath=local_file_name, nsdModel=nsd_json @@ -149,10 +150,10 @@ class NsPackage(object): return [0, "Delete CSAR(%s) successfully." % csar_id] def get_csars(self): - csars = [] + csars = {"csars": []} nss = NSPackageModel.objects.filter() for ns in nss: - csars.append({ + csars["csars"].append({ "csarId": ns.nsPackageId, "nsdId": ns.nsdId }) diff --git a/catalog/packages/tests/test_ns.py b/catalog/packages/tests/test_ns.py index de5aa8ed..3f855afa 100644 --- a/catalog/packages/tests/test_ns.py +++ b/catalog/packages/tests/test_ns.py @@ -464,7 +464,7 @@ class TestNsPackage(TestCase): resp = self.client.get("/api/catalog/v1/nspackages") self.assertEqual(resp.status_code, status.HTTP_200_OK) - self.assertEqual([{"csarId":"13", "nsdId": "2"}], resp.data) + self.assertEqual({"csars": [{"csarId":"13", "nsdId": "2"}]}, resp.data) def test_ns_pkg_get_one(self): NSPackageModel(nsPackageId="14", nsdId="2", nsdDesginer="3", nsdVersion="4").save() |