@@ -320,7 +320,18 @@ def host_get_diskpool_volumes(self, disk_pool=None):
320
320
# they want to get the disk pool info of CONF.zvm.disk_pool.
321
321
# The default value of CONF.zvm.disk_pool is None, if it's configured,
322
322
# the format must be "ECKD:eckdpool" or "FBA:fbapool".
323
- disk_pool = disk_pool or CONF .zvm .disk_pool
323
+ disk_pool = disk_pool
324
+ if disk_pool is None :
325
+ disk_pool = CONF .zvm .disk_pool
326
+ if disk_pool is not None :
327
+ disk_pools = disk_pool .split ("," )
328
+ if len (disk_pools ) == 1 :
329
+ disk_pool = disk_pools [0 ]
330
+ else :
331
+ errmsg = ("disk_pool input is required if multiple disk_pool"
332
+ " is configured for sdkserver." )
333
+ LOG .error (errmsg )
334
+ raise exception .SDKInvalidInputFormat (msg = errmsg )
324
335
if disk_pool is None :
325
336
# Support disk_pool not configured, return empty list
326
337
return {}
@@ -409,23 +420,41 @@ def host_diskpool_get_info(self, disk_pool=None, details=False):
409
420
return {'disk_total' : 0 , 'disk_used' : 0 , 'disk_available' : 0 }
410
421
else :
411
422
return {}
412
- if ':' not in disk_pool :
413
- msg = ('Invalid input parameter disk_pool, expect ":" in'
414
- 'disk_pool, eg. ECKD:eckdpool' )
415
- LOG .error (msg )
416
- raise exception .SDKInvalidInputFormat (msg )
417
- diskpool_type = disk_pool .split (':' )[0 ].upper ()
418
- diskpool_name = disk_pool .split (':' )[1 ]
419
- if diskpool_type not in ('ECKD' , 'FBA' ):
420
- msg = ('Invalid disk pool type found in disk_pool, expect'
421
- 'disk_pool like ECKD:eckdpool or FBA:fbapool' )
422
- LOG .error (msg )
423
- raise exception .SDKInvalidInputFormat (msg )
424
-
425
- action = "get information of disk pool: '%s' '%s'" % (disk_pool , details )
426
- with zvmutils .log_and_reraise_sdkbase_error (action ):
427
- return self ._hostops .diskpool_get_info (diskpool_name , details )
428
-
423
+ disk_pools_total = 0
424
+ disk_pools_used = 0
425
+ disk_pools_available = 0
426
+ disk_pools = disk_pool .split (',' )
427
+ disk_pool_info = {}
428
+ for disk_pool in disk_pools :
429
+ if ':' not in disk_pool :
430
+ msg = ('Invalid input parameter disk_pool, expect ":" in'
431
+ 'disk_pool, eg. ECKD:eckdpool' )
432
+ LOG .error (msg )
433
+ raise exception .SDKInvalidInputFormat (msg )
434
+ diskpool_type = disk_pool .split (':' )[0 ].upper ()
435
+ diskpool_name = disk_pool .split (':' )[1 ]
436
+ if diskpool_type not in ('ECKD' , 'FBA' ):
437
+ msg = ('Invalid disk pool type found in disk_pool, expect'
438
+ 'disk_pool like ECKD:eckdpool or FBA:fbapool' )
439
+ LOG .error (msg )
440
+ raise exception .SDKInvalidInputFormat (msg )
441
+
442
+ action = "get information of disk pool: '%s' '%s'" % (disk_pool , details )
443
+ with zvmutils .log_and_reraise_sdkbase_error (action ):
444
+ dp_info = self ._hostops .diskpool_get_info (diskpool_name , details )
445
+ if not details :
446
+ disk_pools_total = disk_pools_total + dp_info .get ("disk_total" , 0 )
447
+ disk_pools_used = disk_pools_used + dp_info .get ("disk_used" , 0 )
448
+ disk_pools_available = disk_pools_available + dp_info .get ("disk_available" , 0 )
449
+ disk_pool_info = {
450
+ 'disk_total' : disk_pools_total ,
451
+ 'disk_used' : disk_pools_used ,
452
+ 'disk_available' : disk_pools_available
453
+ }
454
+ else :
455
+ disk_pool_info .update (dp_info )
456
+ return disk_pool_info
457
+
429
458
def image_delete (self , image_name ):
430
459
"""Delete image from image repository
431
460
@@ -939,7 +968,18 @@ def guest_create(self, userid, vcpus, memory, disk_list=None,
939
968
raise exception .SDKInvalidInputFormat (msg = errmsg )
940
969
941
970
# check disk_pool
942
- disk_pool = disk .get ('disk_pool' ) or CONF .zvm .disk_pool
971
+ disk_pool = disk .get ('disk_pool' )
972
+ if disk_pool is None :
973
+ disk_pool = CONF .zvm .disk_pool
974
+ if disk_pool is not None :
975
+ disk_pools = disk_pool .split ("," )
976
+ if len (disk_pools ) == 1 :
977
+ disk_pool = disk_pools [0 ]
978
+ else :
979
+ errmsg = ("disk_pool input is required if multiple disk_pool"
980
+ " is configured for sdkserver." )
981
+ LOG .error (errmsg )
982
+ raise exception .SDKInvalidInputFormat (msg = errmsg )
943
983
if not swap_only :
944
984
if disk_pool is None :
945
985
errmsg = ("Invalid disk_pool input, disk_pool should"
@@ -1132,7 +1172,19 @@ def guest_create_disks(self, userid, disk_list):
1132
1172
LOG .error (errmsg )
1133
1173
raise exception .SDKInvalidInputFormat (msg = errmsg )
1134
1174
# check disk_pool
1135
- disk_pool = disk .get ('disk_pool' ) or CONF .zvm .disk_pool
1175
+ disk_pool = disk .get ('disk_pool' )
1176
+ if disk_pool is None :
1177
+ disk_pool = CONF .zvm .disk_pool
1178
+ if disk_pool is not None :
1179
+ disk_pools = disk_pool .split ("," )
1180
+ if len (disk_pools ) == 1 :
1181
+ disk_pool = disk_pools [0 ]
1182
+ else :
1183
+ errmsg = ("disk_pool input is required if multiple disk_pool"
1184
+ " is configured for sdkserver." )
1185
+ LOG .error (errmsg )
1186
+ raise exception .SDKInvalidInputFormat (msg = errmsg )
1187
+
1136
1188
if disk_pool is None :
1137
1189
errmsg = ("Invalid disk_pool input, it should be configured"
1138
1190
" for sdkserver." )
0 commit comments