diff options
author | maopengzhang <zhang.maopeng1@zte.com.cn> | 2018-11-08 15:20:43 +0800 |
---|---|---|
committer | maopengzhang <zhang.maopeng1@zte.com.cn> | 2018-11-08 15:20:43 +0800 |
commit | 191a6cfc30ff4fb0d404e3e515963f722511d2d1 (patch) | |
tree | f07a4c065bd6f1d1107ed06c2e14072782f65952 /lcm | |
parent | be15024fb3ced3fab7bb454c7e1a9701b58a05c6 (diff) |
fix grant parameter error
fix operate to operation, etc
Change-Id: Id49cf178604a19ead57585dbfa4c89069a2aff9a
Issue-ID: VFC-1158
Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r-- | lcm/lcm/nf/biz/grant_vnf.py | 67 | ||||
-rw-r--r-- | lcm/lcm/nf/serializers/create_vnf_req.py | 3 | ||||
-rw-r--r-- | lcm/lcm/nf/serializers/instantiate_vnf_request.py | 4 |
3 files changed, 34 insertions, 40 deletions
diff --git a/lcm/lcm/nf/biz/grant_vnf.py b/lcm/lcm/nf/biz/grant_vnf.py index 92f22350..dd22c06e 100644 --- a/lcm/lcm/nf/biz/grant_vnf.py +++ b/lcm/lcm/nf/biz/grant_vnf.py @@ -29,23 +29,24 @@ def grant_resource(data, nf_inst_id, job_id, grant_type, vdus): content_args = { 'vnfInstanceId': nf_inst_id, 'vnfLcmOpOccId': job_id, - 'vnfdId': None, # TODO - 'flavourId': None, # TODO - 'operate': grant_type, + # 'vnfdId': None, # TODO + # 'flavourId': "default", # TODO + 'operation': grant_type, 'isAutomaticInvocation': True, # TODO - 'instantiationLevelId': None, # TODO - 'addResources': [], - 'tmpResources': [], - 'updateResources': [], - 'removeResources': [], - 'placementConstraints': [], - 'vimConstraints': [], - 'additionalParams': {}, - '_links': None # TODO + # 'instantiationLevelId': None, # TODO + # 'addResources': [], + # 'tmpResources': [], + # 'updateResources': [], + # 'removeResources': [], + # 'placementConstraints': [], + # 'vimConstraints': [], + # 'additionalParams': {} + # '_links': None # TODO } if grant_type == GRANT_TYPE.TERMINATE: res_index = 1 + content_args['removeResources'] = [] for vdu in vdus: res_def = { 'id': str(res_index), @@ -61,41 +62,29 @@ def grant_resource(data, nf_inst_id, job_id, grant_type, vdus): } content_args['removeResources'].append(res_def) res_index += 1 - content_args['additionalParams']['vimid'] = vdus[0].vimid + if vdus[0].vimid: + content_args['additionalParams'] = {} + content_args['additionalParams']['vimid'] = vdus[0].vimid elif grant_type == GRANT_TYPE.INSTANTIATE: vim_id = ignore_case_get(ignore_case_get(data, "additionalParams"), "vimId") res_index = 1 + content_args['addResources'] = [] for vdu in vdus: res_def = { 'id': str(res_index), 'type': 'COMPUTE', - 'vduId': None, - 'resourceTemplateId': None, # TODO: shall be present for the planned creation of new resources. - 'resource': None + # 'vduId': vdu["vdu_id"], + 'resourceTemplateId': vdu["vdu_id"] # , None, + # 'resource': None } content_args['addResources'].append(res_def) res_index += 1 - content_args['additionalParams']['vimid'] = vim_id - elif grant_type == GRANT_TYPE.HEAL_RESTART: - res_index = 1 - res_def = { - 'type': 'VDU', - 'resDefId': str(res_index), - 'resDesId': vdus[0].resourceid} - content_args['updateResources'].append(res_def) - content_args['additionalParams']['vimid'] = vdus[0].vimid - elif grant_type == GRANT_TYPE.HEAL_CREATE: - vim_id = vdus[0]["properties"]["location_info"]["vimid"] - res_index = 1 - res_def = { - 'type': 'VDU', - 'resDefId': str(res_index), - 'resDesId': ignore_case_get(vdus[0], "vdu_id") - } - content_args['addResources'].append(res_def) - content_args['additionalParams']['vimid'] = vim_id + if vim_id: + content_args['additionalParams'] = {} + content_args['additionalParams']['vimid'] = vim_id elif grant_type == GRANT_TYPE.OPERATE: res_index = 1 + content_args['updateResources'] = [] for vdu in vdus: res_def = { 'id': str(res_index), @@ -111,10 +100,14 @@ def grant_resource(data, nf_inst_id, job_id, grant_type, vdus): } content_args['updateResources'].append(res_def) res_index += 1 - content_args['additionalParams']['vimid'] = vdus[0].vimid + if vdus[0].vimid: + content_args['additionalParams'] = {} + content_args['additionalParams']['vimid'] = vdus[0].vimid vnfInsts = NfInstModel.objects.filter(nfinstid=nf_inst_id) - content_args['additionalParams']['vnfmid'] = vnfInsts[0].vnfminstid + if vnfInsts[0].vnfminstid: + content_args['additionalParams'] = {} + content_args['additionalParams']['vnfmid'] = vnfInsts[0].vnfminstid logger.info('Grant request data=%s' % content_args) apply_result = apply_grant_to_nfvo(json.dumps(content_args)) logger.info("apply_result: %s" % apply_result) diff --git a/lcm/lcm/nf/serializers/create_vnf_req.py b/lcm/lcm/nf/serializers/create_vnf_req.py index a8fa6654..6aba12f7 100644 --- a/lcm/lcm/nf/serializers/create_vnf_req.py +++ b/lcm/lcm/nf/serializers/create_vnf_req.py @@ -30,4 +30,5 @@ class CreateVnfReqSerializer(serializers.Serializer): help_text="Human-readable description of the VNF instance to be created.", max_length=255, required=False, - allow_null=True) + allow_null=True, + allow_blank=True) diff --git a/lcm/lcm/nf/serializers/instantiate_vnf_request.py b/lcm/lcm/nf/serializers/instantiate_vnf_request.py index 2c3547d2..9290d84a 100644 --- a/lcm/lcm/nf/serializers/instantiate_vnf_request.py +++ b/lcm/lcm/nf/serializers/instantiate_vnf_request.py @@ -53,10 +53,10 @@ class InstantiateVnfRequestSerializer(serializers.Serializer): max_length=255, required=False, allow_null=True) - additionalParams = serializers.DictField( + additionalParams = serializers.JSONField( help_text="Additional input parameters for the instantiation process, \ specific to the VNF being instantiated, \ as declared in the VNFD as part of InstantiateVnfOpConfig.", - child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True), + # child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True), required=False, allow_null=True) |