Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible for esCleaner.py to use a username/password #1318

Merged
merged 1 commit into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugin/storage/es/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The script is using `python3`. All dependencies can be installed with: `python3

Parameters:
* Environment variable TIMEOUT that sets the timeout in seconds for indices deletion (default: 120)
* Optional environment variable ES_USERNAME and ES_PASSWORD
* a number that will delete any indices older than that number in days
* ElasticSearch hostnames
* Example usage: `TIMEOUT=120 ./esCleaner.py 4 localhost:9200`
Expand Down
8 changes: 7 additions & 1 deletion plugin/storage/es/esCleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ def main():
print('ARCHIVE ... specifies whether to remove archive indices. Use true or false')
sys.exit(1)

client = elasticsearch.Elasticsearch(sys.argv[2:])
username = os.getenv("ES_USERNAME")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be added into the help print

password = os.getenv("ES_PASSWORD")

if username is not None and password is not None:
client = elasticsearch.Elasticsearch(sys.argv[2:], http_auth=(username, password))
else:
client = elasticsearch.Elasticsearch(sys.argv[2:])

ilo = curator.IndexList(client)
empty_list(ilo, 'ElasticSearch has no indices')
Expand Down