Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Check if any interface has global unicast address instead of all interfaces #182

Merged
merged 3 commits into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions example/resource_virtual_environment_vm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ resource "proxmox_virtual_environment_vm" "example_template" {

network_device {}

network_device {
vlan_id = 1024
}

node_name = data.proxmox_virtual_environment_nodes.example.names[0]

operating_system {
Expand Down
11 changes: 3 additions & 8 deletions proxmox/virtual_environment_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ func (c *VirtualEnvironmentClient) WaitForNetworkInterfacesFromVMAgent(ctx conte

if err == nil && data != nil && data.Result != nil {
missingIP := false
hasAnyGlobalUnicast := false

if waitForIP {
for _, nic := range *data.Result {
Expand All @@ -408,21 +409,15 @@ func (c *VirtualEnvironmentClient) WaitForNetworkInterfacesFromVMAgent(ctx conte
break
}

hasGlobalUnicast := false
for _, addr := range *nic.IPAddresses {
if ip := net.ParseIP(addr.Address); ip != nil && ip.IsGlobalUnicast() {
hasGlobalUnicast = true
hasAnyGlobalUnicast = true
}
}
if !hasGlobalUnicast {
missingIP = true
break
}

}
}

if !missingIP {
if hasAnyGlobalUnicast || !missingIP {
return data, err
}
}
Expand Down