Skip to content

Commit 45e9bb9

Browse files
committed
Fix rex_pub_key retrieval for containerized Satellite
1 parent 72eb866 commit 45e9bb9

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

robottelo/hosts.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
RHSSO_USER_UPDATE,
5555
SATELLITE_VERSION,
5656
)
57-
from robottelo.enums import NetworkType
57+
from robottelo.enums import InstallMethod, NetworkType
5858
from robottelo.exceptions import (
5959
CapsuleHostError,
6060
CLIFactoryError,
@@ -1775,7 +1775,21 @@ def url_katello_ca_rpm(self):
17751775

17761776
@property
17771777
def rex_pub_key(self):
1778-
return self.execute(f'cat {self.rex_key_path}').stdout.strip()
1778+
if settings.server.install_method == InstallMethod.FOREMANCTL:
1779+
if 'remote-execution' in self.list_foremanctl_features(enabled=True):
1780+
result = self.execute(
1781+
f"podman exec foreman-proxy bash -c 'cat {self.rex_key_path}'"
1782+
)
1783+
else:
1784+
raise SatelliteHostError('remote-execution feature is not enabled')
1785+
else:
1786+
result = self.execute(f'cat {self.rex_key_path}')
1787+
key = result.stdout.strip()
1788+
if not key:
1789+
raise ValueError(
1790+
f'Rex public key is empty. Command returned status {result.status}: {result.stderr}'
1791+
)
1792+
return key
17791793

17801794
def is_foremanctl_available(self):
17811795
"""Check if foremanctl is installed on the system.
@@ -1805,8 +1819,6 @@ def detect_install_method(self):
18051819
:return: InstallMethod enum value
18061820
:rtype: InstallMethod
18071821
"""
1808-
from robottelo.enums import InstallMethod
1809-
18101822
# Runtime override
18111823
if hasattr(self, '_install_method_override'):
18121824
return self._install_method_override
@@ -1855,7 +1867,6 @@ def get_service_names(self):
18551867
:rtype: list
18561868
"""
18571869
from robottelo.constants import InstallationServices
1858-
from robottelo.enums import InstallMethod
18591870

18601871
if self.install_method == InstallMethod.FOREMANCTL:
18611872
return InstallationServices.FOREMANCTL_SERVICES
@@ -2271,7 +2282,6 @@ def install_satellite(
22712282
:param foremanctl_parameters: Parameters list for foremanctl deploy
22722283
:return: Installation result
22732284
"""
2274-
from robottelo.enums import InstallMethod
22752285
from robottelo.utils.installer import InstallerCommand
22762286

22772287
# Determine method

0 commit comments

Comments
 (0)