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'] restart: ['service', 'tgt', 'restart']
status: ['service', 'tgt', 'status'] 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: components:
db: db:

View File

@ -438,6 +438,8 @@ class NovaRuntime(comp.PythonRuntime):
comp.PythonRuntime.pre_start(self) comp.PythonRuntime.pre_start(self)
virt_driver = _canon_virt_driver(self.cfg.get('nova', 'virt_driver')) virt_driver = _canon_virt_driver(self.cfg.get('nova', 'virt_driver'))
if virt_driver == 'libvirt': 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')) 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)) 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): if not virsh.virt_ok(virt_type, self.distro):

View File

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