Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.16.z] Update set_infrastructure _type for RHCloud #17267

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading