Just use executable flag for init scripts instead of moving
This commit is contained in:
parent
1e0b61e88a
commit
722a331f8e
devstack
@ -210,7 +210,7 @@ class KeystoneRuntime(comp.PythonRuntime):
|
||||
|
||||
def post_start(self):
|
||||
tgt_fn = sh.joinpths(self.bin_dir, MANAGE_DATA_CONF)
|
||||
if sh.isfile(tgt_fn):
|
||||
if sh.is_executable(tgt_fn):
|
||||
# If its still there, run it
|
||||
# these environment additions are important
|
||||
# in that they eventually affect how this script runs
|
||||
@ -222,21 +222,17 @@ class KeystoneRuntime(comp.PythonRuntime):
|
||||
setup_cmd = MANAGE_CMD_ROOT + [tgt_fn]
|
||||
LOG.info("Running %r command to initialize keystone." % (" ".join(setup_cmd)))
|
||||
sh.execute(*setup_cmd, env_overrides=env, run_as_root=False)
|
||||
self._backup_key_init(tgt_fn, env)
|
||||
self._toggle_key_init(tgt_fn, env)
|
||||
|
||||
def _backup_key_init(self, src_fn, env):
|
||||
tgt_fn = utils.make_backup_fn(src_fn)
|
||||
LOG.info("Moving %r to %r since we successfully initialized keystone.", src_fn, tgt_fn)
|
||||
sh.move(src_fn, tgt_fn)
|
||||
def _toggle_key_init(self, src_fn, env):
|
||||
add_lines = list()
|
||||
add_lines.append('')
|
||||
add_lines.append('# Ran on %s by %s' % (date.rcf8222date(), sh.getuser()))
|
||||
add_lines.append('# With environment:')
|
||||
for k, v in env.items():
|
||||
for (k, v) in env.items():
|
||||
add_lines.append('# %s => %s' % (k, v))
|
||||
sh.append_file(tgt_fn, utils.joinlinesep(*add_lines))
|
||||
# FIXME - add a trace?
|
||||
return tgt_fn
|
||||
sh.append_file(src_fn, utils.joinlinesep(*add_lines))
|
||||
sh.chmod(src_fn, 0644)
|
||||
|
||||
def _get_apps_to_start(self):
|
||||
apps = list()
|
||||
|
@ -363,23 +363,19 @@ class NovaRuntime(NovaMixin, comp.PythonRuntime):
|
||||
self.wait_time = max(self.cfg.getint('default', 'service_wait_seconds'), 1)
|
||||
self.virsh = lv.Virsh(self.cfg, self.distro)
|
||||
|
||||
def _backup_network_init(self, src_fn, env):
|
||||
tgt_fn = utils.make_backup_fn(src_fn)
|
||||
LOG.info("Moving %r to %r since we successfully initialized nova's network.", src_fn, tgt_fn)
|
||||
sh.move(src_fn, tgt_fn)
|
||||
def _toggle_network_init(self, src_fn, env):
|
||||
add_lines = list()
|
||||
add_lines.append('')
|
||||
add_lines.append('# Ran on %s by %s' % (date.rcf8222date(), sh.getuser()))
|
||||
add_lines.append('# With environment:')
|
||||
for k, v in env.items():
|
||||
add_lines.append('# %s => %s' % (k, v))
|
||||
sh.append_file(tgt_fn, utils.joinlinesep(*add_lines))
|
||||
# FIXME - add a trace?
|
||||
return tgt_fn
|
||||
sh.append_file(src_fn, utils.joinlinesep(*add_lines))
|
||||
sh.chmod(src_fn, 0644)
|
||||
|
||||
def _setup_network_init(self):
|
||||
tgt_fn = sh.joinpths(self.bin_dir, NET_INIT_CONF)
|
||||
if sh.isfile(tgt_fn):
|
||||
if sh.is_executable(tgt_fn):
|
||||
LOG.info("Creating your nova network to be used with instances.")
|
||||
# If still there, run it
|
||||
# these environment additions are important
|
||||
@ -392,7 +388,7 @@ class NovaRuntime(NovaMixin, comp.PythonRuntime):
|
||||
setup_cmd = NET_INIT_CMD_ROOT + [tgt_fn]
|
||||
LOG.info("Running %r command to initialize nova's network." % (" ".join(setup_cmd)))
|
||||
sh.execute(*setup_cmd, env_overrides=env, run_as_root=False)
|
||||
self._backup_network_init(tgt_fn, env)
|
||||
self._toggle_network_init(tgt_fn, env)
|
||||
|
||||
def post_start(self):
|
||||
self._setup_network_init()
|
||||
|
@ -632,6 +632,12 @@ def user_mode(quiet=True):
|
||||
raise excp.StackException(msg)
|
||||
|
||||
|
||||
def is_executable(fn):
|
||||
if not isfile(fn):
|
||||
return False
|
||||
return os.access(fn, os.X_OK)
|
||||
|
||||
|
||||
def geteuid():
|
||||
return os.geteuid()
|
||||
|
||||
|
@ -31,6 +31,7 @@ import progressbar
|
||||
import termcolor
|
||||
|
||||
from devstack import colorlog
|
||||
from devstack import date
|
||||
from devstack import exceptions as excp
|
||||
from devstack import log as logging
|
||||
from devstack import settings
|
||||
@ -98,10 +99,6 @@ def configure_logging(verbosity_level=1, dry_run=False):
|
||||
root_logger.setLevel(log_level)
|
||||
|
||||
|
||||
def make_backup_fn(src_fn):
|
||||
return "%s.bak" % (src_fn)
|
||||
|
||||
|
||||
def load_template(component, template_name):
|
||||
full_pth = sh.joinpths(settings.STACK_TEMPLATE_DIR, component, template_name)
|
||||
contents = sh.load_file(full_pth)
|
||||
|
Loading…
x
Reference in New Issue
Block a user