diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2019-03-25 14:39:10 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2019-03-25 15:01:18 +0800 |
commit | ed97abfb0048fd07e01101c6c811b5395ae2b180 (patch) | |
tree | fe69fd601af1067470d84e15e9d2983b1c7059fa /lcm | |
parent | d5398e82b6e5e6fe304442d9fe38dfaa48b19ba6 (diff) |
Fix query vnf bugs
Change-Id: Ia0d55d7309b68f41650858bdb901de8836964ecc
Issue-ID: VFC-1306
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r-- | lcm/lcm/nf/biz/query_vnf.py | 11 | ||||
-rw-r--r-- | lcm/lcm/nf/serializers/instantiated_vnf_info.py | 4 | ||||
-rw-r--r-- | lcm/lcm/nf/tests/test_query_vnf.py | 60 |
3 files changed, 54 insertions, 21 deletions
diff --git a/lcm/lcm/nf/biz/query_vnf.py b/lcm/lcm/nf/biz/query_vnf.py index 1dd7c2d1..d460c03b 100644 --- a/lcm/lcm/nf/biz/query_vnf.py +++ b/lcm/lcm/nf/biz/query_vnf.py @@ -98,9 +98,13 @@ class QueryVnf: resp_data = { "id": vnf.nfinstid, "vnfInstanceName": vnf.nf_name, - "vnfPkgId": vnf.package_id, - "vnfdVersion": vnf.version, + "vnfInstanceDescription": vnf.nf_desc, + "vnfdId": vnf.vnfdid, "vnfProvider": vnf.vendor, + "vnfProductName": vnf.netype, + "vnfSoftwareVersion": vnf.vnfSoftwareVersion, + "vnfdVersion": vnf.version, + "vnfPkgId": vnf.package_id, "instantiationState": vnf.status, "instantiatedVnfInfo": { "flavourId": vnf.flavour_id, @@ -108,10 +112,11 @@ class QueryVnf: "scaleStatus": [], "extCpInfo": [], "extVirtualLinkInfo": [], - "monitoringParameters": {}, + "monitoringParameters": [], "vnfcResourceInfo": vnfc_arr, "vnfVirtualLinkResourceInfo": vl_arr, "virtualStorageResourceInfo": arr } } + logger.debug("vnf instance: %s", resp_data) return resp_data diff --git a/lcm/lcm/nf/serializers/instantiated_vnf_info.py b/lcm/lcm/nf/serializers/instantiated_vnf_info.py index 82c2ec5b..cd6c93ec 100644 --- a/lcm/lcm/nf/serializers/instantiated_vnf_info.py +++ b/lcm/lcm/nf/serializers/instantiated_vnf_info.py @@ -57,9 +57,9 @@ class InstantiatedVnfInfoSerializer(serializers.Serializer): many=True, required=False, allow_null=True) - monitoringParameters = serializers.DictField( + monitoringParameters = serializers.ListSerializer( help_text="Active monitoring parameters.", - child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True), + child=serializers.CharField(help_text="monitoring parameter", allow_blank=True), required=False, allow_null=True) localizationLanguage = serializers.CharField( diff --git a/lcm/lcm/nf/tests/test_query_vnf.py b/lcm/lcm/nf/tests/test_query_vnf.py index 25824239..88d4402b 100644 --- a/lcm/lcm/nf/tests/test_query_vnf.py +++ b/lcm/lcm/nf/tests/test_query_vnf.py @@ -27,7 +27,13 @@ class ResourceTest(TestCase): self.test_data_single_vnf = { "id": "1", "vnfInstanceName": "VNF1", - "vnfProvider": None, + "vnfInstanceDescription": "VNF DESC", + "vnfdId": "1", + "vnfProvider": "ZTE", + "vnfProductName": "XGW", + "vnfSoftwareVersion": "V1", + "vnfdVersion": "V1", + "vnfPkgId": "2", "instantiationState": "INSTANTIATED", "instantiatedVnfInfo": { "vnfState": "STARTED", @@ -43,19 +49,23 @@ class ResourceTest(TestCase): ], "extVirtualLinkInfo": [], "vnfcResourceInfo": [], - "monitoringParameters": {}, + "monitoringParameters": [], "flavourId": None, "vnfVirtualLinkResourceInfo": [], "scaleStatus": [] - }, - "vnfdVersion": None, - "vnfPkgId": None + } } self.test_data_multi_vnf = [ { "id": "1", "vnfInstanceName": "VNF1", - "vnfProvider": None, + "vnfInstanceDescription": "VNF DESC", + "vnfdId": "1", + "vnfProvider": "ZTE", + "vnfProductName": "XGW", + "vnfSoftwareVersion": "V1", + "vnfdVersion": "V1", + "vnfPkgId": "2", "instantiationState": "INSTANTIATED", "instantiatedVnfInfo": { "vnfState": "STARTED", @@ -71,18 +81,22 @@ class ResourceTest(TestCase): ], "extVirtualLinkInfo": [], "vnfcResourceInfo": [], - "monitoringParameters": {}, + "monitoringParameters": [], "flavourId": None, "vnfVirtualLinkResourceInfo": [], "scaleStatus": [] - }, - "vnfdVersion": None, - "vnfPkgId": None + } }, { "id": "2", "vnfInstanceName": "VNF2", - "vnfProvider": None, + "vnfInstanceDescription": "VNF DESC", + "vnfdId": "1", + "vnfProvider": "ZTE", + "vnfProductName": "XGW", + "vnfSoftwareVersion": "V1", + "vnfdVersion": "V1", + "vnfPkgId": "2", "instantiationState": "INSTANTIATED", "instantiatedVnfInfo": { "vnfState": "STARTED", @@ -98,13 +112,11 @@ class ResourceTest(TestCase): ], "extVirtualLinkInfo": [], "vnfcResourceInfo": [], - "monitoringParameters": {}, + "monitoringParameters": [], "flavourId": None, "vnfVirtualLinkResourceInfo": [], "scaleStatus": [] - }, - "vnfdVersion": None, - "vnfPkgId": None + } } ] @@ -113,7 +125,16 @@ class ResourceTest(TestCase): def test_get_vnf(self): vnf_inst_id = "1" - NfInstModel(nfinstid=vnf_inst_id, nf_name='VNF1', status='INSTANTIATED').save() + NfInstModel(nfinstid=vnf_inst_id, + nf_name='VNF1', + nf_desc="VNF DESC", + vnfdid="1", + netype="XGW", + vendor="ZTE", + vnfSoftwareVersion="V1", + version="V1", + package_id="2", + status='INSTANTIATED').save() StorageInstModel(storageid='s02', vimid='vim01', resourceid='resource01', @@ -157,6 +178,13 @@ class ResourceTest(TestCase): for i in range(1, 3): NfInstModel(nfinstid='%s' % i, nf_name='VNF%s' % i, + nf_desc="VNF DESC", + vnfdid="1", + netype="XGW", + vendor="ZTE", + vnfSoftwareVersion="V1", + version="V1", + package_id="2", status='INSTANTIATED').save() StorageInstModel(storageid='s0%s' % i, vimid='vim0%s' % i, |