!86 [sync] PR-85: update verification method for adding host or updating host info and fix timedcorrect task bug

From: @openeuler-sync-bot 
Reviewed-by: @Lostwayzxc 
Signed-off-by: @Lostwayzxc
This commit is contained in:
openeuler-ci-bot 2023-12-20 01:59:23 +00:00 committed by Gitee
commit 575d81a8bf
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 104 additions and 1 deletions

View File

@ -0,0 +1,27 @@
From cb3af79a8237c6b7e083dc8ba7d324bddf395e08 Mon Sep 17 00:00:00 2001
From: rearcher <123781007@qq.com>
Date: Tue, 19 Dec 2023 10:59:30 +0800
Subject: [PATCH] fix apollo TimedCorrectTask
---
zeus/database/proxy/host.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/zeus/database/proxy/host.py b/zeus/database/proxy/host.py
index 441ef21..471390e 100644
--- a/zeus/database/proxy/host.py
+++ b/zeus/database/proxy/host.py
@@ -372,7 +372,9 @@ class HostProxy(MysqlProxy):
Host.pkey,
Host.ssh_user,
]
- filters = {Host.user == username}
+ filters = set()
+ if username:
+ filters = {Host.user == username}
if host_list:
filters.add(Host.host_id.in_(host_list))
try:
--
2.33.0

View File

@ -0,0 +1,70 @@
From 82cd9883bbf5fc95ca1bd38c36a8a2066aeaa4a1 Mon Sep 17 00:00:00 2001
From: rabbitali <wenxin32@foxmail.com>
Date: Tue, 19 Dec 2023 11:02:31 +0800
Subject: [PATCH] update verification method for adding host or updating host
info
---
zeus/function/verify/host.py | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/zeus/function/verify/host.py b/zeus/function/verify/host.py
index 461fc12..310373c 100644
--- a/zeus/function/verify/host.py
+++ b/zeus/function/verify/host.py
@@ -16,9 +16,7 @@ Author:
Description: For host related interfaces
"""
from vulcanus.restful.serialize.validate import ValidateRules
-from marshmallow import Schema
-from marshmallow import fields
-from marshmallow import validate
+from marshmallow import fields, Schema, validate, validates_schema, ValidationError
class HostSchema(Schema):
@@ -111,7 +109,7 @@ class AddHostSchema(Schema):
validators for parameter of /manage/host/add
"""
- ssh_user = fields.String(required=True, validate=lambda s: len(s) > 0)
+ ssh_user = fields.String(required=True, validate=lambda s: 32 >= len(s) > 0)
password = fields.String(required=True, allow_none=True, validate=lambda s: len(s) >= 0)
host_name = fields.String(
required=True, validate=[validate.Length(min=1, max=50), ValidateRules.space_character_check]
@@ -119,8 +117,13 @@ class AddHostSchema(Schema):
host_ip = fields.IP(required=True)
ssh_pkey = fields.String(required=True, allow_none=True, validate=lambda s: 4096 >= len(s) >= 0)
ssh_port = fields.Integer(required=True, validate=lambda s: 65535 >= s > 0)
- host_group_name = fields.String(required=True, validate=lambda s: len(s) > 0)
- management = fields.Boolean(required=True)
+ host_group_name = fields.String(required=True, validate=lambda s: 20 >= len(s) > 0)
+ management = fields.Boolean(required=True, truthy={True}, falsy={False})
+
+ @validates_schema
+ def check_authentication_info(self, data, **kwargs):
+ if not data.get("ssh_pkey") and not data.get("password"):
+ raise ValidationError("At least one of the password and key needs to be provided")
class AddHostBatchSchema(Schema):
@@ -137,10 +140,12 @@ class UpdateHostSchema(Schema):
"""
host_id = fields.Integer(required=True, validate=lambda s: s > 0)
- ssh_user = fields.String(required=False, validate=lambda s: len(s) > 0)
+ ssh_user = fields.String(required=False, validate=lambda s: 32 >= len(s) > 0)
password = fields.String(required=False, validate=lambda s: len(s) > 0)
ssh_port = fields.Integer(required=False, validate=lambda s: 65535 >= s > 0)
- host_name = fields.String(required=False, validate=lambda s: len(s) > 0)
- host_group_name = fields.String(required=False, validate=lambda s: len(s) > 0)
- management = fields.Boolean(required=False)
+ host_name = fields.String(
+ required=True, validate=[validate.Length(min=1, max=50), ValidateRules.space_character_check]
+ )
+ host_group_name = fields.String(required=False, validate=lambda s: 20 >= len(s) > 0)
+ management = fields.Boolean(required=False, truthy={True}, falsy={False})
ssh_pkey = fields.String(required=False, validate=lambda s: 4096 >= len(s) >= 0)
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: aops-zeus
Version: v1.4.0
Release: 2
Release: 3
Summary: A host and user manager service which is the foundation of aops.
License: MulanPSL2
URL: https://gitee.com/openeuler/%{name}
@ -9,6 +9,8 @@ Patch0001: 0001-add-interface-for-detecting-host-status.patch
Patch0002: 0002-update-the-query-host-list-api.patch
Patch0003: 0003-fix-search_key-validate.patch
Patch0004: 0004-add-rollback-task-execution-method.patch
Patch0005: 0005-fix-apollo-TimedCorrectTask.patch
Patch0006: 0006-update-verification-method-for-adding-host.patch
BuildRequires: python3-setuptools
@ -49,6 +51,10 @@ cp -r database %{buildroot}/opt/aops/
%changelog
* Tue Dec 19 2023 wenxin<wenxin32@foxmail.com> - v1.4.0-3
- update verification method for adding host or updating host info
- fix apollo TimedCorrectTask
* Mon Dec 18 2023 wenxin<wenxin32@foxmail.com> - v1.4.0-2
- Add interface for detecting host status.
- Update query host list api, add a new query method based on host name for it.