Skip to content

Commit

Permalink
Added fixes and tests for issue Additional params in methods - create…
Browse files Browse the repository at this point in the history
…_vd #2
  • Loading branch information
ralequi committed Mar 22, 2023
1 parent a742974 commit 0cadbde
Show file tree
Hide file tree
Showing 21 changed files with 1,263 additions and 12 deletions.
21 changes: 14 additions & 7 deletions pystorcli2/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from . import virtualdrive
from . import exc

from typing import List
from typing import List, Optional


class ControllerMetrics(object):
Expand Down Expand Up @@ -274,7 +274,7 @@ def encls(self):
"""
return enclosure.Enclosures(ctl_id=self._ctl_id, binary=self._binary)

def create_vd(self, name, raid, drives, strip='64'):
def create_vd(self, name: str, raid: str, drives: str, strip: str = '64', PDperArray: Optional[int] = None) -> Optional[virtualdrive.VirtualDrive]:
"""Create virtual drive (raid) managed by current controller
Args:
Expand All @@ -290,12 +290,19 @@ def create_vd(self, name, raid, drives, strip='64'):
args = [
'add',
'vd',
'type={0}'.format(raid),
'r{0}'.format(raid),
'name={0}'.format(name),
'drives={0}'.format(drives),
'strip={0}'.format(strip)
]

if raid == '1' or raid == '10':

This comment has been minimized.

Copy link
@ulmitov

ulmitov Mar 23, 2023

Collaborator

i've noticed that pdperarray behaves differenlty some times.
for now i have two rules:
if 'raid10' in args:
args = args.replace('strip=', 'pdperarray=2 strip=')
if 'raid00' in args:
args = args.replace('strip=', 'pdperarray=1 strip=')

but i do not have a raid contorller to check all raid types.
Instead of hardcoding the pdperarray here, can you please add a general options param in args ? so that it will be possible to append any additional args to add vd command.

Because there are more additional params for add vd:

The StorCLI tool supports the commands that follow to add virtual drives:
storcli /cx add vd raid[0|1|5|6|10|50|60][Size=<VD1_Sz>,<VD2_Sz>,..|all]
[name=,..] drives=e:s|e:s-x,y;e:s-x,y,z
[PDperArray=x][pdcache=on|off|default]=default|automatic(auto)|
none|maximum(max)|MaximumWithoutCaching(maxnocache)] [wt|wb|awb] [nora|ra]
[direct|cached][cachevd] [Strip=<8|16|32|64|128|256|1024>]
[AfterVd=X][EmulationType=0|1|2] [Spares = [e:]s|[e:]s-x|[e:]s-x,y]
[force][ExclusiveAccess]

storcli /cx add vd each raid0 [name=,..] [drives=e:s|e:s-x|e:s-x,y]
[pdcache=on|off|default]=default|automatic(auto)|
none|maximum(max)|MaximumWithoutCaching(maxnocache)] [wt|wb|awb] [nora|ra]
[direct|cached][EmulationType=0|1|2]
[Strip=<8|16|32|64|128|256|1024>][ExclusiveAccess]

storcli /cx add VD cachecade|cc raid[0,1] drives =[e:]s|[e:]s-x|[e:]s-x,y
[WT|WB|AWB] [assignvds = 0,1,2]

if PDperArray is None:
PDperArray = 2

if PDperArray is not None:
args.append('PDperArray={0}'.format(PDperArray))

self._run(args)
for vd in self.vds:
if name == vd.name:
Expand Down Expand Up @@ -327,7 +334,7 @@ def __init__(self, binary='storcli64'):
self._binary = binary
self._storcli = StorCLI(binary)

@property
@ property
def _ctl_ids(self) -> List[str]:
out = self._storcli.run(['show'])
response = common.response_data(out)
Expand All @@ -337,21 +344,21 @@ def _ctl_ids(self) -> List[str]:
else:
return [ctl['Ctl'] for ctl in common.response_data(out)['System Overview']]

@property
@ property
def _ctls(self):
for ctl_id in self._ctl_ids:
yield Controller(ctl_id=ctl_id, binary=self._binary)

def __iter__(self):
return self._ctls

@property
@ property
def ids(self):
"""(list of str): controllers id
"""
return self._ctl_ids

def get_ctl(self, ctl_id):
def get_ctl(self, ctl_id: int) -> Optional[Controller]:
"""Get controller object by id
Args:
Expand Down
2 changes: 1 addition & 1 deletion pystorcli2/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.0.6"
__version__ = "0.5.0.8"
15 changes: 12 additions & 3 deletions tests/baseTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,22 @@ def get_cmdRunner(self, folder: str, options: List[str] = []):
return StorcliCMDFile(folder, options)

def setupEnv(self, folder: str):
# Check if storcli exists in self
if hasattr(self, 'storcli'):
return

# get cmdRunner
cmdRunner = self.get_cmdRunner(folder)

StorCLI.enable_singleton()
r = StorCLI(cmdrunner=cmdRunner)
r.clear_cache()
self.storcli = StorCLI(cmdrunner=cmdRunner)
self.storcli.clear_cache()
# Conflirm cmdRunner is set properly
r.set_cmdrunner(cmdRunner)
self.storcli.set_cmdrunner(cmdRunner)

return self.get_device_data(folder)

def get_storcli(self, folder: str):
self.setupEnv(folder)

return self.storcli
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Controllers": [
{
"Command Status": {
"CLI Version": "007.1704.0000.0000 Jan 16, 2021",
"Operating system": "Linux 5.15.0-58-generic",
"Controller": 0,
"Status": "Success",
"Description": "Add VD Succeeded."
}
}
]
}
Loading

0 comments on commit 0cadbde

Please sign in to comment.