Skip to content

Commit

Permalink
fix(ovirt): use default values for platforms, when not set
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ko committed Sep 5, 2024
1 parent 3b2dd63 commit 62d9c74
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/source/ovirt/ovirt_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ func (o *OVirtSource) syncHosts(nbi *inventory.NetboxInventory) error {
}

var hostPlatform *objects.Platform
var osDistribution, osVersion, osArch string
osDistribution := constants.DefaultOSName
osVersion := constants.DefaultOSVersion
cpuArch := constants.DefaultCPUArch

Check warning on line 243 in internal/source/ovirt/ovirt_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L241-L243

Added lines #L241 - L243 were not covered by tests
if os, exists := host.Os(); exists {
if ovirtOsType, exists := os.Type(); exists {
osDistribution = ovirtOsType
Expand All @@ -250,13 +252,13 @@ func (o *OVirtSource) syncHosts(nbi *inventory.NetboxInventory) error {
}
// We extract architecture from reported_kernel_cmdline
if reportedKernelCmdline, exists := os.ReportedKernelCmdline(); exists {
osArch = utils.ExtractCPUArch(reportedKernelCmdline)
if bitArch, ok := constants.Arch2Bit[osArch]; ok {
osArch = bitArch
cpuArch = utils.ExtractCPUArch(reportedKernelCmdline)
if bitArch, ok := constants.Arch2Bit[cpuArch]; ok {
cpuArch = bitArch

Check warning on line 257 in internal/source/ovirt/ovirt_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L255-L257

Added lines #L255 - L257 were not covered by tests
}
}
}
platformName := utils.GeneratePlatformName(osDistribution, osVersion, osArch)
platformName := utils.GeneratePlatformName(osDistribution, osVersion, cpuArch)

Check warning on line 261 in internal/source/ovirt/ovirt_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L261

Added line #L261 was not covered by tests
hostPlatformStruct := &objects.Platform{
Name: platformName,
Slug: utils.Slugify(platformName),
Expand Down

0 comments on commit 62d9c74

Please sign in to comment.