kiwi.snapshot_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 Dict 20from abc import ( 21 ABCMeta, 22 abstractmethod 23) 24 25# project 26from kiwi.exceptions import KiwiSnapshotManagerSetupError 27 28 29class SnapshotManager(metaclass=ABCMeta): 30 """ 31 **SnapshotManager factory** 32 33 :param str name: snapshot management name 34 :param str device: storage device node name 35 :param str root_dir: root directory path 36 :param str mountpoint: mountpoint of the filesystem to snapshot 37 :param str root_volume_name: the name of the root volume in case 38 snapshots are hosted in a subvolume. 39 :param dict custom_args: dictionary of custom snapshot manager arguments 40 """ 41 @abstractmethod 42 def __init__(self) -> None: 43 return None # pragma: no cover 44 45 @staticmethod 46 def new( 47 name: str, device: str, root_dir: str, mountpoint: str, 48 root_volume_name: str, custom_args: Dict = None 49 ): 50 name_map = { 51 'snapper': 'Snapper', 52 } 53 try: 54 snapshot_manager = importlib.import_module( 55 'kiwi.snapshot_manager.{0}'.format(name) 56 ) 57 module_name = 'SnapshotManager{0}'.format(name_map[name]) 58 return snapshot_manager.__dict__[module_name]( 59 device, root_dir, mountpoint, root_volume_name, custom_args 60 ) 61 except Exception as issue: 62 raise KiwiSnapshotManagerSetupError( 63 'Support for {0} snapshot manager not implemented: {1}'.format( 64 name, issue 65 ) 66 )
class
SnapshotManager:
30class SnapshotManager(metaclass=ABCMeta): 31 """ 32 **SnapshotManager factory** 33 34 :param str name: snapshot management name 35 :param str device: storage device node name 36 :param str root_dir: root directory path 37 :param str mountpoint: mountpoint of the filesystem to snapshot 38 :param str root_volume_name: the name of the root volume in case 39 snapshots are hosted in a subvolume. 40 :param dict custom_args: dictionary of custom snapshot 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: str, root_dir: str, mountpoint: str, 49 root_volume_name: str, custom_args: Dict = None 50 ): 51 name_map = { 52 'snapper': 'Snapper', 53 } 54 try: 55 snapshot_manager = importlib.import_module( 56 'kiwi.snapshot_manager.{0}'.format(name) 57 ) 58 module_name = 'SnapshotManager{0}'.format(name_map[name]) 59 return snapshot_manager.__dict__[module_name]( 60 device, root_dir, mountpoint, root_volume_name, custom_args 61 ) 62 except Exception as issue: 63 raise KiwiSnapshotManagerSetupError( 64 'Support for {0} snapshot manager not implemented: {1}'.format( 65 name, issue 66 ) 67 )
SnapshotManager factory
Parameters
- str name: snapshot management name
- str device: storage device node name
- str root_dir: root directory path
- str mountpoint: mountpoint of the filesystem to snapshot
- str root_volume_name: the name of the root volume in case snapshots are hosted in a subvolume.
- dict custom_args: dictionary of custom snapshot manager arguments
@staticmethod
def
new( name: str, device: str, root_dir: str, mountpoint: str, root_volume_name: str, custom_args: Dict = None):
46 @staticmethod 47 def new( 48 name: str, device: str, root_dir: str, mountpoint: str, 49 root_volume_name: str, custom_args: Dict = None 50 ): 51 name_map = { 52 'snapper': 'Snapper', 53 } 54 try: 55 snapshot_manager = importlib.import_module( 56 'kiwi.snapshot_manager.{0}'.format(name) 57 ) 58 module_name = 'SnapshotManager{0}'.format(name_map[name]) 59 return snapshot_manager.__dict__[module_name]( 60 device, root_dir, mountpoint, root_volume_name, custom_args 61 ) 62 except Exception as issue: 63 raise KiwiSnapshotManagerSetupError( 64 'Support for {0} snapshot manager not implemented: {1}'.format( 65 name, issue 66 ) 67 )