Skip to content

Commit

Permalink
Update set infra type rhcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
ColeHiggins2 committed Jan 6, 2025
1 parent 6d0df0b commit 4836779
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,14 +1165,23 @@ def set_infrastructure_type(self, infrastructure_type='physical'):
: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 4836779

Please sign in to comment.