-
Notifications
You must be signed in to change notification settings - Fork 3
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
Incorporate vmware/govmomi/vcsim
in tests
#585
Comments
Short version for exporting a vSphere inventory: cd /tmp
wget https://github.com/vmware/govmomi/releases/download/v0.27.2/govc_Linux_x86_64.tar.gz
tar zfx govc_Linux_x86_64.tar.gz
mv govc $HOME/go/bin/
wget https://github.com/vmware/govmomi/releases/download/v0.27.2/vcsim_Linux_x86_64.tar.gz
tar zxf vcsim_Linux_x86_64.tar.gz
mv vcsim $HOME/go/bin
export GOVC_URL=https://vc1.example.com/sdk
export GOVC_USERNAME=vc1-read-only-service-account
export GOVC_PASSWORD=placeholder
export GOVC_INSECURE=1
$HOME/go/bin/govc object.save I'm happy to see that a |
With those environment variables defined, I'm able to list Custom Attributes of the live vCenter instance via |
The next step is to start vcsim like so to load the inventory: $ vcsim -load vcsim-vc1.example.com
export GOVC_URL=https://user:[email protected]:8989/sdk GOVC_SIM_PID=4073 and from another console tab I ran: $ export GOVC_URL=https://user:[email protected]:8989/sdk GOVC_SIM_PID=4073
$ govc fields.ls
govc: Post "https://127.0.0.1:8989/sdk": x509: certificate signed by unknown authority
$ export GOVC_INSECURE=1
$ govc fields.ls
... The expected Custom Attributes were listed. |
Using the v0.28.1 copy of $ ./check_vmware_tools-v0.28.1-0-g2cb33db-linux-amd64 --username bob --password apples --server 127.0.0.1 --port 8989 --trust-cert
{"level":"error","version":"check-vmware v0.28.1-0-g2cb33db (https://github.com/atc0005/check-vmware)","logging_level":"info","plugin_type":"vmware-tools","plugin_timeout":"10s","username":"bob","user_domain":"","trust_cert":true,"server":"127.0.0.1","port":8989,"included_resource_pools":"","excluded_resource_pools":"","num_excluded_resource_pools":0,"num_included_resource_pools":0,"ignored_vms":"","eval_powered_off":false,"vms_total":81,"vms_filtered":27,"vms_excluded_by_name":0,"vms_excluded_by_power_state":54,"vms_with_tools_issues":6,"vms_without_tools_issues":21,"resource_pools_evaluated":1,"time":"2022-01-04T06:54:34-06:00","caller":"github.com/atc0005/check-vmware/cmd/check_vmware_tools/main.go:310","message":"issues with VMware Tools found"}
CRITICAL: 6 VMs with VMware Tools issues detected (evaluated 27 VMs, 1 Resource Pools)
**ERRORS**
* 6 of 27 VMs with VMware Tools issues
**THRESHOLDS**
* CRITICAL: VMware Tools not running, not installed, unsupported or blacklisted version.
* WARNING: Outdated VMware Tools installation.
**DETAILED INFO**
* 01) vm1 (poweredOn, guestToolsNotInstalled)
* 02) vm2 (poweredOn, guestToolsSupportedOld)
* 03) vm3 (poweredOn, guestToolsSupportedOld)
* 04) vm4 (poweredOn, guestToolsSupportedOld)
* 05) vm5 (poweredOn, guestToolsSupportedOld)
* 06) vm6 (poweredOn, guestToolsSupportedOld)
---
* vSphere environment: https://127.0.0.1:8989/sdk
* Plugin User Agent: check-vmware/v0.28.1-0-g2cb33db
* VMs (evaluated: 27, total: 81)
* Powered off VMs evaluated: false
* Specified VMs to exclude (0): []
* Specified Resource Pools to explicitly include (0): []
* Specified Resource Pools to explicitly exclude (0): []
* Resource Pools evaluated (1): [Resources]
| 'vms'=81;;;; 'vms_excluded_by_name'=0;;;; 'vms_excluded_by_power_state'=54;;;; 'vms_with_tools_issues'=6;;;; 'vms_without_tools_issues'=21;;;; 'resource_pools_excluded'=0;;;; 'resource_pools_included'=0;;;; 'resource_pools_evaluated'=1;;;; 'time'=190ms;;;; This is extremely promising. |
vmware/govmomi/vcsim
in tests
Current workflow for setting up a quick test environment: Console Tab 1cd $HOME/Desktop
vcsim -load vcsim-vc1.example.com Console Tab 2# These environment variables are used by govc (natively)
export GOVC_INSECURE=1
export GOVC_URL=https://user:[email protected]:8989/sdk
# These environment variables are used by PowerCLI commands (explicitly)
export VCSIM_SERVER=127.0.0.1
export VCSIM_PORT=8989
export VCSIM_USER=bob
export VCSIM_PASS=apples
# Use govc CLI tool to list current Custom Attributes
govc fields.ls
# Launch PowerShell 7.x for further testing
pwsh # Use PowerCLI to list VM names & their IP Addresses
PS /home/ubuntu/Desktop> $server = Connect-VIServer -server $env:VCSIM_SERVER -User $env:VCSIM_USER -Password $env:VCSIM_PASS -Port $env:VCSIM_PORT
PS /home/ubuntu/Desktop> Get-VM | Where-Object {$_.PowerState -eq 'PoweredOn'} | Select-Object -Property Name, @{N="IP";E={@($_.Guest.IPAddress)}} | Format-Table -AutoSize
# Optional listing of supported methods and types
# $About = Invoke-RestMethod -Uri "https://$($server):$($env:VCSIM_PORT)/about" -Method Get -SkipCertificateCheck
# $About.Methods
# $About.Types Further work: # List Custom Attributes
PS /home/ubuntu/Desktop> Get-CustomAttribute | Format-Table -AutoSize
Key Name TargetType
--- ---- ----------
339 AutoDeploy.MachineIdentity VMHost
6 Location VMHost
502 Location
101 Notes VMHost
201 Tier VirtualMachine
301 com.vmware.vcIntegrity.customField.scheduledTask.action
302 com.vmware.vcIntegrity.customField.scheduledTask.signature
303 com.vmware.vcIntegrity.customField.scheduledTask.target
# Create new Custom Attributes
PS /home/ubuntu/Desktop> New-CustomAttribute -Name 'Backup Status' -TargetType 'VirtualMachine'
Key Name TargetType
--- ---- ----------
0 Backup Status VirtualMachine
PS /home/ubuntu/Desktop> New-CustomAttribute -Name 'Last Backup' -TargetType 'VirtualMachine'
Key Name TargetType
--- ---- ----------
1 Last Backup VirtualMachine
# Set Custom Attribute values on a VM from inventory
PS /home/ubuntu/Desktop> Set-Annotation -Entity rhelcluster2 -CustomAttribute 'Backup Status' -Value 'Backup Job ID [43915] Client: [vcapps], Backup Set: [defaultBackupSet], Subclient: [VMs With Validation] Parent Backup Job ID [43901]'
AnnotatedEntity Name Value
--------------- ---- -----
rhelcluster2 Backup Status Backup Job ID [43915] Client: [vcapps], Backup Se…
PS /home/ubuntu/Desktop> Set-Annotation -Entity rhelcluster2 -CustomAttribute 'Last Backup' -Value '2021-11-09 9:07:21 PM'
AnnotatedEntity Name Value
--------------- ---- -----
rhelcluster2 Last Backup 2021-11-09 9:07:21 PM I'll need to spend more time with |
Alternative to the PowerShell snippets: govc fields.ls
govc fields.add -type VirtualMachine 'Backup Status'
govc fields.add -type VirtualMachine 'Last Backup'
govc fields.set 'Backup Status' 'Backup Job ID [43915] Client: [vcapps], Backup Set: [defaultBackupSet], Subclient: [VMs With Validation] Parent Backup Job ID [43901]' rhelcluster2
govc fields.set 'Last Backup' '2021-11-09 9:07:21 PM' rhelcluster2
govc fields.info rhelcluster2 I'm seeing duplicate Custom Attributes listed, but this may be a bug in |
Some development efforts are proving challenging as I don't have a lab environment that I can test against. In particular, I find myself needing to set Custom Attributes in vCenter and I don't have a test environment where I can safely do so.
Resources
vcsim
supportvcsim URLs
The text was updated successfully, but these errors were encountered: