summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaibin Huang <haibin.huang@intel.com>2019-07-22 05:18:38 +0000
committermaopeng zhang <zhang.maopeng1@zte.com.cn>2019-07-22 11:00:44 +0000
commitb7f679695743d0c2a046997bf4a6ed5ae0ac1e43 (patch)
treeeed8b3c201671603981daae79fc51ff9e4b92cfd
parentb6a08c041bbca7c97fb28fe73389000a28d58c0e (diff)
Fix wrong virtual storages structure
Issue-ID: VFC-1460 Signed-off-by: Haibin Huang <haibin.huang@intel.com> Change-Id: I8fff7c7177fe79cdd06541509ffd0ca1e6501a95
-rw-r--r--lcm/lcm/pub/vimapi/adaptor.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/lcm/lcm/pub/vimapi/adaptor.py b/lcm/lcm/pub/vimapi/adaptor.py
index 55f6d164..3c5af44e 100644
--- a/lcm/lcm/pub/vimapi/adaptor.py
+++ b/lcm/lcm/pub/vimapi/adaptor.py
@@ -292,7 +292,7 @@ def create_flavor(vim_cache, res_cache, data, flavor, do_notify, res_type):
location_info = flavor["properties"]["location_info"]
vim_id, tenant_name = location_info["vimid"], location_info["tenant"]
virtual_compute = flavor["virtual_compute"]
- virtual_storages = flavor["virtual_storages"]
+ virtual_storages = ignore_case_get(flavor, "virtual_storages")
virtual_cpu = ignore_case_get(virtual_compute, "virtual_cpu")
virtual_memory = ignore_case_get(virtual_compute, "virtual_memory")
param = {
@@ -316,18 +316,26 @@ def create_flavor(vim_cache, res_cache, data, flavor, do_notify, res_type):
if flavor_id:
set_res_cache(res_cache, res_type, flavor["vdu_id"], flavor_id)
else:
- for virtual_storage in virtual_storages:
- vs_id = virtual_storage["virtual_storage_id"]
- for vs in data["volume_storages"]:
- if vs["volume_storage_id"] == vs_id:
- disk_type = ignore_case_get(vs["properties"], "type_of_storage")
- disk_size = int(ignore_case_get(vs["properties"], "size_of_storage").replace('GB', '').replace('"', '').strip())
- if disk_type == "root":
- param["disk"] = disk_size
- elif disk_type == "ephemeral":
- param["ephemeral"] = disk_size
- elif disk_type == "swap":
- param["swap"] = disk_size
+ if virtual_storages:
+ for virtual_storage in virtual_storages:
+ vs_id = virtual_storage["virtual_storage_id"]
+ for vs in data["volume_storages"]:
+ if vs["volume_storage_id"] == vs_id:
+ disk_type = ignore_case_get(vs["properties"], "type_of_storage")
+ size_of_storage = ignore_case_get(vs["properties"], "size_of_storage")
+ disk_size = int(size_of_storage.replace('GB', '').replace('"', '').strip())
+ if disk_type == "root":
+ param["disk"] = disk_size
+ elif disk_type == "ephemeral":
+ param["ephemeral"] = disk_size
+ elif disk_type == "swap":
+ param["swap"] = disk_size
+ else:
+ virtual_storages = ignore_case_get(virtual_compute, "virtual_storages")
+ size_of_storage = ignore_case_get(virtual_storages[0], "size_of_storage")
+ disk_size = int(size_of_storage.replace('GB', '').replace('"', '').strip())
+ param["disk"] = disk_size
+
tenant_id = get_tenant_id(vim_cache, vim_id, tenant_name)
logger.debug("param:%s" % param)
ret = api.create_flavor(vim_id, tenant_id, param)