diff --git a/app/modules/service/ha_cluster.py b/app/modules/service/ha_cluster.py index 263f156e..8de9dbe9 100644 --- a/app/modules/service/ha_cluster.py +++ b/app/modules/service/ha_cluster.py @@ -144,7 +144,6 @@ def update_vip(cluster_id: int, router_id: int, cluster: Union[HAClusterRequest, s = server_sql.get_server_by_id(value['id']) raise Exception(f'error: Cannot add server {s.hostname}: {e}') - print('cluster.virt_server',cluster.virt_server) if cluster.virt_server: add_or_update_virt(cluster, servers, cluster_id, vip_id, group_id) else: diff --git a/app/routes/ha/routes.py b/app/routes/ha/routes.py index b515c469..0db50c20 100644 --- a/app/routes/ha/routes.py +++ b/app/routes/ha/routes.py @@ -112,12 +112,13 @@ def show_ha_cluster(service, cluster_id): return render_template('service.html', **kwargs) -@bp.route('//slaves//', methods=['GET', 'POST']) +@bp.route('//slaves/', defaults={'vip_id': False}, methods=['GET']) +@bp.route('//slaves//', methods=['GET']) @check_services @get_user_params() def get_slaves(service, cluster_id, vip_id): lang = g.user_params['lang'] - if request.method == 'GET': + if not vip_id: router_id = ha_sql.get_router_id(cluster_id, default_router=1) else: vip = ha_sql.select_cluster_vip_by_vip_id(cluster_id, vip_id) diff --git a/app/static/js/ha.js b/app/static/js/ha.js index db30e2ab..e45bdb38 100644 --- a/app/static/js/ha.js +++ b/app/static/js/ha.js @@ -507,7 +507,6 @@ function add_vip_ha_cluster(cluster_id, cluster_name, vip_id='', vip='', edited= let save_word = translate_div.attr('data-save'); let tabel_title = $("#add-vip-table").attr('title'); let buttons = []; - let req_method = 'GET'; if (edited) { $.ajax({ url: api_prefix + "/ha/cluster/" + cluster_id + "/vip/" + vip_id, @@ -534,7 +533,6 @@ function add_vip_ha_cluster(cluster_id, cluster_name, vip_id='', vip='', edited= } }); $('#vrrp-ip-add').val(vip); - req_method = 'POST'; tabel_title = $("#add-vip-table").attr('data-edit'); buttons = [{ text: save_word, @@ -593,9 +591,12 @@ function add_vip_ha_cluster(cluster_id, cluster_name, vip_id='', vip='', edited= } }] } + let url = "/ha/cluster/slaves/" + cluster_id; + if (vip_id) { + url = "/ha/cluster/slaves/" + cluster_id + "/" + vip_id; + } $.ajax({ - url: "/ha/cluster/slaves/" + cluster_id + "/" + vip_id, - type: req_method, + url: url, success: function (data) { if (data.indexOf('error:') != '-1') { toastr.error(data);