mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 02:31:10 +00:00
fix(vm): allow scsi
and sata
for CD-ROM interface (#1971)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
9655bd9ec7
commit
b1b8d1570f
@ -168,9 +168,9 @@ output "ubuntu_vm_public_key" {
|
|||||||
Set `file_id` to `none` to leave the CD-ROM drive empty.
|
Set `file_id` to `none` to leave the CD-ROM drive empty.
|
||||||
- `file_id` - (Optional) A file ID for an ISO file (defaults to `cdrom` as
|
- `file_id` - (Optional) A file ID for an ISO file (defaults to `cdrom` as
|
||||||
in the physical drive). Use `none` to leave the CD-ROM drive empty.
|
in the physical drive). Use `none` to leave the CD-ROM drive empty.
|
||||||
- `interface` - (Optional) A hardware interface to connect CD-ROM drive to,
|
- `interface` - (Optional) A hardware interface to connect CD-ROM drive to (defaults to `ide3`).
|
||||||
must be `ideN` (defaults to `ide3`). Note that `q35` machine type only
|
"Must be one of `ideN`, `sataN`, `scsiN`, where N is the index of the interface. " +
|
||||||
supports `ide0` and `ide2`.
|
"Note that `q35` machine type only supports `ide0` and `ide2` of IDE interfaces.
|
||||||
- `clone` - (Optional) The cloning configuration.
|
- `clone` - (Optional) The cloning configuration.
|
||||||
- `datastore_id` - (Optional) The identifier for the target datastore.
|
- `datastore_id` - (Optional) The identifier for the target datastore.
|
||||||
- `node_name` - (Optional) The name of the source node (leave blank, if
|
- `node_name` - (Optional) The name of the source node (leave blank, if
|
||||||
|
@ -51,6 +51,46 @@ func TestAccResourceVMCDROM(t *testing.T) {
|
|||||||
RefreshState: true,
|
RefreshState: true,
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
|
{"sata cdrom", []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: te.RenderConfig(`
|
||||||
|
resource "proxmox_virtual_environment_vm" "test_cdrom" {
|
||||||
|
node_name = "{{.NodeName}}"
|
||||||
|
started = false
|
||||||
|
name = "test-cdrom"
|
||||||
|
cdrom {
|
||||||
|
file_id = "none"
|
||||||
|
interface = "sata3"
|
||||||
|
}
|
||||||
|
}`),
|
||||||
|
Check: ResourceAttributes("proxmox_virtual_environment_vm.test_cdrom", map[string]string{
|
||||||
|
"cdrom.0.interface": "sata3",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
RefreshState: true,
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{"scsi cdrom", []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: te.RenderConfig(`
|
||||||
|
resource "proxmox_virtual_environment_vm" "test_cdrom" {
|
||||||
|
node_name = "{{.NodeName}}"
|
||||||
|
started = false
|
||||||
|
name = "test-cdrom"
|
||||||
|
cdrom {
|
||||||
|
file_id = "none"
|
||||||
|
interface = "scsi5"
|
||||||
|
}
|
||||||
|
}`),
|
||||||
|
Check: ResourceAttributes("proxmox_virtual_environment_vm.test_cdrom", map[string]string{
|
||||||
|
"cdrom.0.interface": "scsi5",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
RefreshState: true,
|
||||||
|
},
|
||||||
|
}},
|
||||||
{"enable cdrom", []resource.TestStep{
|
{"enable cdrom", []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: te.RenderConfig(`
|
Config: te.RenderConfig(`
|
||||||
|
@ -263,14 +263,12 @@ func SCSIHardwareValidator() schema.SchemaValidateDiagFunc {
|
|||||||
}, false))
|
}, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDEInterfaceValidator is a schema validation function for IDE interfaces.
|
// CDROMInterfaceValidator is a schema validation function for IDE interfaces.
|
||||||
func IDEInterfaceValidator() schema.SchemaValidateDiagFunc {
|
func CDROMInterfaceValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
return validation.ToDiagFunc(validation.StringMatch(
|
||||||
"ide0",
|
regexp.MustCompile(`^(ide[0-3]|sata[0-5]|scsi([0-9]|1[0-3]))$`),
|
||||||
"ide1",
|
"must be one of `ide[0-3]`, `sata[0-5]`, `scsi[0-13]`",
|
||||||
"ide2",
|
))
|
||||||
"ide3",
|
|
||||||
}, false))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// VirtiofsCacheValidator is a schema validation function for virtiofs cache configs.
|
// VirtiofsCacheValidator is a schema validation function for virtiofs cache configs.
|
||||||
|
@ -531,7 +531,7 @@ func VM() *schema.Resource {
|
|||||||
Description: "The CDROM interface",
|
Description: "The CDROM interface",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: dvCDROMInterface,
|
Default: dvCDROMInterface,
|
||||||
ValidateDiagFunc: IDEInterfaceValidator(),
|
ValidateDiagFunc: CDROMInterfaceValidator(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -6003,6 +6003,9 @@ func vmDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
|||||||
timeout = shutdownTimeout
|
timeout = shutdownTimeout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset the default timeout for the delete operation
|
||||||
|
ctx = context.WithoutCancel(ctx)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(ctx, time.Duration(timeout)*time.Second)
|
ctx, cancel := context.WithTimeout(ctx, time.Duration(timeout)*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user