def make_json_error(ex): status_code = (ex.code if isinstance(ex, HTTPException) else 500) description = (ex.description if isinstance(ex, HTTPException) else str(ex)) return render({'error': status_code, 'error_message': description}, status=status_code)
def clusters_create(): data = request_data() try: return render(api.create_cluster(data).wrapped_dict) except Exception, e: abort_and_log(500, "Exception while adding new Cluster", e)
def clusters_list(): try: return render(clusters=[c.dict for c in api.get_clusters()]) except Exception, e: abort_and_log(500, 'Exception while listing Clusters', e)
def templates_delete(template_id): api.terminate_node_template(id=template_id) return render()
def templates_create(): data = request_data() try: return render(api.create_node_template(data).wrapped_dict) except Exception, e: abort_and_log(500, "Exception while adding NodeTemplate", e)
def templates_list(): try: return render( node_templates=[nt.dict for nt in api.get_node_templates()]) except Exception, e: abort_and_log(500, "Exception while listing NodeTemplates", e)
def clusters_delete(cluster_id): api.terminate_cluster(id=cluster_id) return render()
abort_and_log(500, "Exception while adding NodeTemplate", e) @rest.get('/node-templates/<template_id>') def templates_get(template_id): nt = None try: nt = api.get_node_template(id=template_id) except Exception, e: abort_and_log(500, "Exception while getting NodeTemplate by id " "'%s'" % template_id, e) if nt is None: abort_and_log(404, "NodeTemplate with id '%s' not found" % template_id) return render(nt.wrapped_dict) @rest.put('/node-templates/<template_id>') def templates_update(template_id): raise NotImplementedError("Template update op isn't implemented (id '%s')" % template_id) @rest.delete('/node-templates/<template_id>') def templates_delete(template_id): api.terminate_node_template(id=template_id) return render() @rest.get('/clusters')