From 5c6fc136329df1dc12ee244a250a1221df8920b9 Mon Sep 17 00:00:00 2001 From: Vlad Spoiala Date: Wed, 20 Jan 2021 10:19:49 +0200 Subject: [PATCH] Add support for configuring write and read policies when creating a volume. Change-Id: I752d54224afb0d75594bdf71a6dc1a7c27635b08 --- pyghmi/ipmi/oem/lenovo/imm.py | 12 ++++++++++-- pyghmi/redfish/oem/lenovo/xcc.py | 12 ++++++++++-- pyghmi/storage.py | 6 +++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 94887681..ccd2c86c 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -1297,10 +1297,18 @@ class XCCClient(IMMClient): nameappend += 1 else: name = vol.name - if vol.stripsize: + if vol.stripsize is not None: stripsize = int(math.log(vol.stripsize * 2, 2)) else: stripsize = props['stripsize'] + if vol.read_policy is not None: + read_policy = vol.read_policy + else: + read_policy = props["cpra"] + if vol.write_policy is not None: + write_policy = vol.write_policy + else: + write_policy = props["cpwb"] strsize = 'remainder' if vol.size is None else str(vol.size) if strsize in ('all', '100%'): volsize = params['capacity'] @@ -1320,7 +1328,7 @@ class XCCClient(IMMClient): raise pygexc.InvalidParameterValue( 'Requested sizes exceed available capacity') vols.append('{0};{1};{2};{3};{4};{5};{6};{7};{8};|'.format( - name, volsize, stripsize, props['cpwb'], props['cpra'], + name, volsize, stripsize, write_policy, read_policy, props['cpio'], props['ap'], props['dcp'], props['initstate'])) url = '/api/function' cid = params['controller'].split(',') diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index cea4e181..2a50775a 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -358,10 +358,18 @@ class OEMHandler(generic.OEMHandler): nameappend += 1 else: name = vol.name - if vol.stripsize: + if vol.stripsize is not None: stripsize = int(math.log(vol.stripsize * 2, 2)) else: stripsize = props['stripsize'] + if vol.read_policy is not None: + read_policy = vol.read_policy + else: + read_policy = props["cpra"] + if vol.write_policy is not None: + write_policy = vol.write_policy + else: + write_policy = props["cpwb"] strsize = 'remainder' if vol.size is None else str(vol.size) if strsize in ('all', '100%'): volsize = params['capacity'] @@ -382,7 +390,7 @@ class OEMHandler(generic.OEMHandler): raise pygexc.InvalidParameterValue( 'Requested sizes exceed available capacity') vols.append('{0};{1};{2};{3};{4};{5};{6};{7};{8};|'.format( - name, volsize, stripsize, props['cpwb'], props['cpra'], + name, volsize, stripsize, write_policy, read_policy, props['cpio'], props['ap'], props['dcp'], props['initstate'])) url = '/api/function' cid = params['controller'].split(',') diff --git a/pyghmi/storage.py b/pyghmi/storage.py index f9f024c2..74e0773d 100644 --- a/pyghmi/storage.py +++ b/pyghmi/storage.py @@ -64,7 +64,7 @@ class Array(object): class Volume(object): def __init__(self, name=None, size=None, status=None, id=None, - stripsize=None): + stripsize=None, read_policy=None, write_policy=None): """Define a Volume as an object :param name: Name of the volume @@ -72,6 +72,8 @@ class Volume(object): :param status: Controller indicated status of the volume :param id: Controller identifier of a given volume :param stripsize: The stripsize of the volume in kibibytes + :param read_policy: The read policy of the volume + :param write_policy: The write policy of the volume """ self.name = name if isinstance(size, int): @@ -89,6 +91,8 @@ class Volume(object): self.status = status self.id = id self.stripsize = stripsize + self.read_policy = read_policy + self.write_policy = write_policy class ConfigSpec(object):