File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 25
25
26
26
def get_disk_type (diskdev ):
27
27
"""Check disk type"""
28
- cmd = "cat /sys/block/{}/queue/rotational" .format (diskdev .replace ('/dev/' ,'' ))
28
+ diskdev_name = diskdev .replace ('/dev/' ,'' )
29
+ cmd = "lsblk -l -n |grep disk"
29
30
proc = subprocess .Popen (cmd , shell = True , text = True , stdout = subprocess .PIPE )
30
- out = proc .stdout .readline ()
31
- return out .rstrip ()
31
+ outs = proc .stdout .readlines ()
32
+ for out in outs :
33
+ if out .split ()[0 ] in diskdev_name :
34
+ cmd = "cat /sys/block/{}/queue/rotational" .format (diskdev_name )
35
+ proc = subprocess .Popen (cmd , shell = True , text = True , stdout = subprocess .PIPE )
36
+ out = proc .stdout .readline ()
37
+ return out .rstrip ()
38
+
39
+ print ("disk {} does not exist in the device" .format (diskdev_name ))
40
+ sys .exit (1 )
32
41
33
42
34
43
def import_ssd_api (diskdev ):
You can’t perform that action at this time.
0 commit comments