kiwi.volume_manager
1# Copyright (c) 2015 SUSE Linux GmbH. All rights reserved. 2# 3# This file is part of kiwi. 4# 5# kiwi is free software: you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation, either version 3 of the License, or 8# (at your option) any later version. 9# 10# kiwi is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with kiwi. If not, see <http://www.gnu.org/licenses/> 17# 18import importlib 19from typing import ( 20 Dict, List 21) 22from abc import ( 23 ABCMeta, 24 abstractmethod 25) 26 27# project 28from kiwi.exceptions import KiwiVolumeManagerSetupError 29 30 31class VolumeManager(metaclass=ABCMeta): 32 """ 33 **VolumeManager factory** 34 35 :param str name: volume management name 36 :param dict device_map: 37 dictionary of low level DeviceProvider intances 38 :param str root_dir: root directory path name 39 :param list volumes: list of volumes from :class:`XMLState::get_volumes()` 40 :param dict custom_args: dictionary of custom volume manager arguments 41 """ 42 @abstractmethod 43 def __init__(self) -> None: 44 return None # pragma: no cover 45 46 @staticmethod 47 def new( 48 name: str, device_map: object, root_dir: str, 49 volumes: List, custom_args: Dict = None 50 ): 51 name_map = { 52 'lvm': 'LVM', 53 'btrfs': 'Btrfs' 54 } 55 try: 56 volume_manager = importlib.import_module( 57 'kiwi.volume_manager.{0}'.format(name) 58 ) 59 module_name = 'VolumeManager{0}'.format(name_map[name]) 60 return volume_manager.__dict__[module_name]( 61 device_map, root_dir, volumes, custom_args 62 ) 63 except Exception as issue: 64 raise KiwiVolumeManagerSetupError( 65 'Support for {0} volume manager not implemented: {1}'.format( 66 name, issue 67 ) 68 )
class
VolumeManager:
32class VolumeManager(metaclass=ABCMeta): 33 """ 34 **VolumeManager factory** 35 36 :param str name: volume management name 37 :param dict device_map: 38 dictionary of low level DeviceProvider intances 39 :param str root_dir: root directory path name 40 :param list volumes: list of volumes from :class:`XMLState::get_volumes()` 41 :param dict custom_args: dictionary of custom volume manager arguments 42 """ 43 @abstractmethod 44 def __init__(self) -> None: 45 return None # pragma: no cover 46 47 @staticmethod 48 def new( 49 name: str, device_map: object, root_dir: str, 50 volumes: List, custom_args: Dict = None 51 ): 52 name_map = { 53 'lvm': 'LVM', 54 'btrfs': 'Btrfs' 55 } 56 try: 57 volume_manager = importlib.import_module( 58 'kiwi.volume_manager.{0}'.format(name) 59 ) 60 module_name = 'VolumeManager{0}'.format(name_map[name]) 61 return volume_manager.__dict__[module_name]( 62 device_map, root_dir, volumes, custom_args 63 ) 64 except Exception as issue: 65 raise KiwiVolumeManagerSetupError( 66 'Support for {0} volume manager not implemented: {1}'.format( 67 name, issue 68 ) 69 )
VolumeManager factory
Parameters
- str name: volume management name
- dict device_map: dictionary of low level DeviceProvider intances
- str root_dir: root directory path name
- **list volumes: list of volumes from
XMLState:**: get_volumes() - dict custom_args: dictionary of custom volume manager arguments
@staticmethod
def
new( name: str, device_map: object, root_dir: str, volumes: List, custom_args: Dict = None):
47 @staticmethod 48 def new( 49 name: str, device_map: object, root_dir: str, 50 volumes: List, custom_args: Dict = None 51 ): 52 name_map = { 53 'lvm': 'LVM', 54 'btrfs': 'Btrfs' 55 } 56 try: 57 volume_manager = importlib.import_module( 58 'kiwi.volume_manager.{0}'.format(name) 59 ) 60 module_name = 'VolumeManager{0}'.format(name_map[name]) 61 return volume_manager.__dict__[module_name]( 62 device_map, root_dir, volumes, custom_args 63 ) 64 except Exception as issue: 65 raise KiwiVolumeManagerSetupError( 66 'Support for {0} volume manager not implemented: {1}'.format( 67 name, issue 68 ) 69 )