From 99e85e14e645c9044aae412bf8aa9bc13bc3adbb Mon Sep 17 00:00:00 2001 From: wenxin Date: Thu, 27 Apr 2023 17:41:18 +0800 Subject: [PATCH] fix script bug and add validation rules (cherry picked from commit 7dd30863c11d48136ac5872297b11c12fc90e817) --- 0001-fix-script-docker-install-error.patch | 104 +++++++++++++++++++++ 0002-add-custom-validation-rules.patch | 78 ++++++++++++++++ aops-vulcanus.spec | 9 +- 3 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 0001-fix-script-docker-install-error.patch create mode 100644 0002-add-custom-validation-rules.patch diff --git a/0001-fix-script-docker-install-error.patch b/0001-fix-script-docker-install-error.patch new file mode 100644 index 0000000..211a9ea --- /dev/null +++ b/0001-fix-script-docker-install-error.patch @@ -0,0 +1,104 @@ +From 5ecf2c9769dc81b1a9da2c4ef1821184766a370b Mon Sep 17 00:00:00 2001 +From: gongzt +Date: Mon, 24 Apr 2023 09:36:25 +0800 +Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E9=94=AE=E9=83=A8?= + =?UTF-8?q?=E7=BD=B2=E4=B8=AD=E6=A3=80=E6=9F=A5docker=E3=80=81docker-compo?= + =?UTF-8?q?se=E5=AE=89=E8=A3=85=E7=9A=84=E9=94=99=E8=AF=AF=EF=BC=8C?= + =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=A4=E4=BA=92=E5=BC=8F=E5=91=BD=E4=BB=A4?= + =?UTF-8?q?=E4=B8=AD=E6=A0=87=E8=AF=86=E7=AC=A6=E9=94=99=E8=AF=AF?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + .../deploy/container/aops-apollo/Dockerfile | 2 +- + .../deploy/container/aops-diana/Dockerfile | 2 +- + scripts/deploy/container/run.sh | 22 ++++++++++++------- + 3 files changed, 16 insertions(+), 10 deletions(-) + +diff --git a/scripts/deploy/container/aops-apollo/Dockerfile b/scripts/deploy/container/aops-apollo/Dockerfile +index 996b7ec..ea0a3fc 100644 +--- a/scripts/deploy/container/aops-apollo/Dockerfile ++++ b/scripts/deploy/container/aops-apollo/Dockerfile +@@ -1,5 +1,5 @@ + FROM openeuler/openeuler:22.03-lts-sp1 + WORKDIR /app +-COPY *.repo /app/ ++COPY * /app/ + RUN dnf install aops-apollo -y --setopt=reposdir=/app + CMD ["/bin/bash","/app/start.sh"] +\ No newline at end of file +diff --git a/scripts/deploy/container/aops-diana/Dockerfile b/scripts/deploy/container/aops-diana/Dockerfile +index 03297ec..9e9eef9 100644 +--- a/scripts/deploy/container/aops-diana/Dockerfile ++++ b/scripts/deploy/container/aops-diana/Dockerfile +@@ -1,5 +1,5 @@ + FROM openeuler/openeuler:22.03-lts-sp1 + WORKDIR /app +-COPY *.repo /app/ ++COPY * /app/ + RUN dnf install aops-diana -y --setopt=reposdir=/app + CMD ["/bin/bash","/app/start.sh"] +\ No newline at end of file +diff --git a/scripts/deploy/container/run.sh b/scripts/deploy/container/run.sh +index c32a57a..581c0bc 100755 +--- a/scripts/deploy/container/run.sh ++++ b/scripts/deploy/container/run.sh +@@ -44,10 +44,6 @@ prometheus(){ + docker_build(){ + copy_aops_conf + prepare_dockerfile_repo +- storage_mysql_data +- storage_es_data +- prometheus +- docker-compose -f docker-compose-base-service.yml build --no-cache + docker-compose build --no-cache + rm ./aops-apollo/*.repo + rm ./aops-diana/*.repo +@@ -56,14 +52,21 @@ docker_build(){ + } + + install_docker_compose(){ +- installed_docker_compose=`rpm -ql docker-compose` +- if [ "$(echo $installed_docker_compose | grep "is not installed")" != "" ]; then ++ docker_compose_installed=`rpm -q docker-compose` ++ if [ $? -ne 0 ] ; then + dnf install docker-compose -y ++ else ++ echo "docker-compose is already installed." ++ fi ++ docker_installed=`rpm -q docker` ++ if [ $? -ne 0 ] ; then ++ dnf install docker -y ++ else ++ echo "docker is already installed." + fi + } + + main(){ +- + install_docker_compose + while : + do +@@ -71,7 +74,7 @@ main(){ + echo "1. Build the docker container (build)." + echo "2. Start the container orchestration service (start-service/start-env)." + echo "3. Stop all container services (stop-service/stop-env)." +- read "Enter to exit the operation (Q/q)." ++ echo "Enter to exit the operation (Q/q)." + read -p "Select an operation procedure to continue: " operation + case $operation in + "build") +@@ -82,6 +85,9 @@ main(){ + docker-compose up -d + ;; + "start-env") ++ prometheus ++ storage_es_data ++ storage_mysql_data + docker-compose -f docker-compose-base-service.yml up -d + ;; + "stop-service") +-- +Gitee + diff --git a/0002-add-custom-validation-rules.patch b/0002-add-custom-validation-rules.patch new file mode 100644 index 0000000..e65dfa7 --- /dev/null +++ b/0002-add-custom-validation-rules.patch @@ -0,0 +1,78 @@ +From e1a72048bed334ff2e5014e2437598aa5580760f Mon Sep 17 00:00:00 2001 +From: rabbitali +Date: Wed, 26 Apr 2023 19:25:32 +0800 +Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= + =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99;=E6=B7=BB=E5=8A=A0?= + =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95=E6=8E=A5?= + =?UTF-8?q?=E5=8F=A3=E7=9A=84=E8=B7=AF=E7=94=B1?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + vulcanus/conf/constant.py | 1 + + vulcanus/restful/serialize/validate.py | 31 ++++++++++++++++++++++++++ + 2 files changed, 32 insertions(+) + +diff --git a/vulcanus/conf/constant.py b/vulcanus/conf/constant.py +index 9779602..7185685 100644 +--- a/vulcanus/conf/constant.py ++++ b/vulcanus/conf/constant.py +@@ -53,6 +53,7 @@ GET_GROUP = "/manage/host/group/get" + COLLECT_CONFIG = '/manage/config/collect' + + USER_LOGIN = "/manage/account/login" ++LOGOUT = "/manage/account/logout" + CHANGE_PASSWORD = '/manage/account/change' + ADD_USER = '/manage/account/add' + GITEE_AUTH_LOGIN = "/manage/account/gitee/login" +diff --git a/vulcanus/restful/serialize/validate.py b/vulcanus/restful/serialize/validate.py +index bfe25ad..1c00804 100644 +--- a/vulcanus/restful/serialize/validate.py ++++ b/vulcanus/restful/serialize/validate.py +@@ -15,6 +15,7 @@ Time: + Author: + Description: + """ ++import re + from marshmallow import ValidationError + + +@@ -42,3 +43,33 @@ def validate(verifier, data, load=False): + errors = verifier().validate(data) + + return result, errors ++ ++ ++class ValidateRules: ++ """ ++ Custom validation rules ++ """ ++ ++ @staticmethod ++ def space_character_check(string: str) -> None: ++ """ ++ one of validation rules for string, no spaces are allowed at the beginning or end. ++ """ ++ if len(string.strip()) != len(string): ++ raise ValidationError("there may be space character exists at the beginning or end!") ++ ++ @staticmethod ++ def account_name_check(string: str) -> None: ++ """ ++ validation rules for username, which only contains string or number ++ """ ++ if not re.findall("[a-zA-Z0-9]{5,20}", string): ++ raise ValidationError("username should only contains string or number, between 5 and 20 characters!") ++ ++ @staticmethod ++ def account_password_check(string: str) -> None: ++ """ ++ validation rules for password, which only contains string or number ++ """ ++ if not re.findall("[a-zA-Z0-9]{6,20}", string): ++ raise ValidationError("password should only contains string or number, between 6 and 20 characters!!") +\ No newline at end of file +-- +Gitee + diff --git a/aops-vulcanus.spec b/aops-vulcanus.spec index af88331..92740bb 100644 --- a/aops-vulcanus.spec +++ b/aops-vulcanus.spec @@ -1,10 +1,12 @@ Name: aops-vulcanus Version: v1.2.0 -Release: 1 +Release: 2 Summary: A basic tool libraries of aops, including logging, configure and response, etc. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} Source0: %{name}-%{version}.tar.gz +Patch0001: 0001-fix-script-docker-install-error.patch +Patch0002: 0002-add-custom-validation-rules.patch BuildRequires: python3-setuptools Requires: python3-concurrent-log-handler python3-xmltodict python3-pyyaml python3-marshmallow >= 3.13.0 @@ -29,7 +31,7 @@ tools for aops, it's about aops deploy %prep -%autosetup -n %{name}-%{version} +%autosetup -n %{name}-%{version} -p1 # build for aops-vulcanus @@ -59,6 +61,9 @@ cp -r scripts %{buildroot}/opt/aops/ %changelog +* Thu Apr 27 2023 wenixn - v1.2.0-2 +- add custom validation rules;fix script docker install error + * Mon Apr 17 2023 wenixn - v1.2.0-1 - update token authentication method; update the structure of response body - update database connect method -- Gitee