def expression_update_post(): expression_id = request.form['expression_id'].strip() expression = request.form['expression'].strip() func = request.form['func'].strip() op = request.form['op'].strip() right_value = request.form['right_value'].strip() uic_groups = request.form['uic'].strip() max_step = request.form['max_step'].strip() priority = int(request.form['priority'].strip()) note = request.form['note'].strip() url = request.form['url'].strip() callback = request.form['callback'].strip() before_callback_sms = request.form['before_callback_sms'] before_callback_mail = request.form['before_callback_mail'] after_callback_sms = request.form['after_callback_sms'] after_callback_mail = request.form['after_callback_mail'] msg = required_chk({ 'expression': expression, 'func': func, 'op': op, 'right_value': right_value, }) if msg: return jsonify(msg=msg) if not max_step: max_step = 3 if not priority: priority = 0 return jsonify(msg=Expression.save_or_update( expression_id, expression, func, op, right_value, uic_groups, max_step, priority, note, url, callback, before_callback_sms, before_callback_mail, after_callback_sms, after_callback_mail, g.user_name, ))
def expression_update_post(): expression_id = request.form["expression_id"].strip() expression = request.form["expression"].strip() func = request.form["func"].strip() op = request.form["op"].strip() right_value = request.form["right_value"].strip() uic_groups = request.form["uic"].strip() max_step = request.form["max_step"].strip() priority = int(request.form["priority"].strip()) note = request.form["note"].strip() url = request.form["url"].strip() callback = request.form["callback"].strip() before_callback_sms = request.form["before_callback_sms"] before_callback_mail = request.form["before_callback_mail"] after_callback_sms = request.form["after_callback_sms"] after_callback_mail = request.form["after_callback_mail"] msg = required_chk({"expression": expression, "func": func, "op": op, "right_value": right_value}) if msg: return jsonify(msg=msg) if not max_step: max_step = 3 if not priority: priority = 0 return jsonify( msg=Expression.save_or_update( expression_id, expression, func, op, right_value, uic_groups, max_step, priority, note, url, callback, before_callback_sms, before_callback_mail, after_callback_sms, after_callback_mail, g.user_name, ) )
def cluster_node_post(group_id): group_id = int(group_id) group = HostGroup.read(where='id = %s', params=[group_id]) if not group: return jsonify(msg='no such group %s' % group_id) numerator = request.form['numerator'].strip() denominator = request.form['denominator'].strip() endpoint = request.form['endpoint'].strip() metric = request.form['metric'].strip() tags = request.form['tags'].strip() ds_type = 'GAUGE' step = request.form['step'].strip() msg = required_chk({ 'numerator': numerator, 'denominator': denominator, 'endpoint': endpoint, 'metric': metric, 'ds_type': ds_type, 'step': step, }) if msg: return jsonify(msg=msg) if Cluster.exists('endpoint=%s and metric=%s and tags=%s', [endpoint, metric, tags]): return jsonify(msg='%s/%s/%s is already existent' % (endpoint, metric, tags)) last_id = Cluster.insert({ 'grp_id': group_id, 'numerator': numerator, 'denominator': denominator, 'endpoint': endpoint, 'metric': metric, 'tags': tags, 'ds_type': ds_type, 'step': step, 'creator': g.user_name, }) if last_id > 0: return jsonify(msg='') else: return jsonify(msg='occur error')
def nodata_update_post(): nodata_id = request.form['nodata_id'].strip() name = request.form['name'].strip() obj = request.form['obj'].strip() obj_type = request.form['obj_type'].strip() metric = request.form['metric'].strip() tags = request.form['tags'].strip() dstype = request.form['dstype'].strip() step = request.form['step'].strip() mock = request.form['mock'].strip() msg = required_chk({ 'name' : name, 'endpoint' : obj, 'endpoint_type' : obj_type, 'metric' : metric, 'type' : dstype, 'step' : step, 'mock_value': mock, }) if msg: return jsonify(msg=msg) return jsonify(msg=Nodata.save_or_update( nodata_id, name, obj, obj_type, metric, tags, dstype, step, mock, g.user_name, ))
def nodata_update_post(): nodata_id = request.form['nodata_id'].strip() name = request.form['name'].strip() obj = request.form['obj'].strip() obj_type = request.form['obj_type'].strip() metric = request.form['metric'].strip() tags = request.form['tags'].strip() dstype = request.form['dstype'].strip() step = request.form['step'].strip() mock = request.form['mock'].strip() msg = required_chk({ 'name': name, 'endpoint': obj, 'endpoint_type': obj_type, 'metric': metric, 'type': dstype, 'step': step, 'mock_value': mock, }) if msg: return jsonify(msg=msg) return jsonify(msg=Nodata.save_or_update( nodata_id, name, obj, obj_type, metric, tags, dstype, step, mock, g.user_name, ))