req file extended
This commit is contained in:
0
initialize.py
Normal file
0
initialize.py
Normal file
@@ -1,3 +1,6 @@
|
||||
fastapi[standard]>=0.116.2
|
||||
httpx>=0.28.1
|
||||
redis>=6.4.0
|
||||
redis>=6.4.0
|
||||
pydantic
|
||||
redis[hiredis]
|
||||
dotenv
|
||||
38
src/start.py
Normal file
38
src/start.py
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user