Remove 'vnf_packages' key from vnf package list response

As per ETSI GS NFV-SOL 005 V2.4.1 (2018-02) table 9.4.2.3.2-2, GET Vnf
Packages should return list of all Vnf packages, but as per current
implemention this api is returning dictionory with resource name as key
i.e {'vnf_packages': [{vnf_package1}, {vnf_package2},...]}. Hence
removing the resource key and returning api response as a list.

As per process to fix this issue we need to provide micro version
support in tacker as well as in python-tackerclient for command.
The list api was part of VNF package api which released in train cycle.
But we can not instantiate, terminate and Heal VNF as these feature is
not released yet and about to release in U cycle. The changes we have
proposed will be useful after U release and that is why we think we
should do these change without micro version support.

Closes-bug: #1871054
Change-Id: I7f5105fc7a49f9d31fb32119c725dae0421cfde7
This commit is contained in:
Shubham 2020-04-03 17:55:48 +05:30 committed by Prashant Bhole
parent ffee7ed0dc
commit 70ac63d834
4 changed files with 24 additions and 12 deletions

View File

@ -0,0 +1,14 @@
---
fixes:
- |
Includes the fix for `bug 1871054`_ which as per
`ETSI GS NFV-SOL 005 V2.6.1`_ table 9.4.2.3.2-2 should return list of vnf
packages in ``list`` instead of ``dictionary`` for
``GET /vnfpkgm/v1/vnf_packages`` API.
.. note:: Users should use python-tackerclient version >= 1.0.1 to list
vnf packages otherwise it would break as this change is not
backward compatible.
.. _ETSI GS NFV-SOL 005 V2.6.1: https://www.etsi.org/deliver/etsi_gs/NFV-SOL/001_099/005/02.06.01_60/gs_nfv-sol005v020601p.pdf
.. _bug 1871054 : https://bugs.launchpad.net/tacker/+bug/1871054

View File

@ -118,5 +118,5 @@ class ViewBuilder(base.BaseViewBuilder):
include_fields = set(self.FLATTEN_ATTRIBUTES.keys()) - \ include_fields = set(self.FLATTEN_ATTRIBUTES.keys()) - \
exclude_fields exclude_fields
return {'vnf_packages': [self._get_vnf_package(vnf_package, return [self._get_vnf_package(vnf_package,
include_fields=include_fields)for vnf_package in vnf_packages]} include_fields=include_fields)for vnf_package in vnf_packages]

View File

@ -146,7 +146,7 @@ class VnfPackageTest(base.BaseTackerTest):
resp, body = self.http_client.do_request(self.base_url, "GET") resp, body = self.http_client.do_request(self.base_url, "GET")
self.assertEqual(200, resp.status_code) self.assertEqual(200, resp.status_code)
package_uuids = [obj['id'] for obj in body['vnf_packages']] package_uuids = [obj['id'] for obj in body]
self.assertIn(vnf_package_list[0], package_uuids) self.assertIn(vnf_package_list[0], package_uuids)
self.assertIn(vnf_package_list[1], package_uuids) self.assertIn(vnf_package_list[1], package_uuids)
@ -225,7 +225,7 @@ class VnfPackageTest(base.BaseTackerTest):
package = deepcopy(self.package2) package = deepcopy(self.package2)
for attr in ['softwareImages', 'checksum', 'userDefinedData']: for attr in ['softwareImages', 'checksum', 'userDefinedData']:
package.pop(attr, None) package.pop(attr, None)
expected_result = {'vnf_packages': [package]} expected_result = [package]
self.assertEqual(expected_result, body) self.assertEqual(expected_result, body)
def test_index_attribute_selector_all_fields(self): def test_index_attribute_selector_all_fields(self):
@ -243,7 +243,7 @@ class VnfPackageTest(base.BaseTackerTest):
'all_fields': ''} 'all_fields': ''}
filter_url = self.base_url + "?" + urllib.parse.urlencode(filter_expr) filter_url = self.base_url + "?" + urllib.parse.urlencode(filter_expr)
resp, body = self.http_client.do_request(filter_url, "GET") resp, body = self.http_client.do_request(filter_url, "GET")
expected_result = {'vnf_packages': [self.package1]} expected_result = [self.package1]
self.assertEqual(expected_result, body) self.assertEqual(expected_result, body)
def test_index_attribute_selector_exclude_default(self): def test_index_attribute_selector_exclude_default(self):
@ -254,7 +254,7 @@ class VnfPackageTest(base.BaseTackerTest):
package2 = deepcopy(self.package2) package2 = deepcopy(self.package2)
for attr in ['softwareImages', 'checksum', 'userDefinedData']: for attr in ['softwareImages', 'checksum', 'userDefinedData']:
package2.pop(attr, None) package2.pop(attr, None)
expected_result = {'vnf_packages': [package2]} expected_result = [package2]
self.assertEqual(expected_result, body) self.assertEqual(expected_result, body)
def test_index_attribute_selector_exclude_fields(self): def test_index_attribute_selector_exclude_fields(self):
@ -266,7 +266,7 @@ class VnfPackageTest(base.BaseTackerTest):
for software_image in package2['softwareImages']: for software_image in package2['softwareImages']:
software_image.pop('checksum', None) software_image.pop('checksum', None)
package2.pop('checksum', None) package2.pop('checksum', None)
expected_result = {'vnf_packages': [package2]} expected_result = [package2]
self.assertEqual(expected_result, body) self.assertEqual(expected_result, body)
def test_index_attribute_selector_fields(self): def test_index_attribute_selector_fields(self):
@ -286,7 +286,7 @@ class VnfPackageTest(base.BaseTackerTest):
'version']: 'version']:
software_image.pop(attr, None) software_image.pop(attr, None)
package1.pop('checksum', None) package1.pop('checksum', None)
expected_result = {'vnf_packages': [package1]} expected_result = [package1]
self.assertEqual(expected_result, body) self.assertEqual(expected_result, body)
def _create_and_onboard_vnf_package(self, file_name=None): def _create_and_onboard_vnf_package(self, file_name=None):

View File

@ -78,9 +78,7 @@ VNFPACKAGE_RESPONSE = {
}], }],
} }
VNFPACKAGE_INDEX_RESPONSE = { VNFPACKAGE_INDEX_RESPONSE = [VNFPACKAGE_RESPONSE]
'vnf_packages': [VNFPACKAGE_RESPONSE]
}
def index_response(remove_attrs=None, vnf_package_updates=None): def index_response(remove_attrs=None, vnf_package_updates=None):
@ -94,7 +92,7 @@ def index_response(remove_attrs=None, vnf_package_updates=None):
vnf_package.pop(attr, None) vnf_package.pop(attr, None)
if vnf_package_updates: if vnf_package_updates:
vnf_package.update(vnf_package_updates) vnf_package.update(vnf_package_updates)
return {'vnf_packages': [vnf_package]} return [vnf_package]
def _fake_software_image(updates=None): def _fake_software_image(updates=None):