Merge "Add platform service parameters for crashdump"
This commit is contained in:
commit
bb7372b5ad
|
@ -1304,6 +1304,13 @@ SERVICE_PARAM_HTTP_PORT_HTTPS_DEFAULT = 8443
|
|||
SERVICE_PARAM_SECTION_OPENSTACK_HELM = 'helm'
|
||||
SERVICE_PARAM_NAME_ENDPOINT_DOMAIN = "endpoint_domain"
|
||||
|
||||
# Crashdump Service Parameters
|
||||
SERVICE_PARAM_SECTION_CRASHDUMP = 'crashdump'
|
||||
SERVICE_PARAM_CRASHDUMP_MAX_FILES = 'max_files'
|
||||
SERVICE_PARAM_CRASHDUMP_MAX_SIZE = 'max_size'
|
||||
SERVICE_PARAM_CRASHDUMP_MAX_USED = 'max_used'
|
||||
SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE = 'min_available'
|
||||
|
||||
# Collectd Service Parameters
|
||||
SERVICE_PARAM_SECTION_COLLECTD = 'collectd'
|
||||
SERVICE_PARAM_COLLECTD_NETWORK_SERVERS = 'network_servers'
|
||||
|
|
|
@ -485,6 +485,15 @@ def _validate_kernel_audit(name, value):
|
|||
constants.SERVICE_PARAM_PLATFORM_AUDITD_ENABLED)))
|
||||
|
||||
|
||||
def _validate_human_readable(name, value):
|
||||
pattern = r'^\d+(?:[.,]\d+)?\s*(K|Ki|M|Mi|G|Gi|T|Ti)$'
|
||||
|
||||
if not re.match(pattern, value):
|
||||
raise wsme.exc.ClientSideError(
|
||||
"Parameter '%s' value must be written in human readable format, "
|
||||
"e.g., '100M', '2.5Gi', '500K', etc." % name)
|
||||
|
||||
|
||||
def _byte_transform(param_value, param_name):
|
||||
format1 = re.search(r"^(-*[0-9]+([\.][0-9]+)*)([B|K|M|G|T|P|E])$", str(param_value))
|
||||
format2 = re.search(r"^(0)$", str(param_value))
|
||||
|
@ -1352,6 +1361,32 @@ OPENSTACK_HELM_PARAMETER_RESOURCE = {
|
|||
'openstack::helm::params::endpoint_domain',
|
||||
}
|
||||
|
||||
PLATFORM_CRASHDUMP_PARAMETER_OPTIONAL = [
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE,
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MAX_FILES,
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MAX_USED,
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE,
|
||||
]
|
||||
PLATFORM_CRASHDUMP_PARAMETER_VALIDATOR = {
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE:
|
||||
_validate_human_readable,
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MAX_FILES:
|
||||
_validate_positive_integer,
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MAX_USED:
|
||||
_validate_human_readable,
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE:
|
||||
_validate_human_readable,
|
||||
}
|
||||
PLATFORM_CRASHDUMP_PARAMETER_RESOURCE = {
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE:
|
||||
'platform::crashdump::params::max_size',
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MAX_FILES:
|
||||
'platform::crashdump::params::max_files',
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MAX_USED:
|
||||
'platform::crashdump::params::max_used',
|
||||
constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE:
|
||||
'platform::crashdump::params::min_available',
|
||||
}
|
||||
|
||||
COLLECTD_NETWORK_SERVERS_PARAMETER_DATA_FORMAT = {
|
||||
constants.SERVICE_PARAM_COLLECTD_NETWORK_SERVERS:
|
||||
|
@ -1486,6 +1521,11 @@ SERVICE_PARAMETER_SCHEMA = {
|
|||
SERVICE_PARAM_DATA_FORMAT: PLATFORM_CRI_PARAMETER_DATA_FORMAT,
|
||||
SERVICE_PARAM_RESOURCE: PLATFORM_CRI_PARAMETER_RESOURCE,
|
||||
},
|
||||
constants.SERVICE_PARAM_SECTION_CRASHDUMP: {
|
||||
SERVICE_PARAM_OPTIONAL: PLATFORM_CRASHDUMP_PARAMETER_OPTIONAL,
|
||||
SERVICE_PARAM_VALIDATOR: PLATFORM_CRASHDUMP_PARAMETER_VALIDATOR,
|
||||
SERVICE_PARAM_RESOURCE: PLATFORM_CRASHDUMP_PARAMETER_RESOURCE,
|
||||
},
|
||||
constants.SERVICE_PARAM_SECTION_COLLECTD: {
|
||||
SERVICE_PARAM_OPTIONAL: COLLECTD_PARAMETER_OPTIONAL,
|
||||
SERVICE_PARAM_VALIDATOR: COLLECTD_PARAMETER_VALIDATOR,
|
||||
|
|
|
@ -10802,6 +10802,17 @@ class ConductorManager(service.PeriodicService):
|
|||
personalities = [constants.CONTROLLER,
|
||||
constants.WORKER,
|
||||
constants.STORAGE]
|
||||
elif section == constants.SERVICE_PARAM_SECTION_CRASHDUMP:
|
||||
personalities = [constants.CONTROLLER,
|
||||
constants.WORKER,
|
||||
constants.STORAGE]
|
||||
config_uuid = self._config_update_hosts(context, personalities)
|
||||
|
||||
config_dict = {
|
||||
'personalities': personalities,
|
||||
"classes": ['platform::crashdump::runtime']
|
||||
}
|
||||
self._config_apply_runtime_manifest(context, config_uuid, config_dict)
|
||||
elif section == constants.SERVICE_PARAM_SECTION_PLATFORM_KERNEL:
|
||||
reboot = True
|
||||
personalities = [constants.CONTROLLER,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2019 Wind River Systems, Inc.
|
||||
# Copyright (c) 2019-2023 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -276,6 +276,198 @@ class ApiServiceParameterTestCaseMixin(object):
|
|||
'name': constants.SERVICE_PARAM_NAME_POSTGRESQL_MAX_PARALLEL_WORKERS_PER_GATHER,
|
||||
'value': '1'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_FILES,
|
||||
'value': '-1'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_FILES,
|
||||
'value': '2a'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_FILES,
|
||||
'value': 'one'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE,
|
||||
'value': '1GB'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE,
|
||||
'value': '1,G'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE,
|
||||
'value': '500m'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_USED,
|
||||
'value': '20GB'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_USED,
|
||||
'value': '10gb'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_USED,
|
||||
'value': '10,5GB'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE,
|
||||
'value': '20GB'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE,
|
||||
'value': '10gb'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE,
|
||||
'value': '10,5GB'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE,
|
||||
'value': '3.2Gi'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_FILES,
|
||||
'value': '5'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_USED,
|
||||
'value': '6,2G'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE,
|
||||
'value': '486.5Mi'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE,
|
||||
'value': '2Gi'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE,
|
||||
'value': '850M'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE,
|
||||
'value': '850,5Mi'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE,
|
||||
'value': '850.5Mi'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_USED,
|
||||
'value': '4Gi'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_USED,
|
||||
'value': '900M'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_USED,
|
||||
'value': '900,5Mi'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_USED,
|
||||
'value': '900.5Mi'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE,
|
||||
'value': '3G'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE,
|
||||
'value': '2Gi'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE,
|
||||
'value': '400M'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE,
|
||||
'value': '400,5Mi'
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MIN_AVAILABLE,
|
||||
'value': ''
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_FILES,
|
||||
'value': ''
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_USED,
|
||||
'value': ''
|
||||
},
|
||||
{
|
||||
'service': constants.SERVICE_TYPE_PLATFORM,
|
||||
'section': constants.SERVICE_PARAM_SECTION_CRASHDUMP,
|
||||
'name': constants.SERVICE_PARAM_CRASHDUMP_MAX_SIZE,
|
||||
'value': ''
|
||||
},
|
||||
]
|
||||
|
||||
service_parameter_wildcard = {
|
||||
|
@ -475,6 +667,39 @@ class ApiServiceParameterPostTestSuiteMixin(ApiServiceParameterTestCaseMixin):
|
|||
response = self.post(post_object)
|
||||
self.validate_data(post_object, response)
|
||||
|
||||
def test_crashdump_formats(self):
|
||||
# Test invalid max_files format
|
||||
post_object = self.service_parameter_data[37]
|
||||
self.post(post_object, expect_errors=True, error_message="Parameter '" +
|
||||
self.service_parameter_data[37]['name'] +
|
||||
"' must be positive integer.")
|
||||
|
||||
for param in range(38, 40):
|
||||
post_object = self.service_parameter_data[param]
|
||||
self.post(post_object, expect_errors=True, error_message="Parameter '" +
|
||||
self.service_parameter_data[param]['name'] +
|
||||
"' must be an integer value.")
|
||||
|
||||
# Test invalid max_size, max_used and min_available format
|
||||
for param in range(40, 49):
|
||||
post_object = self.service_parameter_data[param]
|
||||
self.post(post_object, expect_errors=True, error_message="Parameter '" +
|
||||
self.service_parameter_data[param]['name'] +
|
||||
"' value must be written in human readable format, " +
|
||||
"e.g., '100M', '2.5Gi', '500K', etc.")
|
||||
|
||||
# test empty value
|
||||
for param in range(65, 69):
|
||||
post_object = self.service_parameter_data[param]
|
||||
self.post(post_object, expect_errors=True,
|
||||
error_message="The service parameter value is mandatory")
|
||||
|
||||
# Test valid max_files, max_size, max_used and min_available format
|
||||
for param in range(49, 53):
|
||||
post_object = self.service_parameter_data[param]
|
||||
response = self.post(post_object)
|
||||
self.validate_data(post_object, response)
|
||||
|
||||
|
||||
class ApiServiceParameterDeleteTestSuiteMixin(ApiServiceParameterTestCaseMixin):
|
||||
""" Tests deletion.
|
||||
|
|
Loading…
Reference in New Issue