do not let size: largest in storage autoinstall config match the install media
This commit is contained in:
parent
2fc55b4363
commit
f585505069
|
@ -345,6 +345,8 @@ A match spec supports the following keys:
|
|||
* `ssd: yes|no`: matches a disk that is or is not an SSD (vs a rotating drive)
|
||||
* `size: largest|smallest`: take the largest or smallest disk rather than an arbitrary one if there are multiple matches (support for `smallest` added in version 20.06.1)
|
||||
|
||||
A special sort of key is `install-media: yes`, which will take the disk the installer was loaded from (the `ssd` and `size` selectors will never return this disk). If installing to the install media, care obviously needs to be take to not overwrite the installer itself!
|
||||
|
||||
So for example, to match an arbitrary disk it is simply:
|
||||
|
||||
- type: disk
|
||||
|
|
|
@ -1185,6 +1185,12 @@ class FilesystemModel(object):
|
|||
is_ssd = disk.info_for_display()['rotational'] == 'false'
|
||||
return is_ssd == match['ssd']
|
||||
|
||||
def match_install_media(disk):
|
||||
return disk in self._exclusions
|
||||
|
||||
if match.get('install-media', False):
|
||||
matchers.append(match_install_media)
|
||||
|
||||
if 'serial' in match:
|
||||
matchers.append(match_serial)
|
||||
if 'model' in match:
|
||||
|
@ -1209,6 +1215,8 @@ class FilesystemModel(object):
|
|||
break
|
||||
else:
|
||||
candidates.append(candidate)
|
||||
if 'size' in match or 'ssd' in match:
|
||||
candidates = [c for c in candidates if c not in self._exclusions]
|
||||
if match.get('size') == 'smallest':
|
||||
candidates.sort(key=lambda d: d.size)
|
||||
if match.get('size') == 'largest':
|
||||
|
|
Loading…
Reference in New Issue