Merge pull request #104 from dreamhost/remove-db-and-libvirt-component-platform-knowledge-956265

Remove db and libvirt component platform knowledge 956265
This commit is contained in:
Joshua Harlow 2012-03-16 12:32:22 -07:00
commit 6892ed1c05
9 changed files with 60 additions and 38 deletions

1
.gitignore vendored

@ -14,3 +14,4 @@ pidfile
.DS_Store
TAGS
*.rc
*_flymake.*

@ -34,6 +34,10 @@ commands:
components:
db:
install: devstack.distros.rhel6:DBInstaller
uninstall: devstack.components.db:DBUninstaller
start: devstack.components.db:DBRuntime
stop: devstack.components.db:DBRuntime
packages:
- name: mysql
removable: True

@ -38,10 +38,21 @@ 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:
install: devstack.distros.oneiric:OneiricDBInstaller
install: devstack.distros.oneiric:DBInstaller
uninstall: devstack.components.db:DBUninstaller
start: devstack.components.db:DBRuntime
stop: devstack.components.db:DBRuntime

@ -23,6 +23,7 @@ COLOR_MAP = {
logging.WARNING: 'yellow',
logging.ERROR: 'red',
logging.CRITICAL: 'red',
logging.AUDIT: 'green',
}
COLOR_ATTRS = {

@ -21,6 +21,8 @@ from devstack import settings
from devstack import shell as sh
from devstack import utils
import abc
LOG = logging.getLogger("devstack.components.db")
# How long we wait before using the database after a restart
@ -78,6 +80,8 @@ class DBUninstaller(comp.PkgUninstallComponent):
class DBInstaller(comp.PkgInstallComponent):
__meta__ = abc.ABCMeta
def __init__(self, *args, **kargs):
comp.PkgInstallComponent.__init__(self, *args, **kargs)
self.runtime = DBRuntime(*args, **kargs)
@ -99,6 +103,7 @@ class DBInstaller(comp.PkgInstallComponent):
for key, prompt in WARMUP_PWS:
self.pw_gen.get_password(key, prompt)
@abc.abstractmethod
def _configure_db_confs(self):
pass

@ -439,6 +439,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):

@ -30,7 +30,7 @@ from devstack.packaging import apt
LOG = logging.getLogger(__name__)
class OneiricDBInstaller(db.DBInstaller):
class DBInstaller(db.DBInstaller):
def _configure_db_confs(self):
LOG.info("Fixing up %s mysql configs.", self.distro.name)

@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
"""Platform-specific logic for RHEL6 components.
"""Platform-specific logic for RedHat Enterprise Linux v6 components.
"""
from devstack import log as logging
@ -31,22 +31,20 @@ SOCKET_CONF = "/etc/httpd/conf.d/wsgi-socket-prefix.conf"
HTTPD_CONF = '/etc/httpd/conf/httpd.conf'
class Rhel6DBInstaller(db.DBInstaller):
class DBInstaller(db.DBInstaller):
def _configure_db_confs(self):
dbtype = self.cfg.get("db", "type")
if dbtype == 'mysql':
LOG.info("Fixing up mysql configs.")
fc = sh.load_file('/etc/my.cnf')
lines = fc.splitlines()
new_lines = list()
for line in lines:
if line.startswith('skip-grant-tables'):
line = '#' + line
new_lines.append(line)
fc = utils.joinlinesep(*new_lines)
with sh.Rooted(True):
sh.write_file('/etc/my.cnf', fc)
LOG.info("Fixing up %s mysql configs.", self.distro.name)
fc = sh.load_file('/etc/my.cnf')
lines = fc.splitlines()
new_lines = list()
for line in lines:
if line.startswith('skip-grant-tables'):
line = '#' + line
new_lines.append(line)
fc = utils.joinlinesep(*new_lines)
with sh.Rooted(True):
sh.write_file('/etc/my.cnf', fc)
class Rhel6HorizonInstaller(horizon.HorizonInstaller):

@ -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)