diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-03-25 14:17:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-03-25 14:17:11 +0000 |
| commit | 2d02ce3ba00c3e4300bb841483d00d18210f79ff (patch) | |
| tree | 8771971d0fe8dcf53ea10d5ee7ef6429d115d5a8 /nova/virt | |
| parent | 1a5ee2e695c652c93ef32771bb92e419d9715cc6 (diff) | |
| parent | e136de1aea8d1469465272942fa3d2769cbe3a80 (diff) | |
Merge "xenapi: fix console for rescued instance"
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 8728a46a4..ce3301fd9 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -33,6 +33,7 @@ from nova.compute import instance_types from nova.compute import power_state from nova.compute import task_states from nova.compute import vm_mode +from nova.compute import vm_states from nova import context as nova_context from nova import exception from nova.openstack.common import excutils @@ -1365,11 +1366,17 @@ class VMOps(object): def get_vnc_console(self, instance): """Return connection info for a vnc console.""" - try: - vm_ref = self._get_vm_opaque_ref(instance) - except exception.NotFound: - # The compute manager expects InstanceNotFound for this case. - raise exception.InstanceNotFound(instance_id=instance['uuid']) + if instance['vm_state'] == vm_states.RESCUED: + name = '%s-rescue' % instance['name'] + vm_ref = vm_utils.lookup(self._session, name) + if vm_ref is None: + # The rescue instance might not be ready at this point. + raise exception.InstanceNotReady(instance_id=instance['uuid']) + else: + vm_ref = vm_utils.lookup(self._session, instance['name']) + if vm_ref is None: + # The compute manager expects InstanceNotFound for this case. + raise exception.InstanceNotFound(instance_id=instance['uuid']) session_id = self._session.get_session_id() path = "/console?ref=%s&session_id=%s" % (str(vm_ref), session_id) |
