Files
python-venusclient/venusclient/v1/anomaly_shell.py
leiyashuai 38abcf7de5 Add add_anomaly_rule to venusclient
Change-Id: I1dbdcc50cbb354c68f3173bd2bfd8a0553ab9495
2023-09-14 13:47:35 +08:00

59 lines
1.9 KiB
Python

# Copyright 2023 Inspur
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from venusclient.common import cliutils as utils
@utils.arg('--title',
metavar='<title>',
dest='title',
help='The title of anomaly rule, required')
@utils.arg('--desc',
metavar='<desc>',
dest='desc',
help='The description of anomaly rule, required')
@utils.arg('--keyword',
metavar='<keyword>',
dest='keyword',
help='Keyword, only support exact-match at present, required')
@utils.arg('--log_type',
metavar='<log_type>',
dest='log_type',
help='The type of log, flog is platform log, and slog is operate '
'system log, required')
@utils.arg('--module',
metavar='<module>',
dest='module',
help='Application module or service, required')
def do_add_anomaly_rule(cs, args):
"""add an anomaly rule"""
endpoint = cs.anomaly.add_anomaly_rule(args.title, args.desc, args.keyword,
args.log_type, args.module)
print(endpoint)
return endpoint
def do_rule_list(cs, args):
"""get anomaly rule list"""
endpoint = cs.anomaly.rule_list(args)
print(endpoint)
return endpoint
def do_record_list(cs, args):
"""get anomaly record list"""
endpoint = cs.anomaly.rule_list(args)
print(endpoint)
return endpoint