修复溯源文件配置问题
(cherry picked from commit d676421aa73e0694ba70f336eeb01297328ba87f)
This commit is contained in:
parent
88309e4128
commit
397df26938
286
0005-fixe-traceability-configuration-bugs.patch
Normal file
286
0005-fixe-traceability-configuration-bugs.patch
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
From 6d869ac7b13aa5d176cbbd208d22f13d153f1e9f Mon Sep 17 00:00:00 2001
|
||||||
|
From: smjiao <smjiao@isoftstone.com>
|
||||||
|
Date: Mon, 18 Sep 2023 20:34:35 +0800
|
||||||
|
Subject: [PATCH] fix bug
|
||||||
|
|
||||||
|
---
|
||||||
|
.../ragdoll/config_model/bash_config.py | 1 -
|
||||||
|
.../ragdoll/config_model/hosts_config.py | 3 +-
|
||||||
|
.../ragdoll/config_model/ssh_config.py | 2 +
|
||||||
|
.../ragdoll/controllers/confs_controller.py | 68 ++++++++++++-------
|
||||||
|
.../ragdoll/models/host_sync_result.py | 8 +--
|
||||||
|
.../ragdoll/models/host_sync_status.py | 8 +--
|
||||||
|
.../yang_modules/openEuler-sysctl.conf.yang | 2 +-
|
||||||
|
7 files changed, 56 insertions(+), 36 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/gala-ragdoll/ragdoll/config_model/bash_config.py b/gala-ragdoll/ragdoll/config_model/bash_config.py
|
||||||
|
index 7b4b87d..608cd58 100644
|
||||||
|
--- a/gala-ragdoll/ragdoll/config_model/bash_config.py
|
||||||
|
+++ b/gala-ragdoll/ragdoll/config_model/bash_config.py
|
||||||
|
@@ -30,7 +30,6 @@ class BashConfig(BaseHandlerConfig):
|
||||||
|
for line in conf_list:
|
||||||
|
if line is None or line.strip() == '':
|
||||||
|
continue
|
||||||
|
-
|
||||||
|
conf_dict_list.append(line)
|
||||||
|
return conf_dict_list
|
||||||
|
|
||||||
|
diff --git a/gala-ragdoll/ragdoll/config_model/hosts_config.py b/gala-ragdoll/ragdoll/config_model/hosts_config.py
|
||||||
|
index 72b953e..0bda98d 100644
|
||||||
|
--- a/gala-ragdoll/ragdoll/config_model/hosts_config.py
|
||||||
|
+++ b/gala-ragdoll/ragdoll/config_model/hosts_config.py
|
||||||
|
@@ -17,6 +17,7 @@ Description: /etc/hosts config handler
|
||||||
|
import re
|
||||||
|
import json
|
||||||
|
|
||||||
|
+from ragdoll.config_model.base_handler_config import BaseHandlerConfig
|
||||||
|
from ragdoll.log.log import LOGGER
|
||||||
|
from ragdoll.utils.yang_module import YangModule
|
||||||
|
from ragdoll.const.conf_handler_const import NOT_SYNCHRONIZE, SYNCHRONIZED
|
||||||
|
@@ -102,7 +103,7 @@ class HostsConfig(BaseHandlerConfig):
|
||||||
|
|
||||||
|
def write_conf(self):
|
||||||
|
content = ""
|
||||||
|
- for key, value in self.conf:
|
||||||
|
+ for key, value in self.conf.items():
|
||||||
|
if value is not None:
|
||||||
|
conf_item = " ".join((key, str(value))).replace('\n', '\n\t')
|
||||||
|
content = content + conf_item + "\n"
|
||||||
|
diff --git a/gala-ragdoll/ragdoll/config_model/ssh_config.py b/gala-ragdoll/ragdoll/config_model/ssh_config.py
|
||||||
|
index c0cd0e0..bc46038 100644
|
||||||
|
--- a/gala-ragdoll/ragdoll/config_model/ssh_config.py
|
||||||
|
+++ b/gala-ragdoll/ragdoll/config_model/ssh_config.py
|
||||||
|
@@ -17,11 +17,13 @@ Description: sshd config analyze
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
|
||||||
|
+from ragdoll.config_model.base_handler_config import BaseHandlerConfig
|
||||||
|
from ragdoll.utils.yang_module import YangModule
|
||||||
|
from ragdoll.const.conf_handler_const import NOT_SYNCHRONIZE, SYNCHRONIZED
|
||||||
|
|
||||||
|
SPACER_LIST = [' ', '\t']
|
||||||
|
|
||||||
|
+
|
||||||
|
class SshConfig(BaseHandlerConfig):
|
||||||
|
|
||||||
|
def parse_conf_to_dict(self, conf_info):
|
||||||
|
diff --git a/gala-ragdoll/ragdoll/controllers/confs_controller.py b/gala-ragdoll/ragdoll/controllers/confs_controller.py
|
||||||
|
index ae766fa..071e8c5 100644
|
||||||
|
--- a/gala-ragdoll/ragdoll/controllers/confs_controller.py
|
||||||
|
+++ b/gala-ragdoll/ragdoll/controllers/confs_controller.py
|
||||||
|
@@ -11,6 +11,7 @@ from ragdoll.models.domain_name import DomainName # noqa: E501
|
||||||
|
from ragdoll.models.excepted_conf_info import ExceptedConfInfo # noqa: E501
|
||||||
|
from ragdoll.models.expected_conf import ExpectedConf # noqa: E501
|
||||||
|
from ragdoll.models.real_conf_info import RealConfInfo # noqa: E501
|
||||||
|
+from ragdoll.models.sync_req import SyncReq
|
||||||
|
from ragdoll.models.sync_status import SyncStatus # noqa: E501
|
||||||
|
from ragdoll.models.conf_base_info import ConfBaseInfo
|
||||||
|
from ragdoll.models.conf_is_synced import ConfIsSynced
|
||||||
|
@@ -28,6 +29,7 @@ from ragdoll.utils.host_tools import HostTools
|
||||||
|
from ragdoll.utils.object_parse import ObjectParse
|
||||||
|
from ragdoll import util
|
||||||
|
from ragdoll.const.conf_files import yang_conf_list
|
||||||
|
+from ragdoll.log.log import LOGGER
|
||||||
|
|
||||||
|
TARGETDIR = GitTools().target_dir
|
||||||
|
|
||||||
|
@@ -163,9 +165,11 @@ def get_the_sync_status_of_domain(body=None): # noqa: E501
|
||||||
|
man_conf_list = []
|
||||||
|
for d_man_conf in manage_confs:
|
||||||
|
man_conf_list.append(d_man_conf.get("filePath").split(":")[-1])
|
||||||
|
+ LOGGER.info("manage_confs is {}".format(manage_confs))
|
||||||
|
for d_host in sync_status.host_status:
|
||||||
|
d_sync_status = d_host.sync_status
|
||||||
|
file_list = []
|
||||||
|
+ LOGGER.info("d_sync_status is {}".format(d_sync_status))
|
||||||
|
for d_file in d_sync_status:
|
||||||
|
file_path = d_file.file_path
|
||||||
|
file_list.append(file_path)
|
||||||
|
@@ -426,10 +430,16 @@ def sync_conf_to_host_from_domain(body=None): # noqa: E501
|
||||||
|
:rtype: List[HostSyncResult]
|
||||||
|
"""
|
||||||
|
if connexion.request.is_json:
|
||||||
|
- body = ConfHost.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
|
+ body = SyncReq.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
|
|
||||||
|
domain = body.domain_name
|
||||||
|
- host_list = body.host_ids
|
||||||
|
+ sync_list = body.sync_list
|
||||||
|
+ LOGGER.info("sync_list is {}".format(sync_list))
|
||||||
|
+
|
||||||
|
+ host_sync_confs = dict()
|
||||||
|
+
|
||||||
|
+ for sync in sync_list:
|
||||||
|
+ host_sync_confs[sync.host_id] = sync.sync_configs
|
||||||
|
|
||||||
|
# check the input domain
|
||||||
|
check_res = Format.domainCheck(domain)
|
||||||
|
@@ -458,11 +468,12 @@ def sync_conf_to_host_from_domain(body=None): # noqa: E501
|
||||||
|
|
||||||
|
# Check whether the host is in the managed host list
|
||||||
|
exist_host = []
|
||||||
|
- if len(host_list) > 0:
|
||||||
|
- for host in host_list:
|
||||||
|
+ if len(host_sync_confs) > 0:
|
||||||
|
+ host_ids = host_sync_confs.keys()
|
||||||
|
+ for host_id in host_ids:
|
||||||
|
for d_host in res_host_text:
|
||||||
|
- if host.get("hostId") == d_host.get("hostId"):
|
||||||
|
- exist_host.append(host)
|
||||||
|
+ if host_id == d_host.get("hostId"):
|
||||||
|
+ exist_host.append(host_id)
|
||||||
|
else:
|
||||||
|
for d_host in res_host_text:
|
||||||
|
temp_host = {}
|
||||||
|
@@ -489,28 +500,35 @@ def sync_conf_to_host_from_domain(body=None): # noqa: E501
|
||||||
|
|
||||||
|
# Deserialize and reverse parse the expected configuration
|
||||||
|
sync_res = []
|
||||||
|
- for d_host in exist_host:
|
||||||
|
- host_sync_result = HostSyncResult(host_id=d_host,
|
||||||
|
+ for host_id in exist_host:
|
||||||
|
+ host_sync_result = HostSyncResult(host_id=host_id,
|
||||||
|
sync_result=[])
|
||||||
|
+ sync_confs = host_sync_confs.get(host_id)
|
||||||
|
for d_man_conf in manage_confs:
|
||||||
|
file_path = d_man_conf.get("filePath").split(":")[-1]
|
||||||
|
- contents = d_man_conf.get("contents")
|
||||||
|
- object_parse = ObjectParse()
|
||||||
|
- content = object_parse.parse_json_to_conf(file_path, contents)
|
||||||
|
- # Configuration to the host
|
||||||
|
- sync_conf_url = conf_tools.load_url_by_conf().get("sync_url")
|
||||||
|
- headers = {"Content-Type": "application/json"}
|
||||||
|
- data = {"host_id": d_host, "file_path": file_path, "content": content}
|
||||||
|
- sync_response = requests.put(sync_conf_url, data=json.dumps(data), headers=headers)
|
||||||
|
-
|
||||||
|
- resp_status = json.loads(sync_response.text).get("status")
|
||||||
|
- conf_sync_res = ConfSyncedRes(file_path=file_path,
|
||||||
|
- result="")
|
||||||
|
- if resp_status:
|
||||||
|
- conf_sync_res.result = "SUCCESS"
|
||||||
|
- else:
|
||||||
|
- conf_sync_res.result = "FAILED"
|
||||||
|
- host_sync_result.sync_result.append(conf_sync_res)
|
||||||
|
+ if file_path in sync_confs:
|
||||||
|
+ file_path = d_man_conf.get("filePath").split(":")[-1]
|
||||||
|
+ contents = d_man_conf.get("contents")
|
||||||
|
+ object_parse = ObjectParse()
|
||||||
|
+ content = object_parse.parse_json_to_conf(file_path, contents)
|
||||||
|
+ LOGGER.info("content IS {}".format(content))
|
||||||
|
+ # Configuration to the host
|
||||||
|
+ sync_conf_url = conf_tools.load_url_by_conf().get("sync_url")
|
||||||
|
+ headers = {"Content-Type": "application/json"}
|
||||||
|
+ data = {"host_id": host_id, "file_path": file_path, "content": content}
|
||||||
|
+ sync_response = requests.put(sync_conf_url, data=json.dumps(data), headers=headers)
|
||||||
|
+
|
||||||
|
+ resp_code = json.loads(sync_response.text).get('code')
|
||||||
|
+ resp = json.loads(sync_response.text).get('data').get('resp')
|
||||||
|
+ LOGGER.info("resp_code IS {}".format(resp_code))
|
||||||
|
+ LOGGER.info("resp IS {}".format(resp))
|
||||||
|
+ conf_sync_res = ConfSyncedRes(file_path=file_path,
|
||||||
|
+ result="")
|
||||||
|
+ if resp_code == "200" and resp.get('sync_result') is True:
|
||||||
|
+ conf_sync_res.result = "SUCCESS"
|
||||||
|
+ else:
|
||||||
|
+ conf_sync_res.result = "FAILED"
|
||||||
|
+ host_sync_result.sync_result.append(conf_sync_res)
|
||||||
|
sync_res.append(host_sync_result)
|
||||||
|
|
||||||
|
return sync_res
|
||||||
|
diff --git a/gala-ragdoll/ragdoll/models/host_sync_result.py b/gala-ragdoll/ragdoll/models/host_sync_result.py
|
||||||
|
index 3e8d951..8604e31 100644
|
||||||
|
--- a/gala-ragdoll/ragdoll/models/host_sync_result.py
|
||||||
|
+++ b/gala-ragdoll/ragdoll/models/host_sync_result.py
|
||||||
|
@@ -17,7 +17,7 @@ class HostSyncResult(Model):
|
||||||
|
Do not edit the class manually.
|
||||||
|
"""
|
||||||
|
|
||||||
|
- def __init__(self, host_id: str=None, sync_result: List[ConfSyncedRes]=None): # noqa: E501
|
||||||
|
+ def __init__(self, host_id: int = None, sync_result: List[ConfSyncedRes] = None): # noqa: E501
|
||||||
|
"""HostSyncResult - a model defined in Swagger
|
||||||
|
|
||||||
|
:param host_id: The host_id of this HostSyncResult. # noqa: E501
|
||||||
|
@@ -26,7 +26,7 @@ class HostSyncResult(Model):
|
||||||
|
:type sync_result: List[ConfSyncedRes]
|
||||||
|
"""
|
||||||
|
self.swagger_types = {
|
||||||
|
- 'host_id': str,
|
||||||
|
+ 'host_id': int,
|
||||||
|
'sync_result': List[ConfSyncedRes]
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@ class HostSyncResult(Model):
|
||||||
|
return util.deserialize_model(dikt, cls)
|
||||||
|
|
||||||
|
@property
|
||||||
|
- def host_id(self) -> str:
|
||||||
|
+ def host_id(self) -> int:
|
||||||
|
"""Gets the host_id of this HostSyncResult.
|
||||||
|
|
||||||
|
the id of host # noqa: E501
|
||||||
|
@@ -61,7 +61,7 @@ class HostSyncResult(Model):
|
||||||
|
return self._host_id
|
||||||
|
|
||||||
|
@host_id.setter
|
||||||
|
- def host_id(self, host_id: str):
|
||||||
|
+ def host_id(self, host_id: int):
|
||||||
|
"""Sets the host_id of this HostSyncResult.
|
||||||
|
|
||||||
|
the id of host # noqa: E501
|
||||||
|
diff --git a/gala-ragdoll/ragdoll/models/host_sync_status.py b/gala-ragdoll/ragdoll/models/host_sync_status.py
|
||||||
|
index 5a40397..a785d17 100644
|
||||||
|
--- a/gala-ragdoll/ragdoll/models/host_sync_status.py
|
||||||
|
+++ b/gala-ragdoll/ragdoll/models/host_sync_status.py
|
||||||
|
@@ -16,7 +16,7 @@ class HostSyncStatus(Model):
|
||||||
|
Do not edit the class manually.
|
||||||
|
"""
|
||||||
|
|
||||||
|
- def __init__(self, host_id: str=None, sync_status: List[ConfIsSynced]=None): # noqa: E501
|
||||||
|
+ def __init__(self, host_id: int = None, sync_status: List[ConfIsSynced] = None): # noqa: E501
|
||||||
|
"""SyncStatus - a model defined in Swagger
|
||||||
|
|
||||||
|
:param host_id: The host_id of this HostSyncStatus. # noqa: E501
|
||||||
|
@@ -25,7 +25,7 @@ class HostSyncStatus(Model):
|
||||||
|
:type host_status: List[object]
|
||||||
|
"""
|
||||||
|
self.swagger_types = {
|
||||||
|
- 'host_id': str,
|
||||||
|
+ 'host_id': int,
|
||||||
|
'sync_status': List[ConfIsSynced]
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@ class HostSyncStatus(Model):
|
||||||
|
return util.deserialize_model(dikt, cls)
|
||||||
|
|
||||||
|
@property
|
||||||
|
- def host_id(self) -> str:
|
||||||
|
+ def host_id(self) -> int:
|
||||||
|
"""Gets the host_id of this HostSyncStatus.
|
||||||
|
|
||||||
|
domain name # noqa: E501
|
||||||
|
@@ -60,7 +60,7 @@ class HostSyncStatus(Model):
|
||||||
|
return self._host_id
|
||||||
|
|
||||||
|
@host_id.setter
|
||||||
|
- def host_id(self, host_id: str):
|
||||||
|
+ def host_id(self, host_id: int):
|
||||||
|
"""Sets the host_id of this HostSyncStatus.
|
||||||
|
|
||||||
|
host id # noqa: E501
|
||||||
|
diff --git a/gala-ragdoll/yang_modules/openEuler-sysctl.conf.yang b/gala-ragdoll/yang_modules/openEuler-sysctl.conf.yang
|
||||||
|
index e013ee2..01025a4 100644
|
||||||
|
--- a/gala-ragdoll/yang_modules/openEuler-sysctl.conf.yang
|
||||||
|
+++ b/gala-ragdoll/yang_modules/openEuler-sysctl.conf.yang
|
||||||
|
@@ -62,7 +62,7 @@ module openEuler-sysctl.conf {
|
||||||
|
|
||||||
|
sysctl:path "openEuler:/etc/sysctl.conf";
|
||||||
|
sysctl:type "kv";
|
||||||
|
- sysctl:spacer "";
|
||||||
|
+ sysctl:spacer "=";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\ No newline at end of file
|
||||||
|
--
|
||||||
|
2.38.1.windows.1
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: A-Ops
|
Name: A-Ops
|
||||||
Version: v1.3.1
|
Version: v1.3.1
|
||||||
Release: 3
|
Release: 4
|
||||||
Summary: The intelligent ops toolkit for openEuler
|
Summary: The intelligent ops toolkit for openEuler
|
||||||
License: MulanPSL2
|
License: MulanPSL2
|
||||||
URL: https://gitee.com/openeuler/A-Ops
|
URL: https://gitee.com/openeuler/A-Ops
|
||||||
@ -9,6 +9,7 @@ Patch0001: 0001-fix-host-upload-traceability-configuration-issue.patch
|
|||||||
Patch0002: 0002-fix-kv-bug.patch
|
Patch0002: 0002-fix-kv-bug.patch
|
||||||
Patch0003: 0003-fix-server-startup-error.patch
|
Patch0003: 0003-fix-server-startup-error.patch
|
||||||
Patch0004: 0004-codecheck.patch
|
Patch0004: 0004-codecheck.patch
|
||||||
|
Patch0005: 0005-fixe-traceability-configuration-bugs.patch
|
||||||
|
|
||||||
%global debug_package %{nil}
|
%global debug_package %{nil}
|
||||||
|
|
||||||
@ -96,6 +97,9 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Sep 19 2023 smjiao<smjiao@isoftstone.com> - v1.3.1-4
|
||||||
|
- fix traceability configuration bugs
|
||||||
|
|
||||||
* Thu Sep 14 2023 gongzhengtang<gong_zhengtang@163.com> - v1.3.1-3
|
* Thu Sep 14 2023 gongzhengtang<gong_zhengtang@163.com> - v1.3.1-3
|
||||||
- fix server startup error and code check
|
- fix server startup error and code check
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user