From 1561e636faee6f81cfa10acfa99fb117e8e5e8f3 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 31 Jan 2012 22:05:38 -0800 Subject: [PATCH] Some cleanups. --- devstack/component.py | 78 ++++++++++++++------------ devstack/components/db.py | 6 +- devstack/components/glance.py | 21 ++----- devstack/components/horizon.py | 34 +++-------- devstack/components/keystone.py | 22 ++------ devstack/components/keystone_client.py | 14 ++--- devstack/components/nova.py | 42 ++++---------- devstack/components/nova_client.py | 14 ++--- devstack/components/novnc.py | 14 ++--- devstack/components/openstack_x.py | 14 ++--- devstack/components/quantum.py | 22 +++----- devstack/components/quantum_client.py | 14 ++--- devstack/components/rabbit.py | 8 +-- devstack/shell.py | 11 ++++ 14 files changed, 114 insertions(+), 200 deletions(-) diff --git a/devstack/component.py b/devstack/component.py index ce6af27e..4de59c54 100644 --- a/devstack/component.py +++ b/devstack/component.py @@ -70,32 +70,41 @@ class PkgInstallComponent(ComponentBase): def download(self): locations = self._get_download_locations() base_dir = self.appdir - am_downloaded = 0 for location_info in locations: - uri = location_info.get("uri") - if not uri: - continue - branch = location_info.get("branch") + uri_tuple = location_info.get("uri") + branch_tuple = location_info.get("branch") subdir = location_info.get("subdir") target_loc = None if subdir and len(subdir): target_loc = sh.joinpths(base_dir, subdir) else: target_loc = base_dir - dirsmade = down.download(target_loc, uri, branch) + branch = None + if branch_tuple: + branch = self.cfg.get(branch_tuple[0], branch_tuple[1]) + uri = self.cfg.get(uri_tuple[0], uri_tuple[1]) + self.tracewriter.dir_made(*down.download(target_loc, uri, branch)) self.tracewriter.downloaded(target_loc, uri) - self.tracewriter.dir_made(*dirsmade) - am_downloaded += 1 - return am_downloaded + return len(locations) def _get_param_map(self, config_fn): - return None - - def _get_pkgs(self): return dict() + def _get_pkgs(self): + return list() + + def _get_pkgs_expanded(self): + short = self._get_pkgs() + if not short: + return dict() + pkgs = dict() + for fn in short: + full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) + pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) + return pkgs + def install(self): - pkgs = self._get_pkgs() + pkgs = self._get_pkgs_expanded() if pkgs: pkgnames = sorted(pkgs.keys()) LOG.info("Installing packages (%s)." % (", ".join(pkgnames))) @@ -106,14 +115,14 @@ class PkgInstallComponent(ComponentBase): return self.tracedir def pre_install(self): - pkgs = self._get_pkgs() + pkgs = self._get_pkgs_expanded() if pkgs: mp = self._get_param_map(None) self.packager.pre_install(pkgs, mp) return self.tracedir def post_install(self): - pkgs = self._get_pkgs() + pkgs = self._get_pkgs_expanded() if pkgs: mp = self._get_param_map(None) self.packager.post_install(pkgs, mp) @@ -166,19 +175,25 @@ class PythonInstallComponent(PkgInstallComponent): PkgInstallComponent.__init__(self, component_name, *args, **kargs) def _get_python_directories(self): - py_dirs = list() - py_dirs.append({ - 'name': self.component_name, - 'work_dir': self.appdir, - }) + py_dirs = dict() + py_dirs[self.component_name] = self.appdir return py_dirs def _get_pips(self): - return dict() + return list() + + def _get_pips_expanded(self): + shorts = self._get_pips() + if not shorts: + return dict() + pips = dict() + for fn in shorts: + full_name = sh.joinpths(settings.STACK_PIP_DIR, fn) + pips = utils.extract_pip_list([full_name], self.distro, pips) + return pips def _install_pips(self): - #install any need pip items - pips = self._get_pips() + pips = self._get_pips_expanded() if pips: LOG.info("Setting up %s pips (%s)" % (len(pips), ", ".join(pips.keys()))) pip.install(pips, self.distro) @@ -197,21 +212,12 @@ class PythonInstallComponent(PkgInstallComponent): return "%s-%s" % (tr.PY_TRACE, name) def _install_python_setups(self): - #setup any python directories pydirs = self._get_python_directories() if pydirs: - actual_dirs = list() - for pydir_info in pydirs: - working_dir = pydir_info.get('work_dir', self.appdir) - actual_dirs.append(working_dir) - LOG.info("Setting up %s python directories (%s)" % (len(pydirs), ", ".join(actual_dirs))) - self.tracewriter.make_dir(self.tracedir) - for pydir_info in pydirs: - name = pydir_info.get("name") - if not name: - #TODO should we raise an exception here? - continue - working_dir = pydir_info.get('work_dir', self.appdir) + LOG.info("Setting up %s python directories (%s)" % (len(pydirs), pydirs)) + for (name, wkdir) in pydirs.items(): + working_dir = wkdir or self.appdir + self.tracewriter.make_dir(working_dir) record_fn = tr.touch_trace(self.tracedir, self._format_trace_name(name)) self.tracewriter.file_touched(record_fn) (stdout, stderr) = sh.execute(*PY_INSTALL, cwd=working_dir, run_as_root=True) diff --git a/devstack/components/db.py b/devstack/components/db.py index 6a4e45df..3870707d 100644 --- a/devstack/components/db.py +++ b/devstack/components/db.py @@ -143,11 +143,7 @@ class DBInstaller(comp.PkgInstallComponent): sh.execute(*UBUNTU_HOST_ADJUST, run_as_root=True) def _get_pkgs(self): - pkgs = comp.PkgInstallComponent._get_pkgs(self) - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) - return pkgs + return list(REQ_PKGS) def post_install(self): parent_result = comp.PkgInstallComponent.post_install(self) diff --git a/devstack/components/glance.py b/devstack/components/glance.py index 2cb4c646..99b1e74e 100644 --- a/devstack/components/glance.py +++ b/devstack/components/glance.py @@ -85,35 +85,24 @@ class GlanceUninstaller(comp.PythonUninstallComponent): class GlanceInstaller(comp.PythonInstallComponent): def __init__(self, *args, **kargs): comp.PythonInstallComponent.__init__(self, TYPE, *args, **kargs) - self.git_loc = self.cfg.get("git", "glance_repo") - self.git_branch = self.cfg.get("git", "glance_branch") self.cfgdir = sh.joinpths(self.appdir, CONFIG_DIR) def _get_download_locations(self): - places = comp.PythonInstallComponent._get_download_locations(self) + places = list() places.append({ - 'uri': self.git_loc, - 'branch': self.git_branch, + 'uri': ("git", "glance_repo"), + 'branch': ("git", "glance_branch"), }) return places def _get_config_files(self): - #these are the config files we will be adjusting return list(CONFIGS) def _get_pips(self): - pips = comp.PythonInstallComponent._get_pips(self) - for fn in REQ_PIPS: - full_name = sh.joinpths(settings.STACK_PIP_DIR, fn) - pips = utils.extract_pip_list([full_name], self.distro, pips) - return pips + return list(REQ_PIPS) def _get_pkgs(self): - pkgs = comp.PythonInstallComponent._get_pkgs(self) - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) - return pkgs + return list(REQ_PKGS) def post_install(self): parent_result = comp.PythonInstallComponent.post_install(self) diff --git a/devstack/components/horizon.py b/devstack/components/horizon.py index 7ea186c3..01b7afdb 100644 --- a/devstack/components/horizon.py +++ b/devstack/components/horizon.py @@ -70,32 +70,22 @@ class HorizonUninstaller(comp.PythonUninstallComponent): class HorizonInstaller(comp.PythonInstallComponent): def __init__(self, *args, **kargs): comp.PythonInstallComponent.__init__(self, TYPE, *args, **kargs) - self.git_loc = self.cfg.get("git", "horizon_repo") - self.git_branch = self.cfg.get("git", "horizon_branch") self.horizon_dir = sh.joinpths(self.appdir, ROOT_HORIZON) self.dash_dir = sh.joinpths(self.appdir, ROOT_DASH) def _get_download_locations(self): - places = comp.PythonInstallComponent._get_download_locations(self) + places = list() places.append({ - 'uri': self.git_loc, - 'branch': self.git_branch, + 'uri': ("git", "horizon_repo"), + 'branch': ("git", "horizon_branch"), }) return places def _get_pkgs(self): - pkgs = comp.PythonInstallComponent._get_pkgs(self) - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) - return pkgs + return list(REQ_PKGS) def _get_pips(self): - pips = comp.PythonInstallComponent._get_pips(self) - for fn in REQ_PIPS: - full_name = sh.joinpths(settings.STACK_PIP_DIR, fn) - pips = utils.extract_pip_list([full_name], self.distro, pips) - return pips + return list(REQ_PIPS) def _get_target_config_name(self, config_name): if config_name == HORIZON_PY_CONF: @@ -107,19 +97,12 @@ class HorizonInstaller(comp.PythonInstallComponent): return comp.PythonInstallComponent._get_target_config_name(self, config_name) def _get_python_directories(self): - py_dirs = list() - py_dirs.append({ - 'name': HORIZON_NAME, - 'work_dir': self.horizon_dir, - }) - py_dirs.append({ - 'name': DASH_NAME, - 'work_dir': self.dash_dir, - }) + py_dirs = dict() + py_dirs[HORIZON_NAME] = self.horizon_dir + py_dirs[DASH_NAME] = self.dash_dir return py_dirs def _get_config_files(self): - #these are the config files we will be adjusting return list(CONFIGS) def _setup_blackhole(self): @@ -131,6 +114,7 @@ class HorizonInstaller(comp.PythonInstallComponent): def _sync_db(self): #Initialize the horizon database (it stores sessions and notices shown to users). #The user system is external (keystone). + LOG.info("Initializing the horizon database") sh.execute(*DB_SYNC_CMD, cwd=self.dash_dir) def _fake_quantum(self): diff --git a/devstack/components/keystone.py b/devstack/components/keystone.py index 5fe19466..73bea24c 100644 --- a/devstack/components/keystone.py +++ b/devstack/components/keystone.py @@ -73,32 +73,22 @@ class KeystoneUninstaller(comp.PythonUninstallComponent): class KeystoneInstaller(comp.PythonInstallComponent): def __init__(self, *args, **kargs): comp.PythonInstallComponent.__init__(self, TYPE, *args, **kargs) - self.git_loc = self.cfg.get("git", "keystone_repo") - self.git_branch = self.cfg.get("git", "keystone_branch") self.cfgdir = sh.joinpths(self.appdir, CONFIG_DIR) self.bindir = sh.joinpths(self.appdir, BIN_DIR) def _get_download_locations(self): - places = comp.PythonInstallComponent._get_download_locations(self) + places = list() places.append({ - 'uri': self.git_loc, - 'branch': self.git_branch, + 'uri': ("git", "keystone_repo"), + 'branch': ("git", "keystone_branch"), }) return places def _get_pips(self): - pips = comp.PythonInstallComponent._get_pips(self) - for fn in REQ_PIPS: - full_name = sh.joinpths(settings.STACK_PIP_DIR, fn) - pips = utils.extract_pip_list([full_name], self.distro, pips) - return pips + return list(REQ_PIPS) def _get_pkgs(self): - pkgs = comp.PythonInstallComponent._get_pkgs(self) - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) - return pkgs + return list(REQ_PKGS) def post_install(self): parent_result = comp.PythonInstallComponent.post_install(self) @@ -120,7 +110,7 @@ class KeystoneInstaller(comp.PythonInstallComponent): return list(CONFIGS) def _setup_db(self): - LOG.info("Fixing up database named %s", DB_NAME) + LOG.info("Fixing up database named %s.", DB_NAME) db.drop_db(self.cfg, DB_NAME) db.create_db(self.cfg, DB_NAME) diff --git a/devstack/components/keystone_client.py b/devstack/components/keystone_client.py index 82f94af8..b906e587 100644 --- a/devstack/components/keystone_client.py +++ b/devstack/components/keystone_client.py @@ -37,23 +37,17 @@ class KeyStoneClientUninstaller(comp.PythonUninstallComponent): class KeyStoneClientInstaller(comp.PythonInstallComponent): def __init__(self, *args, **kargs): comp.PythonInstallComponent.__init__(self, TYPE, *args, **kargs) - self.git_loc = self.cfg.get("git", "keystoneclient_repo") - self.git_branch = self.cfg.get("git", "keystoneclient_branch") def _get_download_locations(self): - places = comp.PythonInstallComponent._get_download_locations(self) + places = list() places.append({ - 'uri': self.git_loc, - 'branch': self.git_branch, + 'uri': ("git", "keystoneclient_repo"), + 'branch': ("git", "keystoneclient_branch"), }) return places def _get_pkgs(self): - pkgs = comp.PythonInstallComponent._get_pkgs(self) - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) - return pkgs + return list(REQ_PKGS) class KeyStoneClientRuntime(comp.EmptyRuntime): diff --git a/devstack/components/nova.py b/devstack/components/nova.py index 3390c37d..683073cf 100644 --- a/devstack/components/nova.py +++ b/devstack/components/nova.py @@ -184,45 +184,25 @@ class NovaUninstaller(comp.PythonUninstallComponent): class NovaInstaller(comp.PythonInstallComponent): def __init__(self, *args, **kargs): comp.PythonInstallComponent.__init__(self, TYPE, *args, **kargs) - self.git_repo = self.cfg.get("git", "nova_repo") - self.git_branch = self.cfg.get("git", "nova_branch") self.bindir = sh.joinpths(self.appdir, BIN_DIR) self.paste_conf_fn = self._get_target_config_name(PASTE_CONF) def _get_pkgs(self): - pkgs = comp.PythonInstallComponent._get_pkgs(self) - # Get the core pkgs - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) - # Walk through the subcomponents (like 'vol' and 'cpu') and add those - # those packages as well. - sub_components = [] - if self.component_opts: - sub_components = self.component_opts - else: - sub_components = SUBCOMPONENTS - # Add the extra dependencies + pkgs = list(REQ_PKGS) + sub_components = self.component_opts or SUBCOMPONENTS for c in sub_components: - fns = ADD_PKGS.get(c) - if fns: - for fn in fns: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) + fns = ADD_PKGS.get(c) or [] + pkgs.extend(fns) return pkgs def _get_pips(self): - pips = comp.PythonInstallComponent._get_pips(self) - for fn in REQ_PIPS: - full_name = sh.joinpths(settings.STACK_PIP_DIR, fn) - pips = utils.extract_pip_list([full_name], self.distro, pips) - return pips + return list(REQ_PIPS) def _get_download_locations(self): - places = comp.PythonInstallComponent._get_download_locations(self) + places = list() places.append({ - 'uri': self.git_repo, - 'branch': self.git_branch, + 'uri': ("git", "nova_repo"), + 'branch': ("git", "nova_branch"), }) return places @@ -263,12 +243,12 @@ class NovaInstaller(comp.PythonInstallComponent): return parent_result def _setup_db(self): - LOG.info("Fixing up database named %s", DB_NAME) + LOG.info("Fixing up database named %s.", DB_NAME) db.drop_db(self.cfg, DB_NAME) db.create_db(self.cfg, DB_NAME) def _setup_vol_groups(self): - LOG.info("Attempting to setup volume groups for nova volume management") + LOG.info("Attempting to setup volume groups for nova volume management.") mp = dict() backing_file = self.cfg.get('nova', 'volume_backing_file') # check if we need to have a default backing file @@ -301,7 +281,7 @@ class NovaInstaller(comp.PythonInstallComponent): utils.execute_template(*RESTART_TGT_CMD, check_exit_code=False, tracewriter=self.tracewriter) def _process_lvs(self, mp): - LOG.info("Attempting to setup logical volumes for nova volume management") + LOG.info("Attempting to setup logical volumes for nova volume management.") lvs_result = utils.execute_template(*VG_LVS_CMD, params=mp, tracewriter=self.tracewriter) LOG.debug("lvs result: %s" % (lvs_result)) vol_name_prefix = self.cfg.get('nova', 'volume_name_prefix') diff --git a/devstack/components/nova_client.py b/devstack/components/nova_client.py index 113b9255..b2be5772 100644 --- a/devstack/components/nova_client.py +++ b/devstack/components/nova_client.py @@ -37,23 +37,17 @@ class NovaClientUninstaller(comp.PythonUninstallComponent): class NovaClientInstaller(comp.PythonInstallComponent): def __init__(self, *args, **kargs): comp.PythonInstallComponent.__init__(self, TYPE, *args, **kargs) - self.git_loc = self.cfg.get("git", "novaclient_repo") - self.git_branch = self.cfg.get("git", "novaclient_branch") def _get_download_locations(self): - places = comp.PythonInstallComponent._get_download_locations(self) + places = list() places.append({ - 'uri': self.git_loc, - 'branch': self.git_branch, + 'uri': ("git", "novaclient_repo"), + 'branch': ("git", "novaclient_branch"), }) return places def _get_pkgs(self): - pkgs = comp.PythonInstallComponent._get_pkgs(self) - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) - return pkgs + return list(REQ_PKGS) class NovaClientRuntime(comp.EmptyRuntime): diff --git a/devstack/components/novnc.py b/devstack/components/novnc.py index 801f15c6..2383bbc6 100644 --- a/devstack/components/novnc.py +++ b/devstack/components/novnc.py @@ -49,23 +49,17 @@ class NoVNCUninstaller(comp.PkgUninstallComponent): class NoVNCInstaller(comp.PkgInstallComponent): def __init__(self, *args, **kargs): comp.PkgInstallComponent.__init__(self, TYPE, *args, **kargs) - self.git_loc = self.cfg.get("git", "novnc_repo") - self.git_branch = self.cfg.get("git", "novnc_branch") def _get_download_locations(self): - places = comp.PkgInstallComponent._get_download_locations(self) + places = list() places.append({ - 'uri': self.git_loc, - 'branch': self.git_branch, + 'uri': ("git", "novnc_repo"), + 'branch': ("git", "novnc_branch"), }) return places def _get_pkgs(self): - pkgs = comp.PkgInstallComponent._get_pkgs(self) - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) - return pkgs + return list(REQ_PKGS) class NoVNCRuntime(comp.ProgramRuntime): diff --git a/devstack/components/openstack_x.py b/devstack/components/openstack_x.py index 0b9f087f..7a234dc8 100644 --- a/devstack/components/openstack_x.py +++ b/devstack/components/openstack_x.py @@ -37,23 +37,17 @@ class OpenstackXUninstaller(comp.PythonUninstallComponent): class OpenstackXInstaller(comp.PythonInstallComponent): def __init__(self, *args, **kargs): comp.PythonInstallComponent.__init__(self, TYPE, *args, **kargs) - self.git_loc = self.cfg.get("git", "openstackx_repo") - self.git_branch = self.cfg.get("git", "openstackx_branch") def _get_download_locations(self): - places = comp.PythonInstallComponent._get_download_locations(self) + places = list() places.append({ - 'uri': self.git_loc, - 'branch': self.git_branch, + 'uri': ("git", "openstackx_repo"), + 'branch': ("git", "openstackx_branch"), }) return places def _get_pkgs(self): - pkgs = comp.PythonInstallComponent._get_pkgs(self) - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) - return pkgs + return list(REQ_PKGS) class OpenstackXRuntime(comp.EmptyRuntime): diff --git a/devstack/components/quantum.py b/devstack/components/quantum.py index 5d1568ae..bdb12875 100644 --- a/devstack/components/quantum.py +++ b/devstack/components/quantum.py @@ -80,8 +80,6 @@ class QuantumUninstaller(comp.PkgUninstallComponent): class QuantumInstaller(comp.PkgInstallComponent): def __init__(self, *args, **kargs): comp.PkgInstallComponent.__init__(self, TYPE, *args, **kargs) - self.git_loc = self.cfg.get("git", "quantum_repo") - self.git_branch = self.cfg.get("git", "quantum_branch") self.q_vswitch_agent = False self.q_vswitch_service = False plugin = self.cfg.get("quantum", "q_plugin") @@ -98,27 +96,21 @@ class QuantumInstaller(comp.PkgInstallComponent): self.q_vswitch_agent = True def _get_download_locations(self): - places = comp.PkgInstallComponent._get_download_locations(self) + places = list() places.append({ - 'uri': self.git_loc, - 'branch': self.git_branch, + 'uri': ("git", "quantum_repo"), + 'branch': ("git", "quantum_branch"), }) return places def _get_pkgs(self): - pkglist = comp.PkgInstallComponent._get_pkgs(self) - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkglist = utils.extract_pkg_list([full_name], self.distro, pkglist) + pkglist = list(REQ_PKGS) if self.q_vswitch_service: - listing_fn = sh.joinpths(settings.STACK_PKG_DIR, PKG_VSWITCH) - pkglist = utils.extract_pkg_list([listing_fn], self.distro, pkglist) + pkglist.append(PKG_VSWITCH) return pkglist def _get_config_files(self): - parent_list = comp.PkgInstallComponent._get_config_files(self) - parent_list.extend(CONFIG_FILES) - return parent_list + return list(CONFIG_FILES) def _get_target_config_name(self, config_fn): if config_fn == PLUGIN_CONF: @@ -198,7 +190,7 @@ class QuantumInstaller(comp.PkgInstallComponent): return parent_result def _setup_db(self): - LOG.info("Fixing up database named %s", DB_NAME) + LOG.info("Fixing up database named %s.", DB_NAME) db.drop_db(self.cfg, DB_NAME) db.create_db(self.cfg, DB_NAME) diff --git a/devstack/components/quantum_client.py b/devstack/components/quantum_client.py index e89d3458..a23b178b 100644 --- a/devstack/components/quantum_client.py +++ b/devstack/components/quantum_client.py @@ -37,23 +37,17 @@ class QuantumClientUninstaller(comp.PythonUninstallComponent): class QuantumClientInstaller(comp.PythonInstallComponent): def __init__(self, *args, **kargs): comp.PythonInstallComponent.__init__(self, TYPE, *args, **kargs) - self.git_loc = self.cfg.get("git", "quantum_client_repo") - self.git_branch = self.cfg.get("git", "quantum_client_branch") def _get_download_locations(self): - places = comp.PythonInstallComponent._get_download_locations(self) + places = list() places.append({ - 'uri': self.git_loc, - 'branch': self.git_branch, + 'uri': ("git", "quantum_client_repo"), + 'branch': ("git", "quantum_client_branch"), }) return places def _get_pkgs(self): - pkgs = comp.PythonInstallComponent._get_pkgs(self) - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) - return pkgs + return list(REQ_PKGS) class QuantumClientRuntime(comp.EmptyRuntime): diff --git a/devstack/components/rabbit.py b/devstack/components/rabbit.py index 322c8bdb..b16a2ea9 100644 --- a/devstack/components/rabbit.py +++ b/devstack/components/rabbit.py @@ -55,7 +55,7 @@ class RabbitUninstaller(comp.PkgUninstallComponent): def pre_uninstall(self): try: self.runtime.restart() - LOG.info("Resetting the guest password to \"%s\"", RESET_BASE_PW) + LOG.info("Resetting the rabbit-mq guest password to \"%s\"", RESET_BASE_PW) cmd = PWD_CMD + [RESET_BASE_PW] sh.execute(*cmd, run_as_root=True) except IOError: @@ -83,11 +83,7 @@ class RabbitInstaller(comp.PkgInstallComponent): return parent_result def _get_pkgs(self): - pkgs = comp.PkgInstallComponent._get_pkgs(self) - for fn in REQ_PKGS: - full_name = sh.joinpths(settings.STACK_PKG_DIR, fn) - pkgs = utils.extract_pkg_list([full_name], self.distro, pkgs) - return pkgs + return list(REQ_PKGS) class RabbitRuntime(comp.EmptyRuntime): diff --git a/devstack/shell.py b/devstack/shell.py index 728d1300..f9a5b329 100644 --- a/devstack/shell.py +++ b/devstack/shell.py @@ -21,6 +21,7 @@ import os.path import pwd import shutil import subprocess +import tempfile from devstack import env from devstack import exceptions as excp @@ -161,6 +162,16 @@ def _gen_password(pw_len): return stdout.strip() +def write_file_su(fn, text, flush=True): + with tempfile.NamedTemporaryFile() as fh: + tmp_fn = fh.name + fh.write(text) + if flush: + fh.flush() + cmd = ['cp', tmp_fn, fn] + execute(*cmd, run_as_root=True) + + def prompt_password(pw_prompt=None): if pw_prompt: rc = getpass.getpass(pw_prompt)