Skip to content

Commit

Permalink
Support transactional-update for registration
Browse files Browse the repository at this point in the history
On SUSE Micro systems with a RO root filesystem we need to use the
transactional-update register command to complete the registration.
SUSEConnect disables itself in this situation and produces and error.

Signed-off-by: Robert Schweikert <rjschwei@suse.com>
  • Loading branch information
rjschwei committed May 7, 2024
1 parent 8277db2 commit 79f93f9
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion usr/sbin/registercloudguest
Expand Up @@ -440,8 +440,41 @@ if not utils.is_registration_supported(cfg):

# Check SUSE/SLES registration command to be present
register_cmd = '/usr/sbin/SUSEConnect'
# For transactional systems we need to do a few extra things
p = subprocess.Popen(
['findmnt', '--noheadings', '--json', '/'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
res = p.communicate()
# If we get an error from findmnt move forward on a best effort basis
if p.returncode:
logging.warning('Unable to find filesystem information for "/"')
else:
fsinfo = json.loads(res[0])
fsdata = fsinfo.get('filesystems')
if fsdata:
fsoptions = fsdata[0].get('options')
# If we are on a RO system we need to use the
# transactional-update command
if 'ro' in fsoptions.split(','):
cmd_name = 'transactional-update'
for path in ['/sbin/','/usr/sbin/']:
exec_path = path + cmd_name
if os.path.exists(exec_path):
register_cmd = exec_path
break
else:
err_msg = 'transactional-update command not found.'
err_msg += 'But is required on a RO filesystem for '
err_msg += 'registration'
logging.error(err_msg)
print(err_msg, file=sys.stderr)
sys.exit(1)
if not (os.path.exists(register_cmd) and os.access(register_cmd, os.X_OK)):
logging.error('No registration executable found')
err_msg = 'No registration executable found'
logging.error(err_msg)
print(err_msg, file=sys.stderr)
sys.exit(1)

# get product list
Expand All @@ -460,8 +493,12 @@ failed_smts = []

while not base_registered:
utils.add_hosts_entry(registration_target)
sub_cmd = ''
if 'transactional' in register_cmd:
sub_cmd = 'register'
cmd = [
register_cmd,
sub_cmd,
'--url',
'https://%s' % registration_target.get_FQDN()
]
Expand Down

0 comments on commit 79f93f9

Please sign in to comment.