[Buildbot-devel] LibVirtSlave master snippets?
Frank Marien
frank at apsu.be
Sat Feb 26 15:42:23 UTC 2011
Dear all,
Thanks John & Neal,
By putting the master on the VM host, and stealing snippets from
shenzou, I'm almost there.
---cut here---
from buildbot.libvirtbuildslave import LibVirtSlave
from buildbot.libvirtbuildslave import Connection
connection = Connection("qemu:///system")
c['slaves'] = []
[...]
slave = LibVirtSlave("arch32", "<password>", connection,
"/data/vms/snapshots/arch32.tmp", base_image="/data/vms/arch32.img",
max_builds=1, missing_timeout=30, build_wait_timeout=30)
c['slaves'].append(slave)
---cut here---
The master now starts the (cloned) VM, which starts the slave, which
builds the code.. Yeah!
My only remaining issue is that the master can't seem to *stop* the
slave again: "domain" is not an object at that point in the runtime:
------------------
2011-02-26 16:33:56+0100 [-] setting expectations for next time
2011-02-26 16:33:56+0100 [-] new expectations: 367.477597952 seconds
2011-02-26 16:33:56+0100 [-] Got buildFinished notification - attempting
to insubstantiate
2011-02-26 16:33:56+0100 [-] Attempting to stop 'arch32'
2011-02-26 16:33:56+0100 [-] Unhandled Error
Traceback (most recent call last):
File
"/usr/lib/python2.7/site-packages/buildbot/process/base.py", line 478,
in allStepsDone
return self.buildFinished(text, self.result)
File
"/usr/lib/python2.7/site-packages/buildbot/process/base.py", line 511,
in buildFinished
self.deferred.callback(self)
File
"/usr/lib/python2.7/site-packages/twisted/internet/defer.py", line 361,
in callback
self._startRunCallbacks(result)
File
"/usr/lib/python2.7/site-packages/twisted/internet/defer.py", line 455,
in _startRunCallbacks
self._runCallbacks()
--- <exception caught here> ---
File
"/usr/lib/python2.7/site-packages/twisted/internet/defer.py", line 542,
in _runCallbacks
current.result = callback(current.result, *args, **kw)
File
"/usr/lib/python2.7/site-packages/buildbot/process/base.py", line 225,
in _release_slave
self.slavebuilder.buildFinished()
File
"/usr/lib/python2.7/site-packages/buildbot/process/builder.py", line
317, in buildFinished
self.slave.buildFinished(self)
File
"/usr/lib/python2.7/site-packages/buildbot/libvirtbuildslave.py", line
264, in buildFinished
self.insubstantiate()
File
"/usr/lib/python2.7/site-packages/buildbot/buildslave.py", line 715, in
insubstantiate
d = self.stop_instance(fast)
File
"/usr/lib/python2.7/site-packages/buildbot/libvirtbuildslave.py", line
239, in stop_instance
d = domain.destroy()
exceptions.AttributeError: 'int' object has no attribute 'destroy'
-------------------
WKR
Frank.
On 02/23/2011 07:29 PM, Neal Chant wrote:
> On Tue, 2011-02-22 at 22:51 +0100, Frank Marien wrote:
>
>> Trying to use a libvirt buildslave..
>> Not getting anywhere with the 2-line example in the docs..
>>
>> I can instantiate a Connection object with the parameters found in the
>> class docs, using the URL I used in virt-manager,
>> that will make an ssh connection, just fine.
>>
>> But filling it out as a parameter to the LibVirtSlave constructor
>> (_init_) yields an assert.. as well as not using it at all.
>> (I can't access the box from here.. no details until thursday)
>>
>> My question: does anyone have a snippet of master config where you use
>> LibVirtSlave. That would really help me..
>
> Hi,
>
> The below worked in 7.i_forget.
>
> note, if you require instant off there is a timeout setting to change in
> buildslave.py. build_wait_timeout
>
> HTH
> Neal
>
> ============================================================
> from twisted.internet import defer, threads
> from buildbot.buildslave import AbstractLatentBuildSlave
> import libvirt
>
> class VirshBuildSlave(AbstractLatentBuildSlave):
> #def __init__(self, name, password):
> # self.virsh_name = name
> # self.host_passwd = password
>
> #To use, subclass and implement start_instance and stop_instance.
> def start_instance(self):
> return threads.deferToThread(self._start_instance)
>
> def _start_instance(self):
> # responsible for starting instance that will try to connect
> with this
> # master. Should return deferred. Problems should use an
> errback. The
> # callback value can be None, or can be an iterable of short
> strings to
> # include in the "substantiate success" status message, such as
> # identifying the instance that started.
> conn = libvirt.open(None)
> if conn == None:
> raise NotImplementedError # Should really raise a better error
> try:
> host = conn.lookupByName(self.slavename)
> except:
> raise NotImplementedError # Should really raise a better error
>
> run_state = host.info()[0]
>
> # Start VM
> #if libvirt.VIR_DOMAIN_SHUTOFF == run_state:
> # print "In _start_instance()"
> # host.create() # create _is_ start
>
> # Resume VM
> if libvirt.VIR_DOMAIN_PAUSED == run_state:
> print "In _start_instance()"
> host.resume() # resume _is_ take from suspended state
>
> def stop_instance(self, fast=False):
> return threads.deferToThread(
> self._stop_instance, fast)
>
> def _stop_instance(self, fast=False):
> # responsible for shutting down instance. Return a deferred. If
> `fast`,
> # we're trying to shut the master down, so callback as soon as
> is safe.
> # Callback value is ignored.
> conn = libvirt.open(None)
> if conn == None:
> raise NotImplementedError # Should really raise a better error
> try:
> host = conn.lookupByName(self.slavename)
> except:
> raise NotImplementedError # Should really raise a better error
>
> # Stop VM
> #run_state = host.info()[0]
> #if libvirt.VIR_DOMAIN_RUNNING == run_state:
> # print "In _stop_instance()"
> # host.destroy() # destroy _is_ halt
>
> # Pause VM
> run_state = host.info()[0]
> if libvirt.VIR_DOMAIN_RUNNING == run_state:
> print "In _stop_instance()"
> host.suspend() # suspend
>
> # This is the dictionary that the buildmaster pays attention to. We also
> use
> # a shorter alias to save typing.
> c = BuildmasterConfig = {}
>
> ####### BUILDSLAVES
>
> c['slaves'] = [VirshBuildSlave("win7-x64", "APASSWORD")]
> ============================================================
>
>
--
--
"Agile & Free"
N Frank Marien
C APSU EBVBA
T +32 2 66 999 35
F +32 2 791 57 05
E frank at apsu.be
I #apsu(freenode)
U http://apsu.be/
More information about the devel
mailing list