194 lines
10 KiB
Diff
194 lines
10 KiB
Diff
From faaf35ce2ed973e5bd5b997dd4304b5a24fadb82 Mon Sep 17 00:00:00 2001
|
|
From: smjiao <smjiao@isoftstone.com>
|
|
Date: Thu, 14 Sep 2023 11:10:04 +0800
|
|
Subject: code check
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=utf-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
---
|
|
.../ragdoll/const/conf_handler_const.py | 7 +--
|
|
.../ragdoll/controllers/confs_controller.py | 51 ++++++++++---------
|
|
2 files changed, 32 insertions(+), 26 deletions(-)
|
|
|
|
diff --git a/gala-ragdoll/ragdoll/const/conf_handler_const.py b/gala-ragdoll/ragdoll/const/conf_handler_const.py
|
|
index 6780dfe..0533423 100644
|
|
--- a/gala-ragdoll/ragdoll/const/conf_handler_const.py
|
|
+++ b/gala-ragdoll/ragdoll/const/conf_handler_const.py
|
|
@@ -22,7 +22,8 @@ NOT_SYNCHRONIZE = "NOT SYNCHRONIZE"
|
|
SYNCHRONIZED = "SYNCHRONIZED"
|
|
LIMITS_DOMAIN_RE = re.compile('(^[*]$)|(^[@|0-9A-Za-z]+[0-9A-Za-z]$)')
|
|
LIMITS_TYPE_VALUE = "soft|hard|-|"
|
|
-LIMITS_ITEM_VALUE = "core|data|fsize|memlock|nofile|rss|stack|cpu|nproc|as|maxlogins|maxsyslogins|priority|locks|sigpending|" \
|
|
- "msgqueue|nice|rtprio|"
|
|
+LIMITS_ITEM_VALUE = "core|data|fsize|memlock|nofile|rss|stack|cpu|nproc|as|maxlogins|" \
|
|
+ "maxsyslogins|priority|locks|sigpending|" \
|
|
+ "msgqueue|nice|rtprio|"
|
|
RESOLV_KEY_VALUE = "nameserver|domain|search|sortlist|"
|
|
-FSTAB_COLUMN_NUM = 6
|
|
\ No newline at end of file
|
|
+FSTAB_COLUMN_NUM = 6
|
|
diff --git a/gala-ragdoll/ragdoll/controllers/confs_controller.py b/gala-ragdoll/ragdoll/controllers/confs_controller.py
|
|
index 7703c7c..ae766fa 100644
|
|
--- a/gala-ragdoll/ragdoll/controllers/confs_controller.py
|
|
+++ b/gala-ragdoll/ragdoll/controllers/confs_controller.py
|
|
@@ -31,6 +31,7 @@ from ragdoll.const.conf_files import yang_conf_list
|
|
|
|
TARGETDIR = GitTools().target_dir
|
|
|
|
+
|
|
def get_the_sync_status_of_domain(body=None): # noqa: E501
|
|
"""
|
|
get the status of the domain
|
|
@@ -64,8 +65,8 @@ def get_the_sync_status_of_domain(body=None): # noqa: E501
|
|
is_host_list_exist = Format.isHostInDomain(domain)
|
|
if not is_host_list_exist:
|
|
code_num = 404
|
|
- base_rsp = BaseResponse(code_num, "The host information is not set in the current domain." +
|
|
- "Please add the host information first")
|
|
+ base_rsp = BaseResponse(code_num, "The host information is not set in the current domain." +
|
|
+ "Please add the host information first")
|
|
return base_rsp, code_num
|
|
|
|
# get the host info in domain
|
|
@@ -83,15 +84,15 @@ def get_the_sync_status_of_domain(body=None): # noqa: E501
|
|
|
|
if res_code != 200:
|
|
code_num = res_code
|
|
- base_rsp = BaseResponse(code_num, "Failed to get host info in the current domain. " +
|
|
- "The failure reason is:" + res_text.get('msg'))
|
|
+ base_rsp = BaseResponse(code_num, "Failed to get host info in the current domain. " +
|
|
+ "The failure reason is:" + res_text.get('msg'))
|
|
return base_rsp, code_num
|
|
|
|
if len(res_text) == 0:
|
|
code_num = 404
|
|
|
|
- base_rsp = BaseResponse(code_num, "The host currently controlled in the domain is empty." +
|
|
- "Please add host information to the domain.")
|
|
+ base_rsp = BaseResponse(code_num, "The host currently controlled in the domain is empty." +
|
|
+ "Please add host information to the domain.")
|
|
return base_rsp, code_num
|
|
|
|
# get the host list from the git house
|
|
@@ -104,22 +105,24 @@ def get_the_sync_status_of_domain(body=None): # noqa: E501
|
|
get_man_conf_url = "http://0.0.0.0:" + port + "/management/getManagementConf"
|
|
headers = {"Content-Type": "application/json"}
|
|
get_man_conf_body = DomainName(domain_name=domain)
|
|
- get_man_conf_res = requests.post(get_man_conf_url, data=json.dumps(get_man_conf_body), headers=headers) # post request
|
|
+ get_man_conf_res = requests.post(get_man_conf_url, data=json.dumps(get_man_conf_body),
|
|
+ headers=headers) # post request
|
|
man_ronf_res_text = json.loads(get_man_conf_res.text)
|
|
manage_confs = man_ronf_res_text.get("confFiles")
|
|
print("manage_confs is : {}".format(manage_confs))
|
|
|
|
if len(manage_confs) == 0:
|
|
code_num = 404
|
|
- base_rsp = BaseResponse(code_num, "The configuration is not set in the current domain." +
|
|
- "Please add the configuration information first.")
|
|
+ base_rsp = BaseResponse(code_num, "The configuration is not set in the current domain." +
|
|
+ "Please add the configuration information first.")
|
|
return base_rsp, code_num
|
|
|
|
# query the real conf in host
|
|
print("############## query the real conf ##############")
|
|
get_real_conf_url = "http://0.0.0.0:" + port + "/confs/queryRealConfs"
|
|
query_real_body = ConfHost(domain_name=domain, host_ids=host_ids)
|
|
- get_res_conf_res = requests.post(get_real_conf_url, data=json.dumps(query_real_body), headers=headers) # post request
|
|
+ get_res_conf_res = requests.post(get_real_conf_url, data=json.dumps(query_real_body),
|
|
+ headers=headers) # post request
|
|
real_conf_res_code = get_res_conf_res.status_code
|
|
real_conf_res_text = json.loads(get_res_conf_res.text)
|
|
print("real_conf_res_text is : {}".format(real_conf_res_text))
|
|
@@ -273,8 +276,8 @@ def query_real_confs(body=None): # noqa: E501
|
|
print("is_host_list_exist is : {}".format(is_host_list_exist))
|
|
if not is_host_list_exist:
|
|
code_num = 400
|
|
- base_rsp = BaseResponse(code_num, "The host information is not set in the current domain." +
|
|
- "Please add the host information first")
|
|
+ base_rsp = BaseResponse(code_num, "The host information is not set in the current domain." +
|
|
+ "Please add the host information first")
|
|
return base_rsp, code_num
|
|
|
|
# get all hosts managed by the current domain.
|
|
@@ -300,8 +303,8 @@ def query_real_confs(body=None): # noqa: E501
|
|
|
|
if len(exist_host) == 0 or len(failed_host) == len(host_list):
|
|
code_num = 400
|
|
- base_rsp = BaseResponse(code_num, "The host information is not set in the current domain." +
|
|
- "Please add the host information first")
|
|
+ base_rsp = BaseResponse(code_num, "The host information is not set in the current domain." +
|
|
+ "Please add the host information first")
|
|
return base_rsp, code_num
|
|
|
|
# get the management conf in domain
|
|
@@ -318,14 +321,14 @@ def query_real_confs(body=None): # noqa: E501
|
|
|
|
if res_code != 200:
|
|
code_num = res_code
|
|
- base_rsp = BaseResponse(code_num, "Failed to query the configuration items managed in the current domain. " +
|
|
- "The failure reason is:" + res_text)
|
|
+ base_rsp = BaseResponse(code_num, "Failed to query the configuration items managed in the current domain. " +
|
|
+ "The failure reason is:" + res_text)
|
|
return base_rsp, code_num
|
|
conf_files = res_text.get("confFiles")
|
|
if len(conf_files) == 0:
|
|
code_num = 400
|
|
- base_rsp = BaseResponse(code_num, "The configuration is not set in the current domain." +
|
|
- "Please add the configuration information first")
|
|
+ base_rsp = BaseResponse(code_num, "The configuration is not set in the current domain." +
|
|
+ "Please add the configuration information first")
|
|
return base_rsp, code_num
|
|
|
|
res = []
|
|
@@ -407,7 +410,7 @@ def query_real_confs(body=None): # noqa: E501
|
|
code_num = 400
|
|
res_text = "The real configuration does not found."
|
|
base_rsp = BaseResponse(code_num, "Real configuration query failed." +
|
|
- "The failure reason is : " + res_text)
|
|
+ "The failure reason is : " + res_text)
|
|
return base_rsp, code_num
|
|
|
|
return res
|
|
@@ -469,8 +472,8 @@ def sync_conf_to_host_from_domain(body=None): # noqa: E501
|
|
|
|
if len(exist_host) == 0:
|
|
code_num = 400
|
|
- base_rsp = BaseResponse(code_num, "The host information is not set in the current domain." +
|
|
- "Please add the host information first")
|
|
+ base_rsp = BaseResponse(code_num, "The host information is not set in the current domain." +
|
|
+ "Please add the host information first")
|
|
return base_rsp, code_num
|
|
|
|
# get the management conf in domain
|
|
@@ -478,7 +481,8 @@ def sync_conf_to_host_from_domain(body=None): # noqa: E501
|
|
get_man_conf_url = "http://0.0.0.0:" + port + "/management/getManagementConf"
|
|
headers = {"Content-Type": "application/json"}
|
|
get_man_conf_body = DomainName(domain_name=domain)
|
|
- get_man_conf_res = requests.post(get_man_conf_url, data=json.dumps(get_man_conf_body), headers=headers) # post request
|
|
+ get_man_conf_res = requests.post(get_man_conf_url, data=json.dumps(get_man_conf_body),
|
|
+ headers=headers) # post request
|
|
man_conf_res_text = json.loads(get_man_conf_res.text)
|
|
manage_confs = man_conf_res_text.get("confFiles")
|
|
print("manage_confs is : {}".format(manage_confs))
|
|
@@ -487,7 +491,7 @@ def sync_conf_to_host_from_domain(body=None): # noqa: E501
|
|
sync_res = []
|
|
for d_host in exist_host:
|
|
host_sync_result = HostSyncResult(host_id=d_host,
|
|
- sync_result=[])
|
|
+ sync_result=[])
|
|
for d_man_conf in manage_confs:
|
|
file_path = d_man_conf.get("filePath").split(":")[-1]
|
|
contents = d_man_conf.get("contents")
|
|
@@ -511,6 +515,7 @@ def sync_conf_to_host_from_domain(body=None): # noqa: E501
|
|
|
|
return sync_res
|
|
|
|
+
|
|
def query_supported_confs(body=None):
|
|
"""
|
|
query supported configuration list # noqa: E501
|
|
--
|
|
2.37.1.windows.1
|
|
|