本文整理汇总了Python中bkr.server.model.Group.root_password方法的典型用法代码示例。如果您正苦于以下问题:Python Group.root_password方法的具体用法?Python Group.root_password怎么用?Python Group.root_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.Group
的用法示例。
在下文中一共展示了Group.root_password方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _new_group
# 需要导入模块: from bkr.server.model import Group [as 别名]
# 或者: from bkr.server.model.Group import root_password [as 别名]
def _new_group(self, group_id, display_name, group_name, ldap,
root_password):
user = identity.current.user
if ldap and not user.is_admin():
flash(_(u'Only admins can create LDAP groups'))
redirect('.')
try:
Group.by_name(group_name)
except NoResultFound:
pass
else:
flash( _(u"Group %s already exists." % group_name) )
redirect(".")
group = Group()
session.add(group)
group.record_activity(user=user, service=u'WEBUI', field=u'Group',
action=u'Created')
group.display_name = display_name
group.group_name = group_name
group.ldap = ldap
if group.ldap:
group.refresh_ldap_members()
group.root_password = root_password
if not ldap: # LDAP groups don't have owners
group.user_group_assocs.append(UserGroup(user=user, is_owner=True))
group.activity.append(GroupActivity(user, service=u'WEBUI',
action=u'Added', field_name=u'User',
old_value=None, new_value=user.user_name))
group.activity.append(GroupActivity(user, service=u'WEBUI',
action=u'Added', field_name=u'Owner',
old_value=None, new_value=user.user_name))
return group
示例2: create
# 需要导入模块: from bkr.server.model import Group [as 别名]
# 或者: from bkr.server.model.Group import root_password [as 别名]
def create(self, kw):
"""
Creates a new group.
The *kw* argument must be an XML-RPC structure (dict)
specifying the following keys:
'group_name'
Group name (maximum 16 characters)
'display_name'
Group display name
'ldap'
Populate users from LDAP (True/False)
Returns a message whether the group was successfully created or
raises an exception on failure.
"""
display_name = kw.get('display_name')
group_name = kw.get('group_name')
ldap = kw.get('ldap')
password = kw.get('root_password')
if ldap and not identity.current.user.is_admin():
raise BX(_(u'Only admins can create LDAP groups'))
try:
group = Group.by_name(group_name)
except NoResultFound:
#validate
GroupFormSchema.fields['group_name'].to_python(group_name)
GroupFormSchema.fields['display_name'].to_python(display_name)
group = Group()
session.add(group)
group.record_activity(user=identity.current.user, service=u'XMLRPC',
field=u'Group', action=u'Created')
group.display_name = display_name
group.group_name = group_name
group.ldap = ldap
group.root_password = password
user = identity.current.user
if not ldap:
group.user_group_assocs.append(UserGroup(user=user, is_owner=True))
group.activity.append(GroupActivity(user, service=u'XMLRPC',
action=u'Added', field_name=u'User',
old_value=None, new_value=user.user_name))
group.activity.append(GroupActivity(user, service=u'XMLRPC',
action=u'Added', field_name=u'Owner',
old_value=None, new_value=user.user_name))
if group.ldap:
group.refresh_ldap_members()
return 'Group created: %s.' % group_name
else:
raise BX(_(u'Group already exists: %s.' % group_name))
示例3: create
# 需要导入模块: from bkr.server.model import Group [as 别名]
# 或者: from bkr.server.model.Group import root_password [as 别名]
def create(self, kw):
"""
Creates a new group.
The *kw* argument must be an XML-RPC structure (dict)
specifying the following keys:
'group_name'
Group name (maximum 16 characters)
'display_name'
Group display name
'description'
Group description
'ldap'
Populate users from LDAP (True/False)
Returns a message whether the group was successfully created or
raises an exception on failure.
"""
display_name = kw.get('display_name')
group_name = kw.get('group_name')
description = kw.get('description')
ldap = kw.get('ldap')
password = kw.get('root_password')
if ldap and not identity.current.user.is_admin():
raise BX(_(u'Only admins can create LDAP groups'))
try:
group = Group.by_name(group_name)
except NoResultFound:
group = Group()
session.add(group)
group.record_activity(user=identity.current.user, service=u'XMLRPC',
field=u'Group', action=u'Created')
group.display_name = display_name
group.group_name = group_name
group.description = description
group.root_password = password
if ldap:
group.membership_type = GroupMembershipType.ldap
group.refresh_ldap_members()
else:
group.add_member(identity.current.user, is_owner=True,
service=u'XMLRPC', agent=identity.current.user)
return 'Group created: %s.' % group_name
else:
raise BX(_(u'Group already exists: %s.' % group_name))