diff --git a/0001-update-requirements-and-move-default-task-to-config.patch b/0001-update-requirements-and-move-default-task-to-config.patch new file mode 100644 index 0000000..96e7d68 --- /dev/null +++ b/0001-update-requirements-and-move-default-task-to-config.patch @@ -0,0 +1,202 @@ +From 0172c9670be9657f28bc13ebfde26cc689e52a23 Mon Sep 17 00:00:00 2001 +From: gitee-cmd +Date: Tue, 31 Aug 2021 22:58:46 +0800 +Subject: [PATCH] update requirements and move default task to config + +--- + A-Ops.spec | 1 + + aops-database/aops_database/conf/constant.py | 7 ------ + aops-database/aops_database/manage.py | 9 ++++++-- + aops-database/conf/default.json | 23 +++++++++++++++++++ + aops-database/setup.py | 3 ++- + .../ansible_runner/ansible_runner.py | 5 ++-- + aops-manager/setup.py | 2 +- + aops-utils/aops-utils | 6 ++--- + 8 files changed, 40 insertions(+), 16 deletions(-) + create mode 100644 aops-database/conf/default.json + +diff --git a/A-Ops.spec b/A-Ops.spec +index 42e14a7..5fc66f0 100644 +--- a/A-Ops.spec ++++ b/A-Ops.spec +@@ -188,6 +188,7 @@ popd + + %files -n aops-database + %attr(0644,root,root) %{_sysconfdir}/aops/database.ini ++%attr(0644,root,root) %{_sysconfdir}/aops/default.json + %attr(0755,root,root) %{_unitdir}/aops-database.service + %attr(0755,root,root) %{_bindir}/aops-database + %attr(0755,root,root) %{_bindir}/aops-basedatabase +diff --git a/aops-database/aops_database/conf/constant.py b/aops-database/aops_database/conf/constant.py +index e2e368d..08f78f9 100644 +--- a/aops-database/aops_database/conf/constant.py ++++ b/aops-database/aops_database/conf/constant.py +@@ -31,10 +31,3 @@ DIAG_TREE_INDEX = "diag_tree" + CHECK_RESULT_INDEX = "check_result" + CHECK_RULE_INDEX = "check_rule" + +-DEFAULT_TASK_INFO = [{"task_id": "95c3e692ff3811ebbcd3a89d3a259eef", +- "task_name": "Default deployment", +- "username": "admin", +- "host_list": [{"host_name": "90.90.64.64", "host_id": "11111"}, +- {"host_name": "90.90.64.66", "host_id": "11111"}, +- {"host_name": "90.90.64.65", "host_id": "33333"}] +- }] +diff --git a/aops-database/aops_database/manage.py b/aops-database/aops_database/manage.py +index f097850..4873d03 100644 +--- a/aops-database/aops_database/manage.py ++++ b/aops-database/aops_database/manage.py +@@ -15,6 +15,7 @@ Time: + Author: + Description: Manager that start aops-database + """ ++import os + import sqlalchemy + + from aops_database.function.helper import create_tables, ENGINE, SESSION +@@ -22,12 +23,15 @@ from aops_database.factory.table import User + from aops_database.factory.mapping import MAPPINGS + from aops_database.proxy.deploy import DeployDatabase + from aops_database.proxy.account import UserDatabase +-from aops_database.conf.constant import DEFAULT_TASK_INFO ++from aops_utils.conf.constant import BASE_CONFIG_PATH + from aops_utils.log.log import LOGGER + from aops_utils.restful.status import SUCCEED + from aops_utils.manage import init_app ++from aops_utils.readconfig import read_json_config_file + + ++DEFAULT_TASK_PATH = os.path.join(BASE_CONFIG_PATH, 'default.json') ++ + def init_user(): + """ + Initialize user, add a default user: admin +@@ -75,7 +79,8 @@ def init_es(): + "username": "", + "task_list": [""] + } +- for default_task in DEFAULT_TASK_INFO: ++ task_info = read_json_config_file(DEFAULT_TASK_PATH) ++ for default_task in task_info['tasks']: + data["username"] = default_task["username"] + data["task_list"][0] = default_task["task_id"] + task_name = default_task["task_name"] +diff --git a/aops-database/conf/default.json b/aops-database/conf/default.json +new file mode 100644 +index 0000000..3b53633 +--- /dev/null ++++ b/aops-database/conf/default.json +@@ -0,0 +1,23 @@ ++{ ++ "tasks": [ ++ { ++ "task_id": "95c3e692ff3811ebbcd3a89d3a259eef", ++ "task_name": "Default deployment", ++ "username": "admin", ++ "host_list": [ ++ { ++ "host_name": "90.90.64.64", ++ "host_id": "11111" ++ }, ++ { ++ "host_name": "90.90.64.66", ++ "host_id": "11111" ++ }, ++ { ++ "host_name": "90.90.64.65", ++ "host_id": "33333" ++ } ++ ] ++ } ++ ] ++} +\ No newline at end of file +diff --git a/aops-database/setup.py b/aops-database/setup.py +index 7104fca..1083ad7 100644 +--- a/aops-database/setup.py ++++ b/aops-database/setup.py +@@ -11,6 +11,7 @@ setup( + install_requires=[ + 'SQLAlchemy', + 'elasticsearch>=7', ++ 'PyMySQL', + 'Werkzeug', + 'urllib3', + 'Flask', +@@ -20,7 +21,7 @@ setup( + ], + author='cmd-lsw-yyy-zyc', + data_files=[ +- ('/etc/aops', ['conf/database.ini']), ++ ('/etc/aops', ['conf/database.ini','conf/default.json']), + ('/usr/lib/systemd/system', ['aops-database.service']), + ], + scripts=['aops-basedatabase', 'aops-database'], +diff --git a/aops-manager/aops_manager/deploy_manager/ansible_runner/ansible_runner.py b/aops-manager/aops_manager/deploy_manager/ansible_runner/ansible_runner.py +index 254032b..7f93287 100644 +--- a/aops-manager/aops_manager/deploy_manager/ansible_runner/ansible_runner.py ++++ b/aops-manager/aops_manager/deploy_manager/ansible_runner/ansible_runner.py +@@ -258,8 +258,6 @@ class ResultCallback(CallbackBase): + """ + host_name = result._host.get_name() + result_info = result._result +- self.host_failed[host_name] = {"task_name": result.task_name, +- "result": result_info} + + LOGGER.debug('==============v2_runner_on_failed=========' + '[task:%s]=========[host:%s]==============', +@@ -274,6 +272,9 @@ class ResultCallback(CallbackBase): + LOGGER.debug("%s | FAILED! => %s", host_name, result_info) + if ignore_errors: + LOGGER.info("... ignoring") ++ else: ++ self.host_failed[host_name] = {"task_name": result.task_name, ++ "result": result_info} + + def v2_runner_on_unreachable(self, result): + """ +diff --git a/aops-manager/setup.py b/aops-manager/setup.py +index 50ff633..668a6a7 100644 +--- a/aops-manager/setup.py ++++ b/aops-manager/setup.py +@@ -11,7 +11,7 @@ setup( + version='1.0.0', + packages=find_packages(), + install_requires=[ +- 'ansible>=2.9.24', ++ 'ansible>=2.9.0', + 'PyYAML', + 'marshmallow>=3.13.0', + 'Flask', +diff --git a/aops-utils/aops-utils b/aops-utils/aops-utils +index 5bf1aae..e06e4c3 100644 +--- a/aops-utils/aops-utils ++++ b/aops-utils/aops-utils +@@ -37,7 +37,7 @@ function create_config_file() { + wsgi_file_name=$(get_config "${config_file}" "uwsgi" "wsgi-file") + wsgi_file=$(find /usr/lib -name "aops_"${service_type} | head -n 1) + daemonize=$(get_config "${config_file}" "uwsgi" "daemonize") +- http-timeout=$(get_config "${config_file}" "uwsgi" "http-timeout") ++ http_timeout=$(get_config "${config_file}" "uwsgi" "http-timeout") + harakiri=$(get_config "${config_file}" "uwsgi" "harakiri") + module_name="aops-"${service_type} + module="aops_"${service_type} +@@ -62,7 +62,7 @@ module=${module}.manage + uwsgi-file=${wsgi_file_name} + pidfile=$OUT_PATH/${module_name}.pid + callable=app +-http-timeout=${http-timeout} ++http-timeout=${http_timeout} + harakiri=${harakiri} + daemonize=$daemonize" >"$OUT_PATH"/"${module_name}".ini + chown root: $OUT_PATH/"${module_name}".ini +@@ -108,4 +108,4 @@ function start_or_stop_service() { + elif [ "${OPERATION}" = "stop" ]; then + stop_service $1 + fi +-} +\ No newline at end of file ++} +-- +2.30.0 + diff --git a/A-Ops.spec b/A-Ops.spec index 0c0fde8..48ffa40 100644 --- a/A-Ops.spec +++ b/A-Ops.spec @@ -1,10 +1,11 @@ Name: A-Ops Version: 1.0.0 -Release: 1 +Release: 2 Summary: The intelligent ops toolkit for openEuler -License: MulanPSL2 +License: MulanPSL-2.0 URL: https://gitee.com/openeuler/A-Ops Source0: a-ops-%{version}.tar.gz +patch0001: 0001-update-requirements-and-move-default-task-to-config.patch # build for aops basic module @@ -58,7 +59,7 @@ database center of A-ops, offer database proxy of mysql, elasticsearch and prome %define debug_package %{nil} %prep -%autosetup -n %{name}-v%{version}-%{release} +%autosetup -n %{name}-v%{version}-1.oe1 -p1 %build @@ -133,6 +134,7 @@ popd %files -n aops-database %attr(0644,root,root) %{_sysconfdir}/aops/database.ini +%attr(0644,root,root) %{_sysconfdir}/aops/default.json %attr(0755,root,root) %{_unitdir}/aops-database.service %attr(0755,root,root) %{_bindir}/aops-database %attr(0755,root,root) %{_bindir}/aops-basedatabase @@ -141,5 +143,8 @@ popd %changelog +* Tue 31 Aug 2021 che-mingdao - 1.0.0-2 +- Update requirements and move default task to config. + * Fri 27 Aug 2021 zhu-yuncheng - 1.0.0-1 - Update spec