Merge lp:~ed-leafe/nova/lp785843 into lp:~hudson-openstack/nova/trunk

Proposed by Ed Leafe
Status: Merged
Approved by: Josh Kearney
Approved revision: 1109
Merged at revision: 1109
Proposed branch: lp:~ed-leafe/nova/lp785843
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 13 lines (+2/-1)
1 file modified
nova/virt/xenapi/vmops.py (+2/-1)
To merge this branch: bzr merge lp:~ed-leafe/nova/lp785843
Reviewer Review Type Date Requested Status
Mark Washenberger (community) Approve
Josh Kearney (community) Approve
Rick Harris (community) Approve
Review via email: mp+62321@code.launchpad.net

Description of the change

The code for getting an opaque reference to an instance assumed that there was a reference to an instance obj available when raising an exception. I changed this from raising an InstanceNotFound exception to a NotFound, as this is more appropriate for the failure, and doesn't require an instance ID.

To post a comment you must log in.
Revision history for this message
Rick Harris (rconradharris) wrote :

lgtm. Thanks Ed.

review: Approve
Revision history for this message
Josh Kearney (jk0) wrote :

LGTM.

review: Approve
Revision history for this message
Mark Washenberger (markwash) wrote :

Looks like a good fix--and I can't find anywhere above this code that would appear to require specifically an InstanceNotFound exception.

Sure wish we could add unit tests for this stuff ;-)

review: Approve
Revision history for this message
Vish Ishaya (vishvananda) wrote :

It seems like the standard practice in the rest of the code base is to define a new type of NotFound exception for this and put the error message there. Not sure why that method wasn't used here...

On May 25, 2011, at 8:07 AM, Ed Leafe wrote:

> Ed Leafe has proposed merging lp:~ed-leafe/nova/lp785843 into lp:nova.
>
> Requested reviews:
> Nova Core (nova-core)
> Related bugs:
> Bug #785843 in OpenStack Compute (nova): "Traceback in xenapi/vmops.py masks real exception"
> https://bugs.launchpad.net/nova/+bug/785843
>
> For more details, see:
> https://code.launchpad.net/~ed-leafe/nova/lp785843/+merge/62321
>
> The code for getting an opaque reference to an instance assumed that there was a reference to an instance obj available when raising an exception. I changed this from raising an InstanceNotFound exception to a NotFound, as this is more appropriate for the failure, and doesn't require an instance ID.
> --
> https://code.launchpad.net/~ed-leafe/nova/lp785843/+merge/62321
> You are subscribed to branch lp:nova.
> === modified file 'nova/virt/xenapi/vmops.py'
> --- nova/virt/xenapi/vmops.py 2011-05-24 22:13:59 +0000
> +++ nova/virt/xenapi/vmops.py 2011-05-25 15:06:14 +0000
> @@ -253,7 +253,8 @@
> instance_name = instance_or_vm.name
> vm_ref = VMHelper.lookup(self._session, instance_name)
> if vm_ref is None:
> - raise exception.InstanceNotFound(instance_id=instance_obj.id)
> + raise exception.NotFound(_("No opaque_ref could be determined "
> + "for '%s'.") % instance_or_vm)
> return vm_ref
>
> def _acquire_bootlock(self, vm):
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/virt/xenapi/vmops.py'
2--- nova/virt/xenapi/vmops.py 2011-05-24 22:13:59 +0000
3+++ nova/virt/xenapi/vmops.py 2011-05-25 15:06:14 +0000
4@@ -253,7 +253,8 @@
5 instance_name = instance_or_vm.name
6 vm_ref = VMHelper.lookup(self._session, instance_name)
7 if vm_ref is None:
8- raise exception.InstanceNotFound(instance_id=instance_obj.id)
9+ raise exception.NotFound(_("No opaque_ref could be determined "
10+ "for '%s'.") % instance_or_vm)
11 return vm_ref
12
13 def _acquire_bootlock(self, vm):