Error fixes
Some checks failed
gl/check check status: failure (a2f7e401b619249b5449781cfaefeca1e35cac01)
Some checks failed
gl/check check status: failure (a2f7e401b619249b5449781cfaefeca1e35cac01)
This commit is contained in:
parent
afa9936ede
commit
a2f7e401b6
@ -4,3 +4,4 @@ requests
|
|||||||
jinja2
|
jinja2
|
||||||
dirsync
|
dirsync
|
||||||
cookiecutter
|
cookiecutter
|
||||||
|
opensearch-py
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import otc_metadata
|
import otc_metadata
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
from opensearchpy import helpers as os_helpers
|
|
||||||
from opensearchpy import OpenSearch
|
from opensearchpy import OpenSearch
|
||||||
|
|
||||||
|
|
||||||
def main():
|
metadata = otc_metadata.Services()
|
||||||
|
|
||||||
|
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"
|
||||||
)
|
)
|
||||||
@ -39,16 +40,23 @@ def main():
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--username',
|
'--username',
|
||||||
metavar='<username>',
|
metavar='<username>',
|
||||||
|
required=True,
|
||||||
help='Username for the connection.'
|
help='Username for the connection.'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--password',
|
'--password',
|
||||||
metavar='<password>',
|
metavar='<password>',
|
||||||
|
required=True,
|
||||||
help='Password for the connection.'
|
help='Password for the connection.'
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
return args
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
args = parse_args()
|
||||||
|
|
||||||
data = getData(
|
data = getData(
|
||||||
environment=args.target_environment
|
environment=args.target_environment
|
||||||
@ -64,7 +72,6 @@ def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
def getData(environment):
|
def getData(environment):
|
||||||
metadata = otc_metadata.Services()
|
|
||||||
return metadata.service_types_with_doc_types(
|
return metadata.service_types_with_doc_types(
|
||||||
environment=environment
|
environment=environment
|
||||||
)
|
)
|
||||||
@ -82,7 +89,9 @@ def indexData(deleteIndex, hosts, index, username, password, data):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if deleteIndex == True:
|
if deleteIndex == True:
|
||||||
client.indices.delete(index=index, ignore=[400, 404])
|
delete_index(client, index)
|
||||||
|
|
||||||
|
create_index(client, index, data)
|
||||||
|
|
||||||
def generate_os_host_list(hosts):
|
def generate_os_host_list(hosts):
|
||||||
host_list = []
|
host_list = []
|
||||||
@ -95,4 +104,8 @@ 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)
|
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])
|
Loading…
x
Reference in New Issue
Block a user