#!/usr/bin/env python import ri_data class Pkg(): pkg_list = [] @staticmethod def set_pkg_list (): for i in ri_data.Group.dict.values(): if i.install != 'no': Pkg.pkg_list += i.mandatory if i.selection == 'all': Pkg.pkg_list += [ j[0] for j in i.optional ] else: Pkg.pkg_list += [ j[0] for j in i.optional if j[1] == 'yes' ] class FsType(): mp_fstype_list = [] @staticmethod def set_mp_fstype_list (): for fs in ri_data.MountPoint.list: FsType.mp_fstype_list.append(fs.filesystem) class FunctionDepending: list = [] def __init__(self, pkg): self.package = pkg FunctionDepending.list.append(self) def check(self): return False def error(self): return {} class FileSystem(FunctionDepending): mp_fstype_list = [] def __init__(self, fs_type, fs_pkg): self.filesystem_type = fs_type FunctionDepending.__init__(self, fs_pkg) def check(self): if self.filesystem_type in FsType.mp_fstype_list and self.package not in Pkg.pkg_list: return False return True def error(self): mesg="format filesystem " + self.filesystem_type return {mesg:self.package} class DHCP(FunctionDepending): def __init__(self): FunctionDepending.__init__(self, 'dhcpcd') def check(self): if ri_data.Network.configuration == 'dynamic' and 'dhcpcd' not in Pkg.pkg_list: return False return True def error(self): return {"dynamic configure network":"dhcpcd"} class RAID(FunctionDepending): def __init__(self): FunctionDepending.__init__(self, 'mdadm') def check(self): if 'mdadm' not in Pkg.pkg_list: for i in ri_data.Raid.list: if i.from_os == 'no': return False return True def error(self): return {"make raid":"mdadm"} def check_function_depending(): Pkg.set_pkg_list() FsType.set_mp_fstype_list() func_dep_dict = {} FileSystem("xfs", "xfsprogs") FileSystem("jfs", "jfsutils") DHCP() RAID() for i in FunctionDepending.list: # if function depending package not in package list if not i.check(): tmp = i.error() func_dep_dict.update(tmp) return func_dep_dict #check_function_depending()