Cleanups around common symlink code.

This commit is contained in:
Joshua Harlow 2012-02-28 12:31:57 -08:00
parent 4caac8ba86
commit f6743bdef0
8 changed files with 38 additions and 46 deletions

View File

@ -52,6 +52,9 @@ STOPPER_CLS_MAPPING = {
settings.RUN_TYPE_SCREEN: screen.ScreenRunner,
}
#where symlinks will go
BASE_LINK_DIR = "/etc"
class ComponentBase(object):
def __init__(self, component_name, **kargs):
@ -167,8 +170,15 @@ class PkgInstallComponent(ComponentBase):
def _get_source_config(self, config_fn):
return utils.load_template(self.component_name, config_fn)
def _get_link_dir(self):
return sh.joinpths(BASE_LINK_DIR, self.component_name)
def _get_symlinks(self):
return dict()
links = dict()
for fn in self._get_config_files():
source_fn = self._get_target_config_name(fn)
links[source_fn] = sh.joinpths(self._get_link_dir(), fn)
return links
def _configure_files(self):
configs = self._get_config_files()

View File

@ -110,13 +110,6 @@ class GlanceInstaller(comp.PythonInstallComponent):
def _get_pkgs(self):
return list(REQ_PKGS)
def _get_symlinks(self):
links = dict()
for fn in self._get_config_files():
source_fn = self._get_target_config_name(fn)
links[source_fn] = sh.joinpths("/", "etc", "glance", fn)
return links
def post_install(self):
comp.PythonInstallComponent.post_install(self)
self._setup_db()

View File

@ -110,10 +110,7 @@ class HorizonInstaller(comp.PythonInstallComponent):
self._check_ug()
def _get_symlinks(self):
links = dict()
for fn in self._get_config_files():
source_fn = self._get_target_config_name(fn)
links[source_fn] = sh.joinpths("/", "etc", "horizon", fn)
links = comp.PythonInstallComponent._get_symlinks(self)
src = self._get_target_config_name(HORIZON_APACHE_CONF)
links[src] = APACHE_CONF_TARGETS[self.distro]
if utils.service_enabled(settings.QUANTUM_CLIENT, self.instances, False):

View File

@ -120,13 +120,6 @@ class KeystoneInstaller(comp.PythonInstallComponent):
def _get_pkgs(self):
return list(REQ_PKGS)
def _get_symlinks(self):
links = dict()
for fn in self._get_config_files():
source_fn = self._get_target_config_name(fn)
links[source_fn] = sh.joinpths("/", "etc", "keystone", fn)
return links
def post_install(self):
comp.PythonInstallComponent.post_install(self)
self._setup_db()

View File

@ -89,13 +89,6 @@ class MelangeInstaller(comp.PythonInstallComponent):
db.drop_db(self.cfg, DB_NAME)
db.create_db(self.cfg, DB_NAME)
def _get_symlinks(self):
links = dict()
for fn in self._get_config_files():
source_fn = self._get_target_config_name(fn)
links[source_fn] = sh.joinpths("/", "etc", "melange", fn)
return links
def _get_pkgs(self):
return list(REQ_PKGS)

View File

@ -210,6 +210,19 @@ QUANTUM_OPENSWITCH_OPS = {
CLEANER_DATA_CONF = 'nova-clean.sh'
CLEANER_CMD_ROOT = [sh.joinpths("/", "bin", 'bash')]
#rhel6/fedora libvirt policy
#http://wiki.libvirt.org/page/SSHPolicyKitSetup
LIBVIRT_POLICY_FN = "/etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla"
LIBVIRT_POLICY_CONTENTS = """
[libvirt Management Access]
Identity=unix-group:libvirtd
Action=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes
"""
POLICY_DISTROS = [settings.RHEL6, settings.FEDORA16]
#xenserver specific defaults
XS_DEF_INTERFACE = 'eth1'
XA_CONNECTION_ADDR = '169.254.0.1'
@ -305,12 +318,9 @@ class NovaInstaller(comp.PythonInstallComponent):
return pkgs
def _get_symlinks(self):
links = dict()
for fn in self._get_config_files():
source_fn = self._get_target_config_name(fn)
links[source_fn] = sh.joinpths("/", "etc", "nova", fn)
links = comp.PythonInstallComponent._get_symlinks(self)
source_fn = sh.joinpths(self.cfgdir, API_CONF)
links[source_fn] = sh.joinpths("/", "etc", "nova", API_CONF)
links[source_fn] = sh.joinpths(self._get_link_dir(), API_CONF)
return links
def _get_pips(self):
@ -436,7 +446,17 @@ class NovaInstaller(comp.PythonInstallComponent):
def configure(self):
configs_made = comp.PythonInstallComponent.configure(self)
self._generate_nova_conf()
return configs_made + 1
configs_made += 1
# TODO: maybe this should be a subclass that handles these differences
driver_canon = _canon_virt_driver(self.cfg.get('nova', 'virt_driver'))
if (self.distro in POLICY_DISTROS) and driver_canon == virsh.VIRT_TYPE:
with sh.Rooted(True):
dirsmade = sh.mkdirslist(sh.dirname(LIBVIRT_POLICY_FN))
sh.write_file(LIBVIRT_POLICY_FN, LIBVIRT_POLICY_CONTENTS)
self.tracewriter.dir_made(*dirsmade)
self.tracewriter.cfg_write(LIBVIRT_POLICY_FN)
configs_made += 1
return configs_made
class NovaRuntime(comp.PythonRuntime):

View File

@ -113,13 +113,6 @@ class QuantumInstaller(comp.PkgInstallComponent):
add_deps.append(settings.DB)
return common_deps + add_deps
def _get_symlinks(self):
links = dict()
for fn in self._get_config_files():
source_fn = self._get_target_config_name(fn)
links[source_fn] = sh.joinpths("/", "etc", "quantum", fn)
return links
def _get_pkgs(self):
pkglist = list(REQ_PKGS)
if self.q_vswitch_service:

View File

@ -115,13 +115,6 @@ class SwiftInstaller(comp.PythonInstallComponent):
def _get_pkgs(self):
return list(REQ_PKGS)
def _get_symlinks(self):
links = dict()
for fn in self._get_config_files():
source_fn = self._get_target_config_name(fn)
links[source_fn] = sh.joinpths("/", "etc", "swift", fn)
return links
def warm_configs(self):
for pw_key in WARMUP_PWS:
self.cfg.get("passwords", pw_key)