Use constant for global resources
This commit is contained in:
parent
03d7c1fa7d
commit
aa950be63b
|
@ -219,8 +219,8 @@ func resourceCloudStackTemplateRead(d *schema.ResourceData, meta interface{}) er
|
||||||
d.Set("password_enabled", t.Passwordenabled)
|
d.Set("password_enabled", t.Passwordenabled)
|
||||||
d.Set("is_ready", t.Isready)
|
d.Set("is_ready", t.Isready)
|
||||||
|
|
||||||
if t.Zoneid == "" {
|
if t.Zoneid == IS_GLOBAL_RESOURCE {
|
||||||
d.Set("zone", "-1")
|
setValueOrUUID(d, "zone", t.Zonename, IS_GLOBAL_RESOURCE)
|
||||||
} else {
|
} else {
|
||||||
setValueOrUUID(d, "zone", t.Zonename, t.Zoneid)
|
setValueOrUUID(d, "zone", t.Zonename, t.Zoneid)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ import (
|
||||||
"github.com/xanzy/go-cloudstack/cloudstack"
|
"github.com/xanzy/go-cloudstack/cloudstack"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const IS_GLOBAL_RESOURCE = "-1"
|
||||||
|
|
||||||
type retrieveError struct {
|
type retrieveError struct {
|
||||||
name string
|
name string
|
||||||
value string
|
value string
|
||||||
|
@ -53,7 +55,7 @@ func retrieveUUID(cs *cloudstack.CloudStackClient, name, value string) (uuid str
|
||||||
case "network":
|
case "network":
|
||||||
uuid, err = cs.Network.GetNetworkID(value)
|
uuid, err = cs.Network.GetNetworkID(value)
|
||||||
case "zone":
|
case "zone":
|
||||||
if value == "-1" {
|
if value == IS_GLOBAL_RESOURCE {
|
||||||
return value, nil
|
return value, nil
|
||||||
}
|
}
|
||||||
uuid, err = cs.Zone.GetZoneID(value)
|
uuid, err = cs.Zone.GetZoneID(value)
|
||||||
|
|
Loading…
Reference in New Issue