Skip to content

Commit

Permalink
Enable TPM gathering from vSphere
Browse files Browse the repository at this point in the history
Since #694, we disabled the TPM gathering to avoid "InvalidProperty"
error.
vSphere started supporting TPM API in 6.7, based on that version we will
gather the TPM on supported versions.

Signed-off-by: Liran Rotenberg <[email protected]>
  • Loading branch information
liranr23 authored and ahadas committed Jan 4, 2024
1 parent e7f4db3 commit e3a7f7a
Showing 1 changed file with 42 additions and 31 deletions.
73 changes: 42 additions & 31 deletions pkg/controller/provider/container/vsphere/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,41 +697,52 @@ func (r *Collector) propertySpec() []types.PropertySpec {
},
},
{ // VM
Type: VirtualMachine,
PathSet: []string{
fName,
fParent,
fUUID,
fFirmware,
fFtInfo,
fCpuAffinity,
fCpuHotAddEnabled,
fCpuHotRemoveEnabled,
fMemoryHotAddEnabled,
fNumCpu,
fNumCoresPerSocket,
fMemorySize,
fDevices,
fExtraConfig,
fGuestName,
fGuestID,
//fTpmPresent,
fBalloonedMemory,
fVmIpAddress,
fStorageUsed,
fDatastore,
fNetwork,
fRuntimeHost,
fPowerState,
fConnectionState,
fIsTemplate,
fSnapshot,
fChangeTracking,
},
Type: VirtualMachine,
PathSet: r.vmPathSet(),
},
}
}

func (r *Collector) vmPathSet() []string {
pathSet := []string{
fName,
fParent,
fUUID,
fFirmware,
fFtInfo,
fCpuAffinity,
fCpuHotAddEnabled,
fCpuHotRemoveEnabled,
fMemoryHotAddEnabled,
fNumCpu,
fNumCoresPerSocket,
fMemorySize,
fDevices,
fExtraConfig,
fGuestName,
fGuestID,
fBalloonedMemory,
fVmIpAddress,
fStorageUsed,
fDatastore,
fNetwork,
fRuntimeHost,
fPowerState,
fConnectionState,
fIsTemplate,
fSnapshot,
fChangeTracking,
}

apiVer := strings.Split(r.client.ServiceContent.About.ApiVersion, ".")
majorVal, _ := strconv.Atoi(apiVer[0])
minorVal, _ := strconv.Atoi(apiVer[1])
if majorVal > 6 || majorVal == 6 && minorVal >= 7 {
pathSet = append(pathSet, fTpmPresent)
}
return pathSet
}

// Apply updates.
func (r *Collector) apply(ctx context.Context, tx *libmodel.Tx, updates []types.ObjectUpdate) (err error) {
for _, u := range updates {
Expand Down

0 comments on commit e3a7f7a

Please sign in to comment.