diff options
author | Thomas Hipp <thipp@suse.de> | 2017-07-07 17:40:35 +0200 |
---|---|---|
committer | Flavio Castelli <flavio@castelli.me> | 2017-07-27 14:59:30 +0200 |
commit | ccf4dff4f872291b5cf131cbdfb3d3c5b2f0dd47 (patch) | |
tree | dfd1952f157bf6f369c561379ed90ba500fd0853 /libvirt/disk_def.go | |
parent | ed3000f4d3b2ee5eeab855f32e9fde80193944df (diff) | |
download | terraform-provider-libvirt-ccf4dff4f872291b5cf131cbdfb3d3c5b2f0dd47.tar terraform-provider-libvirt-ccf4dff4f872291b5cf131cbdfb3d3c5b2f0dd47.tar.gz |
use github.com/libvirt-go-xml
Replace the custom XML structs with libvirt's offcial ones.
This resolves #143.
Signed-off-by: Thomas Hipp <thipp@suse.de>
Diffstat (limited to 'libvirt/disk_def.go')
-rw-r--r-- | libvirt/disk_def.go | 74 |
1 files changed, 27 insertions, 47 deletions
diff --git a/libvirt/disk_def.go b/libvirt/disk_def.go index 26cf513e..ed65c290 100644 --- a/libvirt/disk_def.go +++ b/libvirt/disk_def.go @@ -1,60 +1,40 @@ package libvirt import ( - "encoding/xml" "math/rand" + + "github.com/libvirt/libvirt-go-xml" ) const OUI = "05abcd" -type defDisk struct { - XMLName xml.Name `xml:"disk"` - Type string `xml:"type,attr"` - Device string `xml:"device,attr"` - Wwn string `xml:"wwn,omitempty"` - Format struct { - Type string `xml:"type,attr"` - } `xml:"format"` - Source struct { - File string `xml:"file,attr,omitempty"` - // retain Pool/Volume for compatibility with existing tfstate - Pool string `xml:"pool,attr,omitempty"` - Volume string `xml:"volume,attr,omitempty"` - } `xml:"source"` - Target struct { - Dev string `xml:"dev,attr"` - Bus string `xml:"bus,attr"` - } `xml:"target"` - Driver struct { - Name string `xml:"name,attr"` - Type string `xml:"type,attr"` - } `xml:"driver"` -} - -func newDefDisk() defDisk { - disk := defDisk{} - disk.Type = "file" - disk.Device = "disk" - disk.Format.Type = "qcow2" - disk.Target.Bus = "virtio" - - disk.Driver.Name = "qemu" - disk.Driver.Type = "qcow2" - - return disk +func newDefDisk() libvirtxml.DomainDisk { + return libvirtxml.DomainDisk{ + Type: "file", + Device: "disk", + Target: &libvirtxml.DomainDiskTarget{ + Bus: "virtio", + }, + Driver: &libvirtxml.DomainDiskDriver{ + Name: "qemu", + Type: "qcow2", + }, + } } -func newCDROM() defDisk { - disk := defDisk{} - disk.Type = "file" - disk.Device = "cdrom" - disk.Target.Dev = "hda" - disk.Target.Bus = "ide" - - disk.Driver.Name = "qemu" - disk.Driver.Type = "raw" - - return disk +func newCDROM() libvirtxml.DomainDisk { + return libvirtxml.DomainDisk{ + Type: "file", + Device: "cdrom", + Target: &libvirtxml.DomainDiskTarget{ + Dev: "hda", + Bus: "ide", + }, + Driver: &libvirtxml.DomainDiskDriver{ + Name: "qemu", + Type: "raw", + }, + } } func randomWWN(strlen int) string { |