Add AnomalyManager to venusclient
Change-Id: I2f2c6e94ba5be089b2089272b4f25df9d9f3cc6f
This commit is contained in:
parent
ba69579fe4
commit
971f4a70ef
51
venusclient/v1/anomaly.py
Normal file
51
venusclient/v1/anomaly.py
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
# 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 utils
|
||||||
|
from venusclient.v1 import basemodels
|
||||||
|
|
||||||
|
CREATION_ATTRIBUTES = basemodels.CREATION_ATTRIBUTES
|
||||||
|
|
||||||
|
|
||||||
|
class LogAnomaly(basemodels.BaseModel):
|
||||||
|
model_name = "Anomaly"
|
||||||
|
|
||||||
|
|
||||||
|
class AnomalyManager(basemodels.BaseModelManager):
|
||||||
|
api_name = "anomaly"
|
||||||
|
base_url = "anomaly"
|
||||||
|
resource_class = LogAnomaly
|
||||||
|
|
||||||
|
def rule_list(self, title='', desc='', keyword='',
|
||||||
|
log_type='', module_name='', host_name='',
|
||||||
|
page_num=1, page_size=10):
|
||||||
|
url = '/v1/anomaly/rule/list'
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'title ': title,
|
||||||
|
'desc': desc,
|
||||||
|
'keyword': keyword,
|
||||||
|
'log_type': log_type,
|
||||||
|
'module_name': module_name,
|
||||||
|
'flag': host_name,
|
||||||
|
'page_num': page_num,
|
||||||
|
'page_size': page_size
|
||||||
|
}
|
||||||
|
url += utils.prepare_query_string(params)
|
||||||
|
|
||||||
|
try:
|
||||||
|
resp, body = self.api.json_request('GET', url)
|
||||||
|
return body
|
||||||
|
except Exception as e:
|
||||||
|
raise RuntimeError(str(e))
|
20
venusclient/v1/anomaly_shell.py
Normal file
20
venusclient/v1/anomaly_shell.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
|
||||||
|
def do_rule_list(cs, args):
|
||||||
|
"""get anomaly rule list"""
|
||||||
|
endpoint = cs.anomaly.rule_list(args)
|
||||||
|
print(endpoint)
|
||||||
|
return endpoint
|
@ -18,6 +18,7 @@ from keystoneauth1 import session as ksa_session
|
|||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from venusclient.common import httpclient
|
from venusclient.common import httpclient
|
||||||
from venusclient.v1 import analyse
|
from venusclient.v1 import analyse
|
||||||
|
from venusclient.v1 import anomaly
|
||||||
from venusclient.v1 import config
|
from venusclient.v1 import config
|
||||||
from venusclient.v1 import search
|
from venusclient.v1 import search
|
||||||
|
|
||||||
@ -184,6 +185,7 @@ class Client(object):
|
|||||||
self.config = config.ConfigManager(self.http_client)
|
self.config = config.ConfigManager(self.http_client)
|
||||||
self.search = search.SearchManager(self.http_client)
|
self.search = search.SearchManager(self.http_client)
|
||||||
self.analyse = analyse.AnalyseManager(self.http_client)
|
self.analyse = analyse.AnalyseManager(self.http_client)
|
||||||
|
self.anomaly = anomaly.AnomalyManager(self.http_client)
|
||||||
|
|
||||||
profile = kwargs.pop("profile", None)
|
profile = kwargs.pop("profile", None)
|
||||||
if profiler and profile:
|
if profiler and profile:
|
||||||
|
@ -13,12 +13,13 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from venusclient.v1 import analyse_shell
|
from venusclient.v1 import analyse_shell
|
||||||
|
from venusclient.v1 import anomaly_shell
|
||||||
from venusclient.v1 import config_shell
|
from venusclient.v1 import config_shell
|
||||||
from venusclient.v1 import search_shell
|
from venusclient.v1 import search_shell
|
||||||
|
|
||||||
|
|
||||||
COMMAND_MODULES = [
|
COMMAND_MODULES = [
|
||||||
config_shell,
|
config_shell,
|
||||||
search_shell,
|
search_shell,
|
||||||
analyse_shell
|
analyse_shell,
|
||||||
|
anomaly_shell,
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user