mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 02:31:10 +00:00
initial schema
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
40373922fc
commit
2f766c1e8a
@ -30,11 +30,12 @@ The attributes are also marked as optional to allow the practitioner to set (or
|
|||||||
|
|
||||||
### Optional
|
### Optional
|
||||||
|
|
||||||
- `cdrom` (Attributes Map) The CD-ROM configuration. The key is the interface of the CD-ROM, could be one of `ideN`, `sataN`, `scsiN`, where N is the index of the interface. Note that `q35` machine type only supports `ide0` and `ide2` of IDE interfaces. (see [below for nested schema](#nestedatt--cdrom))
|
- `cdrom` (Attributes Map) The CD-ROM configuration. The key is the interface of the CD-ROM, must be one of `ideN`, `sataN`, `scsiN`, where N is the index of the interface. Note that `q35` machine type only supports `ide0` and `ide2` of IDE interfaces. (see [below for nested schema](#nestedatt--cdrom))
|
||||||
- `clone` (Attributes) The cloning configuration. (see [below for nested schema](#nestedatt--clone))
|
- `clone` (Attributes) The cloning configuration. (see [below for nested schema](#nestedatt--clone))
|
||||||
- `cpu` (Attributes) The CPU configuration. (see [below for nested schema](#nestedatt--cpu))
|
- `cpu` (Attributes) The CPU configuration. (see [below for nested schema](#nestedatt--cpu))
|
||||||
- `description` (String) The description of the VM.
|
- `description` (String) The description of the VM.
|
||||||
- `id` (Number) The unique identifier of the VM in the Proxmox cluster.
|
- `id` (Number) The unique identifier of the VM in the Proxmox cluster.
|
||||||
|
- `initialization` (Attributes) The cloud-init configuration. (see [below for nested schema](#nestedatt--initialization))
|
||||||
- `name` (String) The name of the VM. Doesn't have to be unique.
|
- `name` (String) The name of the VM. Doesn't have to be unique.
|
||||||
- `stop_on_destroy` (Boolean) Set to true to stop (rather than shutdown) the VM on destroy (defaults to `false`).
|
- `stop_on_destroy` (Boolean) Set to true to stop (rather than shutdown) the VM on destroy (defaults to `false`).
|
||||||
- `tags` (Set of String) The tags assigned to the VM.
|
- `tags` (Set of String) The tags assigned to the VM.
|
||||||
@ -79,6 +80,25 @@ Optional:
|
|||||||
- `units` (Number) CPU weight for a VM. Argument is used in the kernel fair scheduler. The larger the number is, the more CPU time this VM gets. Number is relative to weights of all the other running VMs.
|
- `units` (Number) CPU weight for a VM. Argument is used in the kernel fair scheduler. The larger the number is, the more CPU time this VM gets. Number is relative to weights of all the other running VMs.
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--initialization"></a>
|
||||||
|
### Nested Schema for `initialization`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `datastore_id` (String) The identifier for the datastore to create the cloud-init disk in (defaults to `local-lvm`)
|
||||||
|
- `dns` (Attributes) The DNS configuration. (see [below for nested schema](#nestedatt--initialization--dns))
|
||||||
|
- `interface` (String) The hardware interface to connect the cloud-init image to. Must be one of `ideN`, `sataN`, `scsiN`, where N is the index of the interface. Will be detected if the setting is missing but a cloud-init image is present, otherwise defaults to `ide2`. Note that `q35` machine type only supports `ide0` and `ide2` of IDE interfaces.
|
||||||
|
|
||||||
|
<a id="nestedatt--initialization--dns"></a>
|
||||||
|
### Nested Schema for `initialization.dns`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `domain` (String) The domain name to use for the VM.
|
||||||
|
- `servers` (List of String) The list of DNS servers to use.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a id="nestedatt--timeouts"></a>
|
<a id="nestedatt--timeouts"></a>
|
||||||
### Nested Schema for `timeouts`
|
### Nested Schema for `timeouts`
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ func ResourceSchema() schema.Attribute {
|
|||||||
return schema.MapNestedAttribute{
|
return schema.MapNestedAttribute{
|
||||||
Description: "The CD-ROM configuration",
|
Description: "The CD-ROM configuration",
|
||||||
MarkdownDescription: "The CD-ROM configuration. The key is the interface of the CD-ROM, " +
|
MarkdownDescription: "The CD-ROM configuration. The key is the interface of the CD-ROM, " +
|
||||||
"could be one of `ideN`, `sataN`, `scsiN`, where N is the index of the interface. " +
|
"must be one of `ideN`, `sataN`, `scsiN`, where N is the index of the interface. " +
|
||||||
"Note that `q35` machine type only supports `ide0` and `ide2` of IDE interfaces.",
|
"Note that `q35` machine type only supports `ide0` and `ide2` of IDE interfaces.",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
72
fwprovider/vm/cloudinit/resource_schema.go
Normal file
72
fwprovider/vm/cloudinit/resource_schema.go
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cloudinit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
|
||||||
|
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
|
||||||
|
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
|
||||||
|
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
||||||
|
|
||||||
|
customtypes "github.com/bpg/terraform-provider-proxmox/fwprovider/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ResourceSchema defines the schema for the CPU resource.
|
||||||
|
func ResourceSchema() schema.Attribute {
|
||||||
|
return schema.SingleNestedAttribute{
|
||||||
|
Description: "The cloud-init configuration.",
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Attributes: map[string]schema.Attribute{
|
||||||
|
"datastore_id": schema.StringAttribute{
|
||||||
|
Description: "The identifier for the datastore to create the cloud-init disk in (defaults to `local-lvm`)",
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Default: stringdefault.StaticString("local-lvm"),
|
||||||
|
Validators: []validator.String{
|
||||||
|
stringvalidator.LengthAtLeast(1),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"interface": schema.StringAttribute{
|
||||||
|
Description: "The hardware interface to connect the cloud-init image to.",
|
||||||
|
MarkdownDescription: "The hardware interface to connect the cloud-init image to. " +
|
||||||
|
"Must be one of `ideN`, `sataN`, `scsiN`, where N is the index of the interface. " +
|
||||||
|
"Will be detected if the setting is missing but a cloud-init image is present, " +
|
||||||
|
"otherwise defaults to `ide2`. Note that `q35` machine type only supports " +
|
||||||
|
"`ide0` and `ide2` of IDE interfaces.",
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Validators: []validator.String{
|
||||||
|
stringvalidator.RegexMatches(
|
||||||
|
regexp.MustCompile(`^(ide[0-3]|sata[0-5]|scsi([0-9]|1[0-3]))$`),
|
||||||
|
"one of `ide[0-3]`, `sata[0-5]`, `scsi[0-13]`",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"dns": schema.SingleNestedAttribute{
|
||||||
|
Description: "The DNS configuration.",
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Attributes: map[string]schema.Attribute{
|
||||||
|
"domain": schema.StringAttribute{
|
||||||
|
Description: "The domain name to use for the VM.",
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"servers": schema.ListAttribute{
|
||||||
|
Description: "The list of DNS servers to use.",
|
||||||
|
ElementType: customtypes.IPAddrType{},
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,7 @@ import (
|
|||||||
|
|
||||||
"github.com/bpg/terraform-provider-proxmox/fwprovider/types/stringset"
|
"github.com/bpg/terraform-provider-proxmox/fwprovider/types/stringset"
|
||||||
"github.com/bpg/terraform-provider-proxmox/fwprovider/vm/cdrom"
|
"github.com/bpg/terraform-provider-proxmox/fwprovider/vm/cdrom"
|
||||||
|
"github.com/bpg/terraform-provider-proxmox/fwprovider/vm/cloudinit"
|
||||||
"github.com/bpg/terraform-provider-proxmox/fwprovider/vm/cpu"
|
"github.com/bpg/terraform-provider-proxmox/fwprovider/vm/cpu"
|
||||||
"github.com/bpg/terraform-provider-proxmox/fwprovider/vm/vga"
|
"github.com/bpg/terraform-provider-proxmox/fwprovider/vm/vga"
|
||||||
)
|
)
|
||||||
@ -74,6 +75,7 @@ func (r *Resource) Schema(
|
|||||||
},
|
},
|
||||||
Description: "The unique identifier of the VM in the Proxmox cluster.",
|
Description: "The unique identifier of the VM in the Proxmox cluster.",
|
||||||
},
|
},
|
||||||
|
"initialization": cloudinit.ResourceSchema(),
|
||||||
"name": schema.StringAttribute{
|
"name": schema.StringAttribute{
|
||||||
Description: "The name of the VM.",
|
Description: "The name of the VM.",
|
||||||
MarkdownDescription: "The name of the VM. Doesn't have to be unique.",
|
MarkdownDescription: "The name of the VM. Doesn't have to be unique.",
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
package vga
|
package vga
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -7,15 +13,11 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
|
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
|
||||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
|
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
|
||||||
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
||||||
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ResourceSchema defines the schema for the CPU resource.
|
// ResourceSchema defines the schema for the CPU resource.
|
||||||
func ResourceSchema() schema.Attribute {
|
func ResourceSchema() schema.Attribute {
|
||||||
return schema.SingleNestedAttribute{
|
return schema.SingleNestedAttribute{
|
||||||
CustomType: basetypes.ObjectType{
|
|
||||||
AttrTypes: attributeTypes(),
|
|
||||||
},
|
|
||||||
Description: "The VGA configuration.",
|
Description: "The VGA configuration.",
|
||||||
MarkdownDescription: "Configure the VGA Hardware. If you want to use high resolution modes (>= 1280x1024x16) " +
|
MarkdownDescription: "Configure the VGA Hardware. If you want to use high resolution modes (>= 1280x1024x16) " +
|
||||||
"you may need to increase the vga memory option. Since QEMU 2.9 the default VGA display type is `std` " +
|
"you may need to increase the vga memory option. Since QEMU 2.9 the default VGA display type is `std` " +
|
||||||
|
Loading…
Reference in New Issue
Block a user