More dinky cleanups.

This commit is contained in:
Joshua Harlow
2012-02-06 23:08:53 -08:00
parent f3fa4a5370
commit 7af457ae77
5 changed files with 38 additions and 39 deletions

View File

@@ -147,7 +147,7 @@ class PkgInstallComponent(ComponentBase):
return utils.load_template(self.component_name, config_fn)
def _get_symlinks(self):
return {}
return dict()
def _configure_files(self):
configs = self._get_config_files()
@@ -162,7 +162,7 @@ class PkgInstallComponent(ComponentBase):
#now configure it
LOG.info("Configuring file %s" % (fn))
(sourcefn, contents) = self._get_source_config(fn)
LOG.info("Replacing parameters in file %s" % (sourcefn))
LOG.debug("Replacing parameters in file %s" % (sourcefn))
LOG.debug("Replacements = %s" % (parameters))
contents = utils.param_replace(contents, parameters)
LOG.debug("Applying side-effects of param replacement for template %s" % (sourcefn))
@@ -175,7 +175,10 @@ class PkgInstallComponent(ComponentBase):
def _configure_symlinks(self):
links = self._get_symlinks()
for (source, link) in links.items():
link_srcs = sorted(links.keys())
link_srcs.reverse()
for source in link_srcs:
link = links.get(source)
try:
self.tracewriter.symlink(source, link)
except OSError:
@@ -262,18 +265,16 @@ class PkgUninstallComponent(ComponentBase):
def _unconfigure_links(self):
symfiles = self.tracereader.symlinks_made()
if symfiles:
LOG.info("Removing %s symlinks files (%s)" % (len(symfiles), ", ".join(symfiles)))
LOG.info("Removing %s symlink files (%s)" % (len(symfiles), ", ".join(symfiles)))
for fn in symfiles:
if fn:
sh.unlink(fn)
sh.unlink(fn, run_as_root=True)
def _unconfigure_files(self):
cfgfiles = self.tracereader.files_configured()
if cfgfiles:
LOG.info("Removing %s configuration files (%s)" % (len(cfgfiles), ", ".join(cfgfiles)))
for fn in cfgfiles:
if fn:
sh.unlink(fn)
sh.unlink(fn, run_as_root=True)
def uninstall(self):
self._uninstall_pkgs()
@@ -396,7 +397,7 @@ class ProgramRuntime(ComponentBase):
if params and program_opts:
adjusted_opts = list()
for opt in program_opts:
adjusted_opts.append(utils.param_replace(opt, params))
adjusted_opts.append(utils.param_replace(str(opt), params))
program_opts = adjusted_opts
#start it with the given settings
LOG.info("Starting [%s] with options [%s]" % (app_name, ", ".join(program_opts)))

View File

