From cf09ba643158c10c69c7cf2cfa1c5c1a12eaafcc Mon Sep 17 00:00:00 2001 From: root Date: Thu, 18 Sep 2025 09:39:36 +0200 Subject: [PATCH] req file extended --- initialize.py | 0 requirements.txt | 5 ++++- src/start.py | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 initialize.py create mode 100644 src/start.py diff --git a/initialize.py b/initialize.py new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt index 8af5e42..5935683 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,7 @@ fastapi[standard]>=0.116.2 httpx>=0.28.1 redis>=6.4.0 -python-dotenv>=1.1.1 \ No newline at end of file +python-dotenv>=1.1.1 +pydantic +redis[hiredis] +dotenv diff --git a/src/start.py b/src/start.py new file mode 100644 index 0000000..19971bf --- /dev/null +++ b/src/start.py @@ -0,0 +1,38 @@ +import os +import json +from pathlib import Path +from dotenv import load_dotenv +from redis import Redis + +from pydantic import BaseModel, ValidationError, SecretStr, AnyHttpUrl +from typing import Optional, Literal, List, Union + + +def initialize_config(): + load_dotenv() + MY_ENV_VAR = os.getenv('MY_ENV_VAR') + print(MY_ENV_VAR) + +def config_init(redisclient: Redis): + print(f'[INFO] Importing configuration to local DB...') + try: + #redisclient = Redis(host=redishost, port=redisport, decode_responses=True) + inv = { + '1': {'hostname': 'jamaica.muccbc.hq.netapp.com', 'username': '', 'password': ''}, + '2': {'hostname': 'trinidad.muccbc.hq.netapp.com', 'username': '', 'password': ''} + } + + inventory = json.dumps(inv) + redisclient.hset('cluster_inventory', mapping={'inventory': inventory}) + redisclient.close() + return True + + except Exception as e: + print(f"FATAL: Redis DB error: {e}") + return False + +load_dotenv() + +MY_ENV_VAR = os.getenv('MY_ENV_VAR') + +print(MY_ENV_VAR) \ No newline at end of file