Use constant for global resources

This commit is contained in:
Hany Fahim 2015-09-24 16:16:12 -04:00
parent 03d7c1fa7d
commit aa950be63b
2 changed files with 6 additions and 4 deletions

View File

@ -219,8 +219,8 @@ 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")
if t.Zoneid == IS_GLOBAL_RESOURCE {
setValueOrUUID(d, "zone", t.Zonename, IS_GLOBAL_RESOURCE)
} else {
setValueOrUUID(d, "zone", t.Zonename, t.Zoneid)
}

View File

@ -10,6 +10,8 @@ import (
"github.com/xanzy/go-cloudstack/cloudstack"
)
const IS_GLOBAL_RESOURCE = "-1"
type retrieveError struct {
name string
value string
@ -53,7 +55,7 @@ func retrieveUUID(cs *cloudstack.CloudStackClient, name, value string) (uuid str
case "network":
uuid, err = cs.Network.GetNetworkID(value)
case "zone":
if value == "-1" {
if value == IS_GLOBAL_RESOURCE {
return value, nil
}
uuid, err = cs.Zone.GetZoneID(value)