0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-06-30 18:42:58 +00:00

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

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

This allows us to have multiple interfaces and only one (instead of all) has to have assigned ip

* add multiple network devices to the example VM

Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
Szczepan Wiśniowski 2022-12-11 22:29:25 +01:00 committed by GitHub
parent 63dc5cb8f6
commit 722e01053b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -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 {

View File

@ -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 {
@ -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
}
}