Skip to content

Commit

Permalink
fix(ovirt): check if mac exists, otherwise set empty string to it
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ko committed Mar 14, 2024
1 parent ba68e16 commit a8dd731
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/vmware/govmomi v0.36.0 h1:h8+PfYnsIihvUpzD2Mb9kFnSWEz1u2dRWxrBLi79N9I=
github.com/vmware/govmomi v0.36.0/go.mod h1:mtGWtM+YhTADHlCgJBiskSRPOZRsN9MSjPzaZLte/oQ=
github.com/vmware/govmomi v0.36.1 h1:+E/nlfteQ8JvC0xhuKAfpnMsuIeGeGj7rJwqENUcWm8=
github.com/vmware/govmomi v0.36.1/go.mod h1:mtGWtM+YhTADHlCgJBiskSRPOZRsN9MSjPzaZLte/oQ=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down
8 changes: 7 additions & 1 deletion internal/source/ovirt/ovirt_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,12 @@ func (o *OVirtSource) syncVMInterfaces(nbi *inventory.NetboxInventory, ovirtVM *
// We add interface to the list
var vmInterface *objects.VMInterface
var err error
vmInterfaceMac := ""
if macAddressObj, exists := reportedDevice.Mac(); exists {
if macAddress, exists := macAddressObj.Address(); exists {
vmInterfaceMac = macAddress
}
}
if reportedDeviceName, exists := reportedDevice.Name(); exists {
vmInterface, err = nbi.AddVMInterface(o.Ctx, &objects.VMInterface{
NetboxObject: objects.NetboxObject{
Expand All @@ -784,7 +790,7 @@ func (o *OVirtSource) syncVMInterfaces(nbi *inventory.NetboxInventory, ovirtVM *
},
VM: netboxVM,
Name: reportedDeviceName,
MACAddress: strings.ToUpper(reportedDevice.MustMac().MustAddress()),
MACAddress: strings.ToUpper(vmInterfaceMac),
Enabled: true, // TODO
})
if err != nil {
Expand Down

0 comments on commit a8dd731

Please sign in to comment.