From bae2c9d9dff612d8eefc92fa32b76ad4b16ce087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D0=BC=D0=BE=D1=83=D0=BA=D0=B8=D0=BD=20=D0=90?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Mon, 1 Feb 2010 10:07:42 +0300 Subject: [PATCH] Added delay in mounting samba remote resource Modified algorithm create user profile --- README | 2 +- pym/cl_client.py | 74 ++++-------------------------------------------- 2 files changed, 7 insertions(+), 69 deletions(-) diff --git a/README b/README index 8284e4e..6242389 100644 --- a/README +++ b/README @@ -7,7 +7,7 @@ calculate-client needs the following library version installed, in order to run: Python >= 2.5 python-ldap >= 2.0.0 pyxml >= 0.8 - calculate-lib >= 2.1.4 + calculate-lib >= 2.2.0 To install calculate-client , just execute the install script 'setup.py'. Example: diff --git a/pym/cl_client.py b/pym/cl_client.py index 3093af3..e01be14 100644 --- a/pym/cl_client.py +++ b/pym/cl_client.py @@ -480,7 +480,6 @@ conjunction with the 'login' or 'logout'") def errorExit(self): """Отмонтирование пользовательских ресурсов при ошибке""" - # TODO: добавить удаление приватных файлов if self.errorAndUnmountUserRes and self.userName: self.umountUserResNoSync(self.userName, False, False, False, True) @@ -646,18 +645,6 @@ conjunction with the 'login' or 'logout'") else: return () - def createUserDir(self, uid, gid, userDir, mode=0700): - """Создание пользовательской директории""" - if not os.path.exists(userDir): - os.makedirs(userDir) - if mode: - os.chmod(userDir,mode) - os.chown(userDir,uid,gid) - return True - else: - self.printERROR(_("Path %s exists") %userDir) - return False - def applyTemplatesFromUser(self,progress=False): """Применяем шаблоны для пользователя""" # Cоздаем объект шаблон @@ -697,43 +684,6 @@ conjunction with the 'login' or 'logout'") userPwd = getpass.getpass(pwDialog+":") return userPwd - def chownR(self, directory, uid, gid, dirsAndFiles=False): - """изменяет владельца и группу - - для всех файлов и директорий внутри directory - """ - if dirsAndFiles: - dirs, files = dirsAndFiles - # меняем владельца домашней директории - os.chown(directory, uid,gid) - # Меняем владельца директорий - for dirCh in dirs: - if os.path.exists(dirCh): - os.chown(dirCh, uid,gid) - # Меняем владельца файлов - for fileCh in files: - if os.path.exists(fileCh): - if os.path.islink(fileCh): - os.lchown(fileCh, uid, gid) - else: - os.chown(fileCh, uid,gid) - return True - else: - fileObj = _file() - scanObjs = fileObj.scanDirs([directory]) - # меняем владельца домашней директории - os.chown(directory, uid,gid) - # Меняем владельца директорий - for dirCh in scanObjs[0].dirs: - os.chown(dirCh, uid,gid) - # Меняем владельца файлов - for fileCh in scanObjs[0].files: - os.chown(fileCh, uid,gid) - # Меняем владельца ссылок - for linkCh in scanObjs[0].links: - os.lchown(linkCh[1], uid, gid) - return True - def execProg(self, cmdStrProg, inStr=False, retFull=True, envProg={}): """Выполняет внешнюю программу @@ -832,7 +782,6 @@ conjunction with the 'login' or 'logout'") self.printERROR(_("Not found user primary group (gid=%s)"%str(gid))) return False # Создаем пользовательскую директорию - self.clVars.Set('cl_root_path',homeDir,True) homeExists = os.path.exists(homeDir) # Первый проход self.clVars.Set('cl_pass_step','first',True) @@ -844,10 +793,6 @@ conjunction with the 'login' or 'logout'") self.clVars.Set('cl_pass_step','next',True) self.printSUCCESS(_("Apply always templates") + " ...") - # Создаем домашнюю директорию - if not os.path.exists(homeDir): - self.createUserDir(uid, gid, homeDir) - # Записываем переменные self.clVars.Set('ur_login', userName) self.clVars.Set('ur_fullname', fullName) @@ -861,7 +806,6 @@ conjunction with the 'login' or 'logout'") self.errorAndUnmountUserRes = True self.printERROR(_("Can not apply user profile")) return False - self.chownR(homeDir, uid, gid, dirsAndFiles) if not homeExists: self.printSUCCESS(_("Created home dir %s")%homeDir + " ...") self.printSUCCESS(_("User account is configured") + " ...") @@ -962,8 +906,6 @@ conjunction with the 'login' or 'logout'") # Обнуляем переменную удаленный хост if hostAuth == "local": self.clVars.Set("cl_remote_host","",True) - # Изменяем базовую директорию наложения шаблонов - self.clVars.Set("cl_root_path","/",True) # Устанавливаем действие templates_domain self.clVars.Set("cl_pass_type","domain",True) # Наложим шаблоны templates/domain @@ -1033,9 +975,11 @@ conjunction with the 'login' or 'logout'") return False if not os.path.exists(pathRemote): os.makedirs(pathRemote) - mountStr = "mount -t cifs -o user=client //%s/remote %s"\ - %(domain,pathRemote) - textLine = self.execProg(mountStr, None, True, {"PASSWD":pwdRemote}) + #mountStr = "mount -t cifs -o user=client //%s/remote %s"\ + # %(domain,pathRemote) + #textLine= self.execProg(mountStr, None, True, {"PASSWD":pwdRemote}) + textLine = self.mountSleepRes("client", pwdRemote, None, None, + "remote", pathRemote) if not (textLine == None): self.printWARNING(_("Can not mount Samba resource [%s]")%\ "remote" + " ...") @@ -1097,8 +1041,6 @@ conjunction with the 'login' or 'logout'") self.clVars.Delete("cl_remote_pw","local") self.clVars.Set("cl_remote_host","",True) self.clVars.Set("cl_remote_pw","",True) - # Изменяем базовую директорию наложения шаблонов - self.clVars.Set("cl_root_path","/",True) # Наложим шаблоны templates/domain # Новые пути к шаблонам # Устанавливаем действие templates_domain @@ -1134,8 +1076,6 @@ conjunction with the 'login' or 'logout'") manager") + " ..." # Устанавливаем переменную шаблона clVars.Set("cl_pass_run","off",True) - # Изменяем базовую директорию наложения шаблонов - clVars.Set("cl_root_path","/",True) # Устанавливаем действие templates_client clVars.Set("cl_pass_type","install",True) # Новые пути к шаблонам @@ -1170,8 +1110,6 @@ manager") + " ..." manager") + " ..." # Устанавливаем переменную шаблона clVars.Set("cl_pass_run","on",True) - # Изменяем базовую директорию наложения шаблонов - clVars.Set("cl_root_path","/",True) # Устанавливаем действие templates_client clVars.Set("cl_pass_type","install",True) # Новые пути к шаблонам @@ -1634,7 +1572,7 @@ or ld_bind_dn or ld_bind_pw") def mountSambaRes(self,userName,userPwd,uid,gid,res,path, mountUidList=['ftp','home','share']): """Монтирует Samba ресурсы""" - if res in mountUidList: + if not uid is None and not gid is None and res in mountUidList: # Монтируем директории c uid mountStr="mount -t cifs -o user=%s,uid=%s,gid=%s,noperm"\ %(userName,uid,gid) +\