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()
|
metadata = otc_metadata.Services()
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Create Index data for search inside OpenSearch"
|
description="Create Index data for search inside OpenSearch"
|
||||||
@ -53,8 +54,9 @@ def parse_args():
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ def main():
|
|||||||
environment=args.target_environment
|
environment=args.target_environment
|
||||||
)
|
)
|
||||||
|
|
||||||
indexedData = indexData(
|
indexData(
|
||||||
deleteIndex=args.delete_index,
|
deleteIndex=args.delete_index,
|
||||||
hosts=args.hosts,
|
hosts=args.hosts,
|
||||||
index=args.index,
|
index=args.index,
|
||||||
@ -71,11 +73,13 @@ def main():
|
|||||||
data=data
|
data=data
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def getData(environment):
|
def getData(environment):
|
||||||
return metadata.service_types_with_doc_types(
|
return metadata.service_types_with_doc_types(
|
||||||
environment=environment
|
environment=environment
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def indexData(deleteIndex, hosts, index, username, password, data):
|
def indexData(deleteIndex, hosts, index, username, password, data):
|
||||||
hosts = generate_os_host_list(hosts)
|
hosts = generate_os_host_list(hosts)
|
||||||
client = OpenSearch(
|
client = OpenSearch(
|
||||||
@ -88,11 +92,12 @@ def indexData(deleteIndex, hosts, index, username, password, data):
|
|||||||
ssl_show_warn=False
|
ssl_show_warn=False
|
||||||
)
|
)
|
||||||
|
|
||||||
if deleteIndex == True:
|
if deleteIndex is True:
|
||||||
delete_index(client, index)
|
delete_index(client, index)
|
||||||
|
|
||||||
create_index(client, index, data)
|
create_index(client, index, data)
|
||||||
|
|
||||||
|
|
||||||
def generate_os_host_list(hosts):
|
def generate_os_host_list(hosts):
|
||||||
host_list = []
|
host_list = []
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
@ -104,8 +109,10 @@ def generate_os_host_list(hosts):
|
|||||||
host_list.append(json_host)
|
host_list.append(json_host)
|
||||||
return host_list
|
return host_list
|
||||||
|
|
||||||
|
|
||||||
def create_index(client, index, data):
|
def create_index(client, index, data):
|
||||||
return client.indices.create(index, body=data)
|
return client.indices.create(index, body=data)
|
||||||
|
|
||||||
|
|
||||||
def delete_index(client, index):
|
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