本文整理汇总了Python中pulp.server.dispatch.call.CallRequest.creates_resource方法的典型用法代码示例。如果您正苦于以下问题:Python CallRequest.creates_resource方法的具体用法?Python CallRequest.creates_resource怎么用?Python CallRequest.creates_resource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.server.dispatch.call.CallRequest
的用法示例。
在下文中一共展示了CallRequest.creates_resource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: POST
# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import creates_resource [as 别名]
def POST(self, repo_id):
# Params (validation will occur in the manager)
params = self.params()
distributor_type = params.get('distributor_type_id', None)
distributor_config = params.get('distributor_config', None)
distributor_id = params.get('distributor_id', None)
auto_publish = params.get('auto_publish', False)
# Update the repo
distributor_manager = manager_factory.repo_distributor_manager()
weight = pulp_config.config.getint('tasks', 'create_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
action_tag('add_distributor')]
if distributor_id is not None:
tags.append(resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id))
call_request = CallRequest(distributor_manager.add_distributor,
[repo_id, distributor_type],
{'repo_plugin_config': distributor_config, 'auto_publish': auto_publish,
'distributor_id': distributor_id},
weight=weight,
tags=tags,
kwarg_blacklist=['repo_plugin_config'])
call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id)
if distributor_id is not None:
call_request.creates_resource(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id)
return execution.execute_created(self, call_request, distributor_id)
示例2: POST
# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import creates_resource [as 别名]
def POST(self):
body = self.params()
id = body.get('id')
display_name = body.get('display_name')
description = body.get('description')
notes = body.get('notes')
manager = managers.consumer_manager()
args = [id, display_name, description, notes]
weight = pulp_config.config.getint('tasks', 'create_weight')
tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, id),
action_tag('create')]
call_request = CallRequest(manager.register,
args,
weight=weight,
tags=tags)
call_request.creates_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, id)
call_report = CallReport.from_call_request(call_request)
call_report.serialize_result = False
consumer = execution.execute_sync(call_request, call_report)
consumer.update({'_href': serialization.link.child_link_obj(consumer['id'])})
return self.created(consumer['_href'], consumer)
示例3: POST
# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import creates_resource [as 别名]
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)
示例4: POST
# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import creates_resource [as 别名]
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)
示例5: POST
# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import creates_resource [as 别名]
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()
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,
weight=weight,
tags=tags,
kwarg_blacklist=['password'])
call_request.creates_resource(dispatch_constants.RESOURCE_USER_TYPE, login)
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)
示例6: POST
# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import creates_resource [as 别名]
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)