Show all devices even if nothing is attached.

This commit is contained in:
Eric Helgeson 2020-12-28 20:38:21 -06:00
parent 59b54c48fb
commit d68f089966
3 changed files with 17 additions and 6 deletions

View File

@ -53,6 +53,8 @@ def rascsi_service(action):
def list_devices():
device_list = []
for id in range(8):
device_list.append({"id": str(id), "un": "-", "type": "-", "file": "-"})
output = subprocess.run(["rasctl", "-l"], capture_output=True).stdout.decode("utf-8")
for line in output.splitlines():
# Valid line to process, continue
@ -64,9 +66,10 @@ def list_devices():
device = {}
segments = line.split("|")
if len(segments) > 4:
device['id'] = segments[1].strip()
device['un'] = segments[2].strip()
device['type'] = segments[3].strip()
device['file'] = segments[4].strip()
device_list.append(device)
idx = int(segments[1].strip())
device_list[idx]["id"] = str(idx)
device_list[idx]['un'] = segments[2].strip()
device_list[idx]['type'] = segments[3].strip()
device_list[idx]['file'] = segments[4].strip()
return device_list

View File

@ -31,6 +31,7 @@
</tr>
{% for device in devices %}
<tr>
{% if device.id != "7" %}
<td style="text-align:center">{{device.id}}</td>
<td style="text-align:center">{{device.type}}</td>
<td>{{device.file}}</td>
@ -47,6 +48,12 @@
</form>
{% endif %}
</td>
{% else %}
<td style="text-align:center">{{device.id}}</td>
<td style="text-align:center">-</td>
<td>Host Machine</td>
<td>-</td>
{% endif %}
</tr>
{% endfor %}
</tbody>

View File

@ -31,13 +31,14 @@ def index():
def get_valid_scsi_ids(devices):
invalid_list = EXCLUDE_SCSI_IDS.copy()
for device in devices:
if device['file'] != "NO MEDIA":
if device['file'] != "NO MEDIA" and device['file'] != "-":
invalid_list.append(int(device['id']))
valid_list = list(range(8))
for id in invalid_list:
valid_list.remove(id)
valid_list.reverse()
return valid_list