Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 44 additions & 30 deletions zvmsdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,36 +346,50 @@ def host_get_diskpool_volumes(self, disk_pool=None):
# they want to get the disk pool info of CONF.zvm.disk_pool.
# The default value of CONF.zvm.disk_pool is None, if it's configured,
# the format must be "ECKD:eckdpool" or "FBA:fbapool".
disk_pool = disk_pool
if disk_pool is None:
disk_pool = CONF.zvm.disk_pool
if disk_pool is not None:
disk_pools = disk_pool.split(",")
if len(disk_pools) == 1:
disk_pool = disk_pools[0]
else:
errmsg = ("disk_pool input is required if multiple disk_pool"
" is configured for sdkserver.")
LOG.error(errmsg)
raise exception.SDKInvalidInputFormat(msg=errmsg)
if disk_pool is None:
# Support disk_pool not configured, return empty list
return {}
if ':' not in disk_pool:
msg = ('Invalid input parameter disk_pool, expect ":" in'
'disk_pool, eg. ECKD:eckdpool')
LOG.error(msg)
raise exception.SDKInvalidInputFormat(msg)
diskpool_type = disk_pool.split(':')[0].upper()
if diskpool_type not in ('ECKD', 'FBA'):
msg = ('Invalid disk pool type found in disk_pool, expect'
'disk_pool like ECKD:eckdpool or FBA:fbapool')
LOG.error(msg)
raise exception.SDKInvalidInputFormat(msg)

action = "get the volumes of disk pool: '%s'" % disk_pool
with zvmutils.log_and_reraise_sdkbase_error(action):
return self._hostops.diskpool_get_volumes(disk_pool)
try:
if disk_pool is None:
disk_pool = CONF.zvm.disk_pool
if not disk_pool:
# Support disk_pool not configured, return empty
return {}
if isinstance(disk_pool, list):
disk_pools = disk_pool
elif isinstance(disk_pool, str):
disk_pools = [each_pool.strip() for each_pool in disk_pool.split(",") if each_pool.strip()]
else:
disk_pools = []
if not disk_pools:
# Support disk_pool not configured, return empty list
return {}
results = {}
for each_pool in disk_pools:
if ':' not in each_pool:
msg = ('Invalid input parameter disk_pool, expect ":" in'
'disk_pool, eg. ECKD:eckdpool')
LOG.error(msg)
raise exception.SDKInvalidInputFormat(msg)
diskpool_type, diskpool_name = each_pool.split(':', 1)
diskpool_type = diskpool_type.upper()
diskpool_name = diskpool_name.upper()

if diskpool_type not in ('ECKD', 'FBA'):
msg = ('Invalid disk pool type found in disk_pool, expect'
'disk_pool like ECKD:eckdpool or FBA:fbapool')
LOG.error(msg)
raise exception.SDKInvalidInputFormat(msg)
# Get volumes from each diskpool
action = "get the volumes of disk pool: '%s'" % each_pool
with zvmutils.log_and_reraise_sdkbase_error(action):
results[diskpool_name] = self._hostops.diskpool_get_volumes(each_pool)
LOG.info("Diskpool volumes are %s " % results)
return results
except exception.SDKInvalidInputFormat:
errmsg = (
"disk_pool input is not configured "
"correctly for sdkserver. Please check the diskpool configuration"
)
LOG.error(errmsg)
raise

def host_get_volume_info(self, volume=None):
""" Retrieve volume information.
Expand Down