本文整理汇总了Python中sahara.utils.api.render函数的典型用法代码示例。如果您正苦于以下问题:Python render函数的具体用法?Python render怎么用?Python render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clusters_delete
def clusters_delete(cluster_id):
data = u.request_data()
force = data.get('force', False)
stack_name = api.get_cluster(cluster_id).get(
'extra', {}).get(
'heat_stack_name', None)
api.terminate_cluster(cluster_id, force=force)
if force:
return u.render({"stack_name": stack_name}, status=200)
else:
return u.render(res=None, status=204)
示例2: clusters_scale
def clusters_scale(cluster_id, data):
result = u.to_wrapped_dict_no_render(
api.scale_cluster, cluster_id, data)
u._replace_hadoop_version_plugin_version(result['cluster'])
u._replace_tenant_id_project_id(result['cluster'])
_replace_tenant_id_project_id_provision_steps(result['cluster'])
return u.render(result)
示例3: clusters_create
def clusters_create(data):
# renaming hadoop_version -> plugin_version
# this can be removed once APIv1 is deprecated
data['hadoop_version'] = data['plugin_version']
del data['plugin_version']
if data.get('count', None) is not None:
result = api.create_multiple_clusters(data)
for c in result['clusters']:
u._replace_hadoop_version_plugin_version(c['cluster'])
u._replace_tenant_id_project_id(c['cluster'])
return u.render(result)
else:
result = api.create_cluster(data).to_wrapped_dict()
u._replace_hadoop_version_plugin_version(result['cluster'])
u._replace_tenant_id_project_id(result['cluster'])
return u.render(result)
示例4: job_templates_list
def job_templates_list():
result = api.get_job_templates(**u.get_request_args().to_dict())
for jt in result:
u._replace_tenant_id_project_id(jt)
_replace_tenant_id_project_id_job_binary(jt['mains'])
_replace_tenant_id_project_id_job_binary(jt['libs'])
return u.render(res=result, name='job_templates')
示例5: job_templates_update
def job_templates_update(job_templates_id, data):
result = {'job_template': api.update_job_template(
job_templates_id, data).to_dict()}
u._replace_tenant_id_project_id(result['job_template'])
_replace_tenant_id_project_id_job_binary(result['job_template']['mains'])
_replace_tenant_id_project_id_job_binary(result['job_template']['libs'])
return u.render(result)
示例6: version_list
def version_list():
context.set_ctx(None)
return api_utils.render({
"versions": [
{"id": "v1.0", "status": "CURRENT"}
]
})
示例7: clusters_delete
def clusters_delete(cluster_id, **kwargs):
all_tenants = kwargs.get('all_tenants', None)
if all_tenants:
ctx = context.ctx()
ctx.check_admin()
api.terminate_cluster(cluster_id)
return u.render()
示例8: jobs_execute
def jobs_execute(data):
result = {'job': api.execute_job(data)}
dict.update(result['job'],
{'engine_job_id': result['job']['oozie_job_id']})
dict.pop(result['job'], 'oozie_job_id')
u._replace_tenant_id_project_id(result['job'])
_replace_job_id_job_template_id(result['job'])
return u.render(result)
示例9: jobs_get
def jobs_get(job_id):
data = u.get_request_args()
refresh_status = six.text_type(
data.get('refresh_status', 'false')).lower() == 'true'
result = {'job': api.get_job_execution(job_id, refresh_status)}
result['job'].pop('oozie_job_id', force=True)
u._replace_tenant_id_project_id(result['job'])
_replace_job_id_job_template_id(result['job'])
return u.render(result)
示例10: job_types_get
def job_types_get():
# We want to use flat=False with to_dict() so that
# the value of each arg is given as a list. This supports
# filters of the form ?type=Pig&type=Java, etc.
request_args = u.get_request_args().to_dict(flat=False)
if 'plugin_version' in request_args:
request_args['hadoop_version'] = request_args['plugin_version']
del request_args['plugin_version']
return u.render(job_types=api.get_job_types(**request_args))
示例11: cluster_templates_update
def cluster_templates_update(cluster_template_id, data):
if data.get('plugin_version', None):
data['hadoop_version'] = data['plugin_version']
del data['plugin_version']
result = u.to_wrapped_dict_no_render(
api.update_cluster_template, cluster_template_id, data)
u._replace_hadoop_version_plugin_version(result['cluster_template'])
u._replace_tenant_id_project_id(result['cluster_template'])
return u.render(result)
示例12: cluster_templates_create
def cluster_templates_create(data):
# renaming hadoop_version -> plugin_version
# this can be removed once APIv1 is deprecated
data['hadoop_version'] = data['plugin_version']
del data['plugin_version']
result = api.create_cluster_template(data).to_wrapped_dict()
u._replace_hadoop_version_plugin_version(result['cluster_template'])
u._replace_tenant_id_project_id(result['cluster_template'])
return u.render(result)
示例13: cluster_template_export
def cluster_template_export(cluster_template_id):
content = u.to_wrapped_dict_no_render(
api.export_cluster_template, cluster_template_id)
u._replace_hadoop_version_plugin_version(content['cluster_template'])
u._replace_tenant_id_project_id(content['cluster_template'])
_cluster_template_export_helper(content['cluster_template'])
res = u.render(content)
res.headers.add('Content-Disposition', 'attachment',
filename='cluster_template.json')
return res
示例14: clusters_get
def clusters_get(cluster_id):
data = u.get_request_args()
show_events = six.text_type(
data.get('show_progress', 'false')).lower() == 'true'
result = u.to_wrapped_dict_no_render(
api.get_cluster, cluster_id, show_events)
u._replace_hadoop_version_plugin_version(result['cluster'])
u._replace_tenant_id_project_id(result['cluster'])
_replace_tenant_id_project_id_provision_steps(result['cluster'])
return u.render(result)
示例15: jobs_list
def jobs_list():
result = api.job_execution_list(**u.get_request_args().to_dict())
# APIv2: renaming oozie_job_id -> engine_job_id
# once APIv1 is deprecated this can be
# removed
for je in result:
je.pop('oozie_job_id', force=True)
u._replace_tenant_id_project_id(je)
_replace_job_id_job_template_id(je)
return u.render(res=result, name='jobs')