diff options
| author | Chris Behrens <cbehrens@codestud.com> | 2013-03-13 22:48:53 +0000 |
|---|---|---|
| committer | Chris Behrens <cbehrens@codestud.com> | 2013-03-13 22:53:49 +0000 |
| commit | 3bbcb2fc9cf9d474074ac02b1859b7d904dcc0a2 (patch) | |
| tree | e2371b262422b0f9ba213d14c3388ada9e1faa1a | |
| parent | dd6e5368f1a9512f807f5140f687804d6a96adf5 (diff) | |
| download | nova-3bbcb2fc9cf9d474074ac02b1859b7d904dcc0a2.tar.gz nova-3bbcb2fc9cf9d474074ac02b1859b7d904dcc0a2.tar.xz nova-3bbcb2fc9cf9d474074ac02b1859b7d904dcc0a2.zip | |
Fix issues with cells and resize
There are cases where compute API resizez() is called with 'flavor_id'
as a positional argument, so we need to fix up the cells_api version of
resize() to more closely match the super class.
Also: A recent change for storing instance_type info in system_metadata
happened to make an incorrect change, assuming cells_api was for child
cells.. which it's for the API cell. It needs to pull the instance type
from the DB just like the super class does.
Fixes bug 1154843
Change-Id: Ifdf2a68c3bff6d27d5f192e2eb73f9b79804c2c7
| -rw-r--r-- | nova/compute/cells_api.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/nova/compute/cells_api.py b/nova/compute/cells_api.py index d5a07490b..46a04ab38 100644 --- a/nova/compute/cells_api.py +++ b/nova/compute/cells_api.py @@ -326,14 +326,16 @@ class ComputeCellsAPI(compute_api.API): @check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.STOPPED], task_state=[None]) @validate_cell - def resize(self, context, instance, *args, **kwargs): + def resize(self, context, instance, flavor_id=None, *args, **kwargs): """Resize (ie, migrate) a running instance. If flavor_id is None, the process is considered a migration, keeping the original flavor_id. If flavor_id is not None, the instance should be migrated to a new host and resized to the new flavor_id. """ - super(ComputeCellsAPI, self).resize(context, instance, *args, **kwargs) + super(ComputeCellsAPI, self).resize(context, instance, + flavor_id=flavor_id, *args, + **kwargs) # NOTE(johannes): If we get to this point, then we know the # specified flavor_id is valid and exists. We'll need to load @@ -341,13 +343,11 @@ class ComputeCellsAPI(compute_api.API): old_instance_type = instance_types.extract_instance_type(instance) - flavor_id = kwargs.get('flavor_id') - if not flavor_id: new_instance_type = old_instance_type else: - new_instance_type = instance_types.extract_instance_type(instance, - 'new_') + new_instance_type = instance_types.get_instance_type_by_flavor_id( + flavor_id, read_deleted="no") # NOTE(johannes): Later, when the resize is confirmed or reverted, # the superclass implementations of those methods will need access @@ -363,7 +363,8 @@ class ComputeCellsAPI(compute_api.API): # FIXME(comstud): pass new instance_type object down to a method # that'll unfold it - self._cast_to_cells(context, instance, 'resize', *args, **kwargs) + self._cast_to_cells(context, instance, 'resize', flavor_id=flavor_id, + *args, **kwargs) @validate_cell def add_fixed_ip(self, context, instance, *args, **kwargs): |
