Skip to content

Commit

Permalink
Allow compute manager prep_resize to accept kwargs
Browse files Browse the repository at this point in the history
Fixes issues when trying to resize instances. Fixes LP bug #919642.

Change-Id: I411d29404902c377088750e1ae4560b8a419d4f2
  • Loading branch information
Dan Prince committed Jan 21, 2012
1 parent ae13abc commit 255ce80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion nova/compute/manager.py
Expand Up @@ -1115,7 +1115,7 @@ def finish_revert_resize(self, context, instance_uuid, migration_id):
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
@checks_instance_lock
@wrap_instance_fault
def prep_resize(self, context, instance_uuid, instance_type_id):
def prep_resize(self, context, instance_uuid, instance_type_id, **kwargs):
"""Initiates the process of moving a running instance to another host.
Possibly changes the RAM and disk size in the process.
Expand Down
21 changes: 14 additions & 7 deletions nova/tests/test_compute.py
Expand Up @@ -949,7 +949,8 @@ def fake(*args, **kwargs):
self.stubs.Set(self.compute.network_api, 'get_instance_nw_info', fake)
context = self.context.elevated()
instance = self._create_fake_instance()
self.compute.prep_resize(context, instance['uuid'], 1)
self.compute.prep_resize(context, instance['uuid'], 1,
filter_properties={})
migration_ref = db.migration_get_by_instance_and_status(context,
instance['uuid'], 'pre-migrating')
try:
Expand All @@ -975,7 +976,8 @@ def fake(*args, **kwargs):
self.stubs.Set(self.compute.network_api, 'get_instance_nw_info', fake)
context = self.context.elevated()
instance = self._create_fake_instance()
self.compute.prep_resize(context, instance['uuid'], 1)
self.compute.prep_resize(context, instance['uuid'], 1,
filter_properties={})
migration_ref = db.migration_get_by_instance_and_status(context,
instance['uuid'], 'pre-migrating')

Expand All @@ -997,7 +999,8 @@ def test_resize_instance_notification(self):
test_notifier.NOTIFICATIONS = []

db.instance_update(self.context, instance_uuid, {'host': 'foo'})
self.compute.prep_resize(context, instance_uuid, 1)
self.compute.prep_resize(context, instance_uuid, 1,
filter_properties={})
db.migration_get_by_instance_and_status(context,
instance_uuid,
'pre-migrating')
Expand Down Expand Up @@ -1050,7 +1053,8 @@ def throw_up(*args, **kwargs):

self.compute.run_instance(self.context, instance_uuid)
db.instance_update(self.context, instance_uuid, {'host': 'foo'})
self.compute.prep_resize(context, instance_uuid, 1)
self.compute.prep_resize(context, instance_uuid, 1,
filter_properties={})
migration_ref = db.migration_get_by_instance_and_status(context,
instance_uuid, 'pre-migrating')

Expand All @@ -1071,7 +1075,8 @@ def test_resize_instance(self):
self.compute.run_instance(self.context, instance_uuid)
db.instance_update(self.context, instance_uuid,
{'host': 'foo'})
self.compute.prep_resize(context, instance_uuid, 1)
self.compute.prep_resize(context, instance_uuid, 1,
filter_properties={})
migration_ref = db.migration_get_by_instance_and_status(context,
instance_uuid, 'pre-migrating')
self.compute.resize_instance(context, instance_uuid,
Expand Down Expand Up @@ -1103,7 +1108,8 @@ def fake(*args, **kwargs):

new_instance_type_ref = db.instance_type_get_by_flavor_id(context, 3)
self.compute.prep_resize(context, inst_ref['uuid'],
new_instance_type_ref['id'])
new_instance_type_ref['id'],
filter_properties={})

migration_ref = db.migration_get_by_instance_and_status(context,
inst_ref['uuid'], 'pre-migrating')
Expand Down Expand Up @@ -1160,7 +1166,8 @@ def raise_migration_failure(*args):

self.compute.run_instance(self.context, inst_ref['uuid'])
db.instance_update(self.context, inst_ref['uuid'], {'host': 'foo'})
self.compute.prep_resize(context, inst_ref['uuid'], 1)
self.compute.prep_resize(context, inst_ref['uuid'], 1,
filter_properties={})
migration_ref = db.migration_get_by_instance_and_status(context,
inst_ref['uuid'], 'pre-migrating')
self.assertRaises(Exception, self.compute.resize_instance,
Expand Down

0 comments on commit 255ce80

Please sign in to comment.