summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordagnello <davide_agnello@hotmail.com>2015-03-15 14:05:42 -0700
committerdagnello <davide_agnello@hotmail.com>2015-03-25 17:38:45 -0700
commit5d5cc38467d0caa0366fb5a05b8f82343586a476 (patch)
treeebc6bfd258f78e476ac08066f2b129fb64ba5ed6
parent3565bd3fc620ca68689f4de33068d13b69b7ac4a (diff)
downloadtrove-5d5cc38467d0caa0366fb5a05b8f82343586a476.tar.gz
Updating Flavor Resize Restrictions
Updating instance flavor resize restriction logic to: Resize the instance if current flavor id and new flavor id are different. Except when: * current flavor allows for volume support and new flavor does not * current flavor has ephemeral support enabled and new flavor does not Change-Id: If708f795858489114cfa09901591d95b1bcb530b closing-bug: 1382931
-rw-r--r--trove/instance/models.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/trove/instance/models.py b/trove/instance/models.py
index 5fcbe5d9..36ee49c1 100644
--- a/trove/instance/models.py
+++ b/trove/instance/models.py
@@ -847,31 +847,28 @@ class Instance(BuiltInstance):
{'instance_id': self.id, 'flavor_id': new_flavor_id})
if self.db_info.cluster_id is not None:
raise exception.ClusterInstanceOperationNotSupported()
- # Validate that the flavor can be found and that it isn't the same size
- # as the current one.
+
+ # Validate that the old and new flavor IDs are not the same, new flavor
+ # can be found and has ephemeral/volume support if required by the
+ # current flavor.
+ if self.flavor_id == new_flavor_id:
+ raise exception.BadRequest(_("The new flavor id must be different "
+ "than the current flavor id of '%s'.")
+ % self.flavor_id)
client = create_nova_client(self.context)
try:
new_flavor = client.flavors.get(new_flavor_id)
except nova_exceptions.NotFound:
raise exception.FlavorNotFound(uuid=new_flavor_id)
+
old_flavor = client.flavors.get(self.flavor_id)
- new_flavor_size = new_flavor.ram
- old_flavor_size = old_flavor.ram
if self.volume_support:
if new_flavor.ephemeral != 0:
raise exception.LocalStorageNotSupported()
- if new_flavor_size == old_flavor_size:
- raise exception.CannotResizeToSameSize()
elif self.device_path is not None:
# ephemeral support enabled
if new_flavor.ephemeral == 0:
raise exception.LocalStorageNotSpecified(flavor=new_flavor_id)
- if (new_flavor_size == old_flavor_size and
- new_flavor.ephemeral == new_flavor.ephemeral):
- raise exception.CannotResizeToSameSize()
- elif new_flavor_size == old_flavor_size:
- # uses local storage
- raise exception.CannotResizeToSameSize()
# Set the task to RESIZING and begin the async call before returning.
self.update_db(task_status=InstanceTasks.RESIZING)