aops-vulcanus/0005-suitable-for-version-2003-sp3.patch
2023-11-16 10:45:32 +08:00

197 lines
8.2 KiB
Diff

From 91490e80fe9c6deb16042a2919f3c916ce274e1e Mon Sep 17 00:00:00 2001
From: gongzt <gong_zhengtang@163.com>
Date: Mon, 16 Oct 2023 11:08:12 +0800
Subject: It is suitable for version 20.03-LTS-sp3
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
aops-vulcanus | 33 +------------------------
aops-vulcanus.spec | 2 +-
scripts/deploy/aops-basedatabase.sh | 38 ++++++++++++++++++++++++++++-
scripts/deploy/container/run.sh | 11 ++++++---
4 files changed, 46 insertions(+), 38 deletions(-)
diff --git a/aops-vulcanus b/aops-vulcanus
index f00b4a0..cef2b4f 100644
--- a/aops-vulcanus
+++ b/aops-vulcanus
@@ -192,36 +192,5 @@ except pymysql.err.OperationalError:
echo "[INFO] mysql check ok"
}
-function init_database_and_table() {
- CONFIG_FILE=$1
- mysql_ip=$(get_config "${CONFIG_FILE}" "mysql" "ip")
- port=$(get_config "${CONFIG_FILE}" "mysql" "port")
- sql_file=$2
- init_database_and_table_cmd="import pymysql,os
-try:
- database = pymysql.connect(host='$mysql_ip', port=$port, database='mysql', autocommit=True)
- with open('$sql_file', 'r', encoding='utf-8') as file:
- sql = file.read()
- if not sql:
- print(False)
- else:
- cursor = database.cursor()
- for command in filter(lambda _sql: _sql != os.linesep and _sql, sql.split(';')):
- sql_command = command.replace(os.linesep, '')
- if not sql_command:
- continue
- cursor.execute(sql_command)
- database.close()
-except (IOError, pymysql.err.OperationalError):
- print(False)
-"
- init_result=$(python3 -c "$init_database_and_table_cmd")
- if [ "${init_result}" = "False" ]; then
- echo "[ERROR] Table initialization failed"
- echo "[INFO] 1. Make sure that the data table initialization of the zeus service is performed first."
- echo "[INFO] 2. Check that the database configuration file is correct, please check value of 'ip' and 'port' of mysql in ${CONFIG_FILE}"
- else
- echo "[INFO] Database and table initialization ok"
- fi
-}
+
diff --git a/aops-vulcanus.spec b/aops-vulcanus.spec
index bf802e3..e5c4d86 100644
--- a/aops-vulcanus.spec
+++ b/aops-vulcanus.spec
@@ -14,7 +14,7 @@ Requires: python3-concurrent-log-handler python3-xmltodict python3-pyyaml pyth
Requires: python3-requests python3-xlrd python3-prettytable python3-pygments python3-sqlalchemy
Requires: python3-elasticsearch >= 7 python3-prometheus-api-client python3-urllib3 python3-werkzeug
Requires: python3-flask python3-flask-restful python3-PyMySQL python3-kafka-python
-Requires: python-jwt python-redis python3-Flask-APScheduler >= 1.11.0 python3-APScheduler
+Requires: python-jwt python3-redis python3-Flask-APScheduler >= 1.11.0 python3-APScheduler
Provides: aops-vulcanus
Conflicts: aops-utils
diff --git a/scripts/deploy/aops-basedatabase.sh b/scripts/deploy/aops-basedatabase.sh
index 438716d..a8f5898 100755
--- a/scripts/deploy/aops-basedatabase.sh
+++ b/scripts/deploy/aops-basedatabase.sh
@@ -1,5 +1,4 @@
#!/bin/bash
-. /usr/bin/aops-vulcanus
REPO_CONFIG_FILE="/etc/yum.repos.d/aops_elascticsearch.repo"
INSTALL_SOFTWARE=$2
@@ -128,6 +127,43 @@ function install_database() {
fi
}
+function get_config() {
+ INIFILE=$1
+ SECTION=$2
+ ITEM=$3
+ awk -F '=' '/\['"$SECTION"'\]/{a=1}a==1&&$1~/'"$ITEM"'/{print $2; exit}' "$INIFILE"
+}
+
+function init_database_and_table() {
+ CONFIG_FILE=$1
+ mysql_ip=$(get_config "${CONFIG_FILE}" "mysql" "ip")
+ port=$(get_config "${CONFIG_FILE}" "mysql" "port")
+ sql_file=$2
+ init_database_and_table_cmd="import pymysql,os
+from pymysql.constants import CLIENT
+try:
+ database = pymysql.connect(host='$mysql_ip', port=$port, database='mysql', autocommit=True,client_flag=CLIENT.MULTI_STATEMENTS)
+ with open('$sql_file', 'r', encoding='utf-8') as file:
+ sql = file.read()
+ if not sql:
+ print(False)
+ else:
+ cursor = database.cursor()
+ cursor.execute(sql)
+ database.close()
+except (IOError, pymysql.err.OperationalError):
+ print(False)
+"
+ init_result=$(python3 -c "$init_database_and_table_cmd")
+ if [ "${init_result}" = "False" ]; then
+ echo "[ERROR] Table initialization failed"
+ echo "[INFO] 1. Make sure that the data table initialization of the zeus service is performed first."
+ echo "[INFO] 2. Check that the database configuration file is correct, please check value of 'ip' and 'port' of mysql in ${CONFIG_FILE}"
+ else
+ echo "[INFO] Database and table initialization ok"
+ fi
+}
+
function main(){
operation=$1
service=$2
diff --git a/scripts/deploy/container/run.sh b/scripts/deploy/container/run.sh
index 581c0bc..dffbfaf 100755
--- a/scripts/deploy/container/run.sh
+++ b/scripts/deploy/container/run.sh
@@ -71,11 +71,12 @@ main(){
while :
do
echo "===========================Container arrangement==========================="
- 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)."
+ echo "Welcome to the one-click deployment script, supporting pre-building of container images and start-stop of services."
+ echo "Image Building (build): supports the generation of docker images for zeus, apollo, hermes services."
+ echo "Service Start (start): the service types are divided into basic environment services and application services. Basic environment services include mysql, elasticsearch, redis, kafka, prometheus, which can be started by entering the 'start-env' option. Application services include apollo, zeus, hermes, which can be started by entering the 'start-service' option. please remember that, in the absence of a pre-existing environment, the correct order of using one-click startup services is to first execute "start-env" and then "start-service" Both steps are essential and cannot be skipped."
+ echo "Stop Service (stop): enter 'stop-env' or 'stop-service' to stop the basic environment services and application services respectively. After the basic environment services are stopped, if the configuration items of the application services are not reconfigured, it will cause the application services to be unusable. Conversely, after stopping the application services, there is no impact on the basic environment services."
echo "Enter to exit the operation (Q/q)."
- read -p "Select an operation procedure to continue: " operation
+ read -p "Please enter build, start-env, start-service, stop-env, stop-service, or q/Q to proceed to the next step: " operation
case $operation in
"build")
docker_build
@@ -83,6 +84,8 @@ main(){
;;
"start-service")
docker-compose up -d
+ bash /opt/aops/scripts/aops-basedatabase.sh init zeus
+ bash /opt/aops/scripts/aops-basedatabase.sh init apollo
;;
"start-env")
prometheus
--
Gitee
From adf7afd90a882e013e0d16a7e1af35572d75f38f Mon Sep 17 00:00:00 2001
From: gongzt <gong_zhengtang@163.com>
Date: Wed, 18 Oct 2023 14:11:59 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E9=80=82=E9=85=8D20.03-sp3=E7=89=88?=
=?UTF-8?q?=E6=9C=AC=E4=B8=AD=E7=9A=84python-jwt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
vulcanus/token.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/vulcanus/token.py b/vulcanus/token.py
index e449991..786d5f3 100644
--- a/vulcanus/token.py
+++ b/vulcanus/token.py
@@ -60,12 +60,16 @@ def generate_token(unique_iden, minutes=20, **kwargs):
try:
token_body["key"] = unique_iden
token_body["create_time"] = time.localtime()
- return jwt.encode(
+ jwt_token = jwt.encode(
token_body,
configuration.individuation.get("PRIVATE_KEY"),
algorithm="HS256",
headers=dict(alg="HS256"),
)
+ if isinstance(jwt_token, bytes):
+ jwt_token = jwt_token.decode("utf-8")
+ return jwt_token
+
except Exception:
raise ValueError("Token generation failed")
--
Gitee