Exclude non-bootable storage template from image-topology

PowerVC 1.2.3 added complex boot/data volume concepts and it's image
accessible storage connective group's volume type API will return all
volume types for boot and data volume, we expose the PowerVC storage
templates in image's image-topology property and that property need only
include the bootable storage templates based on PowerVC 1.2.3 introduced
boot/data volume concept as we just expose the volume only for boot
volume at this time. The fix is just to exclude the SCG accessible
storage template via it's
['extra_specs']['capabilities:volume_backend_name'] property, and only
include the the storage template with such property value in SCG's
boot_providers list which means that volume type is a bootable volume
types. If SCG does not have such boot_providers property, then we just
ignore such checking.

Close-Bug: #1460563
Change-Id: Ifa608a514ec70b831d04802b728dff14864578ab
This commit is contained in:
terryyao 2015-06-01 16:32:46 +08:00
parent 714bc0d9d8
commit a16ac6df90
1 changed files with 14 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# Copyright 2013, 2014 IBM Corp.
# Copyright 2013, 2015 IBM Corp.
import logging
import exception
import os
@ -613,13 +613,25 @@ class Utils(object):
if scg_list is not None:
scg_storage_templates = {}
for scg in scg_list:
boot_providers = scg.__dict__.get('boot_providers')
accessible_storage_templates = []
volume_types = scg.list_all_volume_types()
volume_type_ids = []
for vol_type in volume_types:
volume_type_ids.append(vol_type.__dict__.get("id"))
for storage_template in all_storage_templates:
if(storage_template.__dict__.get("id") in volume_type_ids):
st_dict = storage_template.__dict__
st_specs = st_dict.get('extra_specs')
sp_name = None
if boot_providers and st_specs:
sp_name_key = 'capabilities:volume_backend_name'
sp_name = st_specs.get(sp_name_key)
if sp_name and sp_name not in boot_providers:
log_args = (storage_template, sp_name, boot_providers)
LOG.info('volume type %s with storage provider %s is '
'not in boot provider list %s' % log_args)
continue
if(st_dict.get("id") in volume_type_ids):
accessible_storage_templates.append(storage_template)
scg_storage_templates[scg.id] = accessible_storage_templates
return scg_storage_templates