develop
asamoukin 15 years ago
parent 7243a6abaf
commit 84411977a3

@ -885,8 +885,68 @@ conjunction with the 'login' or 'logout'")
break
return foundMount
def relevanceProfiles(self, hostAuth):
"""Определяем актуальность наложенных профилей
в зависимости от версии программы
Перед запуском обязательно должен быть определен объект переменных
self.clVars
Если актуальны - True, если нет False
"""
# 'local' или имя хоста
if hostAuth != self.clVars.Get("os_remote_auth"):
return False
hostName =
clProf = cl_profile.profile(self.clVars)
# Текущая версия программы
currentVersion = self.clVars.Get("cl_ver")
# Версия программы которая ранее работала с профилями
previousVersion = self.clVars.Get("os_remote_client")
cVersion, pVersion = clProf._convertVers(currentVersion,previousVersion)
# Если версии программ не равны то профили не актуальные
if cVersion != pVersion:
return False
return True
def applyRelevanceProfiles(self, hostAuth):
"""Накладывает релевантные профили
Перед запуском обязательно должен быть определен объект переменных
self.clVars
"""
if not self.relevanceProfiles(hostAuth):
# Обнуляем переменную удаленный хост
if hostAuth == "local":
self.clVars.Set("cl_remote_host","",True)
# Изменяем базовую директорию наложения профилей
self.clVars.Set("cl_root_path","/",True)
# Наложим профили install/domain
# Новые пути к профилям
profPaths=[\
'/usr/lib/calculate/calculate-client/profile/install/domain',
'/var/calculate/remote/client-profile/install/domain',
'/var/calculate/client-profile/install/domain']
# Изменяем переменную хранения профилей
self.clVars.Set("cl_profile_path",profPaths,True)
# Наложим профили
dirsAndFiles = self.applyProfilesFromSystem()
if not dirsAndFiles:
self.printERROR(_("Not apply 'install/domain' profiles"))
return False
if hostAuth == "local":
self.printOK(_("Set profiles in local mode"))
else:
self.printOK(_("Set profiles in network mode"))
currentVersion = self.clVars.Get("cl_ver")
self.clVars.Write("os_remote_client", currentVersion)
self.clVars.Write("os_remote_auth", hostAuth)
return True
def mountRemote(self):
"""Монтирование remote и домашней директории если компьютер в домене"""
"""Монтирование remote и домашней директории если компьютер в домене
а так-же ввод в домен если найдено имя хоста и пароль для подключения
"""
# Проверяем на root
if not self.isRoot():
return False
@ -897,8 +957,11 @@ conjunction with the 'login' or 'logout'")
foundMountHome = self.isMount("/var/calculate/client-home","none",
False)
else:
self.printERROR("The computer is not in domain")
return False
self.printWARNING(_("This computer is not in domain"))
# Если профили не актуальны накладываем новую версию профилей
if not self.applyRelevanceProfiles("local"):
return False
return True
pathHome = "/var/calculate/client-home"
if foundMountRemote:
self.printWARNING(_("Samba resource [remote] is mount") + \
@ -909,6 +972,7 @@ conjunction with the 'login' or 'logout'")
if foundMountHome and foundMountRemote:
return True
flagLocalProfile = False
if not foundMountRemote:
pathRemote = "/var/calculate/remote"
pwdRemote = self.clVars.Get("cl_remote_pw")
@ -923,12 +987,22 @@ conjunction with the 'login' or 'logout'")
//%s/remote %s" %(escPwdRemote,domain,pathRemote)
textLine = self.execProg(mountStr)
if not (textLine == None):
self.printERROR(_("Can not mount Samba resource [remote]") +\
self.printWarning(_("Can not mount Samba resource [remote]") +\
" ...")
return False
flagLocalProfile = True
# Если профили не актуальны накладываем новую версию профилей
if not self.applyRelevanceProfiles("local"):
return False
if foundMountHome:
umountStr = "umount /home"
textLine = self.execProg(umountStr)
if not (textLine == None):
self.printERROR(_("Can not unmount") + " /home")
return False
return True
self.printSUCCESS(_("Mount Samba resource [remote]") +\
" ...")
if not foundMountHome:
if (not foundMountHome) and (not flagLocalProfile):
if not os.path.exists(pathHome):
os.makedirs(pathHome)
mountStr = "mount -o bind %s /home" %pathHome
@ -938,7 +1012,11 @@ conjunction with the 'login' or 'logout'")
" ...")
return False
self.printSUCCESS(_("Mount") + " " + str(pathHome) + " " +\
" ...")
" ...")
# Накладываем сетевые профили
if domain:
if not self.applyRelevanceProfiles(domain):
return False
return True
def delDomain(self):
@ -1006,10 +1084,6 @@ conjunction with the 'login' or 'logout'")
manager") + " ..."
# Устанавливаем переменную профиля
clVars.Set("cl_pass_step","uninstall",True)
remoteHost = clVars.Get("cl_remote_host")
if remoteHost:
if not self.delDomain():
return False
# Изменяем базовую директорию наложения профилей
clVars.Set("cl_root_path","/",True)
# Новые пути к профилям
@ -1023,6 +1097,10 @@ manager") + " ..."
if not dirsAndFiles:
self.printERROR(_("Not apply 'install/client' profiles"))
return False
remoteHost = clVars.Get("cl_remote_host")
if remoteHost:
if not self.delDomain():
return False
self.printOK(messageOk)
return True

@ -137,3 +137,9 @@ class Data:
# версия программы
cl_ver = {'value':'2.0.17'}
# Режим работы клиента клиент
# (local или имя хоста клиента)
os_remote_auth = {'mode':'w'}
# Версия программы которой был наложен профиль
os_remote_client = {'mode':'w'}

Loading…
Cancel
Save