From f6743bdef0d6f7d29c65b7c2d09d2a8febd7fd8f Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 28 Feb 2012 12:31:57 -0800 Subject: [PATCH] Cleanups around common symlink code. --- devstack/component.py | 12 +++++++++++- devstack/components/glance.py | 7 ------- devstack/components/horizon.py | 5 +---- devstack/components/keystone.py | 7 ------- devstack/components/melange.py | 7 ------- devstack/components/nova.py | 32 ++++++++++++++++++++++++++------ devstack/components/quantum.py | 7 ------- devstack/components/swift.py | 7 ------- 8 files changed, 38 insertions(+), 46 deletions(-) diff --git a/devstack/component.py b/devstack/component.py index ba834062..5d80cf58 100644 --- a/devstack/component.py +++ b/devstack/component.py @@ -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() diff --git a/devstack/components/glance.py b/devstack/components/glance.py index d53ddfdd..e47ce4c8 100644 --- a/devstack/components/glance.py +++ b/devstack/components/glance.py @@ -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() diff --git a/devstack/components/horizon.py b/devstack/components/horizon.py index b3a37315..2710f58f 100644 --- a/devstack/components/horizon.py +++ b/devstack/components/horizon.py @@ -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): diff --git a/devstack/components/keystone.py b/devstack/components/keystone.py index a3f55e9b..ec2f80df 100644 --- a/devstack/components/keystone.py +++ b/devstack/components/keystone.py @@ -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() diff --git a/devstack/components/melange.py b/devstack/components/melange.py index 9d63c150..4740f038 100644 --- a/devstack/components/melange.py +++ b/devstack/components/melange.py @@ -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) diff --git a/devstack/components/nova.py b/devstack/components/nova.py index f16c4627..60e4efb0 100644 --- a/devstack/components/nova.py +++ b/devstack/components/nova.py @@ -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): diff --git a/devstack/components/quantum.py b/devstack/components/quantum.py index 4dd43b4d..fd8959a2 100644 --- a/devstack/components/quantum.py +++ b/devstack/components/quantum.py @@ -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: diff --git a/devstack/components/swift.py b/devstack/components/swift.py index 69f25740..1f20fb8d 100644 --- a/devstack/components/swift.py +++ b/devstack/components/swift.py @@ -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)