backend #4
@@ -24,7 +24,23 @@ def get_inventory_from_redis(redisclient: Redis):
|
||||
return json.loads(cluster_inv['inventory'])
|
||||
return {}
|
||||
|
||||
def read_config_from_db(redisclient: Redis):
|
||||
def read_config_from_db(redisclient: Redis) -> ConfigSchema:
|
||||
''' Load inventory to global vars'''
|
||||
global_inventory = get_inventory_from_redis(redisclient)
|
||||
return global_inventory
|
||||
GLOBAL_INVENTORY = get_inventory_from_redis(redisclient)
|
||||
for item in GLOBAL_INVENTORY:
|
||||
config = ConfigSchema(
|
||||
hostname=GLOBAL_INVENTORY[item]['hostname'],
|
||||
username=GLOBAL_INVENTORY[item]['username'],
|
||||
password=GLOBAL_INVENTORY[item]['password'],
|
||||
)
|
||||
GLOBAL_INVENTORY += {item: config}
|
||||
return GLOBAL_INVENTORY
|
||||
|
||||
# def load_config() -> ConfigSchema:
|
||||
# logger.info("Loading config from .env file")
|
||||
# config = dotenv_values(".env")
|
||||
# return ConfigSchema(
|
||||
# hostname=config["CLUSTER1_HOSTNAME"],
|
||||
# username=config["CLUSTER1_USERNAME"],
|
||||
# password=config["CLUSTER1_PASSWORD"],
|
||||
# )
|
||||
Reference in New Issue
Block a user