mirror of
https://opendev.org/x/pyghmi
synced 2026-05-18 04:07:19 +00:00
Adapt to more variants in the capacitystr
The capacity str may be GB or GiB or TB or TiB now. Unfortunately, there's no normalized numeric in the api right now. Change-Id: Iccfb6e837a0f2d5ac516c3e908c663bbddda2ed3
This commit is contained in:
@@ -99,6 +99,22 @@ def fixup_str(propstr):
|
||||
' \xff\x00')
|
||||
|
||||
|
||||
def str_to_size(sizestr):
|
||||
if 'GB' in sizestr:
|
||||
sizestr = sizestr.replace('GB', '')
|
||||
sizestr = int(float(sizestr * 1024))
|
||||
elif 'GiB' in sizestr:
|
||||
sizestr = sizestr.replace('GiB', '')
|
||||
sizestr = int(float(sizestr * 1024))
|
||||
elif 'TB' in sizestr:
|
||||
sizestr = sizestr.replace('TB', '')
|
||||
sizestr = int(float(sizestr * 1000 * 1000))
|
||||
elif 'TiB' in sizestr:
|
||||
sizestr = sizestr.replace('TiB', '')
|
||||
sizestr = int(float(sizestr * 1024 * 1024))
|
||||
return sizestr
|
||||
|
||||
|
||||
class IMMClient(object):
|
||||
logouturl = '/data/logout'
|
||||
bmcname = 'IMM'
|
||||
@@ -1502,12 +1518,8 @@ class XCCClient(IMMClient):
|
||||
spares.append(diskinfo)
|
||||
else:
|
||||
disks.append(diskinfo)
|
||||
totalsize = pool['totalCapacityStr'].replace(
|
||||
'GB', '').replace('GiB', '')
|
||||
totalsize = int(float(totalsize) * 1024)
|
||||
freesize = pool['freeCapacityStr'].replace(
|
||||
'GB', '').replace('GiB', '')
|
||||
freesize = int(float(freesize) * 1024)
|
||||
totalsize = str_to_size(pool['totalCapacityStr'])
|
||||
freesize = str_to_size(pool['freeCapacityStr'])
|
||||
pools.append(storage.Array(
|
||||
disks=disks, raid=pool['rdlvlstr'], volumes=volumes,
|
||||
id=(cid, pool['id']), hotspares=spares,
|
||||
|
||||
Reference in New Issue
Block a user