Изменен алгоритм подключения и синхронизации ресурсов Samba при включенной репликации

git-svn-id: http://svn.calculate.ru/calculate2/calculate-client/trunk@963 c91db197-33c1-4113-bf15-f8a5c547ca64
develop
asamoukin 15 years ago
parent b9e450805d
commit 46490c9658

@ -1087,74 +1087,81 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
if sync:
# Ошибка при монтировании unix ресурса удаленного сервера при
# включенной репликации
replError = False
replErrorMount = False
# Ошибка при cинхронизации unix ресурса удаленного сервера при
# включенной репликации
replErrorSync = False
# В случае репликации
prevHost = ""
# Монтирование по умолчанию (default - cвой сервер, remote - чужой)
mountServer = ""
if pathReplRun:
searchPrevHost = self.searchPrevHost(userName)
if searchPrevHost and searchPrevHost[0][0][1].has_key('host'):
prevHost = searchPrevHost[0][0][1]['host'][0]
mountHost = ""
# Монтируем ресурс unix текущего сервера
mountServer = "default"
textLine = self.mountSleepRes(userName,userPwd,uid,gid,
"unix",defaultPath)
if not (textLine == None):
self.printERROR(_("Can not mount Samba resource [%s]")\
%"unix" + " ...")
return False
# Если на текущем сервере в ресурсе unix есть файлы
# то синхронируем настройки
if os.listdir(defaultPath):
if not self.syncUser(userName, homeDir, "login"):
return False
# Отмонтируем ресурс
textLine = self.execProg("umount %s"%defaultPath)
if not (textLine == None):
self.printERROR(_("Can not umount Samba resource \
[%s]")%"unix" + " ...")
return False
if prevHost and prevHost != self.clVars.Get("cl_remote_host"):
# Монтируем настройки пользователя если сервер найден
# Монтируем настройки пользователя удаленного сервера
# если сервер найден
self.clVars.Set("cl_remote_host", prevHost, True)
mountHost = prevHost
textLine = self.mountSambaRes(userName,userPwd,uid,gid,
mountServer = "remote"
textLine = self.mountSleepRes(userName,userPwd,uid,gid,
"unix",defaultPath)
self.clVars.Set("cl_remote_host", defaultHost, True)
if not (textLine == None):
# Проверяем на монтирование директории
if self.isMount(path, 'cifs'):
textLineUmount=\
self.execProg("umount %s"%defaultPath)
if self.isMount(defaultPath, 'cifs'):
textLineUmount=self.execProg("umount %s"%path)
if not (textLineUmount == None):
self.printERROR(_("Can not umount Samba \
resource [%s]")%"unix" + " ...")
resource [%s]")%res + " ...")
return False
i == 0
while (i<len(self.sleeps) and not (textLine == None)):
# Задержка перед следующей попыткой
time.sleep(self.sleeps[i])
# Монтируем Samba ресурс
textLine = self.mountSambaRes(userName,userPwd,uid,
gid,"unix",defaultPath)
if not (textLine == None):
# Проверяем на монтирование директории
if self.isMount(path, 'cifs'):
textLineUmount=\
self.execProg("umount %s"%defaultPath)
if not (textLineUmount == None):
self.printERROR(_("Can not umount \
Samba resource [%s]")%"unix" + " ...")
return False
i += 1
if not (textLine == None):
replError = True
self.clVars.Set("cl_remote_host", defaultHost, True)
if (not prevHost) or\
(prevHost and\
prevHost == self.clVars.Get("cl_remote_host")) or\
replError:
# Монтируем настройки пользователя если сервер не найден
mountHost = self.clVars.Get("cl_remote_host")
textLine = self.mountSambaRes(userName,userPwd,uid,gid,
# Монтируем текущий сервер если ошибка подключения к
# к найденному серверу
mountServer = "default"
textLine = self.mountSleepRes(userName,userPwd,uid,gid,
"unix",defaultPath)
if not (textLine == None):
self.printERROR(_("Can not mount Samba resource \
[%s]")%"unix" + " ...")
return False
replErrorMount = True
else:
mountServer = "default"
# Монтируем текущий сервер если сервер не найден в LDAP
textLine = self.mountSleepRes(userName,userPwd,uid,gid,
"unix",defaultPath)
if not (textLine == None):
self.printERROR(_("Can not mount Samba resource \
[%s]")%"unix" + " ...")
return False
# Синхронизируем настройки пользователя
replErrorSync = False
if not self.syncUser(userName, homeDir, "login"):
if pathReplRun and\
mountHost != self.clVars.Get("cl_remote_host"):
replError = True
replErrorSync = True
else:
return False
if pathReplRun and not replError and\
mountHost != self.clVars.Get("cl_remote_host"):
# В случае репликации перемонтируем ресурс профилей
# на текущий сервер (в случае необходимости)
if not (pathReplRun and mountServer == "default"):
if not self.syncUser(userName, homeDir, "login"):
if pathReplRun and mountServer == "remote":
replErrorSync = True
else:
return False
if pathReplRun and mountServer == "remote":
# В случае репликации перемонтируем ресурс профилей
# на текущий сервер (в случае необходимости)
textLine = self.execProg("umount %s"%defaultPath)
if not (textLine == None):
self.printERROR(_("Can not umount Samba resource \
@ -1166,14 +1173,9 @@ resource [%s]")%"unix" + " ...")
self.printERROR(_("Can not mount Samba resource [%s]")\
%"unix" + " ...")
return False
# Если ошибка синхронизации с удаленного сервера то
# делаем синхронизацию с сервера по умолчанию
if replErrorSync and os.listdir(defaultPath):
if not self.syncUser(userName, homeDir, "login"):
return False
if pathReplRun:
logOutFile = os.path.join(homeDir,self.replLogoutFile)
if replError:
if replErrorMount or replErrorSync:
self.createUserFile(logOutFile,"ERROR", uid, gid)
else:
self.createUserFile(logOutFile,"SUCCESS", uid, gid)
@ -1181,6 +1183,36 @@ resource [%s]")%"unix" + " ...")
self.printOK(_("Get a user profile in the domain") + " ...")
return True
def mountSleepRes(self,userName,userPwd,uid,gid,res,path):
"""Монтирует ресурс при неудаче задержка потом повторное монитрование"""
textLine = self.mountSambaRes(userName,userPwd,uid,gid,res,path)
if not (textLine == None):
# Проверяем на монтирование директории
if self.isMount(path, 'cifs'):
textLineUmount=\
self.execProg("umount %s"%path)
if not (textLineUmount == None):
self.printERROR(_("Can not umount Samba \
resource [%s]")%res + " ...")
return False
i == 0
while (i<len(self.sleeps) and not (textLine == None)):
# Задержка перед следующей попыткой
time.sleep(self.sleeps[i])
# Монтируем Samba ресурс
textLine = self.mountSambaRes(userName,userPwd,uid,
gid,res,path)
if not (textLine == None):
# Проверяем на монтирование директории
if self.isMount(path, 'cifs'):
textLineUmount=self.execProg("umount %s"%path)
if not (textLineUmount == None):
self.printERROR(_("Can not umount Samba \
resource [%s]")%res + " ...")
return False
i += 1
return textLine
def copyFilesToMovie(self, userHome):
"""Переносим файлы пользователя в Home/Moved"""
# Находим директории и файлы в домащней директории

Loading…
Cancel
Save