Merge pull request #1739 from mwhudson/fix-mount-detection
fix detection of mounted partitions
This commit is contained in:
commit
542f34572f
File diff suppressed because it is too large
Load Diff
|
@ -1292,15 +1292,19 @@ class FilesystemModel(object):
|
|||
continue
|
||||
majmin_to_dev[f'{major}:{minor}'] = obj
|
||||
|
||||
log.debug("majmin_to_dev %s", majmin_to_dev)
|
||||
|
||||
mounts = list(self._probe_data.get('mount', []))
|
||||
while mounts:
|
||||
mount = mounts.pop(0)
|
||||
mounts.extend(mount.get('children', []))
|
||||
if mount['target'].startswith(self.target):
|
||||
# Completely ignore mounts under /target, they are probably
|
||||
# leftovers from a previous install attempt.
|
||||
continue
|
||||
if 'maj:min' not in mount:
|
||||
continue
|
||||
log.debug("considering mount of %s", mount['maj:min'])
|
||||
obj = majmin_to_dev.get(mount['maj:min'])
|
||||
if obj is None:
|
||||
continue
|
||||
|
@ -1312,7 +1316,6 @@ class FilesystemModel(object):
|
|||
if isinstance(o, Disk):
|
||||
o._has_in_use_partition = True
|
||||
work.extend(dependencies(o))
|
||||
mounts.extend(mount.get('children', []))
|
||||
|
||||
# This is a special hack for the install media. When written to a USB
|
||||
# stick or similar, both the block device for the whole drive and for
|
||||
|
|
|
@ -2075,3 +2075,17 @@ class TestActiveDirectory(TestAPI):
|
|||
# manager will fail to POST /shutdown.
|
||||
except aiohttp.client_exceptions.ClientOSError:
|
||||
pass
|
||||
|
||||
|
||||
class TestMountDetection(TestAPI):
|
||||
@timeout()
|
||||
async def test_mount_detection(self):
|
||||
# Test that the partition the installer is running from is
|
||||
# correctly identified as mounted.
|
||||
cfg = 'examples/machines/booted-from-rp.json'
|
||||
async with start_server(cfg) as instance:
|
||||
result = await instance.get('/storage/v2')
|
||||
[disk1] = result['disks']
|
||||
self.assertTrue(disk1['has_in_use_partition'])
|
||||
disk1p2 = disk1['partitions'][1]
|
||||
self.assertTrue(disk1p2['is_in_use'])
|
||||
|
|
Loading…
Reference in New Issue