diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-08-06 23:44:52 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-08-06 23:44:52 +0000 |
| commit | 91f2ee518ad8e7241dd7eca183ce2107729a01dc (patch) | |
| tree | 86ad868699ee14b2625b854791f7519944ef2d99 | |
| parent | f7fbc678ab00ad598e62905621595eaacbc91c81 (diff) | |
| parent | 0cee422e2e452d31a6aad1644cf38c2a669e99cb (diff) | |
| download | nova-91f2ee518ad8e7241dd7eca183ce2107729a01dc.tar.gz nova-91f2ee518ad8e7241dd7eca183ce2107729a01dc.tar.xz nova-91f2ee518ad8e7241dd7eca183ce2107729a01dc.zip | |
Merge "Use explicit arguments in compute manager run_instance."
| -rw-r--r-- | nova/compute/manager.py | 34 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 8 |
2 files changed, 24 insertions, 18 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 0f24a2546..f6e3ff9cf 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -496,12 +496,9 @@ class ComputeManager(manager.SchedulerDependentManager): 'block_device_mapping': block_device_mapping } - def _run_instance(self, context, instance_uuid, - requested_networks=None, - injected_files=[], - admin_password=None, - is_first_time=False, - **kwargs): + def _run_instance(self, context, instance_uuid, request_spec, + filter_properties, requested_networks, injected_files, + admin_password, is_first_time): """Launch a new instance with specified options.""" context = context.elevated() try: @@ -526,7 +523,7 @@ class ComputeManager(manager.SchedulerDependentManager): # try to re-schedule instance: self._reschedule_or_reraise(context, instance, requested_networks, admin_password, injected_files, - is_first_time, **kwargs) + is_first_time, request_spec, filter_properties) else: # Spawn success: if (is_first_time and not instance['access_ip_v4'] @@ -542,7 +539,9 @@ class ComputeManager(manager.SchedulerDependentManager): with excutils.save_and_reraise_exception(): self._set_instance_error_state(context, instance_uuid) - def _reschedule_or_reraise(self, context, instance, *args, **kwargs): + def _reschedule_or_reraise(self, context, instance, requested_networks, + admin_password, injected_files, is_first_time, + request_spec, filter_properties): """Try to re-schedule the build or re-raise the original build error to error out the instance. """ @@ -563,8 +562,9 @@ class ComputeManager(manager.SchedulerDependentManager): raise try: - rescheduled = self._reschedule(context, instance_uuid, *args, - **kwargs) + rescheduled = self._reschedule(context, instance_uuid, + requested_networks, admin_password, injected_files, + is_first_time, request_spec, filter_properties) except Exception: rescheduled = False LOG.exception(_("Error trying to reschedule"), @@ -578,9 +578,9 @@ class ComputeManager(manager.SchedulerDependentManager): raise type_, value, tb def _reschedule(self, context, instance_uuid, requested_networks, - admin_password, injected_files, is_first_time, **kwargs): + admin_password, injected_files, is_first_time, request_spec, + filter_properties): - filter_properties = kwargs.get('filter_properties', {}) retry = filter_properties.get('retry', None) if not retry: # no retry information, do not reschedule. @@ -588,7 +588,6 @@ class ComputeManager(manager.SchedulerDependentManager): instance_uuid=instance_uuid) return - request_spec = kwargs.get('request_spec', None) if not request_spec: LOG.debug(_("No request spec, will not reschedule"), instance_uuid=instance_uuid) @@ -825,10 +824,15 @@ class ComputeManager(manager.SchedulerDependentManager): @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) @wrap_instance_fault - def run_instance(self, context, instance_uuid, **kwargs): + def run_instance(self, context, instance_uuid, request_spec=None, + filter_properties={}, requested_networks=None, + injected_files=[], admin_password=None, + is_first_time=False): @utils.synchronized(instance_uuid) def do_run_instance(): - self._run_instance(context, instance_uuid, **kwargs) + self._run_instance(context, instance_uuid, request_spec, + filter_properties, requested_networks, injected_files, + admin_password, is_first_time) do_run_instance() def _shutdown_instance(self, context, instance): diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 5d41cd7c6..443a25e6c 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -4459,7 +4459,7 @@ class ComputeReschedulingTestCase(BaseTestCase): return functools.partial(self.compute._reschedule, self.context, uuid, requested_networks, admin_password, injected_files, - is_first_time) + is_first_time, request_spec=None, filter_properties={}) def test_reschedule_no_filter_properties(self): """no filter_properties will disable re-scheduling""" @@ -4507,7 +4507,8 @@ class ComputeReschedulingExceptionTestCase(BaseTestCase): """Spawn fails and re-scheduling is disabled.""" # this won't be re-scheduled: self.assertRaises(ThatsNoOrdinaryRabbitException, - self.compute._run_instance, self.context, self.instance_uuid) + self.compute._run_instance, self.context, self.instance_uuid, + None, {}, None, None, None, None) def test_exception_with_rescheduling_enabled(self): """Spawn fails and re-scheduling is enabled. Original exception @@ -4535,4 +4536,5 @@ class ComputeReschedulingExceptionTestCase(BaseTestCase): # the original exception should now be raised: self.assertRaises(ThatsNoOrdinaryRabbitException, - self.compute._run_instance, self.context, self.instance_uuid) + self.compute._run_instance, self.context, self.instance_uuid, + None, {}, None, None, None, None) |
