Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions probert/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import pyudev

from probert.utils import sane_block_devices
from probert.utils import interesting_storage_devs

log = logging.getLogger('probert.filesystems')

Expand Down Expand Up @@ -194,21 +194,18 @@ def probe(context=None, enabled_probes=None, **kw):

need_fs_sizing = 'filesystem_sizing' in enabled_probes

for device in sane_block_devices(context):
# Ignore block major=1 (ramdisk) and major=7 (loopback)
# these won't ever be used in recreating storage on target systems.
if device['MAJOR'] not in ["1", "7"]:
fs_info = get_device_filesystem(device, need_fs_sizing)
# The ID_FS_ udev values come from libblkid, which contains code to
# recognize lots of different things that block devices or their
# partitions can contain (filesystems, lvm PVs, bcache, ...). We
# only want to report things that are mountable filesystems here,
# which libblkid conveniently tags with ID_FS_USAGE=filesystem.
# Swap is a bit of a special case because it is not a mountable
# filesystem in the usual sense, but subiquity still needs to
# generate mount actions for it. Crypto is a disguised filesystem.
if fs_info.get("USAGE") in ("filesystem", "crypto") or \
fs_info.get("TYPE") == "swap":
filesystems[device['DEVNAME']] = fs_info
for device in interesting_storage_devs(context):
fs_info = get_device_filesystem(device, need_fs_sizing)
# The ID_FS_ udev values come from libblkid, which contains code to
# recognize lots of different things that block devices or their
# partitions can contain (filesystems, lvm PVs, bcache, ...). We
# only want to report things that are mountable filesystems here,
# which libblkid conveniently tags with ID_FS_USAGE=filesystem.
# Swap is a bit of a special case because it is not a mountable
# filesystem in the usual sense, but subiquity still needs to
# generate mount actions for it. Crypto is a disguised filesystem.
if fs_info.get("USAGE") in ("filesystem", "crypto") or \
fs_info.get("TYPE") == "swap":
filesystems[device['DEVNAME']] = fs_info

return filesystems
18 changes: 1 addition & 17 deletions probert/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from probert.utils import (
read_sys_block_size_bytes,
sane_block_devices,
interesting_storage_devs,
udev_get_attributes,
)
from probert import (bcache, dasd, dmcrypt, filesystem, lvm, mount, multipath,
Expand Down Expand Up @@ -90,22 +90,6 @@ def is_virtual(self):
return self.devpath.startswith('/devices/virtual/')


def interesting_storage_devs(context):
skip_majors = (
'1', # ignore ram disks
'7', # ignore loopback devices
)

for device in sane_block_devices(context):
if device['MAJOR'] in skip_majors:
continue
major, minor = device.get('ID_PART_ENTRY_DISK', '0:0').split(':')
if major in skip_majors:
# also skip partitions that are on a device we don't want
continue
yield device


def blockdev_probe(context=None, **kw):
""" Non-class method for extracting relevant block
devices from pyudev.Context().
Expand Down
16 changes: 16 additions & 0 deletions probert/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,19 @@ def sane_block_devices(context):
# Shouldn't happen but apparently does! (LP: #1868109)
continue
yield device


def interesting_storage_devs(context):
skip_majors = (
'1', # ignore ram disks
'7', # ignore loopback devices
)

for device in sane_block_devices(context):
if device['MAJOR'] in skip_majors:
continue
major, minor = device.get('ID_PART_ENTRY_DISK', '0:0').split(':')
if major in skip_majors:
# also skip partitions that are on a device we don't want
continue
yield device