diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-05-23 10:07:46 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-05-23 10:41:35 +0200 |
commit | 51899c362f2eba1dd067414f2dfa8e78f30ca408 (patch) | |
tree | 939ad35c9e026e4a667eb61184df3dc11a1a35d8 | |
parent | 8fdebbe140bdd92d3c3086ac90a3f869f740b74d (diff) | |
download | vyos-1x-51899c362f2eba1dd067414f2dfa8e78f30ca408.tar.gz vyos-1x-51899c362f2eba1dd067414f2dfa8e78f30ca408.zip |
op-mode: disks: T1621: bugfix no disk output
-rw-r--r-- | op-mode-definitions/disks.xml.in | 1 | ||||
-rwxr-xr-x | src/completion/list_disks.py | 21 |
2 files changed, 15 insertions, 7 deletions
diff --git a/op-mode-definitions/disks.xml.in b/op-mode-definitions/disks.xml.in index fb39c4f3c..2102a2e8e 100644 --- a/op-mode-definitions/disks.xml.in +++ b/op-mode-definitions/disks.xml.in @@ -26,7 +26,6 @@ </tagNode> </children> </node> - <node name="show"> <children> <tagNode name="disk"> diff --git a/src/completion/list_disks.py b/src/completion/list_disks.py index ff1135e23..0aa872abb 100755 --- a/src/completion/list_disks.py +++ b/src/completion/list_disks.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2019 VyOS maintainers and contributors +# Copyright (C) 2019-2021 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -23,11 +23,20 @@ parser.add_argument("-e", "--exclude", type=str, help="Exclude specified device args = parser.parse_args() disks = set() -with open('/proc/partitions') as partitions_file: - for line in partitions_file: - fields = line.strip().split() - if len(fields) == 4 and fields[3].isalpha() and fields[3] != 'name': - disks.add(fields[3]) +with open('/proc/partitions') as f: + table = f.read() + +for line in table.splitlines()[1:]: + fields = line.strip().split() + # probably an empty line at the top + if len(fields) == 0: + continue + disks.add(fields[3]) + +if 'loop0' in disks: + disks.remove('loop0') +if 'sr0' in disks: + disks.remove('sr0') if args.exclude: disks.remove(args.exclude) |