mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-05-20 01:01:20 +00:00
Preserve guest NIC identity before IP assignment (#1319)
This commit is contained in:
parent
1f332bee52
commit
176228381b
2 changed files with 26 additions and 2 deletions
|
|
@ -592,7 +592,16 @@ func processGuestNetworkInterfaces(raw []proxmox.VMNetworkInterface) ([]string,
|
|||
txBytes := parseInterfaceStat(iface.Statistics, "tx-bytes")
|
||||
|
||||
if len(addresses) == 0 && rxBytes == 0 && txBytes == 0 {
|
||||
continue
|
||||
if len(iface.IPAddresses) > 0 {
|
||||
continue
|
||||
}
|
||||
lowerName := strings.ToLower(ifaceName)
|
||||
if ifaceName == "" || lowerName == "lo" || lowerName == "loopback" {
|
||||
continue
|
||||
}
|
||||
if mac == "" || mac == "00:00:00:00:00:00" {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
guestIfaces = append(guestIfaces, models.GuestNetworkInterface{
|
||||
|
|
|
|||
|
|
@ -508,7 +508,7 @@ func TestProcessGuestNetworkInterfaces(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "interface with no IPs and no traffic is excluded",
|
||||
name: "interface with no IPs and no traffic keeps non-loopback identity",
|
||||
raw: []proxmox.VMNetworkInterface{
|
||||
{
|
||||
Name: "eth0",
|
||||
|
|
@ -517,6 +517,21 @@ func TestProcessGuestNetworkInterfaces(t *testing.T) {
|
|||
Statistics: nil,
|
||||
},
|
||||
},
|
||||
wantIPs: []string{},
|
||||
wantIfaces: []models.GuestNetworkInterface{
|
||||
{Name: "eth0", MAC: "00:11:22:33:44:55", Addresses: nil},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "loopback-only interface with no IPs and no traffic is excluded",
|
||||
raw: []proxmox.VMNetworkInterface{
|
||||
{
|
||||
Name: "lo",
|
||||
HardwareAddr: "00:00:00:00:00:00",
|
||||
IPAddresses: nil,
|
||||
Statistics: nil,
|
||||
},
|
||||
},
|
||||
wantIPs: []string{},
|
||||
wantIfaces: []models.GuestNetworkInterface{},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue