diff options
author | Sam Batschelet <samb@endpoint.com> | 2017-09-01 16:12:06 -0400 |
---|---|---|
committer | Flavio Castelli <flavio@castelli.me> | 2017-09-06 14:32:33 +0200 |
commit | 8460d878ef9a36864caa7be7bc0ae5a719d3eb90 (patch) | |
tree | a6c26db150077b6ab714a8d7f1f58c5ce5544220 | |
parent | 8d2b4a3f51b20837238386785431eff3129bd716 (diff) | |
download | terraform-provider-libvirt-8460d878ef9a36864caa7be7bc0ae5a719d3eb90.tar terraform-provider-libvirt-8460d878ef9a36864caa7be7bc0ae5a719d3eb90.tar.gz |
domain: Add support for BootDevice.
-rw-r--r-- | libvirt/resource_libvirt_domain.go | 34 | ||||
-rw-r--r-- | website/docs/r/domain.html.markdown | 1 |
2 files changed, 35 insertions, 0 deletions
diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go index 561cb712..571b7359 100644 --- a/libvirt/resource_libvirt_domain.go +++ b/libvirt/resource_libvirt_domain.go @@ -155,6 +155,27 @@ func resourceLibvirtDomain() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "boot_device": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Required: false, + Elem: &schema.Resource{ + Schema: bootDeviceSchema(), + }, + }, + }, + } +} + +func bootDeviceSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "dev": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Required: false, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, } } @@ -283,6 +304,19 @@ func resourceLibvirtDomainCreate(d *schema.ResourceData, meta interface{}) error } } + var bootDevices []libvirtxml.DomainBootDevice + bootDevice := libvirtxml.DomainBootDevice{} + bootDeviceCount := d.Get("boot_device.#").(int) + for i := 0; i < bootDeviceCount; i++ { + prefix := fmt.Sprintf("boot_device.%d", i) + if boot_map, ok := d.GetOk(prefix + ".dev"); ok { + for _, dev := range boot_map.([]interface{}) { + bootDevice.Dev = dev.(string) + bootDevices = append(bootDevices, bootDevice) + } + } + } + domainDef.OS.BootDevices = bootDevices domainDef.Memory = &libvirtxml.DomainMemory{ Value: uint(d.Get("memory").(int)), Unit: "MiB", diff --git a/website/docs/r/domain.html.markdown b/website/docs/r/domain.html.markdown index 5fae0006..994e5bfe 100644 --- a/website/docs/r/domain.html.markdown +++ b/website/docs/r/domain.html.markdown @@ -55,6 +55,7 @@ The following arguments are supported: * `machine` - (Optional) The machine type, you normally won't need to set this unless you are running on a platform that defaults to the wrong machine type for your template +* `boot_device` - (Optional) A list of devices (dev) which sets boot order ### UEFI images |