mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-04 21:14:05 +00:00
feat: add support for network_device MTU (#176)
* add support for network_device MTU * add mtu to the example templates * change default mtu 1500 -> 0, update docs Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
290734655c
commit
3c02cb1389
@ -127,6 +127,7 @@ output "ubuntu_container_public_key" {
|
|||||||
* `bridge` - (Optional) The name of the network bridge (defaults to `vmbr0`).
|
* `bridge` - (Optional) The name of the network bridge (defaults to `vmbr0`).
|
||||||
* `enabled` - (Optional) Whether to enable the network device (defaults to `true`).
|
* `enabled` - (Optional) Whether to enable the network device (defaults to `true`).
|
||||||
* `mac_address` - (Optional) The MAC address.
|
* `mac_address` - (Optional) The MAC address.
|
||||||
|
* `mtu` - (Optional) Maximum transfer unit of the interface. Cannot be larger than the bridge's MTU.
|
||||||
* `name` - (Required) The network interface name.
|
* `name` - (Required) The network interface name.
|
||||||
* `rate_limit` - (Optional) The rate limit in megabytes per second.
|
* `rate_limit` - (Optional) The rate limit in megabytes per second.
|
||||||
* `vlan_id` - (Optional) The VLAN identifier.
|
* `vlan_id` - (Optional) The VLAN identifier.
|
||||||
|
@ -259,6 +259,7 @@ output "ubuntu_vm_public_key" {
|
|||||||
* `rtl8139` - Realtek RTL8139.
|
* `rtl8139` - Realtek RTL8139.
|
||||||
* `virtio` - VirtIO (paravirtualized).
|
* `virtio` - VirtIO (paravirtualized).
|
||||||
* `vmxnet3` - VMware vmxnet3.
|
* `vmxnet3` - VMware vmxnet3.
|
||||||
|
* `mtu` - (Optional) Force MTU, for VirtIO only. Set to 1 to use the bridge MTU. Cannot be larger than the bridge MTU.
|
||||||
* `rate_limit` - (Optional) The rate limit in megabytes per second.
|
* `rate_limit` - (Optional) The rate limit in megabytes per second.
|
||||||
* `vlan_id` - (Optional) The VLAN identifier.
|
* `vlan_id` - (Optional) The VLAN identifier.
|
||||||
* `node_name` - (Required) The name of the node to assign the virtual machine to.
|
* `node_name` - (Required) The name of the node to assign the virtual machine to.
|
||||||
|
@ -26,6 +26,7 @@ resource "proxmox_virtual_environment_container" "example_template" {
|
|||||||
|
|
||||||
network_interface {
|
network_interface {
|
||||||
name = "veth0"
|
name = "veth0"
|
||||||
|
mtu = 1450
|
||||||
}
|
}
|
||||||
|
|
||||||
node_name = data.proxmox_virtual_environment_nodes.example.names[0]
|
node_name = data.proxmox_virtual_environment_nodes.example.names[0]
|
||||||
|
@ -50,7 +50,9 @@ resource "proxmox_virtual_environment_vm" "example_template" {
|
|||||||
|
|
||||||
name = "terraform-provider-proxmox-example-template"
|
name = "terraform-provider-proxmox-example-template"
|
||||||
|
|
||||||
network_device {}
|
network_device {
|
||||||
|
mtu = 1450
|
||||||
|
}
|
||||||
|
|
||||||
network_device {
|
network_device {
|
||||||
vlan_id = 1024
|
vlan_id = 1024
|
||||||
|
@ -88,6 +88,7 @@ type CustomNetworkDevice struct {
|
|||||||
Queues *int `json:"queues,omitempty" url:"queues,omitempty"`
|
Queues *int `json:"queues,omitempty" url:"queues,omitempty"`
|
||||||
RateLimit *float64 `json:"rate,omitempty" url:"rate,omitempty"`
|
RateLimit *float64 `json:"rate,omitempty" url:"rate,omitempty"`
|
||||||
Tag *int `json:"tag,omitempty" url:"tag,omitempty"`
|
Tag *int `json:"tag,omitempty" url:"tag,omitempty"`
|
||||||
|
MTU *int `json:"mtu,omitempty" url:"mtu,omitempty"`
|
||||||
Trunks []int `json:"trunks,omitempty" url:"trunks,omitempty"`
|
Trunks []int `json:"trunks,omitempty" url:"trunks,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -802,6 +803,9 @@ func (r CustomNetworkDevice) EncodeValues(key string, v *url.Values) error {
|
|||||||
if r.Tag != nil {
|
if r.Tag != nil {
|
||||||
values = append(values, fmt.Sprintf("tag=%d", *r.Tag))
|
values = append(values, fmt.Sprintf("tag=%d", *r.Tag))
|
||||||
}
|
}
|
||||||
|
if r.MTU != nil {
|
||||||
|
values = append(values, fmt.Sprintf("mtu=%d", *r.MTU))
|
||||||
|
}
|
||||||
|
|
||||||
if len(r.Trunks) > 0 {
|
if len(r.Trunks) > 0 {
|
||||||
trunks := make([]string, len(r.Trunks))
|
trunks := make([]string, len(r.Trunks))
|
||||||
@ -1462,6 +1466,14 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
|||||||
}
|
}
|
||||||
r.RateLimit = &fv
|
r.RateLimit = &fv
|
||||||
|
|
||||||
|
case "mtu":
|
||||||
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
r.MTU = &iv
|
||||||
|
|
||||||
case "tag":
|
case "tag":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
|
@ -7,10 +7,11 @@ package proxmoxtf
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
|
||||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
@ -42,6 +43,7 @@ const (
|
|||||||
dvResourceVirtualEnvironmentContainerNetworkInterfaceMACAddress = ""
|
dvResourceVirtualEnvironmentContainerNetworkInterfaceMACAddress = ""
|
||||||
dvResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit = 0
|
dvResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit = 0
|
||||||
dvResourceVirtualEnvironmentContainerNetworkInterfaceVLANID = 0
|
dvResourceVirtualEnvironmentContainerNetworkInterfaceVLANID = 0
|
||||||
|
dvResourceVirtualEnvironmentContainerNetworkInterfaceMTU = 0
|
||||||
dvResourceVirtualEnvironmentContainerOperatingSystemType = "unmanaged"
|
dvResourceVirtualEnvironmentContainerOperatingSystemType = "unmanaged"
|
||||||
dvResourceVirtualEnvironmentContainerPoolID = ""
|
dvResourceVirtualEnvironmentContainerPoolID = ""
|
||||||
dvResourceVirtualEnvironmentContainerStarted = true
|
dvResourceVirtualEnvironmentContainerStarted = true
|
||||||
@ -91,6 +93,7 @@ const (
|
|||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceName = "name"
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceName = "name"
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit = "rate_limit"
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit = "rate_limit"
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID = "vlan_id"
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID = "vlan_id"
|
||||||
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU = "mtu"
|
||||||
mkResourceVirtualEnvironmentContainerNodeName = "node_name"
|
mkResourceVirtualEnvironmentContainerNodeName = "node_name"
|
||||||
mkResourceVirtualEnvironmentContainerOperatingSystem = "operating_system"
|
mkResourceVirtualEnvironmentContainerOperatingSystem = "operating_system"
|
||||||
mkResourceVirtualEnvironmentContainerOperatingSystemTemplateFileID = "template_file_id"
|
mkResourceVirtualEnvironmentContainerOperatingSystemTemplateFileID = "template_file_id"
|
||||||
@ -481,6 +484,12 @@ func resourceVirtualEnvironmentContainer() *schema.Resource {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Default: dvResourceVirtualEnvironmentContainerNetworkInterfaceVLANID,
|
Default: dvResourceVirtualEnvironmentContainerNetworkInterfaceVLANID,
|
||||||
},
|
},
|
||||||
|
mkResourceVirtualEnvironmentVMNetworkDeviceMTU: {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Description: "Maximum transmission unit (MTU)",
|
||||||
|
Optional: true,
|
||||||
|
Default: dvResourceVirtualEnvironmentVMNetworkDeviceMTU,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
MaxItems: maxResourceVirtualEnvironmentContainerNetworkInterfaces,
|
MaxItems: maxResourceVirtualEnvironmentContainerNetworkInterfaces,
|
||||||
@ -791,6 +800,7 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
|||||||
name := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceName].(string)
|
name := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceName].(string)
|
||||||
rateLimit := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit].(float64)
|
rateLimit := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit].(float64)
|
||||||
vlanID := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID].(int)
|
vlanID := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID].(int)
|
||||||
|
mtu, _ := networkInterfaceMap[mkResourceVirtualEnvironmentVMNetworkDeviceMTU].(int)
|
||||||
|
|
||||||
if bridge != "" {
|
if bridge != "" {
|
||||||
networkInterfaceObject.Bridge = &bridge
|
networkInterfaceObject.Bridge = &bridge
|
||||||
@ -830,6 +840,10 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
|||||||
networkInterfaceObject.Tag = &vlanID
|
networkInterfaceObject.Tag = &vlanID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if mtu != 0 {
|
||||||
|
networkInterfaceObject.MTU = &mtu
|
||||||
|
}
|
||||||
|
|
||||||
networkInterfaceArray[ni] = networkInterfaceObject
|
networkInterfaceArray[ni] = networkInterfaceObject
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1003,6 +1017,7 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
|||||||
name := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceName].(string)
|
name := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceName].(string)
|
||||||
rateLimit := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit].(float64)
|
rateLimit := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit].(float64)
|
||||||
vlanID := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID].(int)
|
vlanID := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID].(int)
|
||||||
|
mtu := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU].(int)
|
||||||
|
|
||||||
if bridge != "" {
|
if bridge != "" {
|
||||||
networkInterfaceObject.Bridge = &bridge
|
networkInterfaceObject.Bridge = &bridge
|
||||||
@ -1041,6 +1056,9 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
|||||||
if vlanID != 0 {
|
if vlanID != 0 {
|
||||||
networkInterfaceObject.Tag = &vlanID
|
networkInterfaceObject.Tag = &vlanID
|
||||||
}
|
}
|
||||||
|
if mtu != 0 {
|
||||||
|
networkInterfaceObject.MTU = &mtu
|
||||||
|
}
|
||||||
|
|
||||||
networkInterfaceArray[ni] = networkInterfaceObject
|
networkInterfaceArray[ni] = networkInterfaceObject
|
||||||
}
|
}
|
||||||
@ -1237,6 +1255,12 @@ func resourceVirtualEnvironmentContainerGetExistingNetworkInterface(ctx context.
|
|||||||
networkInterface[mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID] = 0
|
networkInterface[mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nv.MTU != nil {
|
||||||
|
networkInterface[mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU] = *nv.MTU
|
||||||
|
} else {
|
||||||
|
networkInterface[mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU] = 0
|
||||||
|
}
|
||||||
|
|
||||||
networkInterfaces = append(networkInterfaces, networkInterface)
|
networkInterfaces = append(networkInterfaces, networkInterface)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1552,6 +1576,12 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
|||||||
networkInterface[mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID] = 0
|
networkInterface[mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nv.MTU != nil {
|
||||||
|
networkInterface[mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU] = *nv.MTU
|
||||||
|
} else {
|
||||||
|
networkInterface[mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU] = 0
|
||||||
|
}
|
||||||
|
|
||||||
networkInterfaceList = append(networkInterfaceList, networkInterface)
|
networkInterfaceList = append(networkInterfaceList, networkInterface)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1833,6 +1863,7 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
|||||||
name := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceName].(string)
|
name := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceName].(string)
|
||||||
rateLimit := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit].(float64)
|
rateLimit := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit].(float64)
|
||||||
vlanID := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID].(int)
|
vlanID := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID].(int)
|
||||||
|
mtu := networkInterfaceMap[mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU].(int)
|
||||||
|
|
||||||
if bridge != "" {
|
if bridge != "" {
|
||||||
networkInterfaceObject.Bridge = &bridge
|
networkInterfaceObject.Bridge = &bridge
|
||||||
@ -1872,6 +1903,10 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
|||||||
networkInterfaceObject.Tag = &vlanID
|
networkInterfaceObject.Tag = &vlanID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if mtu != 0 {
|
||||||
|
networkInterfaceObject.MTU = &mtu
|
||||||
|
}
|
||||||
|
|
||||||
networkInterfaceArray[ni] = networkInterfaceObject
|
networkInterfaceArray[ni] = networkInterfaceObject
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +194,7 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceMACAddress,
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceMACAddress,
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit,
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit,
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID,
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID,
|
||||||
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU,
|
||||||
})
|
})
|
||||||
|
|
||||||
testValueTypes(t, networkInterfaceSchema, map[string]schema.ValueType{
|
testValueTypes(t, networkInterfaceSchema, map[string]schema.ValueType{
|
||||||
@ -203,6 +204,7 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceName: schema.TypeString,
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceName: schema.TypeString,
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit: schema.TypeFloat,
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit: schema.TypeFloat,
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID: schema.TypeInt,
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID: schema.TypeInt,
|
||||||
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU: schema.TypeInt,
|
||||||
})
|
})
|
||||||
|
|
||||||
operatingSystemSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerOperatingSystem)
|
operatingSystemSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerOperatingSystem)
|
||||||
|
@ -80,6 +80,7 @@ const (
|
|||||||
dvResourceVirtualEnvironmentVMNetworkDeviceModel = "virtio"
|
dvResourceVirtualEnvironmentVMNetworkDeviceModel = "virtio"
|
||||||
dvResourceVirtualEnvironmentVMNetworkDeviceRateLimit = 0
|
dvResourceVirtualEnvironmentVMNetworkDeviceRateLimit = 0
|
||||||
dvResourceVirtualEnvironmentVMNetworkDeviceVLANID = 0
|
dvResourceVirtualEnvironmentVMNetworkDeviceVLANID = 0
|
||||||
|
dvResourceVirtualEnvironmentVMNetworkDeviceMTU = 0
|
||||||
dvResourceVirtualEnvironmentVMOperatingSystemType = "other"
|
dvResourceVirtualEnvironmentVMOperatingSystemType = "other"
|
||||||
dvResourceVirtualEnvironmentVMPoolID = ""
|
dvResourceVirtualEnvironmentVMPoolID = ""
|
||||||
dvResourceVirtualEnvironmentVMSerialDeviceDevice = "socket"
|
dvResourceVirtualEnvironmentVMSerialDeviceDevice = "socket"
|
||||||
@ -181,6 +182,7 @@ const (
|
|||||||
mkResourceVirtualEnvironmentVMNetworkDeviceModel = "model"
|
mkResourceVirtualEnvironmentVMNetworkDeviceModel = "model"
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceRateLimit = "rate_limit"
|
mkResourceVirtualEnvironmentVMNetworkDeviceRateLimit = "rate_limit"
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceVLANID = "vlan_id"
|
mkResourceVirtualEnvironmentVMNetworkDeviceVLANID = "vlan_id"
|
||||||
|
mkResourceVirtualEnvironmentVMNetworkDeviceMTU = "mtu"
|
||||||
mkResourceVirtualEnvironmentVMNetworkInterfaceNames = "network_interface_names"
|
mkResourceVirtualEnvironmentVMNetworkInterfaceNames = "network_interface_names"
|
||||||
mkResourceVirtualEnvironmentVMNodeName = "node_name"
|
mkResourceVirtualEnvironmentVMNodeName = "node_name"
|
||||||
mkResourceVirtualEnvironmentVMOperatingSystem = "operating_system"
|
mkResourceVirtualEnvironmentVMOperatingSystem = "operating_system"
|
||||||
@ -903,6 +905,12 @@ func resourceVirtualEnvironmentVM() *schema.Resource {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Default: dvResourceVirtualEnvironmentVMNetworkDeviceVLANID,
|
Default: dvResourceVirtualEnvironmentVMNetworkDeviceVLANID,
|
||||||
},
|
},
|
||||||
|
mkResourceVirtualEnvironmentVMNetworkDeviceMTU: {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Description: "Maximum transmission unit (MTU)",
|
||||||
|
Optional: true,
|
||||||
|
Default: dvResourceVirtualEnvironmentVMNetworkDeviceMTU,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
MaxItems: maxResourceVirtualEnvironmentVMNetworkDevices,
|
MaxItems: maxResourceVirtualEnvironmentVMNetworkDevices,
|
||||||
@ -2324,6 +2332,7 @@ func resourceVirtualEnvironmentVMGetNetworkDeviceObjects(d *schema.ResourceData)
|
|||||||
model, _ := block[mkResourceVirtualEnvironmentVMNetworkDeviceModel].(string)
|
model, _ := block[mkResourceVirtualEnvironmentVMNetworkDeviceModel].(string)
|
||||||
rateLimit, _ := block[mkResourceVirtualEnvironmentVMNetworkDeviceRateLimit].(float64)
|
rateLimit, _ := block[mkResourceVirtualEnvironmentVMNetworkDeviceRateLimit].(float64)
|
||||||
vlanID, _ := block[mkResourceVirtualEnvironmentVMNetworkDeviceVLANID].(int)
|
vlanID, _ := block[mkResourceVirtualEnvironmentVMNetworkDeviceVLANID].(int)
|
||||||
|
mtu, _ := block[mkResourceVirtualEnvironmentVMNetworkDeviceMTU].(int)
|
||||||
|
|
||||||
device := proxmox.CustomNetworkDevice{
|
device := proxmox.CustomNetworkDevice{
|
||||||
Enabled: enabled,
|
Enabled: enabled,
|
||||||
@ -2346,6 +2355,10 @@ func resourceVirtualEnvironmentVMGetNetworkDeviceObjects(d *schema.ResourceData)
|
|||||||
device.Tag = &vlanID
|
device.Tag = &vlanID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if mtu != 0 {
|
||||||
|
device.MTU = &mtu
|
||||||
|
}
|
||||||
|
|
||||||
networkDeviceObjects[i] = device
|
networkDeviceObjects[i] = device
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3080,6 +3093,11 @@ func resourceVirtualEnvironmentVMReadCustom(ctx context.Context, d *schema.Resou
|
|||||||
} else {
|
} else {
|
||||||
networkDevice[mkResourceVirtualEnvironmentVMNetworkDeviceVLANID] = 0
|
networkDevice[mkResourceVirtualEnvironmentVMNetworkDeviceVLANID] = 0
|
||||||
}
|
}
|
||||||
|
if nd.MTU != nil {
|
||||||
|
networkDevice[mkResourceVirtualEnvironmentVMNetworkDeviceMTU] = nd.MTU
|
||||||
|
} else {
|
||||||
|
networkDevice[mkResourceVirtualEnvironmentVMNetworkDeviceMTU] = 0
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
macAddresses[ni] = ""
|
macAddresses[ni] = ""
|
||||||
networkDevice[mkResourceVirtualEnvironmentVMNetworkDeviceEnabled] = false
|
networkDevice[mkResourceVirtualEnvironmentVMNetworkDeviceEnabled] = false
|
||||||
|
@ -296,6 +296,7 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMNetworkDeviceModel,
|
mkResourceVirtualEnvironmentVMNetworkDeviceModel,
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceRateLimit,
|
mkResourceVirtualEnvironmentVMNetworkDeviceRateLimit,
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceVLANID,
|
mkResourceVirtualEnvironmentVMNetworkDeviceVLANID,
|
||||||
|
mkResourceVirtualEnvironmentVMNetworkDeviceMTU,
|
||||||
})
|
})
|
||||||
|
|
||||||
testValueTypes(t, networkDeviceSchema, map[string]schema.ValueType{
|
testValueTypes(t, networkDeviceSchema, map[string]schema.ValueType{
|
||||||
@ -305,6 +306,7 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMNetworkDeviceModel: schema.TypeString,
|
mkResourceVirtualEnvironmentVMNetworkDeviceModel: schema.TypeString,
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceRateLimit: schema.TypeFloat,
|
mkResourceVirtualEnvironmentVMNetworkDeviceRateLimit: schema.TypeFloat,
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceVLANID: schema.TypeInt,
|
mkResourceVirtualEnvironmentVMNetworkDeviceVLANID: schema.TypeInt,
|
||||||
|
mkResourceVirtualEnvironmentVMNetworkDeviceMTU: schema.TypeInt,
|
||||||
})
|
})
|
||||||
|
|
||||||
operatingSystemSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMOperatingSystem)
|
operatingSystemSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMOperatingSystem)
|
||||||
|
Loading…
Reference in New Issue
Block a user