def config(network): cont = 0 for ip in network.get_ip_list(): print(network.get_path(cont), ip) get_config_file(network.get_path(cont), ip) cont += 1 time.sleep(2)
#!/usr/bin/env python # -*- encoding: utf8 -*- import sys sys.path.append('././') from get_config import get_config_file import random from elasticsearch import Elasticsearch config = get_config_file() class EsUtil: def __init__(self): pass @staticmethod def get_es_servers(): SAAS = (config["elasticsearch"]["SAAS1"], config["elasticsearch"]["SAAS2"], config["elasticsearch"]["SAAS3"]) rand = random.randint(0, 2) url = SAAS[rand] print(url) es_client = Elasticsearch(url) return es_client @staticmethod def create_es_index(business_id, supplier_id): es_client = EsUtil.get_es_servers() es_index = 'q_supplier_robot_{}_{}'.format(business_id, supplier_id)