def cluster_edit_post(cluster_id): cluster_id = int(cluster_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() grp_id = request.form['grp_id'].strip() if cluster_id: # edit if Cluster.exists('endpoint=%s and metric=%s and tags=%s and id<>%s', [endpoint, metric, tags, cluster_id]): return jsonify(msg='%s/%s/%s has already existent' % (endpoint, metric, tags)) Cluster.update_dict( { 'numerator': numerator, 'denominator': denominator, 'endpoint': endpoint, 'metric': metric, 'tags': tags, 'ds_type': ds_type, 'step': step, }, 'id=%s', [cluster_id]) else: # clone last_id = Cluster.insert({ 'numerator': numerator, 'denominator': denominator, 'endpoint': endpoint, 'metric': metric, 'tags': tags, 'ds_type': ds_type, 'step': step, 'creator': g.user_name, 'grp_id': grp_id, }) if last_id <= 0: return jsonify(msg='occur error') return jsonify(msg='')
def cluster_edit_post(cluster_id): cluster_id = int(cluster_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() grp_id = request.form['grp_id'].strip() if cluster_id: # edit if Cluster.exists('endpoint=%s and metric=%s and tags=%s and id<>%s', [endpoint, metric, tags, cluster_id]): return jsonify(msg='%s/%s/%s has already existent' % (endpoint, metric, tags)) Cluster.update_dict({ 'numerator': numerator, 'denominator': denominator, 'endpoint': endpoint, 'metric': metric, 'tags': tags, 'ds_type': ds_type, 'step': step, }, 'id=%s', [cluster_id]) else: # clone last_id = Cluster.insert({ 'numerator': numerator, 'denominator': denominator, 'endpoint': endpoint, 'metric': metric, 'tags': tags, 'ds_type': ds_type, 'step': step, 'creator': g.user_name, 'grp_id': grp_id, }) if last_id <= 0: return jsonify(msg='occur error') return jsonify(msg='')