aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Mac-Vicar P <dmacvicar@suse.de>2017-11-16 13:45:56 +0100
committerDuncan Mac-Vicar P <dmacvicar@suse.de>2017-11-19 16:51:37 +0100
commitbb8be0df22f5635a6d2efc70d4372d2321dfc0f2 (patch)
tree20147ba7189847190aba30b45e4912fd80b18ed8
parent58bfa4b78a143699dff9962b1781a66b202e718e (diff)
downloadterraform-provider-libvirt-bb8be0df22f5635a6d2efc70d4372d2321dfc0f2.tar
terraform-provider-libvirt-bb8be0df22f5635a6d2efc70d4372d2321dfc0f2.tar.gz
Reuse newDefDisk()
-rw-r--r--libvirt/disk_def.go2
-rw-r--r--libvirt/resource_libvirt_domain.go13
2 files changed, 3 insertions, 12 deletions
diff --git a/libvirt/disk_def.go b/libvirt/disk_def.go
index 3283f03b..785542b6 100644
--- a/libvirt/disk_def.go
+++ b/libvirt/disk_def.go
@@ -1,6 +1,7 @@
package libvirt
import (
+ "fmt"
"math/rand"
"github.com/libvirt/libvirt-go-xml"
@@ -14,6 +15,7 @@ func newDefDisk() libvirtxml.DomainDisk {
Device: "disk",
Target: &libvirtxml.DomainDiskTarget{
Bus: "virtio",
+ Dev: fmt.Sprintf("vd%s", DiskLetterForIndex(i)),
},
Driver: &libvirtxml.DomainDiskDriver{
Name: "qemu",
diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go
index 90a0896d..dfb9d2f9 100644
--- a/libvirt/resource_libvirt_domain.go
+++ b/libvirt/resource_libvirt_domain.go
@@ -368,18 +368,7 @@ func resourceLibvirtDomainCreate(d *schema.ResourceData, meta interface{}) error
var disks []libvirtxml.DomainDisk
var scsiDisk = false
for i := 0; i < disksCount; i++ {
- disk := libvirtxml.DomainDisk{
- Type: "file",
- Device: "disk",
- Target: &libvirtxml.DomainDiskTarget{
- Bus: "virtio",
- Dev: fmt.Sprintf("vd%s", DiskLetterForIndex(i)),
- },
- Driver: &libvirtxml.DomainDiskDriver{
- Name: "qemu",
- Type: "qcow2",
- },
- }
+ disk := newDefDisk()
diskKey := fmt.Sprintf("disk.%d", i)
diskMap := d.Get(diskKey).(map[string]interface{})