diff --git a/0001-updated-download-host-template-api.patch b/0001-updated-download-host-template-api.patch deleted file mode 100644 index e9be569b5338fda67c9316dff9a31d9ed95c2c02..0000000000000000000000000000000000000000 --- a/0001-updated-download-host-template-api.patch +++ /dev/null @@ -1,161 +0,0 @@ -From 429e3440238fde2e6051443b5b819e9bcb25536f Mon Sep 17 00:00:00 2001 -From: rabbitali -Date: Thu, 22 Aug 2024 16:49:34 +0800 -Subject: [PATCH 1/1] updated download host template api to support english - ---- - .../host_information_service/app/constant.py | 58 ++++++++++++++++++- - .../app/serialize/host.py | 9 +++ - .../app/views/host.py | 15 +++-- - 3 files changed, 77 insertions(+), 5 deletions(-) - -diff --git a/host-information-service/zeus/host_information_service/app/constant.py b/host-information-service/zeus/host_information_service/app/constant.py -index e9814d3..20dfec7 100644 ---- a/host-information-service/zeus/host_information_service/app/constant.py -+++ b/host-information-service/zeus/host_information_service/app/constant.py -@@ -13,7 +13,7 @@ - - - # host template file content --HOST_TEMPLATE_FILE_CONTENT = """host_ip,ssh_port,ssh_user,password,ssh_pkey,host_name,host_group_name,management -+HOST_TEMPLATE_FILE_CONTENT_FOR_ZH = """host_ip,ssh_port,ssh_user,password,ssh_pkey,host_name,host_group_name,management - 127.0.0.1,22,root,password,private key,test_host,test_host_group,FALSE - 127.0.0.1,23,root,password,private key,test_host,test_host_group,FALSE - ,,,,,,, -@@ -24,6 +24,62 @@ HOST_TEMPLATE_FILE_CONTENT = """host_ip,ssh_port,ssh_user,password,ssh_pkey,host - "4. 上传本文件前,请删除此部分提示内容",,,,,,, - """ - -+# host template file content -+HOST_TEMPLATE_FILE_CONTENT_FOR_EN = """host_ip,ssh_port,ssh_user,password,ssh_pkey,host_name,host_group_name,management -+127.0.0.1,22,root,password,private key,test_host,test_host_group,FALSE -+127.0.0.1,23,root,password,private key,test_host,test_host_group,FALSE -+,,,,,,, -+"Note:",,,,,,, -+"1. Except for the login password and SSH login key, other information should provide valid values",,,,,,, -+"2. Choose to enter password or SSH key, the SSH key will be considered preferly when both are provided.",,,,,,, -+"3. The combination of the host IP and port must be unique; no duplicate entries are allowed.",,,,,,, -+"4. Please delete the note before uploading this file.",,,,,,, -+""" -+ -+ -+class HostTemplate: -+ """A template class for managing host template file contents in different languages. -+ -+ Attributes: -+ _content (dict): A dictionary containing the template file contents for -+ different languages. The keys are language codes ("zh" for Chinese, -+ "en" for English), and the values are the corresponding template file contents. -+ -+ Example: -+ content = HostTemplate.get_file_content("zh") -+ print(content) -+ -+ supported_languages = HostTemplate.support_lang -+ print(supported_languages) -+ """ -+ -+ _content = {"zh": HOST_TEMPLATE_FILE_CONTENT_FOR_ZH, "en": HOST_TEMPLATE_FILE_CONTENT_FOR_EN} -+ -+ @classmethod -+ def get_file_content(cls, lang: str = None) -> str: -+ """Gets the template file content for the specified language. -+ -+ Args: -+ lang (str, optional): The language code for the desired template file content. -+ If not provided or if the specified language is not supported, defaults to English ("en"). -+ -+ Returns: -+ str: The template file content for the specified language, or the English content if -+ the specified language is not supported. -+ """ -+ if lang not in cls._content: -+ lang = "en" -+ return cls._content.get(lang) -+ -+ @staticmethod -+ def support_lang(): -+ """Gets the list of supported languages. -+ -+ Returns: -+ list: A list of language codes representing the supported languages (e.g., ["zh", "en"]). -+ """ -+ return list(HostTemplate._content.keys()) -+ - - class HostStatus: - ONLINE = 0 -diff --git a/host-information-service/zeus/host_information_service/app/serialize/host.py b/host-information-service/zeus/host_information_service/app/serialize/host.py -index c65bc86..e160163 100644 ---- a/host-information-service/zeus/host_information_service/app/serialize/host.py -+++ b/host-information-service/zeus/host_information_service/app/serialize/host.py -@@ -14,6 +14,7 @@ from marshmallow import Schema, ValidationError, fields, validate, validates_sch - from vulcanus.restful.serialize.validate import ValidateRules - - from zeus.host_information_service.database import Host -+from zeus.host_information_service.app.constant import HostTemplate - - - class _AddHost(Schema): -@@ -212,3 +213,11 @@ class HostInfoSchema(Schema): - - basic = fields.Boolean(required=False, missing=True, validate=validate.OneOf([True, False])) - refresh = fields.Boolean(required=False, missing=False, validate=validate.OneOf([True, False])) -+ -+ -+class TemplateLangSchema(Schema): -+ """ -+ File template language -+ """ -+ -+ lang = fields.String(required=False, missing='en', validate=validate.OneOf(HostTemplate.support_lang())) -diff --git a/host-information-service/zeus/host_information_service/app/views/host.py b/host-information-service/zeus/host_information_service/app/views/host.py -index 54d5332..334e01f 100644 ---- a/host-information-service/zeus/host_information_service/app/views/host.py -+++ b/host-information-service/zeus/host_information_service/app/views/host.py -@@ -28,7 +28,7 @@ from vulcanus.restful.response import BaseResponse - from vulcanus.restful.serialize.validate import validate - - from zeus.host_information_service.app import cache --from zeus.host_information_service.app.constant import HOST_TEMPLATE_FILE_CONTENT, HostStatus -+from zeus.host_information_service.app.constant import HostTemplate, HostStatus - from zeus.host_information_service.app.core.ssh import SSH, generate_key - from zeus.host_information_service.app.proxy.host import HostProxy - from zeus.host_information_service.app.serialize.host import ( -@@ -39,6 +39,7 @@ from zeus.host_information_service.app.serialize.host import ( - HostFilterSchema, - HostInfoSchema, - HostsInfo_ResponseSchema, -+ TemplateLangSchema, - UpdateHostSchema, - UpdateHostStatusSchema, - ) -@@ -481,16 +482,22 @@ class HostTemplateAPI(BaseResponse): - Restful API: Get - """ - -- @BaseResponse.handle() -- def get(self): -+ @BaseResponse.handle(schema=TemplateLangSchema) -+ def get(self, **params): - """ - Download host template file - -+ Args: -+ lang (str): The language code for the desired template file content. -+ If not provided or if the specified language is not supported, defaults to English ("en"). -+ - Returns: - BytesIO - """ -+ file_content = HostTemplate.get_file_content(params.get("lang")) -+ - file = BytesIO() -- file.write(HOST_TEMPLATE_FILE_CONTENT.encode('utf-8')) -+ file.write(file_content.encode('utf-8')) - file.seek(0) - response = send_file(file, mimetype="application/octet-stream") - response.headers['Content-Disposition'] = 'attachment; filename=template.csv' --- -2.33.0 - diff --git a/aops-zeus-v2.0.0.tar.gz b/aops-zeus-v2.0.0.tar.gz deleted file mode 100644 index 79539960551b050dd42321b596d28c3c940a14bf..0000000000000000000000000000000000000000 Binary files a/aops-zeus-v2.0.0.tar.gz and /dev/null differ diff --git a/aops-zeus-v2.1.0.tar.gz b/aops-zeus-v2.1.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..307a866e15553a98cecbaa596bd18f09c20c09b1 Binary files /dev/null and b/aops-zeus-v2.1.0.tar.gz differ diff --git a/aops-zeus.spec b/aops-zeus.spec index d96c84953ea6f4157a5d7c46a8fb090ec6cdb235..bbf2068da42e053b9d2f7f0005411aacf3ca25ac 100644 --- a/aops-zeus.spec +++ b/aops-zeus.spec @@ -1,11 +1,11 @@ +%define vulcanus_version v2.1.0 Name: aops-zeus -Version: v2.0.0 -Release: 2 +Version: v2.1.0 +Release: 1 Summary: A service which is the foundation of aops. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} Source0: %{name}-%{version}.tar.gz -Patch0001: 0001-updated-download-host-template-api.patch BuildRequires: python3-setuptools @@ -19,7 +19,7 @@ Provides: aops-zeus %package -n zeus-host-information Summary: A host manager service which is the foundation of aops. -Requires: aops-vulcanus >= v2.0.0 aops-zeus >= v2.0.0 +Requires: aops-vulcanus >= %{vulcanus_version} aops-zeus >= %{version} Requires: python3-gevent python3-uWSGI python3-paramiko %description -n zeus-host-information @@ -27,7 +27,7 @@ A host manager service which is the foundation of aops. %package -n zeus-user-access Summary: A user manager service which is the foundation of aops. -Requires: aops-vulcanus >= v2.0.0 aops-zeus >= v2.0.0 +Requires: aops-vulcanus >= %{vulcanus_version} aops-zeus >= %{version} Requires: python3-celery python3-uWSGI %description -n zeus-user-access @@ -35,7 +35,7 @@ A user manager service which is the foundation of aops. %package -n async-task Summary: A async task of aops. -Requires: aops-vulcanus >= v2.0.0 python3-celery python3-paramiko +Requires: aops-vulcanus >= %{vulcanus_version} python3-celery python3-paramiko %description -n async-task @@ -43,13 +43,13 @@ A async task of aops. %package -n zeus-distribute Summary: A distributed service of aops. -Requires: aops-vulcanus >= v2.0.0 aops-zeus >= v2.0.0 +Requires: aops-vulcanus >= %{vulcanus_version} aops-zeus >= %{version} Requires: python3-uWSGI python3-gevent %description -n zeus-distribute A distributed service of aops. %prep -%autosetup -n %{name}-%{version} -p1 +%autosetup -n %{name}-%{version} # build for aops-zeus @@ -140,6 +140,9 @@ popd %{python3_sitelib}/zeus/distribute_service/* %changelog +* Mon Sep 9 2024 gongzhengtang - v2.1.0-1 +- Support authhub local authentication + * Fri Aug 23 2024 wenxin - v2.0.0-2 - updated download host template api to support english