git-svn-id: http://svn.calculate.ru/calculate2/calculate-server/trunk@131 c91db197-33c1-4113-bf15-f8a5c547ca64
parent
f1ba5527a8
commit
477ea3ca66
@ -0,0 +1,95 @@
|
||||
#!/usr/bin/python
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Calculate Pack, http://www.calculate-linux.ru
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0,os.path.abspath('/usr/lib/calculate/calculate-lib/pym'))
|
||||
sys.path.insert(0,os.path.abspath('/usr/lib/calculate/calculate-server/pym'))
|
||||
import cl_base
|
||||
tr = cl_base.lang()
|
||||
tr.setGlobalDomain('cl_server')
|
||||
tr.setLanguage(sys.modules[__name__])
|
||||
import cl_ldap
|
||||
|
||||
class tsOpt(cl_base.opt):
|
||||
def __init__(self, obj):
|
||||
self.obj =obj
|
||||
self.shortOpt = self.obj.getAllOpt('short')
|
||||
self.longOpt = self.obj.getAllOpt('long')
|
||||
self.opt = {}
|
||||
self.sysArgv = sys.argv[1:]
|
||||
self.__iter = 0
|
||||
self.params = {}
|
||||
cl_base.opt.__init__(self, self.shortOpt, self.longOpt)
|
||||
if "h" in self.opt or (not (self.params.has_key('group') and\
|
||||
self.params.has_key('service')) and\
|
||||
not self.opt):
|
||||
print self.obj.getHelp()
|
||||
else:
|
||||
if self.params.has_key('service'):
|
||||
if not (self.params['service'] in self.obj.allServ):
|
||||
self.handlerErrOpt()
|
||||
else:
|
||||
self.handlerErrOpt()
|
||||
|
||||
def handlerOpt(self,option,value):
|
||||
# Обработчик (опция значение)
|
||||
#print option, value
|
||||
shortOpt = self.obj.getShortOpt(option)
|
||||
if not self.opt.has_key(shortOpt):
|
||||
self.opt[shortOpt] = value
|
||||
|
||||
|
||||
def handlerErrOpt(self):
|
||||
# Обработчик ошибок
|
||||
argv = " ".join(sys.argv[1:])
|
||||
print _("Unrecognized option") + ' "' + argv + '"\n' + \
|
||||
_("Try") + ' "' + sys.argv[0].split("/")[-1] + ' --help" ' +\
|
||||
_("for more information.")
|
||||
|
||||
|
||||
def handlerParam(self,param):
|
||||
# Обработчик хвостов (значение)
|
||||
self.__iter += 1
|
||||
# Достаем название пользователя
|
||||
if self.__iter == 1:
|
||||
self.params['group'] = param
|
||||
# Достаем название сервиса
|
||||
if self.__iter == 2:
|
||||
self.params['service'] = param
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ldapObj = cl_ldap.cl_ldap("cl-groupdel")
|
||||
optObj = tsOpt(ldapObj)
|
||||
flagError = False
|
||||
if optObj.params.has_key('service') and\
|
||||
optObj.params.has_key('group'):
|
||||
if optObj.params['service'] == "ldap":
|
||||
# Добавляем группу
|
||||
if not ldapObj.delGroupLdapServer(optObj.params['group'],
|
||||
optObj.opt):
|
||||
flagError = True
|
||||
elif optObj.params['service'] == "samba":
|
||||
# Добавляем группу
|
||||
if not ldapObj.delGroupLdapServer(optObj.params['group'],
|
||||
optObj.opt):
|
||||
flagError = True
|
||||
if flagError:
|
||||
sys.exit(1)
|
||||
else:
|
||||
sys.exit(0)
|
@ -0,0 +1,95 @@
|
||||
#!/usr/bin/python
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Calculate Pack, http://www.calculate-linux.ru
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0,os.path.abspath('/usr/lib/calculate/calculate-lib/pym'))
|
||||
sys.path.insert(0,os.path.abspath('/usr/lib/calculate/calculate-server/pym'))
|
||||
import cl_base
|
||||
tr = cl_base.lang()
|
||||
tr.setGlobalDomain('cl_server')
|
||||
tr.setLanguage(sys.modules[__name__])
|
||||
import cl_ldap
|
||||
|
||||
class tsOpt(cl_base.opt):
|
||||
def __init__(self, obj):
|
||||
self.obj =obj
|
||||
self.shortOpt = self.obj.getAllOpt('short')
|
||||
self.longOpt = self.obj.getAllOpt('long')
|
||||
self.opt = {}
|
||||
self.sysArgv = sys.argv[1:]
|
||||
self.__iter = 0
|
||||
self.params = {}
|
||||
cl_base.opt.__init__(self, self.shortOpt, self.longOpt)
|
||||
if "h" in self.opt or (not (self.params.has_key('user') and\
|
||||
self.params.has_key('service')) and\
|
||||
not self.opt):
|
||||
print self.obj.getHelp()
|
||||
else:
|
||||
if self.params.has_key('service'):
|
||||
if not (self.params['service'] in self.obj.allServ):
|
||||
self.handlerErrOpt()
|
||||
else:
|
||||
self.handlerErrOpt()
|
||||
|
||||
def handlerOpt(self,option,value):
|
||||
# Обработчик (опция значение)
|
||||
#print option, value
|
||||
shortOpt = self.obj.getShortOpt(option)
|
||||
if not self.opt.has_key(shortOpt):
|
||||
self.opt[shortOpt] = value
|
||||
|
||||
|
||||
def handlerErrOpt(self):
|
||||
# Обработчик ошибок
|
||||
argv = " ".join(sys.argv[1:])
|
||||
print _("Unrecognized option") + ' "' + argv + '"\n' + \
|
||||
_("Try") + ' "' + sys.argv[0].split("/")[-1] + ' --help" ' +\
|
||||
_("for more information.")
|
||||
|
||||
|
||||
def handlerParam(self,param):
|
||||
# Обработчик хвостов (значение)
|
||||
self.__iter += 1
|
||||
# Достаем название пользователя
|
||||
if self.__iter == 1:
|
||||
self.params['user'] = param
|
||||
# Достаем название сервиса
|
||||
if self.__iter == 2:
|
||||
self.params['service'] = param
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ldapObj = cl_ldap.cl_ldap("cl-userdel")
|
||||
optObj = tsOpt(ldapObj)
|
||||
flagError = False
|
||||
if optObj.params.has_key('service') and\
|
||||
optObj.params.has_key('user'):
|
||||
flagError = True
|
||||
if optObj.params['service'] == "ldap":
|
||||
# Добавляем LDAP пользователя
|
||||
if ldapObj.delUserLdapServer(optObj.params['user'], optObj.opt):
|
||||
flagError = False
|
||||
elif optObj.params['service'] == "samba":
|
||||
# Добавляем Samba пользователя
|
||||
if ldapObj.delUserLdapServer(optObj.params['user'], optObj.opt):
|
||||
flagError = False
|
||||
if flagError:
|
||||
sys.exit(1)
|
||||
else:
|
||||
sys.exit(0)
|
||||
|
@ -0,0 +1,95 @@
|
||||
#!/usr/bin/python
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Calculate Pack, http://www.calculate-linux.ru
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0,os.path.abspath('/usr/lib/calculate/calculate-lib/pym'))
|
||||
sys.path.insert(0,os.path.abspath('/usr/lib/calculate/calculate-server/pym'))
|
||||
import cl_base
|
||||
tr = cl_base.lang()
|
||||
tr.setGlobalDomain('cl_server')
|
||||
tr.setLanguage(sys.modules[__name__])
|
||||
import cl_ldap
|
||||
|
||||
class tsOpt(cl_base.opt):
|
||||
def __init__(self, obj):
|
||||
self.obj =obj
|
||||
self.shortOpt = self.obj.getAllOpt('short')
|
||||
self.longOpt = self.obj.getAllOpt('long')
|
||||
self.opt = {}
|
||||
self.sysArgv = sys.argv[1:]
|
||||
self.__iter = 0
|
||||
self.params = {}
|
||||
cl_base.opt.__init__(self, self.shortOpt, self.longOpt)
|
||||
if "h" in self.opt or (not (self.params.has_key('user') and\
|
||||
self.params.has_key('service')) and\
|
||||
not self.opt):
|
||||
print self.obj.getHelp()
|
||||
else:
|
||||
if self.params.has_key('service'):
|
||||
if not (self.params['service'] in self.obj.allServ):
|
||||
self.handlerErrOpt()
|
||||
else:
|
||||
self.handlerErrOpt()
|
||||
|
||||
def handlerOpt(self,option,value):
|
||||
# Обработчик (опция значение)
|
||||
#print option, value
|
||||
shortOpt = self.obj.getShortOpt(option)
|
||||
if not self.opt.has_key(shortOpt):
|
||||
self.opt[shortOpt] = value
|
||||
|
||||
|
||||
def handlerErrOpt(self):
|
||||
# Обработчик ошибок
|
||||
argv = " ".join(sys.argv[1:])
|
||||
print _("Unrecognized option") + ' "' + argv + '"\n' + \
|
||||
_("Try") + ' "' + sys.argv[0].split("/")[-1] + ' --help" ' +\
|
||||
_("for more information.")
|
||||
|
||||
|
||||
def handlerParam(self,param):
|
||||
# Обработчик хвостов (значение)
|
||||
self.__iter += 1
|
||||
# Достаем название пользователя
|
||||
if self.__iter == 1:
|
||||
self.params['user'] = param
|
||||
# Достаем название сервиса
|
||||
if self.__iter == 2:
|
||||
self.params['service'] = param
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ldapObj = cl_ldap.cl_ldap("cl-usermod")
|
||||
optObj = tsOpt(ldapObj)
|
||||
flagError = False
|
||||
if optObj.params.has_key('service') and\
|
||||
optObj.params.has_key('user'):
|
||||
flagError = True
|
||||
if optObj.params['service'] == "ldap":
|
||||
# Добавляем LDAP пользователя
|
||||
if ldapObj.modUserLdapServer(optObj.params['user'], optObj.opt):
|
||||
flagError = False
|
||||
elif optObj.params['service'] == "samba":
|
||||
# Добавляем Samba пользователя
|
||||
if ldapObj.modUserSambaServer(optObj.params['user'], optObj.opt):
|
||||
flagError = False
|
||||
if flagError:
|
||||
sys.exit(1)
|
||||
else:
|
||||
sys.exit(0)
|
||||
|
Loading…
Reference in new issue