Skip to content

Commit

Permalink
drive.state setter now always convert to DriveState. Trying to help w…
Browse files Browse the repository at this point in the history
…ith issue Set drive state minor issue #12
  • Loading branch information
ralequi committed Apr 21, 2023
1 parent 6bad729 commit 104bad9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 0.6.4
=============
- Added some aliases to `drive.state` & `drive.set_state` method. (PR [#12](https://github.com/Naudit/pystorcli2/pull/12))

Version 0.6.3
=============
- Bugfix: `pystorcli` package was incomplete. (submodules were missing)
Expand Down
6 changes: 4 additions & 2 deletions pystorcli2/drive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,10 @@ def set_state(self, value: Union[str, DriveState], force: bool = False):
""" Set drive state
"""
# if DriveState, get the string value
if isinstance(value, DriveState):
value = value.settable_str()
if isinstance(value, str):
value = DriveState.from_string(value)

value = value.settable_str()

args = [
'set',
Expand Down
2 changes: 2 additions & 0 deletions pystorcli2/drive/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def from_string(status: str) -> 'DriveState':

alias = {
'good': DriveState.UGood,
'bad': DriveState.UBad,
'dedicated': DriveState.DHS,
'hotspare': DriveState.GHS,
'unconfigured': DriveState.UGood,
'unconfigured(good)': DriveState.UGood,
Expand Down

0 comments on commit 104bad9

Please sign in to comment.