summaryrefslogtreecommitdiffstats
path: root/utils/test/scripts/kibana_cleanup.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils/test/scripts/kibana_cleanup.py')
-rw-r--r--utils/test/scripts/kibana_cleanup.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/utils/test/scripts/kibana_cleanup.py b/utils/test/scripts/kibana_cleanup.py
index 2cd52af67..e8d452af2 100644
--- a/utils/test/scripts/kibana_cleanup.py
+++ b/utils/test/scripts/kibana_cleanup.py
@@ -7,16 +7,16 @@ import urlparse
logger = logging.getLogger('clear_kibana')
logger.setLevel(logging.DEBUG)
-file_handler = logging.FileHandler('/var/log/{}.log'.format(__name__))
+file_handler = logging.FileHandler('/var/log/{}.log'.format('clear_kibana'))
file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s'))
logger.addHandler(file_handler)
-def delete_all(url, es_user, es_passwd):
- ids = shared_utils.get_elastic_data(url, es_user, es_passwd, body=None, field='_id')
+def delete_all(url, es_creds):
+ ids = shared_utils.get_elastic_data(url, es_creds, body=None, field='_id')
for id in ids:
del_url = '/'.join([url, id])
- shared_utils.delete_request(del_url, es_user, es_passwd)
+ shared_utils.delete_request(del_url, es_creds)
if __name__ == '__main__':
@@ -24,20 +24,17 @@ if __name__ == '__main__':
parser.add_argument('-e', '--elasticsearch-url', default='http://localhost:9200',
help='the url of elasticsearch, defaults to http://localhost:9200')
- parser.add_argument('-u', '--elasticsearch-username',
- help='the username for elasticsearch')
-
- parser.add_argument('-p', '--elasticsearch-password',
- help='the password for elasticsearch')
+ parser.add_argument('-u', '--elasticsearch-username', default=None,
+ help='The username with password for elasticsearch in format username:password')
args = parser.parse_args()
base_elastic_url = args.elasticsearch_url
- es_user = args.elasticsearch_username
- es_passwd = args.elasticsearch_password
+ es_creds = args.elasticsearch_username
urls = (urlparse.urljoin(base_elastic_url, '/.kibana/visualization'),
urlparse.urljoin(base_elastic_url, '/.kibana/dashboard'),
urlparse.urljoin(base_elastic_url, '/.kibana/search'))
for url in urls:
- delete_all(url, es_user, es_passwd)
+ delete_all(url, es_creds)
+