Skip to content

Commit

Permalink
storage/v2: edit reuse existing format/mount value
Browse files Browse the repository at this point in the history
  • Loading branch information
dbungert committed Oct 7, 2021
1 parent 7d80e8c commit 57148ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
11 changes: 8 additions & 3 deletions subiquity/server/controllers/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,15 @@ async def v2_edit_partition_POST(self, data: ModifyPartitionV2) \
if data.partition.grub_device not in (None, partition.grub_device):
raise ValueError('edit_partition does not support changing '
+ 'grub_device')

existing_format = ''
existing_mount = ''
if partition._fs:
existing_format = partition._fs.fstype
if partition._fs._mount:
existing_mount = partition._fs._mount.path
spec = {
'fstype': data.partition.format,
'mount': data.partition.mount,
'fstype': data.partition.format or existing_format,
'mount': data.partition.mount or existing_mount,
}
self.partition_disk_handler(disk, partition, spec)
return await self.v2_GET()
Expand Down
26 changes: 26 additions & 0 deletions subiquity/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,32 @@ async def test_todos_guided(self):
self.assertFalse(resp['need_root'])
self.assertFalse(resp['need_boot'])

@timeout(5)
async def test_edit_partial(self):
disk_id = 'disk-sda'
await self.post('/storage/v2/reformat_disk', disk_id=disk_id)

data = {
'disk_id': disk_id,
'partition': {
'format': 'ext4',
'mount': '/',
}
}
await self.post('/storage/v2/add_partition', data)

data['partition'].update({
'number': 2,
'format': None,
'mount': '/home'
})
resp = await self.post('/storage/v2/edit_partition', data)

sda = first(resp['disks'], 'id', disk_id)
sda2 = first(sda['partitions'], 'number', 2)
self.assertEqual('ext4', sda2['format'])
self.assertEqual('/home', sda2['mount'])


class TestManyDisks(TestAPI):
machine_config = 'examples/many-nics-and-disks.json'
Expand Down

0 comments on commit 57148ee

Please sign in to comment.