Skip to content

Commit

Permalink
Allow Domain class to be specified by Connection class
Browse files Browse the repository at this point in the history
This allows subclasses of Connection to use a subclass of Domain
without any fuss.
  • Loading branch information
Jc2k authored and John Carr committed Apr 29, 2012
1 parent b0d9882 commit 2049177
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions master/buildbot/libvirtbuildslave.py
Expand Up @@ -109,6 +109,8 @@ class Connection(object):
I am a wrapper around a libvirt Connection object.
"""

DomainClass = Domain

def __init__(self, uri):
self.uri = uri
self.connection = libvirt.open(uri)
Expand All @@ -117,15 +119,15 @@ def lookupByName(self, name):
""" I lookup an existing prefined domain """
d = queue.executeInThread(self.connection.lookupByName, name)
def _(res):
return Domain(self, res)
return self.DomainClass(self, res)
d.addCallback(_)
return d

def create(self, xml):
""" I take libvirt XML and start a new VM """
d = queue.executeInThread(self.connection.createXML, xml, 0)
def _(res):
return Domain(self, res)
return self.DomainClass(self, res)
d.addCallback(_)
return d

Expand Down

0 comments on commit 2049177

Please sign in to comment.