2
0
mirror of https://opendev.org/x/pyghmi synced 2026-04-01 15:53:32 +00:00

Merge "Adapt to more variants in the capacitystr"

This commit is contained in:
Zuul
2022-01-25 13:10:32 +00:00
committed by Gerrit Code Review

View File

@@ -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,