本文整理汇总了Python中cm.models.user.User.create方法的典型用法代码示例。如果您正苦于以下问题:Python User.create方法的具体用法?Python User.create怎么用?Python User.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cm.models.user.User
的用法示例。
在下文中一共展示了User.create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
# 需要导入模块: from cm.models.user import User [as 别名]
# 或者: from cm.models.user.User import create [as 别名]
def add(caller_id, user_id):
"""
Function adds new user to DB and creates its home directory.
@cmview_user
@note This method is decorated by user_log decorator, not by admin_cm_log.
This is caused by the fact that CLMAdmin doesn't need to be CMAdmin and
despite not having rights to call CMAdmin functions he needs to call it on
CMAdmin priviledges.
@parameter{user_id}
@response{None}
"""
User.create(user_id)
示例2: add_missing
# 需要导入模块: from cm.models.user import User [as 别名]
# 或者: from cm.models.user.User import create [as 别名]
def add_missing(caller_id, remote):
"""
Adds Users whose ids are listed in @prm{remote} and who are locally
missing.
@cmview_user
@param_post{remote,list(int)} ids of the remote Users
"""
# remote must be passed through POST as a list
# it is a list of users id
try:
# put all the user ids in a list
local = User.objects.all().values_list('id', flat=True)
# create user for all the ids which are in remote but not in the local cm
for user_id in [uid for uid in remote if uid not in local]:
User.create(user_id)
except:
raise CMException('user_create')
示例3: add_missing
# 需要导入模块: from cm.models.user import User [as 别名]
# 或者: from cm.models.user.User import create [as 别名]
def add_missing(caller_id, remote):
"""
Function adds missing users listed in remote that don't belong to local.
@cmview_user
@parameter{remote,list of int}
@response{None}
"""
# remote must be passed through POST as a list
# it is a list of users id
try:
# put all the user ids in a list
local = User.objects.all().values_list('id', flat=True)
# create user for all the ids which are in remote but not in the local cm
for user_id in [uid for uid in remote if uid not in local]:
User.create(user_id)
except:
raise CMException('user_create')
示例4: add
# 需要导入模块: from cm.models.user import User [as 别名]
# 或者: from cm.models.user.User import create [as 别名]
def add(new_user_id):
"""
Adds existing CLM User to CM Users.
@cmview_guest
@param_post{new_user_id,int} id of the existing CLM User
@response{None}
"""
user = User.create(new_user_id)
try:
user.save()
except Exception, e:
log.debug(0, "Adding to DB: %s" % str(e))
raise CMException('user_create')
示例5: first_admin_add
# 需要导入模块: from cm.models.user import User [as 别名]
# 或者: from cm.models.user.User import create [as 别名]
def first_admin_add(caller_id, new_password, clm_address):
"""
Creates first admin of the cluster. It should be called right after
submiting the form for adding new CM. System will not operate properly
with no CM admin existing.
@note It can be run only if no CM admin exists in the CM database.
@cmview_user
@param_post{new_password,string} first *CM admin password* to set
@param_post{clm_address,string}
"""
user = User.create(1)
user.save()
# creates a new admin, which is the caller
admin = Admin()
admin.user = user
admin.password = new_password
try:
admin.save()
except:
raise CMException('admin_add')
# Update config and setup CLM address
try:
lines = []
config = open('/usr/lib/cc1/cm/config.py', 'r')
for line in config.readlines():
if line.startswith('CLM_ADDRESS') and 'NOT_CONFIGURED' in line:
lines.append('CLM_ADDRESS = "https://%s:8000/"\n' % clm_address)
else:
lines.append(line)
config.close()
config = open('/usr/lib/cc1/cm/config.py', 'w')
config.write(''.join(lines))
config.close()
except:
log.exception(caller_id, 'config_update')
raise CMException('config_update')