[APIv2]Add ability to export templates to APIv2
The feature should be supported in both API versions. bp v2-api-experimental-impl bp portable-node-group-and-cluster-templates Change-Id: I102fb2ad16d0256e3a9aa364586332a13826cc90 Co-Authored-By: Iwona Kotlarska <pinus314@gmail.com>
This commit is contained in:
parent
bc2f5f03e2
commit
84b77958a1
|
@ -72,3 +72,26 @@ def cluster_templates_update(cluster_template_id, data):
|
|||
def cluster_templates_delete(cluster_template_id):
|
||||
api.terminate_cluster_template(cluster_template_id)
|
||||
return u.render()
|
||||
|
||||
|
||||
def _cluster_template_export_helper(template):
|
||||
template.pop('id')
|
||||
template.pop('updated_at')
|
||||
template.pop('created_at')
|
||||
template.pop('tenant_id')
|
||||
template.pop('is_default')
|
||||
template['default_image_id'] = '{default_image_id}'
|
||||
template['node_groups'] = '{node_groups}'
|
||||
|
||||
|
||||
@rest.get('/cluster-templates/<cluster_template_id>/export')
|
||||
@acl.enforce("data-processing:cluster-templates:get")
|
||||
@v.check_exists(api.get_cluster_template, 'cluster_template_id')
|
||||
def cluster_template_export(cluster_template_id):
|
||||
content = u.to_wrapped_dict_no_render(
|
||||
api.export_cluster_template, cluster_template_id)
|
||||
_cluster_template_export_helper(content['cluster_template'])
|
||||
res = u.render(content)
|
||||
res.headers.add('Content-Disposition', 'attachment',
|
||||
filename='cluster_template.json')
|
||||
return res
|
||||
|
|
|
@ -74,3 +74,28 @@ def node_group_templates_update(node_group_template_id, data):
|
|||
def node_group_templates_delete(node_group_template_id):
|
||||
api.terminate_node_group_template(node_group_template_id)
|
||||
return u.render()
|
||||
|
||||
|
||||
def _node_group_template_export_helper(template):
|
||||
template.pop('id')
|
||||
template.pop('updated_at')
|
||||
template.pop('created_at')
|
||||
template.pop('tenant_id')
|
||||
template.pop('is_default')
|
||||
template['flavor_id'] = '{flavor_id}'
|
||||
template['security_groups'] = '{security_groups}'
|
||||
template['image_id'] = '{image_id}'
|
||||
template['floating_ip_pool'] = '{floating_ip_pool}'
|
||||
|
||||
|
||||
@rest.get('/node-group-templates/<node_group_template_id>/export')
|
||||
@acl.enforce("data-processing:node-group-templates:get")
|
||||
@v.check_exists(api.get_node_group_template, 'node_group_template_id')
|
||||
def node_group_template_export(node_group_template_id):
|
||||
content = u.to_wrapped_dict_no_render(
|
||||
api.export_node_group_template, node_group_template_id)
|
||||
_node_group_template_export_helper(content['node_group_template'])
|
||||
res = u.render(content)
|
||||
res.headers.add('Content-Disposition', 'attachment',
|
||||
filename='node_group_template.json')
|
||||
return res
|
||||
|
|
|
@ -41,3 +41,7 @@ def terminate_cluster_template(id):
|
|||
|
||||
def update_cluster_template(id, values):
|
||||
return conductor.cluster_template_update(context.ctx(), id, values)
|
||||
|
||||
|
||||
def export_cluster_template(id):
|
||||
return conductor.cluster_template_get(context.ctx(), id)
|
||||
|
|
|
@ -41,3 +41,7 @@ def terminate_node_group_template(id):
|
|||
|
||||
def update_node_group_template(id, values):
|
||||
return conductor.node_group_template_update(context.ctx(), id, values)
|
||||
|
||||
|
||||
def export_node_group_template(id):
|
||||
return conductor.node_group_template_get(context.ctx(), id)
|
||||
|
|
Loading…
Reference in New Issue