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

Create elasticsearh_data.py #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
42 changes: 42 additions & 0 deletions elasticsearh_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import requests
import json
import datetime
import logging
from threading import Thread
from queue import Queue
import glob
import os
import functools
headers = {"Content-Type":"application/json"}
path = r'C:\Users\Manikindi_shaik_Noor\Desktop\batool\esx-localhost-2020-07-16--10.31-2355077.tgz'


elastic_url = "http://%s/%s/%s" % (
1.1.1.1:8080",
"new_index_blob",
"_doc/execution-b9aaa19c-c3b7-4925-94fc-bad39d0b1b91sosreport-MX5108N-A1-20200927083834.tar.xz"
)
import base64

try:
with open(path, "rb") as f:
bytes = f.read()
encoded = str(base64.b64encode(bytes).decode("utf-8") )

upload_data = {}
upload_data["name"] = "esx-localhost-2020-07-16--10.31-2355077.tgz"
upload_data["blob"] = encoded
except Exception as e:
print(str(e))

try:
# print(upload_data)
resp_elastic = requests.put(
elastic_url,
headers=headers,
data=json.dumps(upload_data),
verify=False
)
print("ES Entry completed for {}".format(path))
except Exception as e:
print(e)