From: ying.yunlong Date: Thu, 12 Apr 2018 03:55:43 +0000 (+0800) Subject: Refactor vfc-vnflcm grant update location X-Git-Tag: v1.1.0~13 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=vfc%2Fgvnfm%2Fvnflcm.git;a=commitdiff_plain;h=2e114717247775d3f365aae1e94f6c80f3ceab25 Refactor vfc-vnflcm grant update location Change-Id: I5b6ea39a315b245d2f4f4c0509fb854a797163d2 Issue-ID: VFC-873 Signed-off-by: ying.yunlong --- diff --git a/lcm/lcm/nf/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnf_create/inst_vnf.py index 707e105c..3c102bda 100644 --- a/lcm/lcm/nf/vnf_create/inst_vnf.py +++ b/lcm/lcm/nf/vnf_create/inst_vnf.py @@ -140,25 +140,9 @@ class InstVnf(Thread): content_args['additionalParam']['vnfmid'] = vnfmInfo[0].vnfminstid content_args['additionalParam']['vimid'] = vnfmInfo[0].apiurl logger.info('Grant request data = %s', content_args) - apply_result = apply_grant_to_nfvo(json.dumps(content_args)) - - for vdu in ignore_case_get(self.vnfd_info, "vdus"): - if "location_info" in vdu["properties"]: - vdu["properties"]["location_info"]["vimid"] = ignore_case_get(apply_result, "vimid") - vdu["properties"]["location_info"]["tenant"] = ignore_case_get(apply_result, "tenant") - else: - vdu["properties"]["location_info"] = { - "vimid": ignore_case_get(apply_result, "vimid"), - "tenant": ignore_case_get(apply_result, "tenant")} - for vl in ignore_case_get(self.vnfd_info, "vls"): - if "location_info" in vl["properties"]: - vl["properties"]["location_info"]["vimid"] = ignore_case_get(apply_result, "vimid") - vl["properties"]["location_info"]["tenant"] = ignore_case_get(apply_result, "tenant") - else: - vl["properties"]["location_info"] = { - "vimid": ignore_case_get(apply_result, "vimid"), - "tenant": ignore_case_get(apply_result, "tenant")} + apply_result = apply_grant_to_nfvo(json.dumps(content_args)) + self.set_location(apply_result) logger.info('VnfdInfo = %s' % self.vnfd_info) NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='INSTANTIATED', lastuptime=now_time()) @@ -369,3 +353,14 @@ class InstVnf(Thread): cp["networkId"] = ignore_case_get(extlink, "resourceId") cp["subnetId"] = ignore_case_get(extlink, "resourceSubnetId") break + + def set_location(self, apply_result): + for resource_type in ['vdus', 'vls']: + for resource in ignore_case_get(self.vnfd_info, resource_type): + if "location_info" in resource["properties"]: + resource["properties"]["location_info"]["vimid"] = ignore_case_get(apply_result, "vimid") + resource["properties"]["location_info"]["tenant"] = ignore_case_get(apply_result, "tenant") + else: + resource["properties"]["location_info"] = { + "vimid": ignore_case_get(apply_result, "vimid"), + "tenant": ignore_case_get(apply_result, "tenant")}