Skip to content

Commit

Permalink
Merge pull request #1628 from rxtom/ovnstate
Browse files Browse the repository at this point in the history
incus/network/info (ovn): Fix object not found.
  • Loading branch information
stgraber authored Feb 10, 2025
2 parents b146593 + 8b04822 commit d9336ba
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions internal/server/network/driver_ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,35 +163,43 @@ func (n *ovn) State() (*api.NetworkState, error) {
})
}

hwaddr, ok := n.config["bridge.hwaddr"]
if !ok {
hwaddr, err = n.ovnnb.GetLogicalRouterPortHardwareAddress(context.TODO(), n.getRouterExtPortName())
var chassis string
var hwaddr string
var logicalRouterName string
var uplinkIPv4 string
var uplinkIPv6 string

if n.config["network"] != "none" {
var ok bool
hwaddr, ok = n.config["bridge.hwaddr"]
if !ok {
hwaddr, err = n.ovnnb.GetLogicalRouterPortHardwareAddress(context.TODO(), n.getRouterExtPortName())
if err != nil {
return nil, err
}
}

chassis, err = n.ovnsb.GetLogicalRouterPortActiveChassisHostname(context.TODO(), n.getRouterExtPortName())
if err != nil {
return nil, err
}
}

chassis, err := n.ovnsb.GetLogicalRouterPortActiveChassisHostname(context.TODO(), n.getRouterExtPortName())
if err != nil {
return nil, err
logicalRouterName = string(n.getRouterName())

if n.config[ovnVolatileUplinkIPv4] != "" {
uplinkIPv4 = n.config[ovnVolatileUplinkIPv4]
}

if n.config[ovnVolatileUplinkIPv6] != "" {
uplinkIPv6 = n.config[ovnVolatileUplinkIPv6]
}
}

mtu := int(n.getBridgeMTU())
if mtu == 0 {
mtu = 1500
}

var uplinkIPv4 string
var uplinkIPv6 string

if n.config[ovnVolatileUplinkIPv4] != "" {
uplinkIPv4 = n.config[ovnVolatileUplinkIPv4]
}

if n.config[ovnVolatileUplinkIPv6] != "" {
uplinkIPv6 = n.config[ovnVolatileUplinkIPv6]
}

return &api.NetworkState{
Addresses: addresses,
Counters: api.NetworkStateCounters{},
Expand All @@ -201,7 +209,7 @@ func (n *ovn) State() (*api.NetworkState, error) {
Type: "broadcast",
OVN: &api.NetworkStateOVN{
Chassis: chassis,
LogicalRouter: string(n.getRouterName()),
LogicalRouter: logicalRouterName,
UplinkIPv4: uplinkIPv4,
UplinkIPv6: uplinkIPv6,
},
Expand Down

0 comments on commit d9336ba

Please sign in to comment.