Skip to content

Commit

Permalink
[6.16.z] Update set_infrastructure _type for RHCloud (#17267)
Browse files Browse the repository at this point in the history
Update set_infrastructure _type for RHCloud (#17196)

* Update set infra type rhcloud

* update docstring

(cherry picked from commit 227ac44)

Co-authored-by: Cole Higgins <[email protected]>
  • Loading branch information
Satellite-QE and ColeHiggins2 authored Jan 8, 2025
1 parent c4ed92e commit 50781df
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,19 +1147,27 @@ def unregister_insights(self):
raise ContentHostError('Failed to unregister client from Insights through Satellite')

def set_infrastructure_type(self, infrastructure_type='physical'):
"""Force host to appear as bare-metal orbroker virtual machine in
subscription-manager fact.
"""Force host to appear as bare-metal or virtual machine in subscription-manager fact.
:param str infrastructure_type: One of 'physical', 'virtual'
"""
script_path = '/usr/sbin/virt-what'
self.execute(f'cp -n {script_path} {script_path}.old')
# Remove the custom facts file if it exists
self.execute('rm -f /etc/rhsm/facts/custom.facts')

script_content = ['#!/bin/sh -']
# Define the path for the physical facts file
script_path = '/etc/rhsm/facts/physical.facts'

# Prepare facts content based on infrastructure type
if infrastructure_type == 'virtual':
script_content.append('echo kvm')
script_content = '\n'.join(script_content)
self.execute(f"echo -e '{script_content}' > {script_path}")
facts_content = '{"virt.is_guest": "true"}'
else:
facts_content = '{"virt.is_guest": "false"}'

# Create the physical facts file and write the appropriate content
self.execute(f"echo '{facts_content}' > {script_path}")

# Update subscription manager facts
self.execute('subscription-manager facts --update')

def patch_os_release_version(self, distro='rhel7'):
"""Patch VM OS release version.
Expand Down

0 comments on commit 50781df

Please sign in to comment.