aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libvirt/resource_libvirt_volume.go32
1 files changed, 27 insertions, 5 deletions
diff --git a/libvirt/resource_libvirt_volume.go b/libvirt/resource_libvirt_volume.go
index fb2e57b4..1bc43b19 100644
--- a/libvirt/resource_libvirt_volume.go
+++ b/libvirt/resource_libvirt_volume.go
@@ -184,16 +184,38 @@ func resourceLibvirtVolumeRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("The libvirt connection was nil.")
}
- _, err := virConn.LookupStorageVolByKey(d.Id())
+ volume, err := virConn.LookupStorageVolByKey(d.Id())
if err != nil {
return fmt.Errorf("Can't retrieve volume %s", d.Id())
}
+ defer volume.Free()
- return nil
-}
+ volName, err := volume.GetName()
+ if err != nil {
+ return fmt.Errorf("Error retrieving volume name: %s", err)
+ }
+
+ volPool, err := volume.LookupPoolByVolume()
+ if err != nil {
+ return fmt.Errorf("Error retrieving pool for volume: %s", err)
+ }
+ defer volPool.Free()
+
+ volPoolName, err := volPool.GetName()
+ if err != nil {
+ return fmt.Errorf("Error retrieving pool name: %s", err)
+ }
-func resourceLibvirtVolumeUpdate(d *schema.ResourceData, meta interface{}) error {
- return fmt.Errorf("Couldn't update libvirt domain")
+ d.Set("pool", volPoolName)
+ d.Set("name", volName)
+
+ info, err := volume.GetInfo()
+ if err != nil {
+ return fmt.Errorf("Error retrieving volume name: %s", err)
+ }
+ d.Set("size", info.GetCapacityInBytes())
+
+ return nil
}
func resourceLibvirtVolumeDelete(d *schema.ResourceData, meta interface{}) error {