summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorEd Leafe <ed@leafe.com>2011-01-07 10:23:48 -0600
committerEd Leafe <ed@leafe.com>2011-01-07 10:23:48 -0600
commiteaa5b5994891eee0280b750dff221a4b54932eb9 (patch)
tree806a0911d288421933003ca22c8ee81ee9a38662 /nova/virt
parentb024dcf6f0c1e5a2735e84d21d6edef5ff38d1cf (diff)
getting ready to push for merge prop
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/xenapi/vmops.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 5f1654a49..3df561e7c 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -137,13 +137,17 @@ class VMOps(object):
return instance_or_vm
else:
# Must be the instance name
- instance_name = instance_or_vm
- except AttributeError:
- # Not a string; must be a vm instance
- instance_name = instance_or_vm.name
- vm = VMHelper.lookup(self._session, instance_name)
+ instance = instance_or_vm
+ except (AttributeError, KeyError):
+ # Note the the KeyError will only happen with fakes.py
+ # Not a string; must be an ID or a vm instance
+ if isinstance(instance_or_vm, (int, long)):
+ instance = instance_or_vm
+ else:
+ instance = instance_or_vm.name
+ vm = VMHelper.lookup(self._session, instance)
if vm is None:
- raise Exception(_('Instance not present %s') % instance_name)
+ raise Exception(_('Instance not present %s') % instance)
return vm
def snapshot(self, instance, name):