commit
8b0e01ecc0
@ -24,6 +24,8 @@ import xml.etree.cElementTree as ETree
|
||||
|
||||
from gspylib.common.ErrorCode import ErrorCode
|
||||
from gspylib.common.GaussLog import GaussLog
|
||||
from gspylib.common.ClusterParams import ClusterParams
|
||||
from gspylib.common.DeviceListParams import DeviceListParams
|
||||
from base_utils.security.security_checker import SecurityChecker
|
||||
from domain_utils.domain_common.cluster_constants import ClusterConstants
|
||||
|
||||
@ -111,6 +113,7 @@ class ClusterConfigFile:
|
||||
raise Exception(ErrorCode.GAUSS_512["GAUSS_51200"] % element_name)
|
||||
element = root_node.findall('CLUSTER')[0]
|
||||
nodeArray = element.findall('PARAM')
|
||||
ClusterConfigFile.validate_param_names_in_cluster(nodeArray)
|
||||
(return_status, return_value) = ClusterConfigFile.findParamInCluster(para_name,
|
||||
nodeArray)
|
||||
elif element_name == 'node'.upper():
|
||||
@ -119,6 +122,7 @@ class ClusterConfigFile:
|
||||
raise Exception(ErrorCode.GAUSS_512["GAUSS_51200"] % element_name)
|
||||
device_array = root_node.findall('DEVICELIST')[0]
|
||||
device_node = device_array.findall('DEVICE')
|
||||
ClusterConfigFile.validate_param_names_in_devicelist(device_node)
|
||||
(return_status, return_value) = ClusterConfigFile.findParamByName(nodeName, para_name,
|
||||
device_node)
|
||||
else:
|
||||
@ -126,6 +130,36 @@ class ClusterConfigFile:
|
||||
|
||||
return (return_status, return_value)
|
||||
|
||||
@staticmethod
|
||||
def validate_param_names_in_cluster(node_array):
|
||||
"""
|
||||
function : Validate parameter names in Cluster
|
||||
input : []
|
||||
output : NA
|
||||
"""
|
||||
expected_param_names = ClusterParams.get_all_param_names()
|
||||
pattern = ClusterParams.FLOAT_IP_PATTERN
|
||||
for node in node_array:
|
||||
name = node.attrib['name']
|
||||
if name not in expected_param_names and not pattern.match(name):
|
||||
raise Exception(ErrorCode.GAUSS_512["GAUSS_51258"] % name)
|
||||
|
||||
@staticmethod
|
||||
def validate_param_names_in_devicelist(device_node):
|
||||
"""
|
||||
function : Validate parameter names in DEVICELIST
|
||||
input : Object
|
||||
output : NA
|
||||
"""
|
||||
expected_param_names = DeviceListParams.get_all_param_names()
|
||||
pattern = DeviceListParams.SYNC_NODE_PATTERN
|
||||
for dev in device_node:
|
||||
param_list = dev.findall('PARAM')
|
||||
for param in param_list:
|
||||
thisname = param.attrib['name']
|
||||
if thisname not in expected_param_names and not pattern.match(thisname):
|
||||
raise Exception(ErrorCode.GAUSS_512["GAUSS_51258"] % thisname)
|
||||
|
||||
@staticmethod
|
||||
def findParamByName(node_name, para_name, device_node):
|
||||
"""
|
||||
|
95
script/gspylib/common/ClusterParams.py
Normal file
95
script/gspylib/common/ClusterParams.py
Normal file
@ -0,0 +1,95 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
###########################################################################################
|
||||
# Copyright (c) 2024 Huawei Technologies Co.,Ltd.
|
||||
#
|
||||
# openGauss is licensed under Mulan PSL v2.
|
||||
# You can use this software according to the terms
|
||||
# and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
#
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
# -----------------------------------------------------------------------------------------
|
||||
# Description : ClusterParams.py is used to define the parameters under the cluster label.
|
||||
###########################################################################################
|
||||
import re
|
||||
|
||||
|
||||
class ClusterParams:
|
||||
"""
|
||||
Cluster parameter names constants.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
CLUSTER_NAME = 'clusterName'
|
||||
NODE_NAMES = 'nodeNames'
|
||||
GAUSSDB_APP_PATH = 'gaussdbAppPath'
|
||||
GAUSSDB_LOG_PATH = 'gaussdbLogPath'
|
||||
TMP_MPPDB_PATH = 'tmpMppdbPath'
|
||||
GAUSSDB_TOOL_PATH = 'gaussdbToolPath'
|
||||
CORE_PATH = 'corePath'
|
||||
BACK_IP1S = 'backIp1s'
|
||||
ENABLE_DCF = 'enable_dcf'
|
||||
DCF_CONFIG = 'dcf_config'
|
||||
ENABLE_DSS = 'enable_dss'
|
||||
DSS_HOME = 'dss_home'
|
||||
SS_DSS_VG_NAME = 'ss_dss_vg_name'
|
||||
DSS_VG_INFO = 'dss_vg_info'
|
||||
VOTING_DISK_PATH = 'votingDiskPath'
|
||||
SHARE_DISK_DIR = 'shareDiskDir'
|
||||
DSS_SSL_ENABLE = 'dss_ssl_enable'
|
||||
SS_INTERCONNECT_TYPE = 'ss_interconnect_type'
|
||||
SS_RDMA_WORK_CONFIG = 'ss_rdma_work_config'
|
||||
ENABLE_UWAL = 'enable_uwal'
|
||||
UWAL_DISK_SIZE = 'uwal_disk_size'
|
||||
UWAL_LOG_PATH = 'uwal_log_path'
|
||||
UWAL_RPC_COMPRESSION_SWITCH = 'uwal_rpc_compression_switch'
|
||||
UWAL_RPC_FLOWCONTROL_SWITCH = 'uwal_rpc_flowcontrol_switch'
|
||||
UWAL_RPC_FLOWCONTROL_VALUE = 'uwal_rpc_flowcontrol_value'
|
||||
UWAL_ASYNC_APPEND_SWITCH = 'uwal_async_append_switch'
|
||||
UWAL_DEVICES_PATH = 'uwal_devices_path'
|
||||
PASSWORD = 'password'
|
||||
CLUSTER_TYPE = 'clusterType'
|
||||
|
||||
@staticmethod
|
||||
def get_all_param_names():
|
||||
return [
|
||||
ClusterParams.CLUSTER_NAME,
|
||||
ClusterParams.NODE_NAMES,
|
||||
ClusterParams.GAUSSDB_APP_PATH,
|
||||
ClusterParams.GAUSSDB_LOG_PATH,
|
||||
ClusterParams.TMP_MPPDB_PATH,
|
||||
ClusterParams.GAUSSDB_TOOL_PATH,
|
||||
ClusterParams.CORE_PATH,
|
||||
ClusterParams.BACK_IP1S,
|
||||
ClusterParams.ENABLE_DCF,
|
||||
ClusterParams.DCF_CONFIG,
|
||||
ClusterParams.ENABLE_DSS,
|
||||
ClusterParams.DSS_HOME,
|
||||
ClusterParams.SS_DSS_VG_NAME,
|
||||
ClusterParams.DSS_VG_INFO,
|
||||
ClusterParams.VOTING_DISK_PATH,
|
||||
ClusterParams.SHARE_DISK_DIR,
|
||||
ClusterParams.DSS_SSL_ENABLE,
|
||||
ClusterParams.SS_INTERCONNECT_TYPE,
|
||||
ClusterParams.SS_RDMA_WORK_CONFIG,
|
||||
ClusterParams.ENABLE_UWAL,
|
||||
ClusterParams.UWAL_DISK_SIZE,
|
||||
ClusterParams.UWAL_LOG_PATH,
|
||||
ClusterParams.UWAL_RPC_COMPRESSION_SWITCH,
|
||||
ClusterParams.UWAL_RPC_FLOWCONTROL_SWITCH,
|
||||
ClusterParams.UWAL_RPC_FLOWCONTROL_VALUE,
|
||||
ClusterParams.UWAL_ASYNC_APPEND_SWITCH,
|
||||
ClusterParams.UWAL_DEVICES_PATH,
|
||||
ClusterParams.PASSWORD,
|
||||
ClusterParams.CLUSTER_TYPE
|
||||
]
|
||||
|
||||
FLOAT_IP_PATTERN = re.compile(r'\bfloatIp[0-9]+')
|
85
script/gspylib/common/DeviceListParams.py
Normal file
85
script/gspylib/common/DeviceListParams.py
Normal file
@ -0,0 +1,85 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
###############################################################################################
|
||||
# Copyright (c) 2024 Huawei Technologies Co.,Ltd.
|
||||
#
|
||||
# openGauss is licensed under Mulan PSL v2.
|
||||
# You can use this software according to the terms
|
||||
# and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
#
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
# ---------------------------------------------------------------------------------------------
|
||||
# Description : DeviceListParams.py is used to define the parameters under the DeviceList tag.
|
||||
###############################################################################################
|
||||
import re
|
||||
|
||||
|
||||
class DeviceListParams:
|
||||
"""
|
||||
DeviceList parameter names and patterns constants.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
NAME = 'name'
|
||||
AZ_NAME = 'azName'
|
||||
AZ_PRIORITY = 'azPriority'
|
||||
BACK_IP1 = 'backIp1'
|
||||
SSH_IP1 = 'sshIp1'
|
||||
DATA_NUM = 'dataNum'
|
||||
DATA_PORT_BASE = 'dataPortBase'
|
||||
DATA_NODE1 = 'dataNode1'
|
||||
DATA_NODE1_SYNC_NUM = 'dataNode1_syncNum'
|
||||
CMS_NUM = 'cmsNum'
|
||||
CM_DIR = 'cmDir'
|
||||
CM_SERVER_PORT_BASE = 'cmServerPortBase'
|
||||
CM_SERVER_LISTEN_IP1 = 'cmServerListenIp1'
|
||||
CM_SERVER_HA_IP1 = 'cmServerHaIp1'
|
||||
CM_SERVER_LEVEL = 'cmServerlevel'
|
||||
CM_SERVER_LEVEL1 = 'cmServerLevel'
|
||||
CM_SERVER_RELATION = 'cmServerRelation'
|
||||
CM_SERVER_PORT_STANDBY = 'cmServerPortStandby'
|
||||
CASCADE_ROLE = 'cascadeRole'
|
||||
DATA_LISTEN_IP1 = 'dataListenIp1'
|
||||
DATA_NODE_XLOG_PATH1 = 'dataNodeXlogPath1'
|
||||
FLOAT_IP_MAP1 = 'floatIpMap1'
|
||||
DATA_PORT_STANDBY = 'dataPortStandby'
|
||||
DATA_PORT_DUMMY_STANDBY = 'dataPortDummyStandby'
|
||||
|
||||
@staticmethod
|
||||
def get_all_param_names():
|
||||
return [
|
||||
DeviceListParams.NAME,
|
||||
DeviceListParams.AZ_NAME,
|
||||
DeviceListParams.AZ_PRIORITY,
|
||||
DeviceListParams.BACK_IP1,
|
||||
DeviceListParams.SSH_IP1,
|
||||
DeviceListParams.DATA_NUM,
|
||||
DeviceListParams.DATA_PORT_BASE,
|
||||
DeviceListParams.DATA_NODE1,
|
||||
DeviceListParams.DATA_NODE1_SYNC_NUM,
|
||||
DeviceListParams.CMS_NUM,
|
||||
DeviceListParams.CM_DIR,
|
||||
DeviceListParams.CM_SERVER_PORT_BASE,
|
||||
DeviceListParams.CM_SERVER_LISTEN_IP1,
|
||||
DeviceListParams.CM_SERVER_HA_IP1,
|
||||
DeviceListParams.CM_SERVER_LEVEL,
|
||||
DeviceListParams.CM_SERVER_LEVEL1,
|
||||
DeviceListParams.CM_SERVER_RELATION,
|
||||
DeviceListParams.CM_SERVER_PORT_STANDBY,
|
||||
DeviceListParams.CASCADE_ROLE,
|
||||
DeviceListParams.DATA_LISTEN_IP1,
|
||||
DeviceListParams.DATA_NODE_XLOG_PATH1,
|
||||
DeviceListParams.FLOAT_IP_MAP1,
|
||||
DeviceListParams.DATA_PORT_STANDBY,
|
||||
DeviceListParams.DATA_PORT_DUMMY_STANDBY
|
||||
]
|
||||
|
||||
SYNC_NODE_PATTERN = re.compile(r'^syncNode_.*')
|
@ -501,6 +501,8 @@ class ErrorCode():
|
||||
'GAUSS_51255': "[GAUSS-51255] : Failed to reencrypt the password with dsscmd",
|
||||
'GAUSS_51256': "[GAUSS-51256] : Failed to get the encrypted text with dsscmd",
|
||||
'GAUSS_51257': "[GAUSS-51257] : There are some errors about dsscmd. ",
|
||||
'GAUSS_51258': "[GAUSS-51258] : The parameter [%s] in the XML "
|
||||
"file is an incorrect parameter.",
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<PARAM name="cmServerPortBase" value="15000"/>
|
||||
<PARAM name="cmServerListenIp1" value="192.168.0.1,192.168.0.2,192.168.0.3"/>
|
||||
<PARAM name="cmServerHaIp1" value="192.168.0.1,192.168.0.2,192.168.0.3"/>
|
||||
<PARAM name="cmServerlevel" value="1"/>
|
||||
<PARAM name="cmServerLevel" value="1"/>
|
||||
<PARAM name="cmServerRelation" value="node1_hostname,node2_hostname,node3_hostname"/>
|
||||
<PARAM name="cmDir" value="/opt/huawei/data/cmserver"/>
|
||||
<PARAM name="dataNum" value="1"/>
|
||||
|
@ -3706,7 +3706,7 @@ def checkAuditSystemObject(isSetting):
|
||||
output : NA
|
||||
"""
|
||||
data = collectAuditSystemObject()
|
||||
if int(data.db[0].strip()) < 67121195:
|
||||
if int(data.db[0].strip()) < 67121159:
|
||||
if not isSetting:
|
||||
g_logger.log(
|
||||
" Warning reason:Ensure auditing of database object creation, deletion, and modification is enabled.The parameter 'audit_system_object' determines whether to record audit logs for CREATE, DROP, and ALTER operations on database objects.")
|
||||
@ -3895,7 +3895,7 @@ def setAuditSystemObject(data):
|
||||
output : NA
|
||||
"""
|
||||
try:
|
||||
cmd_set = "gs_guc reload -D %s -c \"audit_system_object = 67121195\"" % (os.getenv('PGDATA'))
|
||||
cmd_set = "gs_guc reload -D %s -c \"audit_system_object = 67121159\"" % (os.getenv('PGDATA'))
|
||||
result = subprocess.run(cmd_set, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||
if not re.search(r'Success to perform gs_guc!', result.stdout):
|
||||
g_logger.log("Failed to set Audit System Object")
|
||||
|
Loading…
x
Reference in New Issue
Block a user