Skip to content

Commit

Permalink
fix: adding more verbose logging output, for easier debug
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ko committed Aug 27, 2024
1 parent 5753c41 commit d35befa
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 148 deletions.
108 changes: 62 additions & 46 deletions internal/source/ovirt/ovirt_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (o *OVirtSource) syncNetworks(nbi *inventory.NetboxInventory) error {
return err
}
if networkVlanID, exists := networkVlan.Id(); exists {
_, err := nbi.AddVlan(o.Ctx, &objects.Vlan{
vlanStruct := &objects.Vlan{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L38

Added line #L38 was not covered by tests
NetboxObject: objects.NetboxObject{
Description: description,
Tags: o.Config.SourceTags,
Expand All @@ -49,9 +49,10 @@ func (o *OVirtSource) syncNetworks(nbi *inventory.NetboxInventory) error {
Status: &objects.VlanStatusActive,
Tenant: vlanTenant,
Comments: network.MustComment(),
})
}
_, err := nbi.AddVlan(o.Ctx, vlanStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L53

Added line #L53 was not covered by tests
if err != nil {
return fmt.Errorf("adding vlan: %v", err)
return fmt.Errorf("adding vlan %s: %v", vlanStruct, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L55

Added line #L55 was not covered by tests
}
}
}
Expand All @@ -71,7 +72,7 @@ func (o *OVirtSource) syncDatacenters(nbi *inventory.NetboxInventory) error {
nbClusterGroupName = mappedClusterGroupName
o.Logger.Debugf(o.Ctx, "mapping datacenter name %s to cluster group name %s", dcName, mappedClusterGroupName)
}
nbClusterGroup := &objects.ClusterGroup{
clusterGroupStruct := &objects.ClusterGroup{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L75

Added line #L75 was not covered by tests
NetboxObject: objects.NetboxObject{
Description: description,
Tags: o.Config.SourceTags,
Expand All @@ -82,16 +83,16 @@ func (o *OVirtSource) syncDatacenters(nbi *inventory.NetboxInventory) error {
Name: nbClusterGroupName,
Slug: utils.Slugify(nbClusterGroupName),
}
_, err := nbi.AddClusterGroup(o.Ctx, nbClusterGroup)
_, err := nbi.AddClusterGroup(o.Ctx, clusterGroupStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L86

Added line #L86 was not covered by tests
if err != nil {
return fmt.Errorf("failed to add oVirt data center %s as Netbox cluster group: %v", dcName, err)
return fmt.Errorf("failed to add oVirt data center %+v as Netbox cluster group: %v", clusterGroupStruct, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L88

Added line #L88 was not covered by tests
}
}
return nil
}

func (o *OVirtSource) syncClusters(nbi *inventory.NetboxInventory) error {
clusterType := &objects.ClusterType{
clusterTypeStruct := &objects.ClusterType{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L95

Added line #L95 was not covered by tests
NetboxObject: objects.NetboxObject{
Tags: o.Config.SourceTags,
CustomFields: map[string]interface{}{
Expand All @@ -101,7 +102,7 @@ func (o *OVirtSource) syncClusters(nbi *inventory.NetboxInventory) error {
Name: "oVirt",
Slug: "ovirt",
}
clusterType, err := nbi.AddClusterType(o.Ctx, clusterType)
nbClusterType, err := nbi.AddClusterType(o.Ctx, clusterTypeStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L105

Added line #L105 was not covered by tests
if err != nil {
return fmt.Errorf("failed to add oVirt cluster type: %v", err)
}
Expand Down Expand Up @@ -148,7 +149,7 @@ func (o *OVirtSource) syncClusters(nbi *inventory.NetboxInventory) error {
},
},
Name: clusterName,
Type: clusterType,
Type: nbClusterType,

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L152

Added line #L152 was not covered by tests
Status: objects.ClusterStatusActive,
Group: clusterGroup,
Site: clusterSite,
Expand Down Expand Up @@ -205,22 +206,24 @@ func (o *OVirtSource) syncHosts(nbi *inventory.NetboxInventory) error {
deviceSlug = utils.GenerateDeviceTypeSlug(hostManufacturerName, hostModel)
}

hostManufacturer, err := nbi.AddManufacturer(o.Ctx, &objects.Manufacturer{
hostManufacturerStruct := &objects.Manufacturer{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L209

Added line #L209 was not covered by tests
Name: hostManufacturerName,
Slug: utils.Slugify(hostManufacturerName),
})
}
hostManufacturer, err := nbi.AddManufacturer(o.Ctx, hostManufacturerStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L213

Added line #L213 was not covered by tests
if err != nil {
return fmt.Errorf("failed adding oVirt Manufacturer %v with error: %s", hostManufacturer, err)
return fmt.Errorf("failed adding oVirt Manufacturer %v with error: %s", hostManufacturerStruct, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L215

Added line #L215 was not covered by tests
}

var hostDeviceType *objects.DeviceType
hostDeviceType, err = nbi.AddDeviceType(o.Ctx, &objects.DeviceType{
hostDeviceTypeStruct := &objects.DeviceType{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L219

Added line #L219 was not covered by tests
Manufacturer: hostManufacturer,
Model: hostModel,
Slug: deviceSlug,
})
}
hostDeviceType, err = nbi.AddDeviceType(o.Ctx, hostDeviceTypeStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L224

Added line #L224 was not covered by tests
if err != nil {
return fmt.Errorf("failed adding oVirt DeviceType %v with error: %s", hostDeviceType, err)
return fmt.Errorf("failed adding oVirt DeviceType %v with error: %s", hostDeviceTypeStruct, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L226

Added line #L226 was not covered by tests
}

var hostStatus *objects.DeviceStatus
Expand Down Expand Up @@ -254,10 +257,11 @@ func (o *OVirtSource) syncHosts(nbi *inventory.NetboxInventory) error {
}
}
platformName := utils.GeneratePlatformName(osDistribution, osVersion, osArch)
hostPlatform, err = nbi.AddPlatform(o.Ctx, &objects.Platform{
hostPlatformStruct := &objects.Platform{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L260

Added line #L260 was not covered by tests
Name: platformName,
Slug: utils.Slugify(platformName),
})
}
hostPlatform, err = nbi.AddPlatform(o.Ctx, hostPlatformStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L264

Added line #L264 was not covered by tests
if err != nil {
return fmt.Errorf("failed adding oVirt Platform %v with error: %s", hostPlatform, err)
}
Expand All @@ -283,9 +287,15 @@ func (o *OVirtSource) syncHosts(nbi *inventory.NetboxInventory) error {
mem, _ := host.Memory()
mem /= (constants.KiB * constants.KiB * constants.KiB) // Value is in Bytes, we convert to GB

hostDeviceRole, err := nbi.AddDeviceRole(o.Ctx, &objects.DeviceRole{Name: constants.DeviceRoleServer, Slug: utils.Slugify(constants.DeviceRoleServer), Color: constants.DeviceRoleServerColor, VMRole: false})
hostDeviceRoleStruct := &objects.DeviceRole{
Name: constants.DeviceRoleServer,
Slug: utils.Slugify(constants.DeviceRoleServer),
Color: constants.DeviceRoleServerColor,
VMRole: false,

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L290-L294

Added lines #L290 - L294 were not covered by tests
}
hostDeviceRole, err := nbi.AddDeviceRole(o.Ctx, hostDeviceRoleStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L296

Added line #L296 was not covered by tests
if err != nil {
return err
return fmt.Errorf("add device role %+v: %s", hostDeviceRoleStruct, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L298

Added line #L298 was not covered by tests
}

nbHost := &objects.Device{
Expand Down Expand Up @@ -313,7 +323,7 @@ func (o *OVirtSource) syncHosts(nbi *inventory.NetboxInventory) error {
}
nbHost, err = nbi.AddDevice(o.Ctx, nbHost)
if err != nil {
return fmt.Errorf("failed to add oVirt host %s with error: %v", hostName, err)
return fmt.Errorf("failed to add oVirt host %+v with error: %v", nbHost, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L326

Added line #L326 was not covered by tests
}

// We also need to sync nics separately, because nic is a separate object in netbox
Expand Down Expand Up @@ -353,7 +363,7 @@ func (o *OVirtSource) syncHostNics(nbi *inventory.NetboxInventory, ovirtHost *ov
if _, ok := processedNicsIDs[masterID]; ok {
masterInterface, err = nbi.AddInterface(o.Ctx, masterInterface)
if err != nil {
return fmt.Errorf("failed to add oVirt master interface %s with error: %v", masterInterface.Name, err)
return fmt.Errorf("failed to add oVirt master interface %+v with error: %v", masterInterface, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L366

Added line #L366 was not covered by tests
}
delete(processedNicsIDs, masterID)
nicID2nic[masterID] = masterInterface
Expand All @@ -363,7 +373,7 @@ func (o *OVirtSource) syncHostNics(nbi *inventory.NetboxInventory, ovirtHost *ov
slaveInterface.LAG = masterInterface
slaveInterface, err := nbi.AddInterface(o.Ctx, slaveInterface)
if err != nil {
return fmt.Errorf("failed to add oVirt slave interface %s with error: %v", slaveInterface.Name, err)
return fmt.Errorf("failed to add oVirt slave interface %+v with error: %v", slaveInterface, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L376

Added line #L376 was not covered by tests
}
delete(processedNicsIDs, slaveID)
nicID2nic[slaveID] = slaveInterface
Expand All @@ -376,7 +386,7 @@ func (o *OVirtSource) syncHostNics(nbi *inventory.NetboxInventory, ovirtHost *ov
if _, ok := processedNicsIDs[parent]; ok {
parentInterface, err := nbi.AddInterface(o.Ctx, parentInterface)
if err != nil {
return fmt.Errorf("failed to add oVirt parent interface %s with error: %v", parentInterface.Name, err)
return fmt.Errorf("failed to add oVirt parent interface %+v with error: %v", parentInterface, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L389

Added line #L389 was not covered by tests
}
nicID2nic[parent] = parentInterface
delete(processedNicsIDs, parent)
Expand All @@ -386,7 +396,7 @@ func (o *OVirtSource) syncHostNics(nbi *inventory.NetboxInventory, ovirtHost *ov
childInterface.ParentInterface = parentInterface
childInterface, err := nbi.AddInterface(o.Ctx, childInterface)
if err != nil {
return fmt.Errorf("failed to add oVirt child interface %s with error: %v", childInterface.Name, err)
return fmt.Errorf("failed to add oVirt child interface %+v with error: %v", childInterface, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L399

Added line #L399 was not covered by tests
}
nicID2nic[child] = childInterface
delete(processedNicsIDs, child)
Expand All @@ -397,7 +407,7 @@ func (o *OVirtSource) syncHostNics(nbi *inventory.NetboxInventory, ovirtHost *ov
for nicID := range processedNicsIDs {
nbNic, err := nbi.AddInterface(o.Ctx, nicID2nic[nicID])
if err != nil {
return fmt.Errorf("failed to add oVirt interface %s with error: %v", nicID2nic[nicID].Name, err)
return fmt.Errorf("failed to add oVirt interface %+v with error: %v", nicID2nic[nicID], err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L410

Added line #L410 was not covered by tests
}
nicID2nic[nicID] = nbNic
}
Expand All @@ -407,7 +417,7 @@ func (o *OVirtSource) syncHostNics(nbi *inventory.NetboxInventory, ovirtHost *ov
nbNic := nicID2nic[nicID]
address := strings.Split(ipv4, "/")[0]
if !utils.SubnetsContainIPAddress(address, o.SourceConfig.IgnoredSubnets) {
nbIPAddress, err := nbi.AddIPAddress(o.Ctx, &objects.IPAddress{
ipAddressStruct := &objects.IPAddress{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L420

Added line #L420 was not covered by tests
NetboxObject: objects.NetboxObject{
Tags: o.Config.SourceTags,
CustomFields: map[string]interface{}{
Expand All @@ -420,16 +430,17 @@ func (o *OVirtSource) syncHostNics(nbi *inventory.NetboxInventory, ovirtHost *ov
DNSName: utils.ReverseLookup(address),
AssignedObjectType: objects.AssignedObjectTypeDeviceInterface,
AssignedObjectID: nbNic.ID,
})
}
nbIPAddress, err := nbi.AddIPAddress(o.Ctx, ipAddressStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L434

Added line #L434 was not covered by tests
if err != nil {
return fmt.Errorf("add ipv4 address: %s", err)
return fmt.Errorf("add ipv4 address %+v: %s", ipAddressStruct, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L436

Added line #L436 was not covered by tests
}
if address == hostIP {
hostCopy := *nbHost
hostCopy.PrimaryIPv4 = nbIPAddress
_, err := nbi.AddDevice(o.Ctx, &hostCopy)
if err != nil {
return fmt.Errorf("adding primary ipv4 address: %s", err)
return fmt.Errorf("adding primary ipv4 address %+v: %s", nbIPAddress, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L443

Added line #L443 was not covered by tests
}
}

Expand All @@ -450,7 +461,7 @@ func (o *OVirtSource) syncHostNics(nbi *inventory.NetboxInventory, ovirtHost *ov
for nicID, ipv6 := range nicID2IPv6 {
nbNic := nicID2nic[nicID]
address := strings.Split(ipv6, "/")[0]
nbIPAddress, err := nbi.AddIPAddress(o.Ctx, &objects.IPAddress{
ipAddressStruct := &objects.IPAddress{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L464

Added line #L464 was not covered by tests
NetboxObject: objects.NetboxObject{
Tags: o.Config.SourceTags,
CustomFields: map[string]interface{}{
Expand All @@ -463,21 +474,23 @@ func (o *OVirtSource) syncHostNics(nbi *inventory.NetboxInventory, ovirtHost *ov
DNSName: utils.ReverseLookup(address),
AssignedObjectType: objects.AssignedObjectTypeDeviceInterface,
AssignedObjectID: nbNic.ID,
})
}
nbIPAddress, err := nbi.AddIPAddress(o.Ctx, ipAddressStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L478

Added line #L478 was not covered by tests
if err != nil {
return fmt.Errorf("add ipv6 address: %s", err)
return fmt.Errorf("add ipv6 address %+v: %s", ipAddressStruct, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L480

Added line #L480 was not covered by tests
}

// Also create prefix if it doesn't exist yet
prefix, mask, err := utils.GetPrefixAndMaskFromIPAddress(nbIPAddress.Address)
if err != nil {
o.Logger.Warningf(o.Ctx, "error extracting prefix from IP address: %s", err)
} else if mask != constants.MaxIPv4MaskBits {
_, err = nbi.AddPrefix(o.Ctx, &objects.Prefix{
prefixStruct := &objects.Prefix{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L488

Added line #L488 was not covered by tests
Prefix: prefix,
})
}
_, err = nbi.AddPrefix(o.Ctx, prefixStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L491

Added line #L491 was not covered by tests
if err != nil {
o.Logger.Warningf(o.Ctx, "adding prefix: %s", err)
o.Logger.Warningf(o.Ctx, "adding prefix %+v: %s", prefixStruct, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L493

Added line #L493 was not covered by tests
}
}
}
Expand Down Expand Up @@ -816,12 +829,13 @@ func (o *OVirtSource) extractVMData(nbi *inventory.NetboxInventory, vmID string,
}
}
platformName := utils.GeneratePlatformName(vmOsType, vmOsVersion, vmCPUArch)
vmPlatform, err := nbi.AddPlatform(o.Ctx, &objects.Platform{
platformStruct := &objects.Platform{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L832

Added line #L832 was not covered by tests
Name: platformName,
Slug: utils.Slugify(platformName),
})
}
vmPlatform, err := nbi.AddPlatform(o.Ctx, platformStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L836

Added line #L836 was not covered by tests
if err != nil {
return nil, fmt.Errorf("failed adding oVirt vm's Platform %v with error: %s", vmPlatform, err)
return nil, fmt.Errorf("failed adding oVirt vm's Platform %v with error: %s", platformStruct, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L838

Added line #L838 was not covered by tests
}

return &objects.VM{
Expand Down Expand Up @@ -870,7 +884,7 @@ func (o *OVirtSource) syncVMInterfaces(nbi *inventory.NetboxInventory, ovirtVM *
o.Logger.Debugf(o.Ctx, "interface %s is filtered out with interfaceFilter %s", reportedDeviceName, o.SourceConfig.InterfaceFilter)
continue
}
vmInterface, err = nbi.AddVMInterface(o.Ctx, &objects.VMInterface{
vmInterfaceStruct := &objects.VMInterface{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L887

Added line #L887 was not covered by tests
NetboxObject: objects.NetboxObject{
Tags: o.Config.SourceTags,
Description: reportedDevice.MustDescription(),
Expand All @@ -882,9 +896,10 @@ func (o *OVirtSource) syncVMInterfaces(nbi *inventory.NetboxInventory, ovirtVM *
Name: reportedDeviceName,
MACAddress: strings.ToUpper(vmInterfaceMac),
Enabled: true, // TODO
})
}
vmInterface, err = nbi.AddVMInterface(o.Ctx, vmInterfaceStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L900

Added line #L900 was not covered by tests
if err != nil {
return fmt.Errorf("failed to sync oVirt vm %s's interface %s: %v", netboxVM.Name, reportedDeviceName, err)
return fmt.Errorf("failed to sync oVirt vm %s's interface %+v: %v", netboxVM.Name, vmInterfaceStruct, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L902

Added line #L902 was not covered by tests
}
} else {
o.Logger.Warning(o.Ctx, "name for oVirt vm's reported device is empty. Skipping...")
Expand Down Expand Up @@ -912,7 +927,7 @@ func (o *OVirtSource) syncVMInterfaces(nbi *inventory.NetboxInventory, ovirtVM *
}

if !utils.SubnetsContainIPAddress(ipAddress, o.SourceConfig.IgnoredSubnets) {
newIPAddress, err := nbi.AddIPAddress(o.Ctx, &objects.IPAddress{
ipAddressStruct := &objects.IPAddress{

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L930

Added line #L930 was not covered by tests
NetboxObject: objects.NetboxObject{
Tags: o.Config.SourceTags,
CustomFields: map[string]interface{}{
Expand All @@ -926,10 +941,11 @@ func (o *OVirtSource) syncVMInterfaces(nbi *inventory.NetboxInventory, ovirtVM *
DNSName: hostname,
AssignedObjectType: objects.AssignedObjectTypeVMInterface,
AssignedObjectID: vmInterface.ID,
})
}
newIPAddress, err := nbi.AddIPAddress(o.Ctx, ipAddressStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L945

Added line #L945 was not covered by tests

if err != nil {
o.Logger.Warningf(o.Ctx, "add ip address: %s", err)
o.Logger.Warningf(o.Ctx, "add ip address %+v: %s", err, ipAddressStruct)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L948

Added line #L948 was not covered by tests
continue
}

Expand All @@ -941,7 +957,7 @@ func (o *OVirtSource) syncVMInterfaces(nbi *inventory.NetboxInventory, ovirtVM *
vmCopy.PrimaryIPv4 = newIPAddress
_, err := nbi.AddVM(o.Ctx, &vmCopy)
if err != nil {
o.Logger.Warningf(o.Ctx, "adding vm's primary ipv4 address: %s", err)
o.Logger.Warningf(o.Ctx, "adding vm's primary ipv4 address %+v: %s", newIPAddress, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L960

Added line #L960 was not covered by tests
continue
}
}
Expand All @@ -954,7 +970,7 @@ func (o *OVirtSource) syncVMInterfaces(nbi *inventory.NetboxInventory, ovirtVM *
Prefix: prefix,
})
if err != nil {
o.Logger.Errorf(o.Ctx, "add prefix: %s", err)
o.Logger.Errorf(o.Ctx, "add prefix %+v: %s", prefix, err)

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

View check run for this annotation

Codecov / codecov/patch

internal/source/ovirt/ovirt_sync.go#L973

Added line #L973 was not covered by tests
}
}
}
Expand Down
Loading

0 comments on commit d35befa

Please sign in to comment.