Ticket #791 (closed enhancement: invalid)

Opened 3 years ago

Last modified 3 years ago

Add support for libvirt-based latent slaves

Reported by: dustin Owned by:
Priority: major Milestone: 0.8.+
Version: 0.8.0 Keywords: virtualization
Cc:

Description

Here's a paste from nelly on IRC:

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]
		if libvirt.VIR_DOMAIN_PAUSED == run_state:
			host.resume()
     
	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.
        	raise NotImplementedError

It doesn't stop instances, and seems to only pause/unpause (not startup/shutdown), but it's a start!

Change History

comment:1 Changed 3 years ago by dustin

  • Keywords latent added

comment:2 Changed 3 years ago by dustin

  • Keywords virtualization added; latent removed
  • Status changed from new to closed
  • Resolution set to invalid

The libvirt patch that John Carr just landed supersedes this, I think.

Note: See TracTickets for help on using tickets.