diff --git a/app/modules/db/ha_cluster.py b/app/modules/db/ha_cluster.py index 3fc2371a..0455c255 100644 --- a/app/modules/db/ha_cluster.py +++ b/app/modules/db/ha_cluster.py @@ -65,6 +65,8 @@ def select_cluster_vip(cluster_id: int, router_id: int) -> HaClusterVip: def select_cluster_vip_by_vip_id(cluster_id: int, vip_id: int) -> HaClusterVip: try: return HaClusterVip.get((HaClusterVip.cluster_id == cluster_id) & (HaClusterVip.id == vip_id)) + except HaClusterVip.DoesNotExist: + raise RoxywiResourceNotFound except Exception as e: out_error(e) diff --git a/app/modules/roxywi/class_models.py b/app/modules/roxywi/class_models.py index c7da7b19..4ba4a555 100644 --- a/app/modules/roxywi/class_models.py +++ b/app/modules/roxywi/class_models.py @@ -207,9 +207,8 @@ class ChannelRequest(BaseModel): class ServerInstall(BaseModel): - ip: Union[IPvAnyAddress, DomainName] + id: int master: Optional[bool] = 0 - name: EscapedString class ServiceInstall(BaseModel): diff --git a/app/modules/service/ha_cluster.py b/app/modules/service/ha_cluster.py index efc19b3b..263f156e 100644 --- a/app/modules/service/ha_cluster.py +++ b/app/modules/service/ha_cluster.py @@ -284,7 +284,7 @@ def _create_or_update_master_slaves_servers(cluster_id: int, servers: dict, rout roxywi_common.logging(cluster_id, f'New server {s.hostname} has been added to the cluster', keep_history=1, roxywi=1, service='HA cluster') except Exception as e: - raise Exception(f'error: Cannot update slave server {server["ip"]}: {e}') + raise Exception(f'error: Cannot update slave server {s.hostname}: {e}') if server['master']: continue diff --git a/app/static/js/install.js b/app/static/js/install.js index 79e5b714..41e11824 100644 --- a/app/static/js/install.js +++ b/app/static/js/install.js @@ -151,9 +151,10 @@ function installService(service) { } let jsonData = {}; let server = { - "ip": $(select_id).val(), + // "ip": $(select_id).val(), "master": '0', - "name": $(select_id + ' option:selected').text(), + "id": $(select_id + ' option:selected').attr('data-id'), + // "name": $(select_id + ' option:selected').text(), } if (service === 'haproxy') { server['version'] = $('#hapver option:selected').val(); diff --git a/app/templates/install.html b/app/templates/install.html index 461b40af..c79181f2 100644 --- a/app/templates/install.html +++ b/app/templates/install.html @@ -46,7 +46,7 @@ @@ -81,7 +81,7 @@ @@ -116,7 +116,7 @@ @@ -223,8 +223,8 @@ {% set values = dict() %} - {% set values = {'0.7.0':'0.7.0', '0.9.0':'0.9.0', '0.10.0':'0.10.0', '0.11.0':'0.11.0', '1.0.0':'1.0.0', '1.1.0':'1.1.0'} %} - {{ select('nginxexpver', values=values, selected='1.1.0') }} + {% set values = {'0.11.0':'0.11.0', '1.0.0':'1.0.0', '1.1.0':'1.1.0', '1.2.0':'1.2.0', '1.3.0':'1.3.0'} %} + {{ select('nginxexpver', values=values, selected='1.3.0') }} diff --git a/app/views/ha/views.py b/app/views/ha/views.py index f39f0131..458dca9c 100644 --- a/app/views/ha/views.py +++ b/app/views/ha/views.py @@ -475,7 +475,10 @@ class HAVIPView(MethodView): default: description: Unexpected error """ - vip = ha_sql.select_cluster_vip_by_vip_id(cluster_id, vip_id) + try: + vip = ha_sql.select_cluster_vip_by_vip_id(cluster_id, vip_id) + except Exception as e: + return roxywi_common.handler_exceptions_for_json_data(e, 'Cannot find VIP') try: ha_cluster.update_vip(cluster_id, vip.router_id, body, self.group_id) return BaseResponse().model_dump(mode='json'), 201 diff --git a/app/views/install/views.py b/app/views/install/views.py index f8f255d2..b02cdbfb 100644 --- a/app/views/install/views.py +++ b/app/views/install/views.py @@ -46,8 +46,8 @@ class InstallView(MethodView): items: type: 'object' properties: - ip: - type: 'string' + id: + type: 'integer' name: type: 'string' services: