Skip to content

Denney-tech/virt-who

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

virt-who

I encountered a problem with Red Hat Satellite (aka TheForeman) where hypervisors in my vcenter had duplicate BIOS UUID's, which led to host-guest mapping failing succcessfully. Only a single host of any duplicate UUID was added to Satellite inventory, along with its respective guests mapping. While there are workarounds for duplicate BIOS UUID's for subscribed VM's to Satellite, such as adding known bad UUID's to Settings > Content > Host Duplicate DMI UUIDs, none of them worked for virt-who hypervisors.

To work around this problem, I created a powershell script that uses VMware.PowerCli to construct the same json that virt-who does, and save it to /etc/virt-who.d/virt-who.json. I also backed up the virt-who config and replace it with a "fake" config that reads from the json file instead connecting to vcenter.

Requirements

reference

# Unlock satellite packages
sudo satellite-maintain packages unlock

# Register the Microsoft RedHat repository
sudo dnf install -y https://packages.microsoft.com/config/rhel/$majorver/packages-microsoft-prod.rpm

# Install PowerShell
sudo dnf install powershell-lts -y

# Lock satellite packages
sudo satellite-maintain packages lock

Modules:

  • Microsoft.PowerShell.SecretManagement
  • Microsoft.PowerShell.SecretStore
  • VMware.PowerCli

Preparation

#!/bin/pwsh
# Install modules
$Modules = @("Microsoft.PowerShell.SecretManagement", "Microsoft.PowerShell.SecretStore", "VMware.PowerCli")
Install-Module $Modules

# Configure secrets
Register-Vault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
Set-SecretStoreConfiguration -Name SecretStore -Authentication None -Interaction None -Scope CurrentUser # required for non-interative scripts
$cred = Get-Credential # Enter your vcenter account username and password
Set-Secret -Name $cred.Username -Secret $cred.GetNetworkCredential().Password

# Configure vmware
# This supresses an interactive prompt every time VMware.PowerCli is imported, and optionally skips tls validation if needed.
Set-PowerCLIConfiguration -Scope User -ParticipateInCeiP $false -DefaultVIServerMode Multiple # optionally if your certs are self-signed: -InvalidCertificateAction Ignore

Backup first! Set the following /etc/virt-who.d/virt-who-config-1.conf file. Use the owner/rhsm* key=value pairs from the original config.

[virt-who-config-1]
type=fake
file=/etc/virt-who.d/virt-who.json
is_hypervisor=True
hypervisor_id=hostname

# get the following from the original config file
owner=OrgName
rhsm_hostname=satellite.example.com
rhsm_username=virt_who_reporter_1
rhsm_encrypted_password=# this encoded password is generated by satellite when the config is deployed.
rhsm_prefix=/rhsm

Lastly, save the virt-who.ps1 file somewhere in /root, chmod 700, and add it to root's crontab.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published