mirror of
https://github.com/nix-community/disko.git
synced 2026-12-01 13:33:28 +01:00
disko2: Add rudimentary plan generation
This commit is contained in:
1 parent
6651792c28
commit
cfcc518b70
28 files changed
+1191
-609
No files matched your search
@@ -6,6 +6,7 @@
|
||||
"efiGptPartitionFirst": true,
|
||||
"partitions": {
|
||||
"ESP": {
|
||||
"_index": 1,
|
||||
"alignment": 0,
|
||||
"content": {
|
||||
"device": "/dev/disk/by-partlabel/disk-main-ESP",
|
||||
@@ -28,6 +29,7 @@
|
||||
"type": "EF00"
|
||||
},
|
||||
"root": {
|
||||
"_index": 2,
|
||||
"alignment": 0,
|
||||
"content": {
|
||||
"device": "/dev/disk/by-partlabel/disk-main-root",
|
||||
@@ -63,4 +65,4 @@
|
||||
"mdadm": {},
|
||||
"nodev": {},
|
||||
"zpool": {}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"efiGptPartitionFirst": true,
|
||||
"partitions": {
|
||||
"ESP": {
|
||||
"_index": 2,
|
||||
"alignment": 0,
|
||||
"content": {
|
||||
"device": "/dev/disk/by-partlabel/disk-main-ESP",
|
||||
@@ -28,6 +29,7 @@
|
||||
"type": "EF00"
|
||||
},
|
||||
"boot": {
|
||||
"_index": 1,
|
||||
"alignment": 0,
|
||||
"content": null,
|
||||
"device": "/dev/disk/by-partlabel/disk-main-boot",
|
||||
@@ -41,6 +43,7 @@
|
||||
"type": "EF02"
|
||||
},
|
||||
"root": {
|
||||
"_index": 3,
|
||||
"alignment": 0,
|
||||
"content": {
|
||||
"device": "/dev/disk/by-partlabel/disk-main-root",
|
||||
@@ -76,4 +79,4 @@
|
||||
"mdadm": {},
|
||||
"nodev": {},
|
||||
"zpool": {}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
import readline
|
||||
from typing import cast
|
||||
|
||||
from disko_lib.eval_config import eval_config_as_json, eval_and_validate_config
|
||||
from disko_lib.eval_config import eval_config_file_as_json, validate_config
|
||||
from disko_lib.messages.msgs import err_missing_arguments, err_too_many_arguments
|
||||
from disko_lib.result import DiskoError, DiskoSuccess
|
||||
from disko_lib.json_types import JsonDict
|
||||
@@ -14,14 +13,14 @@ assert (ROOT_DIR / "flake.nix").exists()
|
||||
|
||||
|
||||
def test_eval_config_missing_arguments() -> None:
|
||||
result = eval_config_as_json(disko_file=None, flake=None)
|
||||
result = eval_config_file_as_json(disko_file=None, flake=None)
|
||||
assert isinstance(result, DiskoError)
|
||||
assert result.messages[0].is_message(err_missing_arguments)
|
||||
assert result.context == "validate args"
|
||||
|
||||
|
||||
def test_eval_config_too_many_arguments() -> None:
|
||||
result = eval_config_as_json(disko_file="foo", flake="bar")
|
||||
result = eval_config_file_as_json(disko_file="foo", flake="bar")
|
||||
assert isinstance(result, DiskoError)
|
||||
assert result.messages[0].is_message(err_too_many_arguments)
|
||||
assert result.context == "validate args"
|
||||
@@ -29,7 +28,7 @@ def test_eval_config_too_many_arguments() -> None:
|
||||
|
||||
def test_eval_config_disko_file() -> None:
|
||||
disko_file_path = ROOT_DIR / "example" / "simple-efi.nix"
|
||||
result = eval_config_as_json(disko_file=str(disko_file_path), flake=None)
|
||||
result = eval_config_file_as_json(disko_file=str(disko_file_path), flake=None)
|
||||
assert isinstance(result, DiskoSuccess)
|
||||
with open(CURRENT_DIR / "file-simple-efi-eval-result.json") as f:
|
||||
expected_result = cast(JsonDict, json.load(f))
|
||||
@@ -37,7 +36,7 @@ def test_eval_config_disko_file() -> None:
|
||||
|
||||
|
||||
def test_eval_config_flake_testmachine() -> None:
|
||||
result = eval_config_as_json(disko_file=None, flake=f"{ROOT_DIR}#testmachine")
|
||||
result = eval_config_file_as_json(disko_file=None, flake=f"{ROOT_DIR}#testmachine")
|
||||
assert isinstance(result, DiskoSuccess)
|
||||
with open(CURRENT_DIR / "flake-testmachine-eval-result.json") as f:
|
||||
expected_result = cast(JsonDict, json.load(f))
|
||||
@@ -46,16 +45,22 @@ def test_eval_config_flake_testmachine() -> None:
|
||||
|
||||
def test_eval_and_validate_config_disko_file() -> None:
|
||||
disko_file_path = ROOT_DIR / "example" / "simple-efi.nix"
|
||||
result = eval_and_validate_config(disko_file=str(disko_file_path), flake=None)
|
||||
assert isinstance(result, DiskoSuccess)
|
||||
eval_result = eval_config_file_as_json(disko_file=str(disko_file_path), flake=None)
|
||||
assert isinstance(eval_result, DiskoSuccess)
|
||||
validate_result = validate_config(eval_result.value)
|
||||
assert isinstance(validate_result, DiskoSuccess)
|
||||
with open(CURRENT_DIR / "file-simple-efi-validate-result.json") as f:
|
||||
expected_result = f.read()
|
||||
assert json.loads(result.value.model_dump_json()) == json.loads(expected_result) # type: ignore[misc]
|
||||
assert json.loads(validate_result.value.model_dump_json(by_alias=True)) == json.loads(expected_result) # type: ignore[misc]
|
||||
|
||||
|
||||
def test_eval_and_validate_flake_testmachine() -> None:
|
||||
result = eval_and_validate_config(disko_file=None, flake=f"{ROOT_DIR}#testmachine")
|
||||
assert isinstance(result, DiskoSuccess)
|
||||
eval_result = eval_config_file_as_json(
|
||||
disko_file=None, flake=f"{ROOT_DIR}#testmachine"
|
||||
)
|
||||
assert isinstance(eval_result, DiskoSuccess)
|
||||
validate_result = validate_config(eval_result.value)
|
||||
assert isinstance(validate_result, DiskoSuccess)
|
||||
with open(CURRENT_DIR / "flake-testmachine-validate-result.json") as f:
|
||||
expected_result = f.read()
|
||||
assert json.loads(result.value.model_dump_json()) == json.loads(expected_result) # type: ignore[misc]
|
||||
assert json.loads(validate_result.value.model_dump_json(by_alias=True)) == json.loads(expected_result) # type: ignore[misc]
|
||||
@@ -1,168 +0,0 @@
|
||||
from disko_lib.dict_diff import dict_diff
|
||||
from disko_lib.json_types import JsonDict
|
||||
|
||||
|
||||
def test_dict_diff_basic() -> None:
|
||||
left: JsonDict = {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3,
|
||||
"d": 4,
|
||||
}
|
||||
right: JsonDict = {
|
||||
"a": 1,
|
||||
"b": 3,
|
||||
"c": 4,
|
||||
"e": 5,
|
||||
}
|
||||
assert dict_diff(left, right) == {
|
||||
"b": 3,
|
||||
"c": 4,
|
||||
"d": None,
|
||||
"e": 5,
|
||||
}
|
||||
assert dict_diff(right, left) == {
|
||||
"b": 2,
|
||||
"c": 3,
|
||||
"d": 4,
|
||||
"e": None,
|
||||
}
|
||||
assert dict_diff(left, left) == {}
|
||||
assert dict_diff(right, right) == {}
|
||||
assert dict_diff({}, {}) == {}
|
||||
assert dict_diff(left, {}) == {
|
||||
"a": None,
|
||||
"b": None,
|
||||
"c": None,
|
||||
"d": None,
|
||||
}
|
||||
assert dict_diff({}, right) == right
|
||||
|
||||
|
||||
def test_dict_diff_arrays() -> None:
|
||||
left: JsonDict = {
|
||||
"a": [1, 2, 3],
|
||||
"b": [4, 5, 6],
|
||||
"c": [7, 8, 9],
|
||||
}
|
||||
right: JsonDict = {
|
||||
"a": [1, 2, 3],
|
||||
"b": [4, 5, 7],
|
||||
"c": [7, 8, 9],
|
||||
"d": [10, 11, 12],
|
||||
}
|
||||
assert dict_diff(left, right) == {
|
||||
"b": [4, 5, 7],
|
||||
"d": [10, 11, 12],
|
||||
}
|
||||
assert dict_diff(right, left) == {
|
||||
"b": [4, 5, 6],
|
||||
"d": None,
|
||||
}
|
||||
assert dict_diff(left, left) == {}
|
||||
assert dict_diff(right, right) == {}
|
||||
assert dict_diff(left, {}) == {
|
||||
"a": None,
|
||||
"b": None,
|
||||
"c": None,
|
||||
}
|
||||
assert dict_diff({}, right) == right
|
||||
|
||||
|
||||
def test_dict_diff_nested() -> None:
|
||||
left: JsonDict = {
|
||||
"a": {
|
||||
"b": {
|
||||
"c": 1,
|
||||
"d": 2,
|
||||
},
|
||||
"e": 3,
|
||||
"f": 4,
|
||||
},
|
||||
"g": {
|
||||
"h": 4,
|
||||
},
|
||||
"k": {
|
||||
"l": {
|
||||
"m": 5,
|
||||
},
|
||||
},
|
||||
}
|
||||
right: JsonDict = {
|
||||
"a": {
|
||||
"b": {
|
||||
"c": 1,
|
||||
"d": 3,
|
||||
},
|
||||
"e": 3,
|
||||
},
|
||||
"g": {
|
||||
"h": 4,
|
||||
"i": 5,
|
||||
},
|
||||
"o": {
|
||||
"p": 6,
|
||||
},
|
||||
}
|
||||
assert dict_diff(left, right) == {
|
||||
"a": {
|
||||
"b": {
|
||||
"d": 3,
|
||||
},
|
||||
"f": None,
|
||||
},
|
||||
"g": {
|
||||
"i": 5,
|
||||
},
|
||||
"k": None,
|
||||
"o": {
|
||||
"p": 6,
|
||||
"_new": True,
|
||||
},
|
||||
}
|
||||
assert dict_diff(right, left) == {
|
||||
"a": {
|
||||
"b": {
|
||||
"d": 2,
|
||||
},
|
||||
"f": 4,
|
||||
},
|
||||
"g": {
|
||||
"i": None,
|
||||
},
|
||||
"k": {
|
||||
"l": {
|
||||
"m": 5,
|
||||
"_new": True,
|
||||
},
|
||||
"_new": True,
|
||||
},
|
||||
"o": None,
|
||||
}
|
||||
assert dict_diff(left, left) == {}
|
||||
assert dict_diff(right, right) == {}
|
||||
assert dict_diff(left, {}) == {
|
||||
"a": None,
|
||||
"g": None,
|
||||
"k": None,
|
||||
}
|
||||
assert dict_diff({}, right) == {
|
||||
"a": {
|
||||
"b": {
|
||||
"c": 1,
|
||||
"d": 3,
|
||||
"_new": True,
|
||||
},
|
||||
"e": 3,
|
||||
"_new": True,
|
||||
},
|
||||
"g": {
|
||||
"h": 4,
|
||||
"i": 5,
|
||||
"_new": True,
|
||||
},
|
||||
"o": {
|
||||
"p": 6,
|
||||
"_new": True,
|
||||
},
|
||||
}
|
||||
@@ -1,110 +1,131 @@
|
||||
{
|
||||
"disks": {
|
||||
"MODEL:ST2000LM003 HN-M201RAD,SN:S321J9GFC01497": {
|
||||
"device": "sda",
|
||||
"type": "disk",
|
||||
"content": {
|
||||
"partitions": {
|
||||
"PARTUUID:c090741b-68e2-4867-96df-2ec00765f2c0": {
|
||||
"size": "128M",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "",
|
||||
"mountpoint": ""
|
||||
}
|
||||
},
|
||||
"UUID:7CA41E5EA41E1B6A": {
|
||||
"size": "1.8T",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ntfs",
|
||||
"mountpoint": "/mnt/g"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"disko": {
|
||||
"devices": {
|
||||
"disk": {
|
||||
"MODEL:SanDisk SD8TB8U256G1001,SN:171887425854": {
|
||||
"device": "sdb",
|
||||
"type": "disk",
|
||||
"content": {
|
||||
"partitions": {
|
||||
"UUID:01D60069CEED69C0": {
|
||||
"size": "499.5M",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ntfs",
|
||||
"mountpoint": ""
|
||||
}
|
||||
},
|
||||
"UUID:01D6006B90875FE0": {
|
||||
"size": "236.8G",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ntfs",
|
||||
"mountpoint": ""
|
||||
}
|
||||
},
|
||||
"UUID:708B-C192": {
|
||||
"size": "100M",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "vfat",
|
||||
"mountpoint": ""
|
||||
},
|
||||
"type": "EF00"
|
||||
},
|
||||
"UUID:90B6FB81B6FB65DE": {
|
||||
"size": "544M",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ntfs",
|
||||
"mountpoint": ""
|
||||
}
|
||||
}
|
||||
"device": "/dev/sdb",
|
||||
"type": "disk",
|
||||
"content": {
|
||||
"type": "gpt",
|
||||
"partitions": {
|
||||
"UUID:01D60069CEED69C0": {
|
||||
"_index": 1,
|
||||
"size": "523730944",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ntfs",
|
||||
"mountpoint": null
|
||||
}
|
||||
},
|
||||
"UUID:01D6006B90875FE0": {
|
||||
"_index": 2,
|
||||
"size": "254301093376",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ntfs",
|
||||
"mountpoint": null
|
||||
}
|
||||
},
|
||||
"UUID:708B-C192": {
|
||||
"_index": 3,
|
||||
"size": "104857600",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "vfat",
|
||||
"mountpoint": null
|
||||
},
|
||||
"type": "EF00"
|
||||
},
|
||||
"UUID:90B6FB81B6FB65DE": {
|
||||
"_index": 4,
|
||||
"size": "570425344",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ntfs",
|
||||
"mountpoint": null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"MODEL:CT2000MX500SSD1,SN:2105E4F0DE85": {
|
||||
"device": "sdd",
|
||||
"type": "disk",
|
||||
"content": {
|
||||
"partitions": {
|
||||
"UUID:2740-1628": {
|
||||
"size": "1000M",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "vfat",
|
||||
"mountpoint": "/boot"
|
||||
},
|
||||
"type": "EF00"
|
||||
},
|
||||
"UUID:ca548f68-4e51-4364-b366-690ecc27590f": {
|
||||
"size": "588.4G",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ext4",
|
||||
"mountpoint": "/"
|
||||
}
|
||||
},
|
||||
"UUID:879299db-4147-4fac-9f34-5e8e92073efc": {
|
||||
"size": "588.4G",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "crypto_LUKS",
|
||||
"mountpoint": ""
|
||||
}
|
||||
},
|
||||
"UUID:9A48E8C248E89E6F": {
|
||||
"size": "685.2G",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ntfs",
|
||||
"mountpoint": "/mnt/s"
|
||||
}
|
||||
}
|
||||
"device": "/dev/sdc",
|
||||
"type": "disk",
|
||||
"content": {
|
||||
"type": "gpt",
|
||||
"partitions": {
|
||||
"UUID:2740-1628": {
|
||||
"_index": 1,
|
||||
"size": "1048576000",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "vfat",
|
||||
"mountpoint": "/boot"
|
||||
},
|
||||
"type": "EF00"
|
||||
},
|
||||
"UUID:ca548f68-4e51-4364-b366-690ecc27590f": {
|
||||
"_index": 2,
|
||||
"size": "631794302976",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ext4",
|
||||
"mountpoint": "/"
|
||||
}
|
||||
},
|
||||
"UUID:879299db-4147-4fac-9f34-5e8e92073efc": {
|
||||
"_index": 3,
|
||||
"size": "631810031616",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "crypto_LUKS",
|
||||
"mountpoint": null
|
||||
}
|
||||
},
|
||||
"UUID:9A48E8C248E89E6F": {
|
||||
"_index": 4,
|
||||
"size": "735743836160",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ntfs",
|
||||
"mountpoint": "/mnt/s"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"MODEL:ST2000LM003 HN-M201RAD,SN:S321J9GFC01497": {
|
||||
"device": "/dev/sdd",
|
||||
"type": "disk",
|
||||
"content": {
|
||||
"type": "gpt",
|
||||
"partitions": {
|
||||
"PARTUUID:c090741b-68e2-4867-96df-2ec00765f2c0": {
|
||||
"_index": 1,
|
||||
"size": "134217728",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "",
|
||||
"mountpoint": null
|
||||
}
|
||||
},
|
||||
"UUID:7CA41E5EA41E1B6A": {
|
||||
"_index": 2,
|
||||
"size": "2000263577600",
|
||||
"content": {
|
||||
"type": "filesystem",
|
||||
"format": "ntfs",
|
||||
"mountpoint": "/mnt/g"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"lvm_vg": {},
|
||||
"mdadm": {},
|
||||
"nodev": {},
|
||||
"zpool": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"blockdevices": [
|
||||
{
|
||||
"id-link": "wwn-0x50004cf20ecb1679",
|
||||
"id-link": "wwn-0x5002538043584d30",
|
||||
"fstype": null,
|
||||
"fssize": null,
|
||||
"fsuse%": null,
|
||||
"kname": "sda",
|
||||
"label": null,
|
||||
"model": "ST2000LM003 HN-M201RAD",
|
||||
"model": "SAMSUNG SSD PM830 mSATA 256GB",
|
||||
"partflags": null,
|
||||
"partlabel": null,
|
||||
"partn": null,
|
||||
@@ -15,75 +15,18 @@
|
||||
"parttypename": null,
|
||||
"partuuid": null,
|
||||
"path": "/dev/sda",
|
||||
"phy-sec": 4096,
|
||||
"pttype": "gpt",
|
||||
"rev": "2BC10001",
|
||||
"serial": "S321J9GFC01497",
|
||||
"size": "1.8T",
|
||||
"phy-sec": 512,
|
||||
"pttype": "dos",
|
||||
"rev": "CXM13D1Q",
|
||||
"serial": "S0XPNYAD407619",
|
||||
"size": 256060514304,
|
||||
"start": null,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
null
|
||||
],
|
||||
"type": "disk",
|
||||
"uuid": null,
|
||||
"children": [
|
||||
{
|
||||
"id-link": "wwn-0x50004cf20ecb1679-part1",
|
||||
"fstype": null,
|
||||
"fssize": null,
|
||||
"fsuse%": null,
|
||||
"kname": "sda1",
|
||||
"label": null,
|
||||
"model": null,
|
||||
"partflags": null,
|
||||
"partlabel": "Microsoft reserved partition",
|
||||
"partn": 1,
|
||||
"parttype": "e3c9e316-0b5c-4db8-817d-f92df00215ae",
|
||||
"parttypename": "Microsoft reserved",
|
||||
"partuuid": "c090741b-68e2-4867-96df-2ec00765f2c0",
|
||||
"path": "/dev/sda1",
|
||||
"phy-sec": 4096,
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": "128M",
|
||||
"start": 34,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
null
|
||||
],
|
||||
"type": "part",
|
||||
"uuid": null
|
||||
},{
|
||||
"id-link": "wwn-0x50004cf20ecb1679-part2",
|
||||
"fstype": "ntfs",
|
||||
"fssize": "1.8T",
|
||||
"fsuse%": "51%",
|
||||
"kname": "sda2",
|
||||
"label": "Groß",
|
||||
"model": null,
|
||||
"partflags": null,
|
||||
"partlabel": "Basic data partition",
|
||||
"partn": 2,
|
||||
"parttype": "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7",
|
||||
"parttypename": "Microsoft basic data",
|
||||
"partuuid": "425b6415-db2b-4684-b619-994bdd0f9b71",
|
||||
"path": "/dev/sda2",
|
||||
"phy-sec": 4096,
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": "1.8T",
|
||||
"start": 264192,
|
||||
"mountpoint": "/mnt/g",
|
||||
"mountpoints": [
|
||||
"/mnt/g"
|
||||
],
|
||||
"type": "part",
|
||||
"uuid": "7CA41E5EA41E1B6A"
|
||||
}
|
||||
]
|
||||
"uuid": null
|
||||
},{
|
||||
"id-link": "wwn-0x5001b444a63292c3",
|
||||
"fstype": null,
|
||||
@@ -103,7 +46,7 @@
|
||||
"pttype": "gpt",
|
||||
"rev": "X4133101",
|
||||
"serial": "171887425854",
|
||||
"size": "238.5G",
|
||||
"size": 256060514304,
|
||||
"start": null,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
@@ -131,7 +74,7 @@
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": "499.5M",
|
||||
"size": 523730944,
|
||||
"start": 64,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
@@ -158,7 +101,7 @@
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": "236.8G",
|
||||
"size": 254301093376,
|
||||
"start": 1022976,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
@@ -185,7 +128,7 @@
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": "100M",
|
||||
"size": 104857600,
|
||||
"start": 497704960,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
@@ -212,7 +155,7 @@
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": "544M",
|
||||
"size": 570425344,
|
||||
"start": 497909760,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
@@ -222,39 +165,12 @@
|
||||
"uuid": "90B6FB81B6FB65DE"
|
||||
}
|
||||
]
|
||||
},{
|
||||
"id-link": "wwn-0x5002538043584d30",
|
||||
"fstype": null,
|
||||
"fssize": null,
|
||||
"fsuse%": null,
|
||||
"kname": "sdc",
|
||||
"label": null,
|
||||
"model": "SAMSUNG SSD PM830 mSATA 256GB",
|
||||
"partflags": null,
|
||||
"partlabel": null,
|
||||
"partn": null,
|
||||
"parttype": null,
|
||||
"parttypename": null,
|
||||
"partuuid": null,
|
||||
"path": "/dev/sdc",
|
||||
"phy-sec": 512,
|
||||
"pttype": "dos",
|
||||
"rev": "CXM13D1Q",
|
||||
"serial": "S0XPNYAD407619",
|
||||
"size": "238.5G",
|
||||
"start": null,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
null
|
||||
],
|
||||
"type": "disk",
|
||||
"uuid": null
|
||||
},{
|
||||
"id-link": "wwn-0x500a0751e4f0de85",
|
||||
"fstype": null,
|
||||
"fssize": null,
|
||||
"fsuse%": null,
|
||||
"kname": "sdd",
|
||||
"kname": "sdc",
|
||||
"label": null,
|
||||
"model": "CT2000MX500SSD1",
|
||||
"partflags": null,
|
||||
@@ -263,12 +179,12 @@
|
||||
"parttype": null,
|
||||
"parttypename": null,
|
||||
"partuuid": null,
|
||||
"path": "/dev/sdd",
|
||||
"path": "/dev/sdc",
|
||||
"phy-sec": 4096,
|
||||
"pttype": "gpt",
|
||||
"rev": "M3CR033",
|
||||
"serial": "2105E4F0DE85",
|
||||
"size": "1.8T",
|
||||
"size": 2000398934016,
|
||||
"start": null,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
@@ -280,9 +196,9 @@
|
||||
{
|
||||
"id-link": "wwn-0x500a0751e4f0de85-part1",
|
||||
"fstype": "vfat",
|
||||
"fssize": "998M",
|
||||
"fsuse%": "6%",
|
||||
"kname": "sdd1",
|
||||
"fssize": 1046478848,
|
||||
"fsuse%": "9%",
|
||||
"kname": "sdc1",
|
||||
"label": "boot",
|
||||
"model": null,
|
||||
"partflags": null,
|
||||
@@ -291,12 +207,12 @@
|
||||
"parttype": "c12a7328-f81f-11d2-ba4b-00a0c93ec93b",
|
||||
"parttypename": "EFI System",
|
||||
"partuuid": "7f623bea-5891-49ee-9980-6534716f0f50",
|
||||
"path": "/dev/sdd1",
|
||||
"path": "/dev/sdc1",
|
||||
"phy-sec": 4096,
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": "1000M",
|
||||
"size": 1048576000,
|
||||
"start": 2048,
|
||||
"mountpoint": "/boot",
|
||||
"mountpoints": [
|
||||
@@ -307,9 +223,9 @@
|
||||
},{
|
||||
"id-link": "wwn-0x500a0751e4f0de85-part2",
|
||||
"fstype": "ext4",
|
||||
"fssize": "578.1G",
|
||||
"fsuse%": "10%",
|
||||
"kname": "sdd2",
|
||||
"fssize": 620727574528,
|
||||
"fsuse%": "13%",
|
||||
"kname": "sdc2",
|
||||
"label": "root",
|
||||
"model": null,
|
||||
"partflags": null,
|
||||
@@ -318,12 +234,12 @@
|
||||
"parttype": "0fc63daf-8483-4772-8e79-3d69d8477de4",
|
||||
"parttypename": "Linux filesystem",
|
||||
"partuuid": "d562416c-1632-40c6-88ed-5095fb921698",
|
||||
"path": "/dev/sdd2",
|
||||
"path": "/dev/sdc2",
|
||||
"phy-sec": 4096,
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": "588.4G",
|
||||
"size": 631794302976,
|
||||
"start": 2050048,
|
||||
"mountpoint": "/",
|
||||
"mountpoints": [
|
||||
@@ -336,7 +252,7 @@
|
||||
"fstype": "crypto_LUKS",
|
||||
"fssize": null,
|
||||
"fsuse%": null,
|
||||
"kname": "sdd3",
|
||||
"kname": "sdc3",
|
||||
"label": "home",
|
||||
"model": null,
|
||||
"partflags": null,
|
||||
@@ -345,12 +261,12 @@
|
||||
"parttype": "0fc63daf-8483-4772-8e79-3d69d8477de4",
|
||||
"parttypename": "Linux filesystem",
|
||||
"partuuid": "0ca34f17-5c80-4f2d-97b5-2a5f559b55b5",
|
||||
"path": "/dev/sdd3",
|
||||
"path": "/dev/sdc3",
|
||||
"phy-sec": 4096,
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": "588.4G",
|
||||
"size": 631810031616,
|
||||
"start": 1236023296,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
@@ -362,8 +278,8 @@
|
||||
{
|
||||
"id-link": "dm-name-crypt-home",
|
||||
"fstype": "btrfs",
|
||||
"fssize": "588.4G",
|
||||
"fsuse%": "49%",
|
||||
"fssize": 631793254400,
|
||||
"fsuse%": "47%",
|
||||
"kname": "dm-0",
|
||||
"label": null,
|
||||
"model": null,
|
||||
@@ -378,7 +294,7 @@
|
||||
"pttype": null,
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": "588.4G",
|
||||
"size": 631793254400,
|
||||
"start": null,
|
||||
"mountpoint": "/home",
|
||||
"mountpoints": [
|
||||
@@ -391,9 +307,9 @@
|
||||
},{
|
||||
"id-link": "wwn-0x500a0751e4f0de85-part4",
|
||||
"fstype": "ntfs",
|
||||
"fssize": "685.2G",
|
||||
"fsuse%": "90%",
|
||||
"kname": "sdd4",
|
||||
"fssize": 735743832064,
|
||||
"fsuse%": "92%",
|
||||
"kname": "sdc4",
|
||||
"label": "Schnell",
|
||||
"model": null,
|
||||
"partflags": null,
|
||||
@@ -402,12 +318,12 @@
|
||||
"parttype": "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7",
|
||||
"parttypename": "Microsoft basic data",
|
||||
"partuuid": "1d55f1cf-5a42-4fa1-a0ba-573fbd0d152c",
|
||||
"path": "/dev/sdd4",
|
||||
"path": "/dev/sdc4",
|
||||
"phy-sec": 4096,
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": "685.2G",
|
||||
"size": 735743836160,
|
||||
"start": 2470027264,
|
||||
"mountpoint": "/mnt/s",
|
||||
"mountpoints": [
|
||||
@@ -417,6 +333,90 @@
|
||||
"uuid": "9A48E8C248E89E6F"
|
||||
}
|
||||
]
|
||||
},{
|
||||
"id-link": "wwn-0x50004cf20ecb1679",
|
||||
"fstype": null,
|
||||
"fssize": null,
|
||||
"fsuse%": null,
|
||||
"kname": "sdd",
|
||||
"label": null,
|
||||
"model": "ST2000LM003 HN-M201RAD",
|
||||
"partflags": null,
|
||||
"partlabel": null,
|
||||
"partn": null,
|
||||
"parttype": null,
|
||||
"parttypename": null,
|
||||
"partuuid": null,
|
||||
"path": "/dev/sdd",
|
||||
"phy-sec": 4096,
|
||||
"pttype": "gpt",
|
||||
"rev": "2BC10001",
|
||||
"serial": "S321J9GFC01497",
|
||||
"size": 2000398934016,
|
||||
"start": null,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
null
|
||||
],
|
||||
"type": "disk",
|
||||
"uuid": null,
|
||||
"children": [
|
||||
{
|
||||
"id-link": "wwn-0x50004cf20ecb1679-part1",
|
||||
"fstype": null,
|
||||
"fssize": null,
|
||||
"fsuse%": null,
|
||||
"kname": "sdd1",
|
||||
"label": null,
|
||||
"model": null,
|
||||
"partflags": null,
|
||||
"partlabel": "Microsoft reserved partition",
|
||||
"partn": 1,
|
||||
"parttype": "e3c9e316-0b5c-4db8-817d-f92df00215ae",
|
||||
"parttypename": "Microsoft reserved",
|
||||
"partuuid": "c090741b-68e2-4867-96df-2ec00765f2c0",
|
||||
"path": "/dev/sdd1",
|
||||
"phy-sec": 4096,
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": 134217728,
|
||||
"start": 34,
|
||||
"mountpoint": null,
|
||||
"mountpoints": [
|
||||
null
|
||||
],
|
||||
"type": "part",
|
||||
"uuid": null
|
||||
},{
|
||||
"id-link": "wwn-0x50004cf20ecb1679-part2",
|
||||
"fstype": "ntfs",
|
||||
"fssize": 2000263573504,
|
||||
"fsuse%": "51%",
|
||||
"kname": "sdd2",
|
||||
"label": "Groß",
|
||||
"model": null,
|
||||
"partflags": null,
|
||||
"partlabel": "Basic data partition",
|
||||
"partn": 2,
|
||||
"parttype": "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7",
|
||||
"parttypename": "Microsoft basic data",
|
||||
"partuuid": "425b6415-db2b-4684-b619-994bdd0f9b71",
|
||||
"path": "/dev/sdd2",
|
||||
"phy-sec": 4096,
|
||||
"pttype": "gpt",
|
||||
"rev": null,
|
||||
"serial": null,
|
||||
"size": 2000263577600,
|
||||
"start": 264192,
|
||||
"mountpoint": "/mnt/g",
|
||||
"mountpoints": [
|
||||
"/mnt/g"
|
||||
],
|
||||
"type": "part",
|
||||
"uuid": "7CA41E5EA41E1B6A"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ import json
|
||||
from pathlib import Path, PosixPath
|
||||
|
||||
from disko_lib.messages import err_unsupported_pttype, warn_generate_partial_failure
|
||||
from disko_lib.result import DiskoError, DiskoSuccess
|
||||
from disko_lib.types import disk
|
||||
from disko_lib.result import DiskoPartialSuccess, DiskoSuccess
|
||||
from disko_lib.generate_config import generate_config
|
||||
from disko_lib.types import device
|
||||
|
||||
CURRENT_DIR = Path(__file__).parent
|
||||
@@ -15,22 +15,22 @@ def test_generate_config_partial_failure_dos_table() -> None:
|
||||
|
||||
assert isinstance(lsblk_result, DiskoSuccess)
|
||||
|
||||
result = disk.generate_config(lsblk_result.value)
|
||||
result = generate_config(lsblk_result.value)
|
||||
|
||||
assert isinstance(result, DiskoError)
|
||||
assert isinstance(result, DiskoPartialSuccess)
|
||||
|
||||
assert result.messages[0].is_message(err_unsupported_pttype)
|
||||
assert result.messages[0].details == {
|
||||
"pttype": "dos",
|
||||
"device": PosixPath("/dev/sdc"),
|
||||
"device": PosixPath("/dev/sda"),
|
||||
}
|
||||
|
||||
assert result.messages[1].is_message(warn_generate_partial_failure)
|
||||
with open(CURRENT_DIR / "partial_failure_dos_table-generate-result.json") as f:
|
||||
assert result.messages[1].details["partial_config"] == json.load(f) # type: ignore[misc]
|
||||
assert result.messages[1].details["failed_devices"] == [PosixPath("/dev/sdc")]
|
||||
assert result.messages[1].details["successful_devices"] == [
|
||||
PosixPath("/dev/sda"),
|
||||
assert result.value == json.load(f) # type: ignore[misc]
|
||||
assert result.messages[1].details["failed"] == [PosixPath("/dev/sda")]
|
||||
assert result.messages[1].details["successful"] == [
|
||||
PosixPath("/dev/sdb"),
|
||||
PosixPath("/dev/sdc"),
|
||||
PosixPath("/dev/sdd"),
|
||||
]
|
||||
Reference in new issue
Block a user