5454 RHSSO_USER_UPDATE ,
5555 SATELLITE_VERSION ,
5656)
57- from robottelo .enums import NetworkType
57+ from robottelo .enums import InstallMethod , NetworkType
5858from robottelo .exceptions import (
5959 CapsuleHostError ,
6060 CLIFactoryError ,
@@ -1805,7 +1805,6 @@ def detect_install_method(self):
18051805 :return: InstallMethod enum value
18061806 :rtype: InstallMethod
18071807 """
1808- from robottelo .enums import InstallMethod
18091808
18101809 # Runtime override
18111810 if hasattr (self , '_install_method_override' ):
@@ -1855,7 +1854,6 @@ def get_service_names(self):
18551854 :rtype: list
18561855 """
18571856 from robottelo .constants import InstallationServices
1858- from robottelo .enums import InstallMethod
18591857
18601858 if self .install_method == InstallMethod .FOREMANCTL :
18611859 return InstallationServices .FOREMANCTL_SERVICES
@@ -2271,7 +2269,6 @@ def install_satellite(
22712269 :param foremanctl_parameters: Parameters list for foremanctl deploy
22722270 :return: Installation result
22732271 """
2274- from robottelo .enums import InstallMethod
22752272 from robottelo .utils .installer import InstallerCommand
22762273
22772274 # Determine method
@@ -2324,13 +2321,14 @@ def install_satellite(
23242321
23252322 return result
23262323
2327- def query_db (self , query , db = 'foreman' , output_format = 'json' ):
2324+ def query_db (self , query , db = 'foreman' , output_format = 'json' , db_user = 'foreman' ):
23282325 """Execute a PostgreSQL query and return the result.
23292326
23302327 Args:
23312328 query: SQL query to execute
23322329 db: Database name (default: 'foreman')
23332330 output_format: Output format - 'json' for JSON array, raw output otherwise
2331+ db_user: Database user (default: 'foreman')
23342332
23352333 Returns:
23362334 list of dicts if output_format='json', str otherwise
@@ -2345,7 +2343,10 @@ def _execute_db_query(cmd):
23452343 raise CLIReturnCodeError (result .status , result .stderr , f'"{ cmd } " failed' )
23462344 return result
23472345
2348- base_cmd = f'sudo -u postgres psql -d { db } '
2346+ if settings .server .install_method == InstallMethod .FOREMANCTL :
2347+ base_cmd = f'podman exec postgresql psql -U { db_user } -d { db } '
2348+ else :
2349+ base_cmd = f'sudo -u postgres psql -d { db } '
23492350
23502351 if output_format == 'json' :
23512352 cmd = f'{ base_cmd } -A -t -c "SELECT json_agg(row_to_json(t)) FROM ({ query } ) t"'
0 commit comments