don't add templates to inventory
Some checks are pending
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-30 12:48:14 +10:00
parent 5875550802
commit 6a41528f41

View File

@@ -116,7 +116,7 @@ func (c *CronTask) AddVmToInventory(vmObject *mo.VirtualMachine, vc *vcenter.Vce
if vmObject.Name == "DBRaaS_testVMTemplate" {
c.Logger.Debug("Found problematic VM")
prettyPrint(vmObject)
//prettyPrint(vmObject)
}
srmPlaceholder = "FALSE" // Default assumption
@@ -124,11 +124,22 @@ func (c *CronTask) AddVmToInventory(vmObject *mo.VirtualMachine, vc *vcenter.Vce
// calculate VM properties we want to store
if vmObject.Config != nil {
if vmObject.Config.Template {
c.Logger.Debug("Not adding templates to inventory")
return nil
} else {
isTemplate = "FALSE"
}
numRam = vmObject.Config.Hardware.MemoryMB
numVcpus = vmObject.Config.Hardware.NumCPU
// Calculate creation date
if vmObject.Config.CreateDate.IsZero() {
c.Logger.Debug("Creation date not available for this VM")
} else {
creationTS = vmObject.Config.CreateDate.Unix()
}
// Calculate disk size
var totalDiskBytes int64
@@ -157,12 +168,6 @@ func (c *CronTask) AddVmToInventory(vmObject *mo.VirtualMachine, vc *vcenter.Vce
srmPlaceholder = "TRUE"
}
if vmObject.Config.Template {
isTemplate = "TRUE"
} else {
isTemplate = "FALSE"
}
// Retrieve the full folder path of the VM
folderPath, err = vc.GetVMFolderPath(*vmObject)
if err != nil {