Fix pep8
All checks were successful
gl/check check status: success (fd50baa0dc87f02339001d38af2498d018793b55)
All checks were successful
gl/check check status: success (fd50baa0dc87f02339001d38af2498d018793b55)
This commit is contained in:
parent
a2f7e401b6
commit
fd50baa0dc
@ -6,6 +6,7 @@ from opensearchpy import OpenSearch
|
||||
|
||||
metadata = otc_metadata.Services()
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Create Index data for search inside OpenSearch"
|
||||
@ -53,8 +54,9 @@ def parse_args():
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
args = parse_args()
|
||||
|
||||
@ -62,7 +64,7 @@ def main():
|
||||
environment=args.target_environment
|
||||
)
|
||||
|
||||
indexedData = indexData(
|
||||
indexData(
|
||||
deleteIndex=args.delete_index,
|
||||
hosts=args.hosts,
|
||||
index=args.index,
|
||||
@ -71,11 +73,13 @@ def main():
|
||||
data=data
|
||||
)
|
||||
|
||||
|
||||
def getData(environment):
|
||||
return metadata.service_types_with_doc_types(
|
||||
environment=environment
|
||||
)
|
||||
|
||||
|
||||
def indexData(deleteIndex, hosts, index, username, password, data):
|
||||
hosts = generate_os_host_list(hosts)
|
||||
client = OpenSearch(
|
||||
@ -88,11 +92,12 @@ def indexData(deleteIndex, hosts, index, username, password, data):
|
||||
ssl_show_warn=False
|
||||
)
|
||||
|
||||
if deleteIndex == True:
|
||||
if deleteIndex is True:
|
||||
delete_index(client, index)
|
||||
|
||||
|
||||
create_index(client, index, data)
|
||||
|
||||
|
||||
def generate_os_host_list(hosts):
|
||||
host_list = []
|
||||
for host in hosts:
|
||||
@ -104,8 +109,10 @@ def generate_os_host_list(hosts):
|
||||
host_list.append(json_host)
|
||||
return host_list
|
||||
|
||||
|
||||
def create_index(client, index, data):
|
||||
return client.indices.create(index, body=data)
|
||||
|
||||
|
||||
def delete_index(client, index):
|
||||
return client.indices.delete(index=index, ignore=[400, 404])
|
||||
return client.indices.delete(index=index, ignore=[400, 404])
|
||||
|
Loading…
x
Reference in New Issue
Block a user