From 4a535c555e71c7178bd686c9b15163a40441a4e1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 15 Mar 2012 20:01:55 -0400 Subject: [PATCH] start adding libvirt instructions to yaml file, ubuntu only for now --- conf/distros/ubuntu-oneiric.yaml | 11 +++++++++ devstack/components/nova.py | 2 ++ devstack/libvirt.py | 42 ++++++++++++++++---------------- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/conf/distros/ubuntu-oneiric.yaml b/conf/distros/ubuntu-oneiric.yaml index e7d7928d..ed6455f6 100644 --- a/conf/distros/ubuntu-oneiric.yaml +++ b/conf/distros/ubuntu-oneiric.yaml @@ -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: diff --git a/devstack/components/nova.py b/devstack/components/nova.py index b5061007..7bc27987 100644 --- a/devstack/components/nova.py +++ b/devstack/components/nova.py @@ -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): diff --git a/devstack/libvirt.py b/devstack/libvirt.py index 2d62ec6f..c2b3cfb5 100644 --- a/devstack/libvirt.py +++ b/devstack/libvirt.py @@ -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)