diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-02-22 17:28:08 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-02-22 17:28:08 +0800 |
commit | 19fce59efa91c1e37b64098ce6e99b2c90eb8f05 (patch) | |
tree | 59b661267c844a4f20f047621f63928587702dd4 /lcm/lcm/pub/vimapi | |
parent | b6c58ae677f7a0ba3ec8bca99d6a88f4326e2065 (diff) |
Modify code and test case of vnflcm and adaptor
Change-Id: I2e4b644a4469add9c18f184e0d66c4988e88c992
Issue-Id: GVNFM-21
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'lcm/lcm/pub/vimapi')
-rw-r--r-- | lcm/lcm/pub/vimapi/adaptor.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lcm/lcm/pub/vimapi/adaptor.py b/lcm/lcm/pub/vimapi/adaptor.py index e1d7537b..593d779d 100644 --- a/lcm/lcm/pub/vimapi/adaptor.py +++ b/lcm/lcm/pub/vimapi/adaptor.py @@ -70,7 +70,7 @@ def create_vim_res(data, do_notify): for subnet in ignore_case_get(data, "vls"): create_subnet(vim_cache, res_cache, subnet, do_notify, RES_SUBNET) for port in ignore_case_get(data, "cps"): - create_port(vim_cache, res_cache, port, do_notify, RES_PORT) + create_port(vim_cache, res_cache, data, port, do_notify, RES_PORT) for flavor in ignore_case_get(data, "vdus"): create_flavor(vim_cache, res_cache, data, flavor, do_notify, RES_FLAVOR) for vm in ignore_case_get(data, "vdus"): @@ -155,8 +155,16 @@ def create_subnet(vim_cache, res_cache, subnet, do_notify, res_type): do_notify(res_type, ret) set_res_cache(res_cache, res_type, subnet["vl_id"], ret["id"]) -def create_port(vim_cache, res_cache, port, do_notify, res_type): - location_info = port["properties"]["location_info"] +def create_port(vim_cache, res_cache, data, port, do_notify, res_type): + location_info = None + port_ref_vdu_id = ignore_case_get(port, "vdu_id") + for vdu in ignore_case_get(data, "vdus"): + if vdu["vdu_id"] == port_ref_vdu_id: + location_info = vdu["properties"]["location_info"] + break + if not location_info: + err_msg = "vdu_id(%s) for cp(%s) is not defined" + raise VimException(err_msg % (port_ref_vdu_id, port["cp_id"]), ERR_CODE) network_id = get_res_id(res_cache, RES_NETWORK, port["vl_id"]) subnet_id = get_res_id(res_cache, RES_SUBNET, port["vl_id"]) param = { |