diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-02-17 04:10:17 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-02-17 04:10:17 +0000 |
| commit | ba930e035b65eaead5e7ea3525ea5afc5e6d41ad (patch) | |
| tree | 12b684c8c7c8485925f4d8c1e544840d3d8e43ff /nova/virt | |
| parent | 31d1a423761ac2d68d227559f4e3f424487333be (diff) | |
| parent | 1c8ad4553b4b8d404f941c5297e3f6e42c9f7e6a (diff) | |
Merge "Completes fix for LP #928910 - libvirt performance"
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/driver.py | 13 | ||||
| -rw-r--r-- | nova/virt/libvirt/connection.py | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/nova/virt/driver.py b/nova/virt/driver.py index 821455b45..20c41ca9f 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -122,6 +122,19 @@ class ComputeDriver(object): # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() + def get_num_instances(self): + """Return the total number of virtual machines. + + Return the number of virtual machines that the hypervisor knows + about. + + :note This implementation works for all drivers, but it is + not particularly efficient. Maintainers of the virt drivers are + encouraged to override this method with something more + efficient. + """ + return len(self.list_instances()) + def instance_exists(self, instance_id): """Checks existence of an instance on the host. diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index c3bfdedda..7043239cb 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -279,6 +279,10 @@ class LibvirtConnection(driver.ComputeDriver): else: return libvirt.openAuth(uri, auth, 0) + def get_num_instances(self): + """Efficient override of base instance_exists method.""" + return self._conn.numOfDomains() + def instance_exists(self, instance_id): """Efficient override of base instance_exists method.""" try: |
