本文整理汇总了Python中pulp.server.webservices.execution.execute_sync函数的典型用法代码示例。如果您正苦于以下问题:Python execute_sync函数的具体用法?Python execute_sync怎么用?Python execute_sync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute_sync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: POST
def POST(self, consumer_id):
consumer_manager = managers.consumer_manager()
consumer_manager.get_consumer(consumer_id)
schedule_data = self.params()
units = schedule_data.pop('units', None)
uninstall_options = {'options': schedule_data.pop('options', {})}
if not units:
raise MissingValue(['units'])
schedule_manager = managers.schedule_manager()
weight = pulp_config.config.getint('tasks', 'create_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
action_tag('create_unit_uninstall_schedule')]
call_request = CallRequest(schedule_manager.create_unit_uninstall_schedule,
[consumer_id, units, uninstall_options, schedule_data],
weight=weight,
tags=tags,
archive=True)
call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)
schedule_id = execution.execute_sync(call_request)
scheduler = dispatch_factory.scheduler()
scheduled_call = scheduler.get(schedule_id)
scheduled_obj = serialization.dispatch.scheduled_unit_management_obj(scheduled_call)
scheduled_obj.update(serialization.link.child_link_obj(schedule_id))
return self.created(scheduled_obj['_href'], scheduled_obj)
示例2: POST
def POST(self, repo_id, importer_id):
importer_manager = manager_factory.repo_importer_manager()
importer = importer_manager.get_importer(repo_id)
if importer_id != importer['id']:
raise exceptions.MissingResource(importer=importer_id)
schedule_options = self.params()
sync_options = {'override_config': schedule_options.pop('override_config', {})}
schedule_manager = manager_factory.schedule_manager()
resources = {dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_READ_OPERATION},
dispatch_constants.RESOURCE_REPOSITORY_IMPORTER_TYPE: {importer_id: dispatch_constants.RESOURCE_UPDATE_OPERATION}}
weight = pulp_config.config.getint('tasks', 'create_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
resource_tag(dispatch_constants.RESOURCE_REPOSITORY_IMPORTER_TYPE, importer_id),
action_tag('create_sync_schedule')]
call_request = CallRequest(schedule_manager.create_sync_schedule,
[repo_id, importer_id, sync_options, schedule_options],
resources=resources,
weight=weight,
tags=tags,
archive=True)
schedule_id = execution.execute_sync(call_request)
scheduler = dispatch_factory.scheduler()
schedule = scheduler.get(schedule_id)
obj = serialization.dispatch.scheduled_sync_obj(schedule)
obj.update(serialization.link.child_link_obj(schedule_id))
return self.created(obj['_href'], obj)
示例3: PUT
def PUT(self, consumer_id, content_type):
"""
Update the association of a profile with a consumer by content type ID.
@param consumer_id: A consumer ID.
@type consumer_id: str
@param content_type: A content unit type ID.
@type content_type: str
@return: The updated model object:
{consumer_id:<str>, content_type:<str>, profile:<dict>}
@rtype: dict
"""
body = self.params()
profile = body.get('profile')
manager = managers.consumer_profile_manager()
tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, content_type),
action_tag('profile_update')]
call_request = CallRequest(manager.update,
[consumer_id, content_type],
{'profile': profile},
tags=tags,
weight=0,
kwarg_blacklist=['profile'])
call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)
call_report = CallReport.from_call_request(call_request)
call_report.serialize_result = False
consumer = execution.execute_sync(call_request, call_report)
link = serialization.link.child_link_obj(consumer_id, content_type)
consumer.update(link)
return self.ok(consumer)
示例4: POST
def POST(self):
# Pull all the user data
user_data = self.params()
login = user_data.get('login', None)
password = user_data.get('password', None)
name = user_data.get('name', None)
# Creation
manager = managers.user_manager()
resources = {dispatch_constants.RESOURCE_USER_TYPE: {login: dispatch_constants.RESOURCE_CREATE_OPERATION}}
args = [login]
kwargs = {'password': password,
'name': name}
weight = pulp_config.config.getint('tasks', 'create_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_USER_TYPE, login),
action_tag('create')]
call_request = CallRequest(manager.create_user,
args,
kwargs,
resources=resources,
weight=weight,
tags=tags,
kwarg_blacklist=['password'])
user = execution.execute_sync(call_request)
user_link = serialization.link.child_link_obj(login)
user.update(user_link)
# Grant permissions
permission_manager = managers.permission_manager()
permission_manager.grant_automatic_permissions_for_resource(user_link['_href'])
return self.created(login, user)
示例5: POST
def POST(self):
group_data = self.params()
group_id = group_data.pop('id', None)
if group_id is None:
raise pulp_exceptions.MissingValue(['id'])
display_name = group_data.pop('display_name', None)
description = group_data.pop('description', None)
repo_ids = group_data.pop('repo_ids', None)
notes = group_data.pop('notes', None)
distributors = group_data.pop('distributors', None)
if group_data:
raise pulp_exceptions.InvalidValue(group_data.keys())
# Create the repo group
manager = managers_factory.repo_group_manager()
args = [group_id, display_name, description, repo_ids, notes]
kwargs = {'distributor_list': distributors}
weight = pulp_config.config.getint('tasks', 'create_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, group_id)]
call_request = CallRequest(manager.create_and_configure_repo_group, args, kwargs, weight=weight,
tags=tags)
call_request.creates_resource(dispatch_constants.RESOURCE_REPOSITORY_GROUP_TYPE, group_id)
group = execution.execute_sync(call_request)
group.update(serialization.link.child_link_obj(group['id']))
group['distributors'] = distributors or []
return self.created(group['_href'], group)
示例6: 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)
示例7: POST
def POST(self):
# Params
params = self.params()
login = params.get('login', None)
resource = params.get('resource', None)
operation_names = params.get('operations', None)
_check_invalid_params({'login':login,
'resource':resource,
'operation_names':operation_names})
operations = _get_operations(operation_names)
# Grant permission synchronously
permission_manager = managers.permission_manager()
tags = [resource_tag(dispatch_constants.RESOURCE_PERMISSION_TYPE, resource),
resource_tag(dispatch_constants.RESOURCE_USER_TYPE, login),
action_tag('grant_permission_to_user')]
call_request = CallRequest(permission_manager.grant,
[resource, login, operations],
tags=tags)
call_request.reads_resource(dispatch_constants.RESOURCE_USER_TYPE, login)
call_request.updates_resource(dispatch_constants.RESOURCE_PERMISSION_TYPE, resource)
return self.ok(execution.execute_sync(call_request))
示例8: DELETE
def DELETE(self, role_id, login):
role_manager = managers.role_manager()
tags = [resource_tag(dispatch_constants.RESOURCE_ROLE_TYPE, role_id),
action_tag('remove_user_from_role')]
call_request = CallRequest(role_manager.remove_user_from_role,
[role_id, login],
tags=tags,
archive=True)
call_request.updates_resource(dispatch_constants.RESOURCE_USER_TYPE, login)
call_request.reads_resource(dispatch_constants.RESOURCE_ROLE_TYPE, role_id)
return self.ok(execution.execute_sync(call_request))
示例9: DELETE
def DELETE(self, role_id, login):
role_manager = managers.role_manager()
resources = {dispatch_constants.RESOURCE_USER_TYPE: {login: dispatch_constants.RESOURCE_UPDATE_OPERATION},
dispatch_constants.RESOURCE_ROLE_TYPE: {role_id: dispatch_constants.RESOURCE_READ_OPERATION}}
tags = [resource_tag(dispatch_constants.RESOURCE_ROLE_TYPE, role_id),
action_tag('remove_user_from_role')]
call_request = CallRequest(role_manager.remove_user_from_role,
[role_id, login],
resources=resources,
tags=tags,
archive=True)
return self.ok(execution.execute_sync(call_request))
示例10: POST
def POST(self):
group_data = self.params()
group_id = group_data.pop('id', None)
if group_id is None:
raise pulp_exceptions.MissingValue(['id'])
display_name = group_data.pop('display_name', None)
description = group_data.pop('description', None)
consumer_ids = group_data.pop('consumer_ids', None)
notes = group_data.pop('notes', None)
if group_data:
raise pulp_exceptions.InvalidValue(group_data.keys())
manager = managers_factory.consumer_group_manager()
weight = pulp_config.config.getint('tasks', 'create_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, group_id)]
call_request = CallRequest(manager.create_consumer_group,
[group_id, display_name, description, consumer_ids, notes],
weight=weight, tags=tags)
call_request.creates_resource(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, group_id)
group = execution.execute_sync(call_request)
group.update(serialization.link.child_link_obj(group['id']))
return self.created(group['_href'], group)