90 lines
2.0 KiB
Python
90 lines
2.0 KiB
Python
#!/usr/bin/env python
|
|
|
|
import ri_data
|
|
|
|
class Pkg():
|
|
list = []
|
|
|
|
@staticmethod
|
|
def set_list ():
|
|
list = ri_data.Group.get_install_pkgs()
|
|
|
|
class FsType():
|
|
list = []
|
|
|
|
@staticmethod
|
|
def set_list ():
|
|
for fs in ri_data.MountPoint.dict.values():
|
|
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):
|
|
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.list and self.package not in 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.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.list and ri_data.Raid.dict:
|
|
return False
|
|
return True
|
|
|
|
def error(self):
|
|
return {"make raid":"mdadm"}
|
|
|
|
def check_function_depending():
|
|
Pkg.set_list()
|
|
FsType.set_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
|
|
|
|
|