Improve the logic and data structure for SCSI ID management in Web UI (#893)

- Have the get_scsi_ids() utility method return a dict, while adding occupied_ids. Leverage this to improve the logic for detecting which IDs are available to be reserved in the Web UI. (Which fixes a recent regression bug that's causing no IDs to be detected as available to be reserved.)
- Improve /scsi/attach endpoint logic to capture dynamic parameter fields now prefixed with "param_" (previous it scanned for any arbitrary field, which wasn't very accurate or secure)
- Added Product string to the block_size:512 CD-ROM device, so that it's obvious when it's being used.
- Tweaked test data for attach_device tests
This commit is contained in:
Daniel Markstedt
2022-10-06 10:00:57 -07:00
committed by GitHub
parent a30438279e
commit 52ebb3a2ae
5 changed files with 53 additions and 40 deletions
+11 -9
View File
@@ -42,8 +42,8 @@ def test_attach_image(http_client, create_test_image, detach_devices):
{
"type": "SCRM",
"drive_props": {
"vendor": "VENDOR",
"product": "PRODUCT",
"vendor": "HD VENDOR",
"product": "HD PRODUCT",
"revision": "0123",
"block_size": "512",
},
@@ -54,8 +54,8 @@ def test_attach_image(http_client, create_test_image, detach_devices):
{
"type": "SCMO",
"drive_props": {
"vendor": "VENDOR",
"product": "PRODUCT",
"vendor": "MO VENDOR",
"product": "MO PRODUCT",
"revision": "0123",
"block_size": "512",
},
@@ -66,17 +66,19 @@ def test_attach_image(http_client, create_test_image, detach_devices):
{
"type": "SCCD",
"drive_props": {
"vendor": "VENDOR",
"product": "PRODUCT",
"vendor": "CD VENDOR",
"product": "CD PRODUCT",
"revision": "0123",
"block_size": "512",
},
},
),
("Host Bridge", {"type": "SCBR", "interface": "eth0", "inet": "10.10.20.1/24"}),
("Ethernet Adapter", {"type": "SCDP", "interface": "eth0", "inet": "10.10.20.1/24"}),
# TODO: Find a portable way to detect network interfaces for testing
("Host Bridge", {"type": "SCBR", "param_inet": "192.168.0.1/24"}),
# TODO: Find a portable way to detect network interfaces for testing
("Ethernet Adapter", {"type": "SCDP", "param_inet": "192.168.0.1/24"}),
("Host Services", {"type": "SCHS"}),
("Printer", {"type": "SCLP", "timeout": 30, "cmd": "lp -oraw %f"}),
("Printer", {"type": "SCLP", "param_timeout": 60, "param_cmd": "lp -fart %f"}),
],
)
def test_attach_device(http_client, detach_devices, device_name, device_config):