Modify list_nodes method in the libvirt driver to it returns all nodes (including stopped ones).
Also modify other methods to use domain uuid instead of domain id so those methods also work on stopped nodes which don't have an id assigned. Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/4aeb37c1 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/4aeb37c1 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/4aeb37c1 Branch: refs/heads/trunk Commit: 4aeb37c123515f38a06e93d4e5c2398bc6eda7b0 Parents: 37b8c8b Author: Tomaz Muraus <[email protected]> Authored: Sun Jan 12 22:01:32 2014 +0100 Committer: Tomaz Muraus <[email protected]> Committed: Sun Jan 12 22:01:32 2014 +0100 ---------------------------------------------------------------------- libcloud/compute/drivers/libvirt_driver.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/4aeb37c1/libcloud/compute/drivers/libvirt_driver.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/libvirt_driver.py b/libcloud/compute/drivers/libvirt_driver.py index ac1ec24..644902f 100644 --- a/libcloud/compute/drivers/libvirt_driver.py +++ b/libcloud/compute/drivers/libvirt_driver.py @@ -61,8 +61,7 @@ class LibvirtNodeDriver(NodeDriver): self.connection = libvirt.open(uri) def list_nodes(self): - domain_ids = self.connection.listDomainsID() - domains = [self.connection.lookupByID(id) for id in domain_ids] + domains = self.connection.listAllDomains() nodes = [] for domain in domains: @@ -78,9 +77,11 @@ class LibvirtNodeDriver(NodeDriver): 'types': self.connection.getType(), 'used_memory': memory / 1024, 'vcpu_count': vcpu_count, 'used_cpu_time': used_cpu_time} + node = Node(id=domain.ID(), name=domain.name(), state=state, public_ips=[], private_ips=[], driver=self, extra=extra) + node._uuid = domain.UUIDString() # we want to use a custom UUID nodes.append(node) return nodes @@ -142,5 +143,8 @@ class LibvirtNodeDriver(NodeDriver): return domain.resume() == 0 def _get_domain_for_node(self, node): - domain = self.connection.lookupByID(int(node.id)) + """ + Return libvirt domain object for the provided node. + """ + domain = self.connection.lookupByUUIDString(node.uuid) return domain