@@ -31,6 +31,8 @@ LOG = logging.getLogger("devstack.components.db")
#used for special setups
MYSQL = 'mysql'
START_WAIT_TIME = 5
#TODO maybe we should handle this differently in the future, blah
DB_ACTIONS = {
MYSQL: {
# Of course these aren't distro independent...
@@ -77,9 +79,6 @@ SQL_RESET_PW_LINKS = ['https://help.ubuntu.com/community/MysqlPasswordReset',
#used as a generic error message
BASE_ERROR = 'Currently we do not know how to %s for database type [%s]'
#used to make params for booting when started (not always take advantage of...)
BOOLEAN_OUTPUT = {True: 'true', False: 'false'}
#the pkg json files db requires for installation
REQ_PKGS = ['db.json']
@@ -131,7 +130,7 @@ class DBInstaller(comp.PkgInstallComponent):
host_ip = self.cfg.get('host', 'ip')
out = {
'PASSWORD': self.cfg.get("passwords", "sql"),
'BOOT_START': "%s" % BOOLEAN_OUTPUT.get(True),
'BOOT_START': ("%s" % (True)).lower(),
'USER': self.cfg.get("db", "sql_user"),
'SERVICE_HOST': host_ip,
'HOST_IP': host_ip

View File

@@ -63,21 +63,12 @@ APACHE_RESTART_CMD = ['service', '%SERVICE%', 'restart']
APACHE_START_CMD = ['service', '%SERVICE%', 'start']
APACHE_STOP_CMD = ['service', '%SERVICE%', 'stop']
APACHE_STATUS_CMD = ['service', '%SERVICE%', 'status']
APACHE_LOG_LOCATIONS = {
settings.RHEL6: {
'ERROR_LOG': '/var/log/horizon/error.log',
'ACCESS_LOG': '/var/log/horizon/access.log',
'SOCKET_DIR': '/var/log/horizon/wsgi',
},
settings.UBUNTU11: {
'ERROR_LOG': '/var/log/apache2/error.log',
'ACCESS_LOG': '/var/log/apache2/access.log',
}
}
#rhel fixups
RHEL_SOCKET_CONF = "/etc/httpd/conf.d/wsgi_socket_prefix.conf"
RHEL_HTTPD_CONF = '/etc/httpd/conf/httpd.conf'
RHEL_FIXUPS = {
'SOCKET_CONF': "/etc/httpd/conf.d/wsgi_socket_prefix.conf",
'HTTPD_CONF': '/etc/httpd/conf/httpd.conf',
}
#users which apache may not like starting as
BAD_APACHE_USERS = ['root']
@@ -117,6 +108,12 @@ class HorizonInstaller(comp.PythonInstallComponent):
src = self._get_target_config_name(HORIZON_APACHE_CONF)
links = dict()
links[src] = APACHE_CONF_TARGETS[self.distro]
if settings.QUANTUM_CLIENT in self.instances:
#TODO remove this junk, blah, puke that we have to do this
qc = self.instances[settings.QUANTUM_CLIENT]
src_pth = sh.joinpths(qc.appdir, 'quantum')
if sh.isdir(src_pth):
links[src_pth] = sh.joinpths(self.dash_dir, 'quantum')
return links
def _check_ug(self):
@@ -154,8 +151,7 @@ class HorizonInstaller(comp.PythonInstallComponent):
def _setup_blackhole(self):
#create an empty directory that apache uses as docroot
black_dir = sh.joinpths(self.appdir, BLACKHOLE_DIR)
self.tracewriter.make_dir(black_dir)
self.tracewriter.make_dir(sh.joinpths(self.appdir, BLACKHOLE_DIR))
def _sync_db(self):
#Initialize the horizon database (it stores sessions and notices shown to users).
@@ -167,7 +163,7 @@ class HorizonInstaller(comp.PythonInstallComponent):
#Horizon currently imports quantum even if you aren't using it.
#Instead of installing quantum we can create a simple module
#that will pass the initial imports.
if settings.QUANTUM in self.instances:
if settings.QUANTUM_CLIENT in self.instances:
return
else:
#Make the fake quantum
@@ -192,16 +188,20 @@ class HorizonInstaller(comp.PythonInstallComponent):
comp.PythonInstallComponent.pre_install(self)
self.tracewriter.make_dir(self.log_dir)
def _rhel_fixups(self):
def _config_fixups(self):
#currently just handling rhel fixups
#TODO: maybe this should be a subclass
if self.distro != settings.RHEL6:
return
#it seems like to get this to work
#we need to do some conf.d/conf work which sort of sucks
(user, group) = self._get_apache_user_group()
with sh.Rooted(True):
#fix the socket prefix to someplace we can use
fc = "WSGISocketPrefix %s" % (sh.joinpths(self.log_dir, "wsgi-socket"))
sh.write_file(RHEL_SOCKET_CONF, fc)
sh.write_file(RHEL_FIXUPS.get("SOCKET_CONF"), fc)
#now adjust the run user and group
fc = sh.load_file(RHEL_HTTPD_CONF)
fc = sh.load_file(RHEL_FIXUPS.get("HTTPD_CONF"))
lines = fc.splitlines()
new_lines = list()
for line in lines:
@@ -211,7 +211,7 @@ class HorizonInstaller(comp.PythonInstallComponent):
line = "Group %s" % (group)
new_lines.append(line)
fc = utils.joinlinesep(*new_lines)
sh.write_file(RHEL_HTTPD_CONF, fc)
sh.write_file(RHEL_FIXUPS.get("HTTPD_CONF"), fc)
def post_install(self):
comp.PythonInstallComponent.post_install(self)
@@ -219,9 +219,7 @@ class HorizonInstaller(comp.PythonInstallComponent):
self._sync_db()
self._setup_blackhole()
self._ensure_db_access()
if self.distro == settings.RHEL6:
LOG.info("Performing rhel 6 horizon fixups.")
self._rhel_fixups()
self._config_fixups()
def _get_apache_user_group(self):
user = self.cfg.get('horizon', 'apache_user')
@@ -246,7 +244,7 @@ class HorizonInstaller(comp.PythonInstallComponent):
mp['ERROR_LOG'] = sh.joinpths(self.log_dir, "error.log")
else:
#Enable quantum in dashboard, if requested
mp['QUANTUM_ENABLED'] = "%s" % (settings.QUANTUM in self.instances)
mp['QUANTUM_ENABLED'] = "%s" % (settings.QUANTUM_CLIENT in self.instances)
mp['OPENSTACK_HOST'] = self.cfg.get('host', 'ip')
return mp

View File

@@ -175,9 +175,10 @@ QUANTUM_OPENSWITCH_OPS = {
'quantum_use_dhcp': None,
}
#ensure libvirt restarted (seems to only be on rhel)
#ensure libvirt restarted
LIBVIRT_RESTART_CMD = {
settings.RHEL6: ['service', 'libvirtd', 'restart'],
settings.UBUNTU11: ['/etc/init.d/libvirt-bin', 'restart'],
}
#pip files that nova requires

View File

@@ -316,9 +316,9 @@ def rmdir(path, quiet=True, run_as_root=False):
def symlink(source, link, force=True, run_as_root=True):
with Rooted(run_as_root):
LOG.debug("Creating symlink from %s => %s" % (link, source))
path = dirname(link)
mkdirslist(path)
LOG.debug("Creating symlink from %s => %s" % (link, source))
if force and exists(link):
unlink(link, True)
os.symlink(source, link)