From 6d22e56006bc8a5847b3cd3a7884b8cb455f2f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Rousselet?= Date: Mon, 23 May 2022 21:19:53 +0200 Subject: [PATCH] Add IPv6 support (#247) --- .../resource_opennebula_virtual_machine.go | 10 +++--- ...esource_opennebula_virtual_machine_test.go | 34 +++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/opennebula/resource_opennebula_virtual_machine.go b/opennebula/resource_opennebula_virtual_machine.go index b5f78bd7a..0d00a3dc0 100644 --- a/opennebula/resource_opennebula_virtual_machine.go +++ b/opennebula/resource_opennebula_virtual_machine.go @@ -656,8 +656,8 @@ func flattenNICComputed(nic shared.NIC) map[string]interface{} { ip, _ := nic.Get(shared.IP) mac, _ := nic.Get(shared.MAC) physicalDevice, _ := nic.GetStr("PHYDEV") - ip6_global, _ := nic.GetStr("IP6_GLOBAL") - ip6_link, _ := nic.GetStr("IP6_LINK") + ip6Global, _ := nic.GetStr("IP6_GLOBAL") + ip6Link, _ := nic.GetStr("IP6_LINK") network, _ := nic.Get(shared.Network) model, _ := nic.Get(shared.Model) @@ -674,8 +674,8 @@ func flattenNICComputed(nic shared.NIC) map[string]interface{} { "nic_id": nicID, "network": network, "computed_ip": ip, - "computed_ip6_global": ip6_global, - "computed_ip6_link": ip6_link, + "computed_ip6_global": ip6Global, + "computed_ip6_link": ip6Link, "computed_mac": mac, "computed_physical_device": physicalDevice, "computed_model": model, @@ -1447,6 +1447,8 @@ func updateNIC(d *schema.ResourceData, meta interface{}) error { }, "network_id", "ip", + "ip6_global", + "ip6_link", "mac", "security_groups", "model", diff --git a/opennebula/resource_opennebula_virtual_machine_test.go b/opennebula/resource_opennebula_virtual_machine_test.go index ae53250e0..8b213e199 100644 --- a/opennebula/resource_opennebula_virtual_machine_test.go +++ b/opennebula/resource_opennebula_virtual_machine_test.go @@ -1465,6 +1465,8 @@ resource "opennebula_virtual_machine" "test" { nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.131" + ip6_global = "2001:db8:0:1::1" + ip6_link = "fe80::1" } timeout = 5 @@ -1504,10 +1506,14 @@ resource "opennebula_virtual_machine" "test" { nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.131" + ip6_global = "2001:db8:0:1::1" + ip6_link = "fe80::1" } nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.132" + ip6_global = "2001:db8:0:1::2" + ip6_link = "fe80::2" } timeout = 5 @@ -1547,10 +1553,14 @@ var testAccVirtualMachineTemplateConfigNICUpdate = testNICVNetResources + ` nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.131" + ip6_global = "2001:db8:0:1::1" + ip6_link = "fe80::1" } nic { network_id = opennebula_virtual_network.network2.id ip = "172.16.100.111" + ip6_global = "2001:db8:0:1::3" + ip6_link = "fe80::3" } timeout = 5 @@ -1590,10 +1600,14 @@ var testAccVirtualMachineTemplateConfigNICIPUpdate = testNICVNetResources + ` nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.131" + ip6_global = "2001:db8:0:1::1" + ip6_link = "fe80::1" } nic { network_id = opennebula_virtual_network.network2.id ip = "172.16.100.112" + ip6_global = "2001:db8:0:1::4" + ip6_link = "fe80::4" } @@ -1635,18 +1649,26 @@ var testAccVirtualMachineTemplateConfigMultipleNICs = testNICVNetResources + ` nic { network_id = opennebula_virtual_network.network2.id ip = "172.16.100.112" + ip6_global = "2001:db8:0:1::3" + ip6_link = "fe80::1" } nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.132" + ip6_global = "2001:db8:0:1::2" + ip6_link = "fe80::2" } nic { network_id = opennebula_virtual_network.network2.id ip = "172.16.100.113" + ip6_global = "2001:db8:0:1::1" + ip6_link = "fe80::3" } nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.133" + ip6_global = "2001:db8:0:1::4" + ip6_link = "fe80::4" } timeout = 5 @@ -1687,18 +1709,26 @@ var testAccVirtualMachineTemplateConfigMultipleNICsOrderedUpdate = testNICVNetRe nic { network_id = opennebula_virtual_network.network2.id ip = "172.16.100.112" + ip6_global = "2001:db8:0:1::3" + ip6_link = "fe80::1" } nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.134" + ip6_global = "2001:db8:0:1::2" + ip6_link = "fe80::2" } nic { network_id = opennebula_virtual_network.network2.id ip = "172.16.100.113" + ip6_global = "2001:db8:0:1::1" + ip6_link = "fe80::3" } nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.133" + ip6_global = "2001:db8:0:1::4" + ip6_link = "fe80::4" } timeout = 5 @@ -1764,6 +1794,8 @@ resource "opennebula_template" "template" { nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.131" + ip6_global = "2001:db8:0:1::1" + ip6_link = "fe80::1" model = "virtio" virtio_queues = "2" } @@ -1797,6 +1829,8 @@ resource "opennebula_virtual_machine" "test" { nic { network_id = opennebula_virtual_network.network2.id ip = "172.16.100.111" + ip6_global = "2001:db8:0:1::1" + ip6_link = "fe80::1" model = "virtio" virtio_queues = "2" }