From 8d6b6f6ecd07a712c55e089df2cd10263c6a085f Mon Sep 17 00:00:00 2001 From: leiyashuai Date: Wed, 13 Sep 2023 19:16:52 +0800 Subject: [PATCH] Add set-custom-config subcommand to venusclient Change-Id: I64fb1aad787e2c95536ec563bde91ac9233f5568 --- venusclient/v1/config.py | 16 ++++++++++++++++ venusclient/v1/config_shell.py | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/venusclient/v1/config.py b/venusclient/v1/config.py index afa58c7..de2c9dc 100644 --- a/venusclient/v1/config.py +++ b/venusclient/v1/config.py @@ -34,3 +34,19 @@ class ConfigManager(basemodels.BaseModelManager): return body except Exception as e: raise RuntimeError(str(e)) + + def set_custom_config(self, config_id, value): + """Set custom config to the specified value. + + :param config_id: The ID of the custom config + :param value: The value to set + :returns: The result of the set action. + """ + url = '/v1/custom_config' + body = {'id': config_id, + 'value': value} + try: + resp, body = self.api.json_request('POST', url, body=body) + return body + except Exception as e: + raise RuntimeError(str(e)) diff --git a/venusclient/v1/config_shell.py b/venusclient/v1/config_shell.py index 31dfa95..825ec02 100644 --- a/venusclient/v1/config_shell.py +++ b/venusclient/v1/config_shell.py @@ -12,9 +12,24 @@ # License for the specific language governing permissions and limitations # under the License. +from venusclient.common import cliutils as utils + def do_get_log_storage_days(cs, args): """get the days of saved logs in elasticsearch(unit day).""" endpoint = cs.config.get_days() print(endpoint) return endpoint + + +@utils.arg('id', + metavar='', + help='The id of custom config') +@utils.arg('value', + metavar='', + help='The value set to custom config') +def do_set_custom_config(cs, args): + """set the custom config.""" + endpoint = cs.config.set_custom_config(args.id, args.value) + print(endpoint) + return endpoint