diff options
| author | Phong Ly <phongdly@us.ibm.com> | 2013-04-26 17:50:11 +0000 |
|---|---|---|
| committer | Phong Ly <phongdly@us.ibm.com> | 2013-05-01 18:40:26 +0000 |
| commit | cccca7a4531cdad88655c27533f63c590a5ddfa1 (patch) | |
| tree | 596a7579651e7c12af2a4d7d24a2209213821e30 | |
| parent | 423289d50d92cf4b780a11c2c3da4e1dbbd865f2 (diff) | |
Fix key error when create lpar instance failed
With existing code, when create lpar instance
failed, it throws a key error because the parameter
is not being passed to PowerVMLPARCreationFailed
function in exception module.
The fix for this is that in module operator, passing
the 'instance_name' to the called function in exception
module.
Fixes bug 1173303
Change-Id: I688eecf7b649b67ca62f72d6d33fd7cd774047c3
| -rw-r--r-- | nova/tests/test_powervm.py | 22 | ||||
| -rw-r--r-- | nova/virt/powervm/operator.py | 3 |
2 files changed, 24 insertions, 1 deletions
diff --git a/nova/tests/test_powervm.py b/nova/tests/test_powervm.py index 9440a13b4..96954269e 100644 --- a/nova/tests/test_powervm.py +++ b/nova/tests/test_powervm.py @@ -22,6 +22,7 @@ import contextlib from nova import context from nova import db +from nova import exception as nova_exception from nova import test from nova.compute import instance_types @@ -214,6 +215,27 @@ class PowerVMDriverTestCase(test.TestCase): state = self.powervm_connection.get_info(self.instance)['state'] self.assertEqual(state, power_state.RUNNING) + def test_spawn_create_lpar_fail(self): + # Verify on a failed spawn, we get the original exception raised. + # helper function + def raise_(ex): + raise ex + + self.flags(powervm_img_local_path='/images/') + self.stubs.Set(images, 'fetch', lambda *x, **y: None) + self.stubs.Set( + self.powervm_connection._powervm, + 'get_host_stats', + lambda *x, **y: raise_( + (nova_exception.ProcessExecutionError('instance_name')))) + fake_net_info = network_model.NetworkInfo([ + fake_network_cache_model.new_vif()]) + self.assertRaises(exception.PowerVMLPARCreationFailed, + self.powervm_connection.spawn, + context.get_admin_context(), + self.instance, + {'id': 'ANY_ID'}, [], 's3cr3t', fake_net_info) + def test_spawn_cleanup_on_fail(self): # Verify on a failed spawn, we get the original exception raised. # helper function diff --git a/nova/virt/powervm/operator.py b/nova/virt/powervm/operator.py index 905d018de..946835224 100644 --- a/nova/virt/powervm/operator.py +++ b/nova/virt/powervm/operator.py @@ -202,7 +202,8 @@ class PowerVMOperator(object): except nova_exception.ProcessExecutionError: LOG.exception(_("LPAR instance '%s' creation failed") % instance['name']) - raise exception.PowerVMLPARCreationFailed() + raise exception.PowerVMLPARCreationFailed( + instance_name=instance['name']) _create_image(context, instance, image_id) LOG.debug(_("Activating the LPAR instance '%s'") |
