start adding libvirt instructions to yaml file, ubuntu only for now

This commit is contained in:
Doug Hellmann 2012-03-15 20:01:55 -04:00
parent f1d89301bb
commit 4a535c555e
3 changed files with 34 additions and 21 deletions

View File

@ -38,6 +38,17 @@ commands:
restart: ['service', 'tgt', 'restart']
status: ['service', 'tgt', 'status']
tgt:
restart:
- cmd: ['stop', 'tgt']
run_as_root: true
- cmd: ['start', 'tgt']
run_as_root: true
libvirt:
restart: ['service', 'libvirt-bin', 'restart']
status: ['service', 'libvirt-bin', 'status']
components:
db:

View File

@ -438,6 +438,8 @@ class NovaRuntime(comp.PythonRuntime):
comp.PythonRuntime.pre_start(self)
virt_driver = _canon_virt_driver(self.cfg.get('nova', 'virt_driver'))
if virt_driver == 'libvirt':
# FIXME: The configuration for the virtualization-type
# should come from the persona.
virt_type = _canon_libvirt_type(self.cfg.get('nova', 'libvirt_type'))
LOG.info("Checking that your selected libvirt virtualization type [%s] is working and running." % (virt_type))
if not virsh.virt_ok(virt_type, self.distro):

View File

@ -32,11 +32,18 @@ LIBVIRT_PROTOCOL_MAP = {
}
VIRT_LIB = 'libvirt'
# How libvirt is restarted
LIBVIRT_RESTART_CMD = ['service', '%SERVICE%', 'restart']
# #distros name the libvirt service differently :-(
# SV_NAME_MAP = {
# settings.RHEL6: 'libvirtd',
# settings.FEDORA16: 'libvirtd',
# settings.UBUNTU11: 'libvirt-bin',
# }
# How we check its status
LIBVIRT_STATUS_CMD = ['service', '%SERVICE%', 'status']
# #how libvirt is restarted
# LIBVIRT_RESTART_CMD = ['service', '%SERVICE%', 'restart']
# #how we check its status
# LIBVIRT_STATUS_CMD = ['service', '%SERVICE%', 'status']
# This is just used to check that libvirt will work with
# a given protocol, may not be ideal but does seem to crap
@ -58,16 +65,12 @@ def _get_virt_lib():
def _status(distro):
cmds = list()
cmds.append({
'cmd': LIBVIRT_STATUS_CMD,
'run_as_root': True,
})
mp = dict()
mp['SERVICE'] = distro.get_command('libvirt-daemon')
cmds = [{'cmd': distro.get_command('libvirt', 'status'),
'run_as_root': True,
}]
result = utils.execute_template(*cmds,
check_exit_code=False,
params=mp)
check_exit_code=False,
params={})
if not result or not result[0]:
return _DEAD
(sysout, stderr) = result[0]
@ -91,14 +94,11 @@ def _destroy_domain(libvirt, conn, dom_name):
def restart(distro):
if _status(distro) != _ALIVE:
cmds = list()
cmds.append({
'cmd': LIBVIRT_RESTART_CMD,
'run_as_root': True,
})
mp = dict()
mp['SERVICE'] = distro.get_command('libvirt-daemon')
utils.execute_template(*cmds, params=mp)
cmds = [{
'cmd': distro.get_command('libvirt', 'restart'),
'run_as_root': True,
}]
utils.execute_template(*cmds, params={})
LOG.info("Restarting the libvirt service, please wait %s seconds until its started." % (WAIT_ALIVE_TIME))
sh.sleep(WAIT_ALIVE_TIME)