fix(sign): read DB options from hub config files in sign spooler
Co-developed-by: Gemini AI <renich+gemini@woralelandia.com> Signed-off-by: Rénich Bon Ćirić <renich@woralelandia.com>
This commit is contained in:
parent
60a6827c3c
commit
3140508cfb
1 changed files with 29 additions and 6 deletions
|
|
@ -93,25 +93,48 @@ def process_queue():
|
||||||
import kojihub
|
import kojihub
|
||||||
import koji
|
import koji
|
||||||
|
|
||||||
# Read configuration file to get KojiDir
|
# Read configuration file to get KojiDir and DB options
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config_files = ['/etc/koji-hub/hub.conf'] + sorted(glob.glob('/etc/koji-hub/hub.conf.d/*.conf'))
|
config_files = ['/etc/koji-hub/hub.conf'] + sorted(glob.glob('/etc/koji-hub/hub.conf.d/*.conf'))
|
||||||
config.read(config_files)
|
config.read(config_files)
|
||||||
|
|
||||||
koji_dir = config.get('hub', 'KojiDir', fallback='/mnt/koji')
|
koji_dir = config.get('hub', 'KojiDir', fallback='/mnt/koji')
|
||||||
|
|
||||||
# Get list of files in spool directory
|
# Connect to database using configuration parameters
|
||||||
files = sorted(os.listdir(SPOOL_DIR))
|
db_opts = {}
|
||||||
if not files:
|
if config.has_option('hub', 'DBConnectionString'):
|
||||||
return
|
db_opts['dsn'] = config.get('hub', 'DBConnectionString')
|
||||||
|
else:
|
||||||
|
if config.has_option('hub', 'DBName'):
|
||||||
|
db_opts['database'] = config.get('hub', 'DBName')
|
||||||
|
if config.has_option('hub', 'DBUser'):
|
||||||
|
db_opts['user'] = config.get('hub', 'DBUser')
|
||||||
|
if config.has_option('hub', 'DBPass'):
|
||||||
|
db_opts['password'] = config.get('hub', 'DBPass')
|
||||||
|
if config.has_option('hub', 'DBHost'):
|
||||||
|
db_opts['host'] = config.get('hub', 'DBHost')
|
||||||
|
elif config.has_option('hub', 'DBhost'):
|
||||||
|
db_opts['host'] = config.get('hub', 'DBhost')
|
||||||
|
if config.has_option('hub', 'DBPort'):
|
||||||
|
try:
|
||||||
|
db_opts['port'] = config.getint('hub', 'DBPort')
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
db_opts = {k: v for k, v in db_opts.items() if v is not None}
|
||||||
|
kojihub.db.setDBopts(**db_opts)
|
||||||
|
|
||||||
# Connect to database
|
|
||||||
try:
|
try:
|
||||||
kojihub.db.connect()
|
kojihub.db.connect()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to connect to Koji Hub DB: {e}")
|
logger.error(f"Failed to connect to Koji Hub DB: {e}")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Get list of files in spool directory
|
||||||
|
files = sorted(os.listdir(SPOOL_DIR))
|
||||||
|
if not files:
|
||||||
|
return
|
||||||
|
|
||||||
for filename in files:
|
for filename in files:
|
||||||
file_path = os.path.join(SPOOL_DIR, filename)
|
file_path = os.path.join(SPOOL_DIR, filename)
|
||||||
if not os.path.isfile(file_path):
|
if not os.path.isfile(file_path):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue