summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2012-08-03 16:28:00 -0400
committerRussell Bryant <rbryant@redhat.com>2012-08-06 15:09:33 -0400
commit0cee422e2e452d31a6aad1644cf38c2a669e99cb (patch)
tree6debc0013c261e3afd41ee879b140ee0fdc4676f
parentce2da5e52b743a15d87bab8b7546449ceb4e6871 (diff)
downloadnova-0cee422e2e452d31a6aad1644cf38c2a669e99cb.tar.gz
nova-0cee422e2e452d31a6aad1644cf38c2a669e99cb.tar.xz
nova-0cee422e2e452d31a6aad1644cf38c2a669e99cb.zip
Use explicit arguments in compute manager run_instance.
Use explicit arguments in functions in the run_instance code path of the compute manager. I think methods of the rpc API are better this way as we have to be careful when changing these functions so we handle versioning and backwards compatibility properly. Spelling out all of the arguments like this makes it easier to catch when things change and to make sure they are changed properly. This is in preparation of changing the instance_uuid to an instance dict, instead. Part of blueprint no-db-messaging. Change-Id: I1e141b471040b0fd4833d4e08d44166a9d12bcad
-rw-r--r--nova/compute/manager.py34
-rw-r--r--nova/tests/compute/test_compute.py8
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)