From e24e83c707f93c677f4aa8e1eb1e8dc71b024729 Mon Sep 17 00:00:00 2001 From: asamoukin Date: Wed, 25 Feb 2009 06:45:26 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=BE=D0=B2=20?= =?UTF-8?q?=D1=81=20=D0=B2=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=80=D0=B5=D0=BF=D0=BB=D0=B8=D0=BA=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.calculate.ru/calculate2/calculate-client/trunk@925 c91db197-33c1-4113-bf15-f8a5c547ca64 --- pym/cl_client.py | 234 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 168 insertions(+), 66 deletions(-) diff --git a/pym/cl_client.py b/pym/cl_client.py index 9b8286c..b062b35 100644 --- a/pym/cl_client.py +++ b/pym/cl_client.py @@ -238,6 +238,10 @@ conjunction with the 'login' or 'logout'") # При включениии репликации # Временные задержки для монтирования в секундах self.sleeps = [0.5, 2, 5] + # DN хранения последнего посещенного пользователя + self.replHostsDN = self.addDN("ou=Worked","ou=Replication", + "ou=LDAP", self.ServicesDN) + self.replLogoutFile = ".logout" def isRoot(self): """Определяет является ли пользователь root""" @@ -279,6 +283,11 @@ conjunction with the 'login' or 'logout'") return resSearch + def searchPrevHost(self, userName): + """Находит сервер к которому был подключен пользователь""" + resSearch = self.searchLdapDN(userName, self.replHostsDN, "uid") + return resSearch + def searchUnixUser(self, userName): """Находит пользователя сервиса Unix""" resSearch = self.searchLdapDN(userName, self.relUsersDN, "uid") @@ -531,7 +540,8 @@ conjunction with the 'login' or 'logout'") if homeExists: self.printWARNING(_("Home dir %s exists")%homeDir) - if set(os.listdir(homeDir))-set(["Home","Disks","FTP"]): + if set(os.listdir(homeDir))-set(["Home","Disks","FTP",\ + self.replLogoutFile]): if not applyAlways: # Получаем пути к профилям постоянного наложения alwProfilePath = self.getAlwaysProfilePath() @@ -827,11 +837,11 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) pathRemote.append((os.path.join(home,"." + userName), "unix")) # Удаленный ресурс home pathRemote.append((os.path.join(homeDir,"Home"), "homes")) - # Удаленный ресурс share - pathRemote.append((os.path.join(homeDir,"Disks"), "share")) # Удаленный ресурс ftp if self.clVars.Get("cl_remote_ftp"): pathRemote.append((os.path.join(homeDir,"FTP"), "ftp")) + # Удаленный ресурс share + pathRemote.append((os.path.join(homeDir,"Disks"), "share")) self.moveHomeDir(homeDir) # Синхронизируем настройки if not self.syncUser(userName, homeDir, "logout"): @@ -841,6 +851,15 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) flagError = False for path, res in pathRemote: if self.isMount(path ,"cifs"): + # В случае репликации + if res == "share": + # Проверка на репликацию + pathReplRun = os.path.join(path, self.replRunFileShare) + if os.path.exists(pathReplRun): + FD = open(pathReplRun) + # Записывает доменное имя сервера если + # с сервером корректно соединились + FD.close() textLine = self.execProg("umount %s"%path) if not (textLine == None): self.printERROR(_("Can not umount Samba resource \ @@ -855,7 +874,7 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) flagError = True break if flagError: - self.printERROR(_("Keep a user profile in the domain")) + self.printERROR(_("Can not keep a user profile in the domain")) return False self.printSUCCESS(_("Keep a user profile in the domain")) self.printOK(_("Umount user resource in domain") + " ...") @@ -891,11 +910,11 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) pathRemote.append((os.path.join(home,"." + userName), "unix")) # Удаленный ресурс home pathRemote.append((os.path.join(homeDir,"Home"), "homes")) - # Удаленный ресурс share - pathRemote.append((os.path.join(homeDir,"Disks"), "share")) # Удаленный ресурс ftp if self.clVars.Get("cl_remote_ftp"): pathRemote.append((os.path.join(homeDir,"FTP"), "ftp")) + # Удаленный ресурс share + pathRemote.append((os.path.join(homeDir,"Disks"), "share")) flagError = False self.moveHomeDir(homeDir) for path, res in pathRemote: @@ -948,6 +967,25 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) break return foundTwoSession + def mountSambaRes(self,userName,userPwd,uid,gid,res,path, + mountUidList=['ftp','share']): + """Монтирует Samba ресурсы""" + if res in mountUidList: + # Монтируем директории c uid + mountStr="mount -t cifs -o user=%s,password=%s,uid=%s,gid=%s"\ + %(userName,userPwd,uid,gid) + " " +\ + "//%s/%s %s" %(self.clVars.Get("cl_remote_host"), + res, path) + else: + # Монтируем директории + mountStr="mount -t cifs -o user=%s,password=%s"%(userName, + userPwd) + " " +\ + "//%s/%s %s" %(self.clVars.Get("cl_remote_host"), + res, path) + + textLine = self.execProg(mountStr) + return textLine + def mountUserRes(self, userName, sync=True): """Монтирование пользовательских ресурсов и синхронизация настроек""" # Проверяем на root @@ -1002,9 +1040,12 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) # Удаленный ресурс ftp pathRemote.append((os.path.join(homeDir,"FTP"), "ftp")) flagError = False - flagSleep = False - # Флаг репликации - flagRepl = False + # Запускаемый файл на сервере в случае репликации + pathReplRun = "" + # Путь к профилю пользователя по умолчанию + defaultPath = "" + # Ност пользователя по умолчанию + defaultHost = self.clVars.Get("cl_remote_host") for path, res in pathRemote: # Создаем директории для монтирования if not os.path.exists(path): @@ -1020,77 +1061,122 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw) # Проверяем на монтирование директории if self.isMount(path, 'cifs'): continue - - if res in ['ftp','share']: - # Монтируем директории c uid - mountStr="mount -t cifs -o user=%s,password=%s,uid=%s,gid=%s"\ - %(userName,userPwd,uid,gid) + " " +\ - "//%s/%s %s" %(self.clVars.Get("cl_remote_host"), - res, path) - else: - # Монтируем директории - mountStr="mount -t cifs -o user=%s,password=%s"%(userName, - userPwd) + " " +\ - "//%s/%s %s" %(self.clVars.Get("cl_remote_host"), - res, path) - - textLine = self.execProg(mountStr) + # В случае репликации не монтируем профиль пользователя + if pathReplRun and res=="unix": + defaultPath = path + continue + # Монтируем Samba ресурс + textLine = self.mountSambaRes(userName,userPwd,uid,gid,res,path) if not (textLine == None): - # В случае репликации - if flagSleep: - i == 0 - while (i