Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Software
idms-linux-installer
Commits
3bd88fe8
Commit
3bd88fe8
authored
Jul 13, 2020
by
Nigel Kukard
Browse files
Add support to get mdadm attribs on create
parent
1d3297d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/idmslinux_installer/util/mdadm.py
View file @
3bd88fe8
...
...
@@ -15,7 +15,7 @@
"""Support class for mdadm."""
from
typing
import
List
from
typing
import
Dict
,
List
from
idmslinux_installer.util.asyncsubprocess
import
(
AsyncSubprocess
,
OutputCallback
)
...
...
@@ -28,8 +28,8 @@ class Mdadm:
def
__init__
(
self
,
load
:
bool
=
True
):
"""Initialize our class and load system partition types."""
def
create
(
self
,
md_device
:
str
,
level
:
int
,
devices
:
List
[
str
],
output_callback
:
OutputCallback
=
None
):
"""Create RAID device."""
def
create
(
self
,
md_device
:
str
,
level
:
int
,
devices
:
List
[
str
],
output_callback
:
OutputCallback
=
None
)
->
Dict
[
str
,
str
]
:
"""Create
a
RAID device
and return the details in a dict
."""
# If we didn't get an output_callback, set it to our own class method
if
not
output_callback
:
...
...
@@ -47,6 +47,22 @@ class Mdadm:
if
proc
.
retcode
!=
0
:
raise
OSError
(
f
'Failed to create md device
{
md_device
}
return code
{
proc
.
retcode
}
'
)
# Grab the UUID
proc
=
AsyncSubprocess
([
'mdadm'
,
'--detail'
,
'--export'
,
md_device
])
result
=
proc
.
run
()
# Raise an exception if we didn't get a positive response back
if
proc
.
retcode
!=
0
:
raise
OSError
(
f
'Failed to get mdadm attributes from device
{
md_device
}
return code
{
proc
.
retcode
}
'
)
# Strip value, then split on the =
attribs
:
Dict
[
str
,
str
]
=
{}
for
line
in
result
:
key
,
value
=
line
.
rstrip
().
split
(
'='
,
1
)
attribs
[
key
]
=
value
return
attribs
def
_default_output_callback
(
self
,
line
:
str
):
line
.
rstrip
()
print
(
f
'mdadm:
{
line
}
'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment