|
|
|
@ -24,6 +24,10 @@ from cl_utils import isMount
|
|
|
|
|
from cl_distr import DistributiveRepository
|
|
|
|
|
|
|
|
|
|
class fillVars(object, glob_attr):
|
|
|
|
|
nonTransferedDirs = ["/","/bin", "/dev", "/etc",
|
|
|
|
|
"/lib", "/lib32", "/lib64",
|
|
|
|
|
"/opt", "/proc", "/sbin",
|
|
|
|
|
"/sys", "/usr", "/var"]
|
|
|
|
|
|
|
|
|
|
def get_os_net_interfaces_info(self):
|
|
|
|
|
"""Информация о существующих сетевых интерфейсах"""
|
|
|
|
@ -172,9 +176,9 @@ class fillVars(object, glob_attr):
|
|
|
|
|
map(lambda x: [x[0], x[1]],
|
|
|
|
|
listFstab)),[""]))[0]
|
|
|
|
|
|
|
|
|
|
def get_os_disk_install(self):
|
|
|
|
|
def get_os_install_disk_mount(self):
|
|
|
|
|
"""List mounted points for installed system"""
|
|
|
|
|
rootdev = self.Get('os_root_dev')
|
|
|
|
|
rootdev = self.Get('os_install_root_dev')
|
|
|
|
|
disk_hash = self.Get('os_disk_hash')
|
|
|
|
|
def getMountPoint(disk):
|
|
|
|
|
if disk == rootdev:
|
|
|
|
@ -184,14 +188,14 @@ class fillVars(object, glob_attr):
|
|
|
|
|
return "swap"
|
|
|
|
|
else:
|
|
|
|
|
mount_point = self.isFstabMount(disk)
|
|
|
|
|
if mount_point == "/":
|
|
|
|
|
if mount_point in self.nonTransferedDirs:
|
|
|
|
|
return ""
|
|
|
|
|
else:
|
|
|
|
|
return mount_point
|
|
|
|
|
return map(lambda x: getMountPoint(x),
|
|
|
|
|
sorted(self.Get('os_disk_hash').keys()))
|
|
|
|
|
|
|
|
|
|
def get_os_disk_load(self):
|
|
|
|
|
def get_os_disk_mount(self):
|
|
|
|
|
"""List mounted points for current operation system"""
|
|
|
|
|
disk_hash = self.Get('os_disk_hash')
|
|
|
|
|
def isSwap(disk):
|
|
|
|
@ -215,6 +219,10 @@ class fillVars(object, glob_attr):
|
|
|
|
|
"""Type of partition devices (primary, extended or logical)"""
|
|
|
|
|
return self.getAttributeFromHash('os_disk_hash','part')
|
|
|
|
|
|
|
|
|
|
def get_os_disk_perform_format(self):
|
|
|
|
|
"""Needformat partitions"""
|
|
|
|
|
return self.getAttributeFromHash('os_disk_hash','needformat')
|
|
|
|
|
|
|
|
|
|
def get_os_disk_size(self):
|
|
|
|
|
"""Partition size"""
|
|
|
|
|
return self.getAttributeFromHash('os_disk_hash','size')
|
|
|
|
@ -252,7 +260,7 @@ class fillVars(object, glob_attr):
|
|
|
|
|
devicesForFstab = sorted(
|
|
|
|
|
filter(lambda x: x[1] != "" and x[1] != "swap",
|
|
|
|
|
zip(self.Get('os_disk_dev'),
|
|
|
|
|
self.Get('os_disk_install'),
|
|
|
|
|
self.Get('os_install_disk_mount'),
|
|
|
|
|
self.Get('os_disk_format'))),
|
|
|
|
|
lambda x,y: cmp(x[1],y[1]))
|
|
|
|
|
# rootLine one string, but it correct work if devicesForFstab is empty
|
|
|
|
@ -325,7 +333,7 @@ class fillVars(object, glob_attr):
|
|
|
|
|
return "\n".join(map(lambda x: "%s\tnone\tswap\tsw\t0 0"%x[0],
|
|
|
|
|
filter(lambda x: x[1] == "swap",
|
|
|
|
|
zip(self.Get('os_disk_dev'),
|
|
|
|
|
self.Get('os_disk_install')))))
|
|
|
|
|
self.Get('os_install_disk_mount')))))
|
|
|
|
|
|
|
|
|
|
def get_os_install_linux_system(self):
|
|
|
|
|
"""Get linux system (server or desktop)"""
|
|
|
|
@ -346,7 +354,7 @@ class fillVars(object, glob_attr):
|
|
|
|
|
"""Get scheduler for root device"""
|
|
|
|
|
root_dev = filter(lambda x: x[1] == '/',
|
|
|
|
|
zip(self.Get('os_disk_dev'),
|
|
|
|
|
self.Get('os_disk_install')))
|
|
|
|
|
self.Get('os_install_disk_mount')))
|
|
|
|
|
if root_dev:
|
|
|
|
|
root_dev = root_dev[0][0]
|
|
|
|
|
root_dev = filter(lambda x: x in root_dev,
|
|
|
|
@ -369,7 +377,7 @@ class fillVars(object, glob_attr):
|
|
|
|
|
def get_os_kernel_resume(self):
|
|
|
|
|
"""Kernel resume parameter"""
|
|
|
|
|
for dev, install in zip(self.Get('os_disk_dev'),
|
|
|
|
|
self.Get('os_disk_install')):
|
|
|
|
|
self.Get('os_install_disk_mount')):
|
|
|
|
|
if install == "swap":
|
|
|
|
|
return "resume=%s"%dev
|
|
|
|
|
return ""
|
|
|
|
@ -382,7 +390,7 @@ class fillVars(object, glob_attr):
|
|
|
|
|
grubconf = reRemoveComments.sub("",open(pathGrubConf,'r').read())
|
|
|
|
|
roothd = filter(lambda x: x[1] == '/',
|
|
|
|
|
zip(self.Get('os_disk_grub'),
|
|
|
|
|
self.Get('os_disk_install')))
|
|
|
|
|
self.Get('os_install_disk_mount')))
|
|
|
|
|
if roothd:
|
|
|
|
|
roothd = "root (hd%s)" % roothd[0][0]
|
|
|
|
|
return ("".join(filter(lambda x: not roothd in x,
|
|
|
|
@ -447,3 +455,47 @@ class fillVars(object, glob_attr):
|
|
|
|
|
return "Linux"
|
|
|
|
|
else:
|
|
|
|
|
return "Linux"
|
|
|
|
|
|
|
|
|
|
def get_os_bind_hash(self):
|
|
|
|
|
"""List mounted points for current operation system"""
|
|
|
|
|
# convert fstab to
|
|
|
|
|
# [['/dev/sda3', '/', '', 'reiserfs', 'noatime', '', '', '0', '2\n'],
|
|
|
|
|
# ['/dev/sda5', '/var/calculate', 'reiserfs', 'noatime', '0', '0\n']]
|
|
|
|
|
listFstab = map(lambda x: filter(lambda x: x,
|
|
|
|
|
x.replace('\t',' ').split(' ')),
|
|
|
|
|
filter(lambda x: not x.startswith('#') and x.strip(),
|
|
|
|
|
open("/etc/fstab")))
|
|
|
|
|
return dict(map(lambda x:[x[0],x[1]],
|
|
|
|
|
filter(lambda x: "bind" in x[3],
|
|
|
|
|
listFstab)))
|
|
|
|
|
|
|
|
|
|
def get_os_bind_dir(self):
|
|
|
|
|
"""Directories for bind"""
|
|
|
|
|
return sorted(self.Get('os_bind_hash').keys())
|
|
|
|
|
|
|
|
|
|
def get_os_bind_mountpoint(self):
|
|
|
|
|
"""Mountpoint for directories bind"""
|
|
|
|
|
bindhash = self.Get('os_bind_hash')
|
|
|
|
|
return [ bindhash[i] for i in sorted(bindhash.keys()) ]
|
|
|
|
|
|
|
|
|
|
def get_os_install_bind_dir(self):
|
|
|
|
|
"""Install directories for bind"""
|
|
|
|
|
return map(lambda x:x[0],
|
|
|
|
|
# skip nonTransferedDirs
|
|
|
|
|
filter(lambda x: not x[0] in self.nonTransferedDirs and
|
|
|
|
|
not x[1] in self.nonTransferedDirs,
|
|
|
|
|
zip(self.Get('os_bind_dir'),
|
|
|
|
|
self.Get('os_bind_mountpoint'))))
|
|
|
|
|
|
|
|
|
|
def get_os_install_bind_mountpoint(self):
|
|
|
|
|
"""Mountpoint for install directories bind"""
|
|
|
|
|
return map(lambda x:x[1],
|
|
|
|
|
# skip nonTransferedDirs
|
|
|
|
|
filter(lambda x: not x[0] in self.nonTransferedDirs and
|
|
|
|
|
not x[1] in self.nonTransferedDirs,
|
|
|
|
|
zip(self.Get('os_bind_dir'),
|
|
|
|
|
self.Get('os_bind_mountpoint'))))
|
|
|
|
|
|
|
|
|
|
def get_os_install_root_dev(self):
|
|
|
|
|
return self.Get('os_root_dev')
|
|
|
|
|
|
|
|
|
|