mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-01 02:52: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:
parent
63dc5cb8f6
commit
722e01053b
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user