diff --git a/opennebula/resource_opennebula_virtual_machine.go b/opennebula/resource_opennebula_virtual_machine.go index 1c68c6395..c88bc6032 100644 --- a/opennebula/resource_opennebula_virtual_machine.go +++ b/opennebula/resource_opennebula_virtual_machine.go @@ -188,6 +188,14 @@ func nicComputedVMFields() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "computed_ip6_global": { + Type: schema.TypeString, + Computed: true, + }, + "computed_ip6_link": { + Type: schema.TypeString, + Computed: true, + }, "computed_mac": { Type: schema.TypeString, Computed: true, @@ -727,6 +735,8 @@ func flattenNICComputed(nic shared.NIC) map[string]interface{} { ip, _ := nic.Get(shared.IP) mac, _ := nic.Get(shared.MAC) physicalDevice, _ := nic.GetStr("PHYDEV") + ip6Global, _ := nic.GetStr("IP6_GLOBAL") + ip6Link, _ := nic.GetStr("IP6_LINK") network, _ := nic.Get(shared.Network) model, _ := nic.Get(shared.Model) @@ -743,6 +753,8 @@ func flattenNICComputed(nic shared.NIC) map[string]interface{} { "nic_id": nicID, "network": network, "computed_ip": ip, + "computed_ip6_global": ip6Global, + "computed_ip6_link": ip6Link, "computed_mac": mac, "computed_physical_device": physicalDevice, "computed_model": model, @@ -758,6 +770,12 @@ func flattenVMNICComputed(NICConfig map[string]interface{}, NIC shared.NIC) map[ if len(NICConfig["ip"].(string)) > 0 { NICMap["ip"] = NICMap["computed_ip"] } + if len(NICConfig["ip6_global"].(string)) > 0 { + NICMap["ip6_global"] = NICMap["computed_ip6_global"] + } + if len(NICConfig["ip6_link"].(string)) > 0 { + NICMap["ip6_link"] = NICMap["computed_ip6_link"] + } if len(NICConfig["mac"].(string)) > 0 { NICMap["mac"] = NICMap["computed_mac"] } @@ -1258,6 +1276,8 @@ func resourceOpennebulaVirtualMachineUpdate(d *schema.ResourceData, meta interfa }, "network_id", "ip", + "ip6Global", + "ip6Link", "mac", "security_groups", "model", diff --git a/opennebula/resource_opennebula_virtual_machine_test.go b/opennebula/resource_opennebula_virtual_machine_test.go index e439cac2e..65a0277dc 100644 --- a/opennebula/resource_opennebula_virtual_machine_test.go +++ b/opennebula/resource_opennebula_virtual_machine_test.go @@ -1405,6 +1405,8 @@ resource "opennebula_virtual_machine" "test" { nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.131" + ip6_global = "2001:db8:abcd::1" + ip6_link = "FE80::C000:1DFF:FEE0:0" } timeout = 5 @@ -1444,10 +1446,14 @@ resource "opennebula_virtual_machine" "test" { nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.131" + ip6_global = "2001:db8:abcd::1" + ip6_link = "FE80::C000:1DFF:FEE0:0" } nic { network_id = opennebula_virtual_network.network1.id ip = "172.16.100.132" + ip6_global = "2001:db8:abcd::2" + ip6_link = "FE80::C000:1DFF:FEE0:0" } timeout = 5 @@ -1464,37 +1470,42 @@ var testAccVirtualMachineTemplateConfigNICUpdate = testNICVNetResources + ` cpu = 0.1 context = { - NETWORK = "YES" - SET_HOSTNAME = "$NAME" - } - - graphics { - type = "VNC" - listen = "0.0.0.0" - keymap = "en-us" - } - - os { - arch = "x86_64" - boot = "" - } + NETWORK = "YES" + SET_HOSTNAME = "$NAME" + } - tags = { - env = "prod" - customer = "test" - } + graphics { + type = "VNC" + listen = "0.0.0.0" + keymap = "en-us" + } + + os { + arch = "x86_64" + boot = "" + } + + tags = { + env = "prod" + customer = "test" + } - nic { - network_id = opennebula_virtual_network.network1.id - ip = "172.16.100.131" - } - nic { - network_id = opennebula_virtual_network.network2.id - ip = "172.16.100.111" - } - - timeout = 5 -} + nic { + network_id = opennebula_virtual_network.network1.id + ip = "172.16.100.131" + ip6_global = "2001:db8:abcd::1" + ip6_link = "FE80::C000:1DFF:FEE0:0" + } + + nic { + network_id = opennebula_virtual_network.network2.id + ip = "172.16.100.111" + ip6_global = "2001:db8:abcd::2" + ip6_link = "FE80::C000:1DFF:FEE0:0" + } + + timeout = 5 + } ` var testAccVirtualMachineTemplateConfigNICIPUpdate = testNICVNetResources + ` @@ -1503,42 +1514,46 @@ var testAccVirtualMachineTemplateConfigNICIPUpdate = testNICVNetResources + ` name = "test-virtual_machine" group = "oneadmin" permissions = "642" - memory = 128 - cpu = 0.1 + memory = 128 + cpu = 0.1 context = { - NETWORK = "YES" - SET_HOSTNAME = "$NAME" + NETWORK = "YES" + SET_HOSTNAME = "$NAME" } graphics { - type = "VNC" - listen = "0.0.0.0" - keymap = "en-us" + type = "VNC" + listen = "0.0.0.0" + keymap = "en-us" } os { - arch = "x86_64" - boot = "" + arch = "x86_64" + boot = "" } tags = { - env = "prod" - customer = "test" + env = "prod" + customer = "test" } nic { - network_id = opennebula_virtual_network.network1.id - ip = "172.16.100.131" - } - nic { - network_id = opennebula_virtual_network.network2.id - ip = "172.16.100.112" + network_id = opennebula_virtual_network.network1.id + ip = "172.16.100.131" + ip6_global = "2001:db8:abcd::1" + ip6_link = "FE80::C000:1DFF:FEE0:0" } + nic { + network_id = opennebula_virtual_network.network2.id + ip = "172.16.100.112" + ip6_global = "2001:db8:abcd::2" + ip6_link = "FE80::C000:1DFF:FEE0:0" + } - timeout = 5 -} + timeout = 5 + } ` var testAccVirtualMachineTemplateConfigMultipleNICs = testNICVNetResources + ` @@ -1547,50 +1562,62 @@ var testAccVirtualMachineTemplateConfigMultipleNICs = testNICVNetResources + ` name = "test-virtual_machine" group = "oneadmin" permissions = "642" - memory = 128 - cpu = 0.1 + memory = 128 + cpu = 0.1 context = { - NETWORK = "YES" - SET_HOSTNAME = "$NAME" + NETWORK = "YES" + SET_HOSTNAME = "$NAME" } graphics { - type = "VNC" - listen = "0.0.0.0" - keymap = "en-us" + type = "VNC" + listen = "0.0.0.0" + keymap = "en-us" } os { - arch = "x86_64" - boot = "" + arch = "x86_64" + boot = "" } tags = { - env = "prod" - customer = "test" + env = "prod" + customer = "test" } keep_nic_order = false + nic { - network_id = opennebula_virtual_network.network2.id - ip = "172.16.100.112" + network_id = opennebula_virtual_network.network2.id + ip = "172.16.100.112" + ip6_global = "2001:db8:abcd::1" + ip6_link = "FE80::C000:1DFF:FEE0:0" } + nic { - network_id = opennebula_virtual_network.network1.id - ip = "172.16.100.132" + network_id = opennebula_virtual_network.network1.id + ip = "172.16.100.132" + ip6_global = "2001:db8:abcd::2" + ip6_link = "FE80::C000:1DFF:FEE0:0" } + nic { - network_id = opennebula_virtual_network.network2.id - ip = "172.16.100.113" + network_id = opennebula_virtual_network.network2.id + ip = "172.16.100.113" + ip6_global = "2001:db8:abcd::3" + ip6_link = "FE80::C000:1DFF:FEE0:0" } + nic { - network_id = opennebula_virtual_network.network1.id - ip = "172.16.100.133" + network_id = opennebula_virtual_network.network1.id + ip = "172.16.100.133" + ip6_global = "2001:db8:abcd::4" + ip6_link = "FE80::C000:1DFF:FEE0:0" } timeout = 5 -} + } ` var testAccVirtualMachineTemplateConfigMultipleNICsOrderedUpdate = testNICVNetResources + ` @@ -1599,11 +1626,11 @@ var testAccVirtualMachineTemplateConfigMultipleNICsOrderedUpdate = testNICVNetRe name = "test-virtual_machine" group = "oneadmin" permissions = "642" - memory = 128 - cpu = 0.1 + memory = 128 + cpu = 0.1 context = { - NETWORK = "YES" + NETWORK = "YES" SET_HOSTNAME = "$NAME" } @@ -1619,7 +1646,7 @@ var testAccVirtualMachineTemplateConfigMultipleNICsOrderedUpdate = testNICVNetRe } tags = { - env = "prod" + env = "prod" customer = "test" } @@ -1651,11 +1678,11 @@ resource "opennebula_virtual_machine" "test" { name = "test-virtual_machine" group = "oneadmin" permissions = "642" - memory = 128 - cpu = 0.1 + memory = 128 + cpu = 0.1 context = { - NETWORK = "YES" + NETWORK = "YES" SET_HOSTNAME = "$NAME" } @@ -1671,7 +1698,7 @@ resource "opennebula_virtual_machine" "test" { } tags = { - env = "prod" + env = "prod" customer = "test" } @@ -1687,11 +1714,11 @@ resource "opennebula_template" "template" { name = "test-template" group = "oneadmin" permissions = "642" - memory = 128 - cpu = 0.1 + memory = 128 + cpu = 0.1 context = { - NETWORK = "YES" + NETWORK = "YES" SET_HOSTNAME = "$NAME" } @@ -1703,8 +1730,8 @@ resource "opennebula_template" "template" { nic { network_id = opennebula_virtual_network.network1.id - ip = "172.16.100.131" - model = "virtio" + ip = "172.16.100.131" + model = "virtio" virtio_queues = "2" } @@ -1735,9 +1762,9 @@ resource "opennebula_virtual_machine" "test" { template_id = opennebula_template.template.id nic { - network_id = opennebula_virtual_network.network2.id - ip = "172.16.100.111" - model = "virtio" + network_id = opennebula_virtual_network.network2.id + ip = "172.16.100.111" + model = "virtio" virtio_queues = "2" } diff --git a/opennebula/shared_schemas.go b/opennebula/shared_schemas.go index e357ff5f5..24f6399ff 100644 --- a/opennebula/shared_schemas.go +++ b/opennebula/shared_schemas.go @@ -22,6 +22,14 @@ func nicFields() map[string]*schema.Schema { Type: schema.TypeString, Optional: true, }, + "ip6_global": { + Type: schema.TypeString, + Optional: true, + }, + "ip6_link": { + Type: schema.TypeString, + Optional: true, + }, "mac": { Type: schema.TypeString, Optional: true, diff --git a/website/docs/r/virtual_machine.html.markdown b/website/docs/r/virtual_machine.html.markdown index df29c68b7..55e659705 100644 --- a/website/docs/r/virtual_machine.html.markdown +++ b/website/docs/r/virtual_machine.html.markdown @@ -138,6 +138,8 @@ A disk update will be triggered in adding or removing a `disk` section, or by a * `network_id` - (Required) ID of the virtual network to attach to the virtual machine. * `ip` - (Optional) IP of the virtual machine on this network. +* `ip6_global` - (Optional) IPv6 of the virtual machine on this network. +* `ip6_link` - (Optional) IPv6 link local of the virtual machine on this network. * `mac` - (Optional) MAC of the virtual machine on this network. * `model` - (Optional) Nic model driver. Example: `virtio`. * `virtio_queues` - (Optional) Virtio multi-queue size. Only if `model` is `virtio`. @@ -176,6 +178,8 @@ The following attribute are exported: * `nic_id` - nic attachment identifier * `network` - network name * `computed_ip` - IP of the virtual machine on this network. +* `computed_ip6_global` - IPv6 of the virtual machine on this network. +* `computed_ip6_link` - IPv6 link local of the virtual machine on this network. * `computed_mac` - MAC of the virtual machine on this network. * `computed_model` - Nic model driver. * `computed_virtio_queues` - Virtio multi-queue size. @@ -195,6 +199,8 @@ The following attribute are exported: * `nic_id` - nic attachment identifier * `network` - network name * `computed_ip` - IP of the virtual machine on this network. +* `computed_ip6_global` - IPv6 of the virtual machine on this network. +* `computed_ip6_link` - IPv6 link local of the virtual machine on this network. * `computed_mac` - MAC of the virtual machine on this network. * `computed_model` - Nic model driver. * `computed_virtio_queues` - Virtio multi-queue size.