Skip to content

Commit 00406f5

Browse files
committed
Fix rex_pub_key retrieval for containerized Satellite
1 parent 72eb866 commit 00406f5

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

robottelo/hosts.py

Lines changed: 18 additions & 7 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,
@@ -1693,7 +1693,6 @@ def podman_logout(self, registry=None):
16931693

16941694

16951695
class Capsule(ContentHost, CapsuleMixins):
1696-
rex_key_path = '~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub'
16971696
product_rpm_name = 'satellite-capsule'
16981697
upstream_rpm_name = 'foreman-proxy'
16991698

@@ -1775,7 +1774,23 @@ def url_katello_ca_rpm(self):
17751774

17761775
@property
17771776
def rex_pub_key(self):
1778-
return self.execute(f'cat {self.rex_key_path}').stdout.strip()
1777+
if settings.server.install_method == InstallMethod.FOREMANCTL:
1778+
if 'remote-execution' in self.list_foremanctl_features(enabled=True):
1779+
result = self.execute(
1780+
"podman secret inspect"
1781+
" foreman_proxy-remote_execution_ssh-id_rsa_foreman_proxy-pub"
1782+
" --showsecret --format '{{.SecretData}}'"
1783+
)
1784+
else:
1785+
raise SatelliteHostError('remote-execution feature is not enabled')
1786+
else:
1787+
result = self.execute('cat ~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub')
1788+
key = result.stdout.strip()
1789+
if not key:
1790+
raise ValueError(
1791+
f'Rex public key is empty. Command returned status {result.status}: {result.stderr}'
1792+
)
1793+
return key
17791794

17801795
def is_foremanctl_available(self):
17811796
"""Check if foremanctl is installed on the system.
@@ -1805,8 +1820,6 @@ def detect_install_method(self):
18051820
:return: InstallMethod enum value
18061821
:rtype: InstallMethod
18071822
"""
1808-
from robottelo.enums import InstallMethod
1809-
18101823
# Runtime override
18111824
if hasattr(self, '_install_method_override'):
18121825
return self._install_method_override
@@ -1855,7 +1868,6 @@ def get_service_names(self):
18551868
:rtype: list
18561869
"""
18571870
from robottelo.constants import InstallationServices
1858-
from robottelo.enums import InstallMethod
18591871

18601872
if self.install_method == InstallMethod.FOREMANCTL:
18611873
return InstallationServices.FOREMANCTL_SERVICES
@@ -2271,7 +2283,6 @@ def install_satellite(
22712283
:param foremanctl_parameters: Parameters list for foremanctl deploy
22722284
:return: Installation result
22732285
"""
2274-
from robottelo.enums import InstallMethod
22752286
from robottelo.utils.installer import InstallerCommand
22762287

22772288
# Determine method

0 commit comments

Comments
 (0)