Merge pull request #1950 from dbungert/lp-2058394-no-format-obj-on-unformatted
filesystem: handle empty string fstype partitions
This commit is contained in:
commit
e54354b8a3
|
@ -1199,9 +1199,11 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
||||||
raise ValueError("new partition too large")
|
raise ValueError("new partition too large")
|
||||||
if requested_size < 1:
|
if requested_size < 1:
|
||||||
requested_size = data.gap.size
|
requested_size = data.gap.size
|
||||||
|
# empty string is an unformatted partition
|
||||||
|
fstype = data.partition.format or None
|
||||||
spec = {
|
spec = {
|
||||||
"size": requested_size,
|
"size": requested_size,
|
||||||
"fstype": data.partition.format,
|
"fstype": fstype,
|
||||||
"mount": data.partition.mount,
|
"mount": data.partition.mount,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -782,6 +782,28 @@ class TestAdd(TestAPI):
|
||||||
with self.assertRaises(ClientResponseError, msg=f"data {data}"):
|
with self.assertRaises(ClientResponseError, msg=f"data {data}"):
|
||||||
await inst.post("/storage/v2/add_partition", data)
|
await inst.post("/storage/v2/add_partition", data)
|
||||||
|
|
||||||
|
@timeout()
|
||||||
|
async def test_add_unformatted_ok(self):
|
||||||
|
disk_id = "disk-sda"
|
||||||
|
async with start_server("examples/machines/simple.json") as inst:
|
||||||
|
for fmt in ("", None):
|
||||||
|
await inst.post("/storage/v2/reset")
|
||||||
|
disk_id = "disk-sda"
|
||||||
|
resp = await inst.get("/storage/v2")
|
||||||
|
[sda] = match(resp["disks"], id=disk_id)
|
||||||
|
[gap] = sda["partitions"]
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"disk_id": disk_id,
|
||||||
|
"gap": gap,
|
||||||
|
"partition": dict(format=fmt, mount="/"),
|
||||||
|
}
|
||||||
|
await inst.post("/storage/v2/add_partition", data)
|
||||||
|
|
||||||
|
v1resp = await inst.get("/storage")
|
||||||
|
empties = match(v1resp["config"], type="format", fstype="")
|
||||||
|
self.assertEqual(0, len(empties), "invalid format object")
|
||||||
|
|
||||||
@timeout()
|
@timeout()
|
||||||
async def test_add_default_size_handling(self):
|
async def test_add_default_size_handling(self):
|
||||||
async with start_server("examples/machines/simple.json") as inst:
|
async with start_server("examples/machines/simple.json") as inst:
|
||||||
|
|
Loading…
Reference in New Issue