Skip to content

Commit

Permalink
fix: adding fallback mechanism for ovirt primary ipv4
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ko committed Feb 21, 2024
1 parent 5cca044 commit dfc6c1a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions internal/source/ovirt/ovirt_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,14 +836,12 @@ func (o *Source) syncVMInterfaces(nbi *inventory.NetboxInventory, ovirtVM *ovirt
// Check if ip is primary
if ipVersion == "v4" {
vmIP := utils.Lookup(netboxVM.Name)
if vmIP != "" {
if ipAddress == vmIP {
vmCopy := *netboxVM
vmCopy.PrimaryIPv4 = newIPAddress
_, err := nbi.AddVM(&vmCopy)
if err != nil {
return fmt.Errorf("adding primary ipv4 address: %s", err)
}
if vmIP != "" && vmIP == ipAddress || netboxVM.PrimaryIPv4 == nil {
vmCopy := *netboxVM
vmCopy.PrimaryIPv4 = newIPAddress
_, err := nbi.AddVM(&vmCopy)
if err != nil {
return fmt.Errorf("adding primary ipv4 address: %s", err)
}
}
}
Expand Down

0 comments on commit dfc6c1a

Please sign in to comment.