fix details & optimize delete es index code
Change-Id: I34ead1f3ffec6dd5a3ae9c38264cbfc6bff6e918
This commit is contained in:
parent
de3899ebe7
commit
41bb0f4e03
@ -26,7 +26,7 @@ _KNOWN_VERSIONS = {
|
||||
"v1.0": {
|
||||
"id": "v1.0",
|
||||
"status": "SUPPORTED",
|
||||
"updated": "2014-06-28T12:20:21Z",
|
||||
"updated": "2023-02-28T18:43:00Z",
|
||||
"links": [
|
||||
{
|
||||
"rel": "describedby",
|
||||
|
@ -27,7 +27,7 @@ TASK_NAME = "delete_es_index"
|
||||
|
||||
|
||||
class DeleteESIndexTask(object):
|
||||
"""delete es index task."""
|
||||
"""delete es index task"""
|
||||
|
||||
def __init__(self):
|
||||
self.elasticsearch_url = CONF.elasticsearch.url
|
||||
@ -35,17 +35,22 @@ class DeleteESIndexTask(object):
|
||||
self.search_lib = ESSearchObj()
|
||||
|
||||
def delete_index(self, name):
|
||||
url = self.elasticsearch_url + '/' + name
|
||||
status, text = utils.request_es(url, "DELETE")
|
||||
if status != 200:
|
||||
LOG.error(_LE("failed to delete es index: %s"), name)
|
||||
return
|
||||
try:
|
||||
url = self.elasticsearch_url + '/' + name
|
||||
status, text = utils.request_es(url, "DELETE")
|
||||
if status != 200:
|
||||
LOG.error(_LE("failed to delete es index: %s"), name)
|
||||
return
|
||||
except Exception as e:
|
||||
LOG.error(_LE("delete es inidex:%s, catch exception:%s"),
|
||||
name, str(e))
|
||||
|
||||
def delete_es_history_index(self):
|
||||
len_d = self.config_api.get_config("log_save_days")
|
||||
if len_d is None:
|
||||
LOG.error(_LE("the config of log_save_days do not exist"))
|
||||
return
|
||||
|
||||
LOG.info(_LI("elasticsearch indexes(log) save days: %d"), len_d)
|
||||
today = time.strftime('%Y-%m-%d')
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user