def update_actions(): handler = ApiPortal() rep_data = json.loads(request.data) grp_name = rep_data["informs"].strip() tem_name = rep_data["name"].strip() # actions = rep_data["actions"].strip() if not handler.api_get_template(tem_name): abort(404) if not handler.api_update_user_strategy(grp_name, tem_name): abort(500) return jsonify(msg="success",action="update"),200
def update_template(): handler = ApiPortal() handler_vm = SQLHandler() rep_data = json.loads(request.data) tem_name = rep_data["name"].strip() new_name = rep_data["new_name"].strip() interval = rep_data["interval_time"].strip() interval_begin = handler.api_get_template_interval(tem_name) host_list = handler.api_get_host_from_template(tem_name) if int(interval_begin) != int(interval): if host_list: for host in host_list: handler_vm.update_db("interval_time",interval_time=interval,hostname=host) if not handler.api_update_template(tem_name, new_name, interval): abort(500) data = handler.api_get_template(new_name) return jsonify(msg="success",data=data,action="update"),200
def delete_template(): handler = ApiPortal() rep_data = json.loads(request.data) tem = rep_data["name"].strip() data = handler.api_get_template(tem) if not data: abort(404) # unlink host group with template if not _unbind_template_group(tem,tem): abort(500) # remove host group if not _delete_host_group(tem): abort(500) # remove template if not handler.api_delete_template(tem): abort(500) return jsonify(msg="success",data=data,action="delete"),200
def create_template(): handler = ApiPortal() ####### need review !!! rep_data = json.loads(request.data) tem = rep_data["name"].strip() interval = rep_data["interval"].strip() print tem print interval #create template if not handler.api_create_template(tem,interval): abort(500) # create host group,the name is same with template if not _create_host_group(tem): abort(500) # link host group with template if not _bind_template_group(tem, tem): abort(500) data = handler.api_get_template(tem) return jsonify(msg='success',data = data, action= "create"),200
def get_template(tem_name): handler = ApiPortal() data = handler.api_get_template(tem_name) if not data: abort(404) return jsonify(msg="success",data=data),200