diff options
author | Duncan Mac-Vicar P <dmacvicar@suse.de> | 2016-03-07 17:02:20 +0100 |
---|---|---|
committer | Duncan Mac-Vicar P <dmacvicar@suse.de> | 2016-03-07 17:02:20 +0100 |
commit | 653b575affed28a293680a9b860c82d98664bb8e (patch) | |
tree | 73dbad04a12a9229bfb0f029fa2a244d76acf8f4 /libvirt/resource_libvirt_volume.go | |
parent | 64a3442db51a0700390147bdc940f17be607877b (diff) | |
download | terraform-provider-libvirt-653b575affed28a293680a9b860c82d98664bb8e.tar terraform-provider-libvirt-653b575affed28a293680a9b860c82d98664bb8e.tar.gz |
add backing store for volumes
Diffstat (limited to 'libvirt/resource_libvirt_volume.go')
-rw-r--r-- | libvirt/resource_libvirt_volume.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libvirt/resource_libvirt_volume.go b/libvirt/resource_libvirt_volume.go index 7e7173ed..b37a2867 100644 --- a/libvirt/resource_libvirt_volume.go +++ b/libvirt/resource_libvirt_volume.go @@ -101,6 +101,20 @@ func resourceLibvirtVolumeCreate(d *schema.ResourceData, meta interface{}) error volumeDef.Capacity.Amount = d.Get("size").(int) } + if baseVolumeId, ok := d.GetOk("base_volume"); ok { + volumeDef.BackingStore = new(defBackingStore) + volumeDef.BackingStore.Format.Type = "qcow2" + baseVolume, err := virConn.LookupStorageVolByKey(baseVolumeId.(string)) + if err != nil { + return fmt.Errorf("Can't retrieve volume %s", baseVolumeId.(string)) + } + baseVolPath, err := baseVolume.GetPath() + if err != nil { + return fmt.Errorf("can't get name for base image '%s'", baseVolumeId) + } + volumeDef.BackingStore.Path = baseVolPath + } + volumeDefXml, err := xml.Marshal(volumeDef) if err != nil { return fmt.Errorf("Error serializing libvirt volume: %s", err) |