diff --git a/builtin/providers/cloudstack/resource_cloudstack_template.go b/builtin/providers/cloudstack/resource_cloudstack_template.go index 15c6ebec4..139a1ef52 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_template.go +++ b/builtin/providers/cloudstack/resource_cloudstack_template.go @@ -219,9 +219,14 @@ func resourceCloudStackTemplateRead(d *schema.ResourceData, meta interface{}) er d.Set("password_enabled", t.Passwordenabled) d.Set("is_ready", t.Isready) + if t.Zoneid == "" { + d.Set("zone", "-1") + } else { + setValueOrUUID(d, "zone", t.Zonename, t.Zoneid) + } + setValueOrUUID(d, "os_type", t.Ostypename, t.Ostypeid) - setValueOrUUID(d, "zone", t.Zonename, t.Zoneid) - + return nil } diff --git a/builtin/providers/cloudstack/resources.go b/builtin/providers/cloudstack/resources.go index cc826492f..6e259ba5f 100644 --- a/builtin/providers/cloudstack/resources.go +++ b/builtin/providers/cloudstack/resources.go @@ -53,6 +53,9 @@ func retrieveUUID(cs *cloudstack.CloudStackClient, name, value string) (uuid str case "network": uuid, err = cs.Network.GetNetworkID(value) case "zone": + if value == "-1" { + return value, nil + } uuid, err = cs.Zone.GetZoneID(value) case "ipaddress": p := cs.Address.NewListPublicIpAddressesParams()