diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2018-04-12 11:55:43 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2018-04-12 11:55:43 +0800 |
commit | 2e114717247775d3f365aae1e94f6c80f3ceab25 (patch) | |
tree | 040604f32d362b4404457ce5f1383c0d0b3c3120 | |
parent | 5bbae495d57db892fe0f43e8841c412f6f6a095e (diff) |
Refactor vfc-vnflcm grant update location
Change-Id: I5b6ea39a315b245d2f4f4c0509fb854a797163d2
Issue-ID: VFC-873
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | lcm/lcm/nf/vnf_create/inst_vnf.py | 31 |
1 files changed, 13 insertions, 18 deletions
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")} |