in cloudstack/resource_cloudstack_autoscale_vm_profile.go [132:189]
func resourceCloudStackAutoScaleVMProfileRead(d *schema.ResourceData, meta interface{}) error {
cs := meta.(*cloudstack.CloudStackClient)
p, count, err := cs.AutoScale.GetAutoScaleVmProfileByID(d.Id())
if err != nil {
if count == 0 {
log.Printf(
"[DEBUG] AutoScaleVmProfile %s no longer exists", d.Id())
d.SetId("")
return nil
}
return err
}
zone, _, err := cs.Zone.GetZoneByID(p.Zoneid)
if err != nil {
return err
}
offering, _, err := cs.ServiceOffering.GetServiceOfferingByID(p.Serviceofferingid)
if err != nil {
return err
}
template, _, err := cs.Template.GetTemplateByID(p.Templateid, "executable", cloudstack.WithZone(p.Zoneid))
if err != nil {
return err
}
setValueOrID(d, "service_offering", offering.Name, p.Serviceofferingid)
setValueOrID(d, "template", template.Name, p.Templateid)
setValueOrID(d, "zone", zone.Name, p.Zoneid)
d.Set("destroy_vm_grace_period", (time.Duration(p.Destroyvmgraceperiod) * time.Second).String())
if p.Otherdeployparams != "" {
var values url.Values
values, err = url.ParseQuery(p.Otherdeployparams)
if err != nil {
return err
}
otherParams := make(map[string]interface{}, len(values))
for key := range values {
otherParams[key] = values.Get(key)
}
d.Set("other_deploy_params", otherParams)
}
metadata, err := getMetadata(cs, d, "AutoScaleVmProfile")
if err != nil {
return err
}
d.Set("metadata", metadata)
return nil
}