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:
		@ -4,3 +4,4 @@ requests
 | 
			
		||||
jinja2
 | 
			
		||||
dirsync
 | 
			
		||||
cookiecutter
 | 
			
		||||
opensearch-py
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,12 @@
 | 
			
		||||
import otc_metadata
 | 
			
		||||
import argparse
 | 
			
		||||
import logging
 | 
			
		||||
from opensearchpy import helpers as os_helpers
 | 
			
		||||
from opensearchpy import OpenSearch
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
metadata = otc_metadata.Services()
 | 
			
		||||
 | 
			
		||||
def parse_args():
 | 
			
		||||
    parser = argparse.ArgumentParser(
 | 
			
		||||
        description="Create Index data for search inside OpenSearch"
 | 
			
		||||
    )
 | 
			
		||||
@ -39,16 +40,23 @@ def main():
 | 
			
		||||
    parser.add_argument(
 | 
			
		||||
        '--username',
 | 
			
		||||
        metavar='<username>',
 | 
			
		||||
        required=True,
 | 
			
		||||
        help='Username for the connection.'
 | 
			
		||||
    )
 | 
			
		||||
    parser.add_argument(
 | 
			
		||||
        '--password',
 | 
			
		||||
        metavar='<password>',
 | 
			
		||||
        required=True,
 | 
			
		||||
        help='Password for the connection.'
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    args = parser.parse_args()
 | 
			
		||||
    return args
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    
 | 
			
		||||
    logging.basicConfig(level=logging.DEBUG)
 | 
			
		||||
    args = parse_args()
 | 
			
		||||
 | 
			
		||||
    data = getData(
 | 
			
		||||
        environment=args.target_environment
 | 
			
		||||
@ -64,7 +72,6 @@ def main():
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
def getData(environment):
 | 
			
		||||
    metadata = otc_metadata.Services()
 | 
			
		||||
    return metadata.service_types_with_doc_types(
 | 
			
		||||
        environment=environment
 | 
			
		||||
    )
 | 
			
		||||
@ -82,7 +89,9 @@ def indexData(deleteIndex, hosts, index, username, password, data):
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    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):
 | 
			
		||||
    host_list = []
 | 
			
		||||
@ -95,4 +104,8 @@ def generate_os_host_list(hosts):
 | 
			
		||||
        host_list.append(json_host)
 | 
			
		||||
    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])
 | 
			
		||||
		Reference in New Issue
	
	Block a user