diff options
author | Fu Jinhua <fu.jinhua@zte.com.cn> | 2018-09-11 00:25:48 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-09-11 00:25:48 +0000 |
commit | 50ad0c42077b5ce1393396b2a3f376a961872124 (patch) | |
tree | 5a619a0d0a8acc5de32b98fa8fcc21d821e3652e | |
parent | b7e6459cede4ad0b9320c240f920aebb5e06c270 (diff) | |
parent | 8201d92a453fb182b8fd8c7a35489001a368629d (diff) |
Merge "Extrat data from gvnfmdriver to vnflcm"
-rw-r--r-- | lcm/lcm/nf/biz/grant_vnf.py | 1 | ||||
-rw-r--r-- | lcm/lcm/nf/biz/instantiate_vnf.py | 31 | ||||
-rw-r--r-- | lcm/lcm/nf/tests/test_instantiate_vnf.py | 22 |
3 files changed, 48 insertions, 6 deletions
diff --git a/lcm/lcm/nf/biz/grant_vnf.py b/lcm/lcm/nf/biz/grant_vnf.py index a92f365e..0889e6dc 100644 --- a/lcm/lcm/nf/biz/grant_vnf.py +++ b/lcm/lcm/nf/biz/grant_vnf.py @@ -99,4 +99,5 @@ def grant_resource(data, nf_inst_id, job_id, grant_type, vdus): 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) return apply_result diff --git a/lcm/lcm/nf/biz/instantiate_vnf.py b/lcm/lcm/nf/biz/instantiate_vnf.py index 1c9a66bf..56e9c146 100644 --- a/lcm/lcm/nf/biz/instantiate_vnf.py +++ b/lcm/lcm/nf/biz/instantiate_vnf.py @@ -155,15 +155,38 @@ class InstantiateVnf(Thread): break def set_location(self, apply_result): + vim_connections = ignore_case_get(apply_result, "vimConnections") + vnfid = ignore_case_get(apply_result, "vnfInstanceId") + directive = ignore_case_get(apply_result, "directive") + vim_assets = ignore_case_get(apply_result, "vimAssets") + access_info = ignore_case_get(vim_connections[0], "accessInfo") + tenant = ignore_case_get(access_info, "tenant") + vimid = ignore_case_get(vim_connections[0], "vimId") + cloud_owner, cloud_regionid = vimid.split("_") + vdu_info = [] + + for flavor in ignore_case_get(vim_assets, "vimComputeResourceFlavour"): + vdu_info.append({"vduName": flavor["resourceProviderId"], + "flavorName": flavor["vimFlavourId"], + "directive": directive}) + 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") + resource["properties"]["location_info"]["vimid"] = vimid + resource["properties"]["location_info"]["tenant"] = tenant + resource["properties"]["location_info"]["vnfId"] = vnfid + resource["properties"]["location_info"]["cloudOwner"] = cloud_owner + resource["properties"]["location_info"]["cloudRegionId"] = cloud_regionid + resource["properties"]["location_info"]["vduInfo"] = vdu_info else: resource["properties"]["location_info"] = { - "vimid": ignore_case_get(apply_result, "vimid"), - "tenant": ignore_case_get(apply_result, "tenant")} + "vimid": vimid, + "tenant": tenant, + "vnfId": vnfid, + "cloudOwner": cloud_owner, + "cloudRegionId": cloud_regionid, + "vduInfo": vdu_info} ''' def get_subnet_ids(self, ext_cp): diff --git a/lcm/lcm/nf/tests/test_instantiate_vnf.py b/lcm/lcm/nf/tests/test_instantiate_vnf.py index 5801cb90..e698c4db 100644 --- a/lcm/lcm/nf/tests/test_instantiate_vnf.py +++ b/lcm/lcm/nf/tests/test_instantiate_vnf.py @@ -35,8 +35,26 @@ class TestNFInstantiate(TestCase): def setUp(self):
self.client = APIClient()
self.grant_result = {
- "vimid": 'vim_1',
- "tenant": 'chinamobile',
+ "vimConnections": [
+ {
+ "vimid": 'vim_1',
+ "accessInfo":
+ {
+ "tenant": 'chinamobile'
+ }
+ },
+ ],
+ "vnfId": "413aa1fe-b4d1-11e8-8268-dff5aab95c63",
+ "vimAssets":
+ {
+ "vimComputeResourceFlavour": [
+ {
+ "resourceProviderId": "vgw",
+ "vimFlavourId": "yui",
+ "directive": ""
+ },
+ ]
+ }
}
def tearDown(self):
|