本文整理汇总了Python中pulp.server.managers.factory.role_manager函数的典型用法代码示例。如果您正苦于以下问题:Python role_manager函数的具体用法?Python role_manager怎么用?Python role_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了role_manager函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_syntactic_sugar_methods
def test_syntactic_sugar_methods(self):
"""
Tests the syntactic sugar methods for retrieving specific managers.
"""
# Setup
factory.initialize()
# Test
self.assertTrue(isinstance(factory.authentication_manager(), AuthenticationManager))
self.assertTrue(isinstance(factory.cert_generation_manager(), CertGenerationManager))
self.assertTrue(isinstance(factory.certificate_manager(), CertificateManager))
self.assertTrue(isinstance(factory.password_manager(), PasswordManager))
self.assertTrue(isinstance(factory.permission_manager(), PermissionManager))
self.assertTrue(isinstance(factory.permission_query_manager(), PermissionQueryManager))
self.assertTrue(isinstance(factory.role_manager(), RoleManager))
self.assertTrue(isinstance(factory.role_query_manager(), RoleQueryManager))
self.assertTrue(isinstance(factory.user_manager(), UserManager))
self.assertTrue(isinstance(factory.user_query_manager(), UserQueryManager))
self.assertTrue(isinstance(factory.repo_manager(), RepoManager))
self.assertTrue(isinstance(factory.repo_unit_association_manager(),
RepoUnitAssociationManager))
self.assertTrue(isinstance(factory.repo_publish_manager(), RepoPublishManager))
self.assertTrue(isinstance(factory.repo_query_manager(), RepoQueryManager))
self.assertTrue(isinstance(factory.repo_sync_manager(), RepoSyncManager))
self.assertTrue(isinstance(factory.content_manager(), ContentManager))
self.assertTrue(isinstance(factory.content_query_manager(), ContentQueryManager))
self.assertTrue(isinstance(factory.content_upload_manager(), ContentUploadManager))
self.assertTrue(isinstance(factory.consumer_manager(), ConsumerManager))
self.assertTrue(isinstance(factory.topic_publish_manager(), TopicPublishManager))
示例2: _initialize_pulp
def _initialize_pulp():
# XXX ORDERING COUNTS
# This initialization order is very sensitive, and each touches a number of
# sub-systems in pulp. If you get this wrong, you will have pulp tripping
# over itself on start up. If you do not know where to add something, ASK!
global _IS_INITIALIZED, STACK_TRACER
if _IS_INITIALIZED:
return
_IS_INITIALIZED = True
# check our db version and other support
migration_models.check_package_versions()
# pulp generic content initialization
manager_factory.initialize()
plugin_api.initialize()
# new async dispatch initialization
dispatch_factory.initialize()
dispatch_history.start_reaper_thread()
# ensure necessary infrastructure
role_manager = manager_factory.role_manager()
role_manager.ensure_super_user_role()
user_manager = manager_factory.user_manager()
user_manager.ensure_admin()
# agent services
AgentServices.start()
# setup debugging, if configured
if config.config.getboolean('server', 'debugging_mode'):
STACK_TRACER = StacktraceDumper()
STACK_TRACER.start()
示例3: setUp
def setUp(self):
ServerTests.setUp(self)
roles = []
User.get_collection().remove()
manager = managers.user_manager()
roles.append(managers.role_manager().super_user_role)
manager.create_user(login=self.USER[0], password=self.USER[1], roles=roles)
示例4: post
def post(self, request):
"""
Revoke permissions from a role.
:param request: WSGI request object
:type request: django.core.handlers.wsgi.WSGIRequest
:return: An empty response
:rtype: django.http.HttpResponse
"""
params = request.body_as_json
role_id = params.get('role_id', None)
resource = params.get('resource', None)
operation_names = params.get('operations', None)
_validate_params({'role_id': role_id,
'resource': resource,
'operation_names': operation_names})
role_manager = factory.role_manager()
permission_manager = factory.permission_manager()
operations = permission_manager.operation_names_to_values(operation_names)
remove_perm = role_manager.remove_permissions_from_role(role_id, resource, operations)
return generate_json_response(remove_perm)
示例5: is_last_super_user
def is_last_super_user(self, login):
"""
Check to see if a user is the last super user
@type user: str
@param user: login of user to check
@rtype: bool
@return: True if the user is the last super user, False otherwise
@raise PulpDataException: if no super users are found
"""
user = User.get_collection().find_one({'login': login})
role_manager = factory.role_manager()
if SUPER_USER_ROLE not in user['roles']:
return False
users = self.find_users_belonging_to_role(SUPER_USER_ROLE)
if not users:
raise PulpDataException(_('no super users defined'))
if len(users) >= 2:
return False
return users[0]['_id'] == user['_id'] # this should be True
示例6: populate
def populate(self):
role_manager = manager_factory.role_manager()
role_manager.create_role(self.ROLE_ID)
for login in self.USER_LOGINS:
user_manager = manager_factory.user_manager()
user_manager.create_user(login=login, password=login, roles=[self.ROLE_ID])
示例7: post
def post(self, request):
"""
Grant permissions to a role.
:param request: WSGI request object
:type request: django.core.handlers.wsgi.WSGIRequest
:return: An empty response
:rtype: django.http.HttpResponse
"""
params = request.body_as_json
role_id = params.get('role_id', None)
resource = params.get('resource', None)
operation_names = params.get('operations', None)
_check_invalid_params({'role_id': role_id,
'resource': resource,
'operation_names': operation_names})
# Grant permission synchronously
role_manager = factory.role_manager()
permission_manager = factory.permission_manager()
operations = permission_manager.operation_names_to_values(operation_names)
add_perm = role_manager.add_permissions_to_role(role_id, resource, operations)
return generate_json_response(add_perm)
示例8: POST
def POST(self):
# Pull all the roles data
role_data = self.params()
role_id = role_data.get('role_id', None)
display_name = role_data.get('display_name', None)
description = role_data.get('description', None)
# Creation
manager = managers.role_manager()
args = [role_id, display_name, description]
weight = pulp_config.config.getint('tasks', 'create_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_ROLE_TYPE, role_id),
action_tag('create')]
call_request = CallRequest(manager.create_role,
args,
weight=weight,
tags=tags)
call_request.creates_resource(dispatch_constants.RESOURCE_ROLE_TYPE, role_id)
role = execution.execute_sync(call_request)
role_link = serialization.link.child_link_obj(role_id)
role.update(role_link)
return self.created(role_id, role)
示例9: POST
def POST(self):
# Params
params = self.params()
role_id = params.get('role_id', None)
resource = params.get('resource', None)
operation_names = params.get('operations', None)
_check_invalid_params({'role_id':role_id,
'resource':resource,
'operation_names':operation_names})
operations = _get_operations(operation_names)
# Grant permission synchronously
role_manager = managers.role_manager()
tags = [resource_tag(dispatch_constants.RESOURCE_ROLE_TYPE, role_id),
action_tag('remove_permission_from_role')]
call_request = CallRequest(role_manager.remove_permissions_from_role,
[role_id, resource, operations],
tags=tags)
call_request.updates_resource(dispatch_constants.RESOURCE_ROLE_TYPE, role_id)
return self.ok(execution.execute_sync(call_request))
示例10: _initialize_pulp
def _initialize_pulp():
# This initialization order is very sensitive, and each touches a number of
# sub-systems in pulp. If you get this wrong, you will have pulp tripping
# over itself on start up.
global _IS_INITIALIZED, STACK_TRACER
if _IS_INITIALIZED:
return
# Verify the database has been migrated to the correct version. This is
# very likely a reason the server will fail to start.
try:
migration_models.check_package_versions()
except Exception:
msg = 'The database has not been migrated to the current version. '
msg += 'Run pulp-manage-db and restart the application.'
raise InitializationException(msg), None, sys.exc_info()[2]
# Load plugins and resolve against types. This is also a likely candidate
# for causing the server to fail to start.
try:
plugin_api.initialize()
except Exception:
msg = 'One or more plugins failed to initialize. If a new type has '
msg += 'been added, run pulp-manage-db to load the type into the '
msg += 'database and restart the application.'
raise InitializationException(msg), None, sys.exc_info()[2]
# There's a significantly smaller chance the following calls will fail.
# The previous two are likely user errors, but the remainder represent
# something gone horribly wrong. As such, I'm not going to account for each
# and instead simply let the exception itself bubble up.
# Load the mappings of manager type to managers
manager_factory.initialize()
# Initialize the tasking subsystem
dispatch_factory.initialize()
# Ensure the minimal auth configuration
role_manager = manager_factory.role_manager()
role_manager.ensure_super_user_role()
user_manager = manager_factory.user_manager()
user_manager.ensure_admin()
# database document reaper
reaper.initialize()
# agent services
AgentServices.start()
# Setup debugging, if configured
if config.config.getboolean('server', 'debugging_mode'):
STACK_TRACER = StacktraceDumper()
STACK_TRACER.start()
# If we got this far, it was successful, so flip the flag
_IS_INITIALIZED = True
示例11: __init__
def __init__(self, admin=None, password=None,
server='ldap://localhost:389',
tls=False):
self.ldapserver = server
self.ldapadmin = admin
self.ldappassword = password
self.ldaptls = tls
self.lconn = None
self.role_manager = factory.role_manager()
示例12: POST
def POST(self, role_id):
# Params (validation will occur in the manager)
params = self.params()
login = params.get('login', None)
if login is None:
raise exceptions.InvalidValue(login)
role_manager = managers.role_manager()
return self.ok(role_manager.add_user_to_role(role_id, login))
示例13: PUT
def PUT(self, role_id):
# Pull all the role update data
role_data = self.params()
delta = role_data.get('delta', None)
manager = managers.role_manager()
role = manager.update_role(role_id, delta)
role.update(serialization.link.current_link_obj())
return self.ok(role)
示例14: DELETE
def DELETE(self, role_id):
manager = managers.role_manager()
resources = {dispatch_constants.RESOURCE_ROLE_TYPE: {role_id: dispatch_constants.RESOURCE_DELETE_OPERATION}}
tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, role_id),
action_tag('delete')]
call_request = CallRequest(manager.delete_role,
[role_id],
resources=resources,
tags=tags)
return self.ok(execution.execute(call_request))
示例15: setUp
def setUp(self):
super(PermissionManagerTests, self).setUp()
self.alpha_num = string.letters + string.digits
self.role_manager = manager_factory.role_manager()
self.role_query_manager = manager_factory.role_query_manager()
self.permission_manager = manager_factory.permission_manager()
self.permission_query_manager = manager_factory.permission_query_manager()
self.role_manager.ensure_super_user_role()
manager_factory.principal_manager().clear_principal()