resize server on flavor_id or flavor_name change

This commit is contained in:
Jon Perritt 2015-02-11 22:05:38 -07:00
parent 49b01a4f0a
commit bb6969a4c5
1 changed files with 8 additions and 4 deletions

View File

@ -550,11 +550,15 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e
d.SetPartial("volume")
}
if d.HasChange("flavor_ref") {
resizeOpts := &servers.ResizeOpts{
FlavorRef: d.Get("flavor_ref").(string),
if d.HasChange("flavor_id") || d.HasChange("flavor_name") {
flavorId, err := getFlavorID(computeClient, d)
if err != nil {
return err
}
err := servers.Resize(computeClient, d.Id(), resizeOpts).ExtractErr()
resizeOpts := &servers.ResizeOpts{
FlavorRef: flavorId,
}
err = servers.Resize(computeClient, d.Id(), resizeOpts).ExtractErr()
if err != nil {
return fmt.Errorf("Error resizing OpenStack server: %s", err)
}