diff options
| author | Matt Dietz <matt.dietz@rackspace.com> | 2011-07-15 19:07:58 +0000 |
|---|---|---|
| committer | Matt Dietz <matt.dietz@rackspace.com> | 2011-07-15 19:07:58 +0000 |
| commit | c8a35349be912bb862789059abc95ccf9f7b8ef5 (patch) | |
| tree | 898a49ce35f3c1d9f802469780164a2e7bca9d90 | |
| parent | 4c779a87651a37f9acf05f1101859a1ce4c288c1 (diff) | |
| download | nova-c8a35349be912bb862789059abc95ccf9f7b8ef5.tar.gz nova-c8a35349be912bb862789059abc95ccf9f7b8ef5.tar.xz nova-c8a35349be912bb862789059abc95ccf9f7b8ef5.zip | |
Updated with some changes from manual testing
| -rw-r--r-- | nova/compute/api.py | 14 | ||||
| -rw-r--r-- | nova/compute/manager.py | 21 | ||||
| -rw-r--r-- | nova/exception.py | 2 |
3 files changed, 25 insertions, 12 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 7857f06a5..2233b9225 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -826,15 +826,16 @@ class API(base.Base): def revert_resize(self, context, instance_id): """Reverts a resize, deleting the 'new' instance in the process.""" context = context.elevated() + instance_ref = self._get_instance(context, instance_id, 'confirm_resize') migration_ref = self.db.migration_get_by_instance_and_status(context, - instance_id, 'finished') + instance_ref['uuid'], 'finished') if not migration_ref: raise exception.MigrationNotFoundByStatus(instance_id=instance_id, status='finished') params = {'migration_id': migration_ref['id']} self._cast_compute_message('revert_resize', context, - migration_ref['dest_compute'], params=params) + instance_ref['uuid'], params=params) self.db.migration_update(context, migration_ref['id'], {'status': 'reverted'}) @@ -842,14 +843,17 @@ class API(base.Base): def confirm_resize(self, context, instance_id): """Confirms a migration/resize and deletes the 'old' instance.""" context = context.elevated() + + instance_ref = self._get_instance(context, instance_id, 'confirm_resize') migration_ref = self.db.migration_get_by_instance_and_status(context, - instance_id, 'finished') + instance_ref['uuid'], 'finished') if not migration_ref: raise exception.MigrationNotFoundByStatus(instance_id=instance_id, status='finished') params = {'migration_id': migration_ref['id']} self._cast_compute_message('confirm_resize', context, - migration_ref['source_compute'], params=params) + instance_ref['uuid'], + params=params) self.db.migration_update(context, migration_ref['id'], {'status': 'confirmed'}) @@ -897,7 +901,7 @@ class API(base.Base): self._cast_scheduler_message(context, {"method": "prep_resize", "args": {"topic": FLAGS.compute_topic, - "instance_uuid": instance_ref['uuid'], + "instance_id": instance_ref['uuid'], "flavor_id": new_instance_type['id']}}) @scheduler_api.reroute_compute("add_fixed_ip") diff --git a/nova/compute/manager.py b/nova/compute/manager.py index e00e3d0ab..55bc1cdcd 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -89,6 +89,10 @@ def checks_instance_lock(function): """Decorator to prevent action against locked instances for non-admins.""" @functools.wraps(function) def decorated_function(self, context, instance_id, *args, **kwargs): + #TODO(anyone): this being called instance_id is forcing a slightly + # confusing convention of pushing instance_uuids + # through an "instance_id" key in the queue args dict when + # casting through the compute API LOG.info(_("check_instance_lock: decorating: |%s|"), function, context=context) LOG.info(_("check_instance_lock: arguments: |%(self)s| |%(context)s|" @@ -664,10 +668,10 @@ class ComputeManager(manager.SchedulerDependentManager): @exception.wrap_exception @checks_instance_lock - def confirm_resize(self, context, migration_id): + def confirm_resize(self, context, instance_id, migration_id): """Destroys the source instance.""" migration_ref = self.db.migration_get(context, migration_id) - instance_ref = self.db.instance_get(context, + instance_ref = self.db.instance_get_by_uuid(context, migration_ref.instance_uuid) self.driver.destroy(instance_ref) @@ -679,7 +683,7 @@ class ComputeManager(manager.SchedulerDependentManager): @exception.wrap_exception @checks_instance_lock - def revert_resize(self, context, migration_id): + def revert_resize(self, context, instance_id, migration_id): """Destroys the new instance on the destination machine. Reverts the model changes, and powers on the old instance on the @@ -687,7 +691,7 @@ class ComputeManager(manager.SchedulerDependentManager): """ migration_ref = self.db.migration_get(context, migration_id) - instance_ref = self.db.instance_get(context, + instance_ref = self.db.instance_get_by_uuid(context, migration_ref.instance_uuid) self.driver.destroy(instance_ref) @@ -732,14 +736,19 @@ class ComputeManager(manager.SchedulerDependentManager): @exception.wrap_exception @checks_instance_lock - def prep_resize(self, context, instance_uuid, flavor_id): + def prep_resize(self, context, instance_id, flavor_id): """Initiates the process of moving a running instance to another host. Possibly changes the RAM and disk size in the process. """ context = context.elevated() - instance_ref = self.db.instance_get_by_uuid(context, instance_uuid) + + # Because of checks_instance_lock, this must currently be called + # instance_id. However, the compute API is always passing the UUID + # of the instance down + instance_ref = self.db.instance_get_by_uuid(context, instance_id) + if instance_ref['host'] == FLAGS.host: raise exception.Error(_( 'Migration error: destination same as source!')) diff --git a/nova/exception.py b/nova/exception.py index 988940d6a..a98b0a36b 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -77,8 +77,8 @@ def wrap_db_error(f): except Exception, e: LOG.exception(_('DB exception wrapped.')) raise DBError(e) - return _wrap _wrap.func_name = f.func_name + return _wrap def wrap_exception(f): |
