From 27c11c4bb4e5c54282caf49cba666f45cfc590c2 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Wed, 8 Feb 2012 15:51:59 -0500 Subject: Remedies LP Bug #928910 - Use libvirt lookupByName() to check existence Make determining if an instance exists on a host more efficient by adding an instance_exists() method to the base virt driver that can be overridden by drivers that have a more efficient mechanism of looking up an instance by its ID / name. Modifies the _check_instance_already_created method of the compute manager to use this new instance_exists() method. Someone from Citrix should look into how to make the instance_exists() method in the Xen and VMWare virt drivers more efficient than the base "loop over all domains and see if the instance ID exists" method now in the base driver class. Change-Id: Ibf219788f9c104698057367da89300a060945778 --- nova/compute/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/compute') diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 90a6a84ec..078f53928 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -440,7 +440,7 @@ class ComputeManager(manager.SchedulerDependentManager): def _check_instance_not_already_created(self, context, instance): """Ensure an instance with the same name is not already present.""" - if instance['name'] in self.driver.list_instances(): + if self.driver.instance_exists(instance['name']): raise exception.Error(_("Instance has already been created")) def _check_image_size(self, context, instance): -- cgit