Commit 38a19898 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Added create_filesystems plugin

parent fb220016
......@@ -127,6 +127,7 @@ class Ili:
steps = [
self._plugins.commit_diskusage_strategy,
self._plugins.commit_disklayout_strategy,
self._plugins.create_filesystems,
self._plugins.mount_filesystems,
self._plugins.pre_install_base,
self._plugins.install_base,
......
......@@ -48,6 +48,10 @@ class Plugin:
"""Commit the disk layout strategy."""
raise NotImplementedError
def create_filesystems(self, ili_state: IliState):
"""Create filesystems."""
raise NotImplementedError
def mount_filesystems(self, ili_state: IliState):
"""Mount filesystems."""
raise NotImplementedError
......@@ -114,9 +118,14 @@ class PluginCollection:
self._call_plugins(ili_state, 'commit_disklayout_strategy')
def create_filesystems(self, ili_state: IliState):
"""Call plugins to create our filesystems."""
self._call_plugins(ili_state, 'create_filesystems')
# Make sure we've got filesystems in our state now
if not ili_state.filesystems:
raise RuntimeError('At least one of the disk layout strategies should of setup the filesystems for install.')
raise RuntimeError('At least one of the create_filesystems plugins should of setup the filesystems for install.')
def mount_filesystems(self, ili_state: IliState):
"""Call plugins to mount our filesystems."""
......
# Copyright (c) 2019, AllWorldIT
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Create filesystems on the provided block devices."""
from typing import Callable, Dict, List, Optional
from idmslinux_installer.ilistate import IliState
from idmslinux_installer.plugin import Plugin
from idmslinux_installer.util.mkfs import Mkfs
# Ignore warning that we have not overridden all base class methods.
# pylama:ignore=W:select=W023
class CreateFilesystems(Plugin):
"""Create filesystems on the provided block devices."""
def __init__(self):
"""Plugin init method."""
self.description = "Create Filesystems"
Plugin.__init__(self)
def create_filesystems(self, ili_state: IliState):
"""Create the filesystems we need on the block devices."""
# Mount the root filesystem
ili_state.output_callback('Mounting root filesystem')
# Create an mkfs object
mkfs = Mkfs()
# Check which block devices we need to create filesystems for
if 'efi' in ili_state.blockdevices:
ili_state.output_callback('Configuring EFI filesystem')
uuid = mkfs.run('vfat', ili_state.blockdevices['efi'], fslabel="efi", args=['-F', '32'],
output_callback=ili_state.output_callback)
ili_state.add_filesystem('efi', uuid, 'vfat', ili_state.blockdevices['efi'])
if 'boot' in ili_state.blockdevices:
ili_state.output_callback('Configuring boot filesystem')
uuid = mkfs.run('ext3', ili_state.blockdevices['boot'], fslabel="boot",
output_callback=ili_state.output_callback)
ili_state.add_filesystem('boot', uuid, 'ext3', ili_state.blockdevices['boot'])
if 'root' in ili_state.blockdevices:
ili_state.output_callback('Configuring root filesystem')
uuid = mkfs.run('ext4', ili_state.blockdevices['root'], fslabel="root",
output_callback=ili_state.output_callback)
ili_state.add_filesystem('root', uuid, 'ext4', ili_state.blockdevices['root'])
......@@ -43,24 +43,6 @@ class DiskLayoutFLAT(Plugin):
# Check the strategy to use for these block devices
if ili_state.disklayout_strategy == 'FLAT':
# Create an mkfs object
mkfs = Mkfs()
ili_state.output_callback('Creating FLAT disk layout')
# Check which block devices we need to create filesystems for
if 'efi' in ili_state.blockdevices:
ili_state.output_callback('Configuring EFI filesystem')
uuid = mkfs.run('vfat', ili_state.blockdevices['efi'], fslabel="efi", args=['-F', '32'],
output_callback=ili_state.output_callback)
ili_state.add_filesystem('efi', uuid, 'vfat', ili_state.blockdevices['efi'])
if 'boot' in ili_state.blockdevices:
ili_state.output_callback('Configuring boot filesystem')
uuid = mkfs.run('ext3', ili_state.blockdevices['boot'], fslabel="boot",
output_callback=ili_state.output_callback)
ili_state.add_filesystem('boot', uuid, 'ext3', ili_state.blockdevices['boot'])
if 'root' in ili_state.blockdevices:
ili_state.output_callback('Configuring root filesystem')
uuid = mkfs.run('ext4', ili_state.blockdevices['root'], fslabel="root",
output_callback=ili_state.output_callback)
ili_state.add_filesystem('root', uuid, 'ext4', ili_state.blockdevices['root'])
# We don't actually have to do anything here as we already have the block devices
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment