Added delay in mounting samba remote resource

Modified algorithm create user profile
develop
Самоукин Алексей 14 years ago
parent 230861cb20
commit bae2c9d9df

@ -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:

@ -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) +\

Loading…
Cancel
Save