From 30f0dd8f32d7d63618fa2212928525d05194a194 Mon Sep 17 00:00:00 2001 From: Ken Schmidt Date: Wed, 20 Dec 2017 15:51:12 -0800 Subject: [PATCH] doing cluster and template lookup in the vm read --- ovirt/vm.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ovirt/vm.go b/ovirt/vm.go index ab55adaf..3501e1d7 100644 --- a/ovirt/vm.go +++ b/ovirt/vm.go @@ -157,8 +157,20 @@ func resourceVMRead(d *schema.ResourceData, meta interface{}) error { return nil } d.Set("name", vm.Name) - d.Set("cluster", vm.Cluster.Name) - d.Set("template", vm.Template.Name) + + cluster, err := con.GetCluster(vm.Cluster.ID) + if err != nil { + d.SetId("") + return nil + } + d.Set("cluster", cluster.Name) + + template, err := con.GetTemplate(vm.Template.ID) + if err != nil { + d.SetId("") + return nil + } + d.Set("template", template.Name) return nil }