コード例 #1
0
 def _configure_db_confs(self):
     dbtype = self.cfg.get("db", "type")
     #TODO: maybe this should be a subclass that handles these differences
     if self.distro == settings.RHEL6 and dbtype == MYSQL:
         LOG.info("Fixing up %s mysql configs." % (settings.RHEL6))
         fc = sh.load_file('/etc/my.cnf')
         lines = fc.splitlines()
         new_lines = list()
         for line in lines:
             if line.startswith('skip-grant-tables'):
                 line = '#' + line
             new_lines.append(line)
         fc = utils.joinlinesep(*new_lines)
         with sh.Rooted(True):
             sh.write_file('/etc/my.cnf', fc)
     elif self.distro == settings.UBUNTU11 and dbtype == MYSQL:
         LOG.info("Fixing up %s mysql configs." % (settings.UBUNTU11))
         fc = sh.load_file('/etc/mysql/my.cnf')
         lines = fc.splitlines()
         new_lines = list()
         for line in lines:
             if line.startswith('bind-address'):
                 line = 'bind-address = %s' % ('0.0.0.0')
             new_lines.append(line)
         fc = utils.joinlinesep(*new_lines)
         with sh.Rooted(True):
             sh.write_file('/etc/mysql/my.cnf', fc)
コード例 #2
0
 def _begin_start(self, name, program, args):
     run_trace = tr.TraceWriter(
         tr.trace_fn(self.trace_dir, SCREEN_TEMPL % (name)))
     run_trace.trace(TYPE, RUN_TYPE)
     run_trace.trace(NAME, name)
     run_trace.trace(ARGS, json.dumps(args))
     full_cmd = [program] + list(args)
     session_name = self._get_session()
     inited_screen = False
     if session_name is None:
         inited_screen = True
         self._do_screen_init()
         session_name = self._get_session()
         if session_name is None:
             msg = "After initializing screen with session named [%s], no screen session with that name was found!" % (
                 SESSION_NAME)
             raise excp.StartException(msg)
     run_trace.trace(SESSION_ID, session_name)
     if inited_screen or not sh.isfile(SCREEN_RC):
         rc_gen = ScreenRcGenerator(self)
         rc_contents = rc_gen.create(session_name, self._get_env())
         out_fn = sh.abspth(SCREEN_RC)
         LOG.info("Writing your created screen rc file to [%s]" % (out_fn))
         sh.write_file(out_fn, rc_contents)
     self._do_start(session_name, name, full_cmd)
     return run_trace.filename()
コード例 #3
0
 def _setup_cleaner(self):
     LOG.info("Configuring cleaner template %s.", CLEANER_DATA_CONF)
     (_, contents) = utils.load_template(self.component_name, CLEANER_DATA_CONF)
     tgt_fn = sh.joinpths(self.bindir, CLEANER_DATA_CONF)
     sh.write_file(tgt_fn, contents)
     sh.chmod(tgt_fn, 0755)
     self.tracewriter.file_touched(tgt_fn)
コード例 #4
0
 def _pre_run(self, instances, component_order):
     if not sh.isdir(self.directory):
         sh.mkdir(self.directory)
     loaded_rc_file = False
     if self.rc_file:
         try:
             if sh.isfile(self.rc_file):
                 LOG.info("Attempting to load rc file at [%s] which has your environment settings." % (self.rc_file))
                 am_loaded = env_rc.RcLoader().load(self.rc_file)
                 LOG.info("Loaded [%s] settings from rc file [%s]" % (am_loaded, self.rc_file))
                 loaded_rc_file = True
         except IOError:
             LOG.warn('Error reading rc file located at [%s]. Skipping loading it.' % (self.rc_file))
     LOG.info("Verifying that the components are ready to rock-n-roll.")
     for component in component_order:
         inst = instances[component]
         inst.verify()
     LOG.info("Warming up your component configurations (ie so you won't be prompted later)")
     for component in component_order:
         inst = instances[component]
         inst.warm_configs()
     if self.gen_rc and not loaded_rc_file and self.rc_file:
         LOG.info("Generating a file at [%s] that will contain your environment settings." % (self.rc_file))
         creator = env_rc.RcGenerator(self.cfg)
         contents = creator.generate()
         sh.write_file(self.rc_file, contents)
コード例 #5
0
 def _begin_start(self, name, program, args):
     fn_name = SCREEN_TEMPL % (name)
     tracefn = tr.touch_trace(self.trace_dir, fn_name)
     runtrace = tr.Trace(tracefn)
     runtrace.trace(TYPE, RUN_TYPE)
     runtrace.trace(NAME, name)
     runtrace.trace(ARGS, json.dumps(args))
     full_cmd = [program] + list(args)
     session_name = self._get_session()
     inited_screen = False
     if session_name is None:
         inited_screen = True
         self._do_screen_init()
         session_name = self._get_session()
         if session_name is None:
             msg = "After initializing screen with session named [%s], no screen session with that name was found!" % (SESSION_NAME)
             raise excp.StartException(msg)
     runtrace.trace(SESSION_ID, session_name)
     if inited_screen or not sh.isfile(SCREEN_RC):
         rc_gen = ScreenRcGenerator(self)
         rc_contents = rc_gen.create(session_name, self._get_env())
         out_fn = sh.abspth(SCREEN_RC)
         LOG.info("Writing your created screen rc file to [%s]" % (out_fn))
         sh.write_file(out_fn, rc_contents)
     self._do_start(session_name, name, full_cmd)
     return tracefn
コード例 #6
0
 def _config_fixups(self):
     #currently just handling rhel fixups
     #TODO: maybe this should be a subclass that handles these differences
     if not (self.distro in APACHE_FIXUPS_DISTROS):
         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()
     socket_fn = APACHE_FIXUPS.get("SOCKET_CONF")
     self.tracewriter.file_touched(socket_fn)
     #not recorded since we aren't really creating this
     httpd_fn = APACHE_FIXUPS.get("HTTPD_CONF")
     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(socket_fn, fc)
         #now adjust the run user and group (of httpd.conf)
         new_lines = list()
         for line in sh.load_file(httpd_fn).splitlines():
             if line.startswith("User "):
                 line = "User %s" % (user)
             if line.startswith("Group "):
                 line = "Group %s" % (group)
             new_lines.append(line)
         sh.write_file(httpd_fn, utils.joinlinesep(*new_lines))
コード例 #7
0
ファイル: nova.py プロジェクト: hagleitn/Openstack-Devstack2
 def _setup_cleaner(self):
     LOG.info("Configuring cleaner template %s.", CLEANER_DATA_CONF)
     (_, contents) = utils.load_template(self.component_name,
                                         CLEANER_DATA_CONF)
     tgt_fn = sh.joinpths(self.bin_dir, CLEANER_DATA_CONF)
     sh.write_file(tgt_fn, contents)
     sh.chmod(tgt_fn, 0755)
     self.tracewriter.file_touched(tgt_fn)
コード例 #8
0
 def _setup_initer(self):
     LOG.info("Configuring keystone initializer template %s.", MANAGE_DATA_CONF)
     (_, contents) = utils.load_template(self.component_name, MANAGE_DATA_CONF)
     params = self._get_param_map(MANAGE_DATA_CONF)
     contents = utils.param_replace(contents, params, True)
     tgt_fn = sh.joinpths(self.bindir, MANAGE_DATA_CONF)
     sh.write_file(tgt_fn, contents)
     sh.chmod(tgt_fn, 0755)
     self.tracewriter.file_touched(tgt_fn)
コード例 #9
0
 def _setup_network_initer(self):
     LOG.info("Configuring nova network initializer template %s.", NET_INIT_CONF)
     (_, contents) = utils.load_template(self.component_name, NET_INIT_CONF)
     params = self._get_param_map(NET_INIT_CONF)
     contents = utils.param_replace(contents, params, True)
     tgt_fn = sh.joinpths(self.bindir, NET_INIT_CONF)
     sh.write_file(tgt_fn, contents)
     sh.chmod(tgt_fn, 0755)
     self.tracewriter.file_touched(tgt_fn)
コード例 #10
0
 def _setup_initer(self):
     LOG.info("Configuring keystone initializer template %r", MANAGE_DATA_CONF)
     (_, contents) = utils.load_template(self.component_name, MANAGE_DATA_CONF)
     mp = self._get_param_map(MANAGE_DATA_CONF)
     contents = utils.param_replace(contents, mp, True)
     # FIXME, stop placing in checkout dir...
     tgt_fn = sh.joinpths(self.bin_dir, MANAGE_DATA_CONF)
     sh.write_file(tgt_fn, contents)
     sh.chmod(tgt_fn, 0755)
     self.tracewriter.file_touched(tgt_fn)
コード例 #11
0
 def _generate_nova_conf(self):
     LOG.info("Generating dynamic content for nova configuration (%s)." % (API_CONF))
     conf_gen = NovaConfConfigurator(self)
     nova_conf = conf_gen.configure()
     tgtfn = self._get_target_config_name(API_CONF)
     LOG.info("Writing nova configuration to %s" % (tgtfn))
     LOG.debug(nova_conf)
     self.tracewriter.make_dir(sh.dirname(tgtfn))
     sh.write_file(tgtfn, nova_conf)
     self.tracewriter.cfg_write(tgtfn)
コード例 #12
0
ファイル: nova.py プロジェクト: hagleitn/Openstack-Devstack2
 def _setup_network_initer(self):
     LOG.info("Configuring nova network initializer template %s.",
              NET_INIT_CONF)
     (_, contents) = utils.load_template(self.component_name, NET_INIT_CONF)
     params = self._get_param_map(NET_INIT_CONF)
     contents = utils.param_replace(contents, params, True)
     tgt_fn = sh.joinpths(self.bin_dir, NET_INIT_CONF)
     sh.write_file(tgt_fn, contents)
     sh.chmod(tgt_fn, 0755)
     self.tracewriter.file_touched(tgt_fn)
コード例 #13
0
 def _setup_initer(self):
     LOG.info("Configuring keystone initializer template %s.",
              MANAGE_DATA_CONF)
     (_, contents) = utils.load_template(self.component_name,
                                         MANAGE_DATA_CONF)
     params = self._get_param_map(MANAGE_DATA_CONF)
     contents = utils.param_replace(contents, params, True)
     tgt_fn = sh.joinpths(self.bin_dir, MANAGE_DATA_CONF)
     sh.write_file(tgt_fn, contents)
     sh.chmod(tgt_fn, 0755)
     self.tracewriter.file_touched(tgt_fn)
コード例 #14
0
 def _generate_paste_api_conf(self):
     LOG.info("Setting up %s" % (PASTE_CONF))
     mp = dict()
     mp['SERVICE_TOKEN'] = self.cfg.get("passwords", "service_token")
     (src_fn, contents) = self._get_source_config(PASTE_CONF)
     LOG.info("Replacing parameters in file %s" % (src_fn))
     LOG.debug("Replacements = %s" % (mp))
     contents = utils.param_replace(contents, mp, True)
     LOG.debug("Writing out to %s" % (self.paste_conf_fn))
     sh.write_file(self.paste_conf_fn, contents)
     self.tracewriter.cfg_write(self.paste_conf_fn)
コード例 #15
0
 def _configure_db_confs(self):
     LOG.info("Fixing up %r mysql configs.", self.distro.name)
     fc = sh.load_file('/etc/mysql/my.cnf')
     lines = fc.splitlines()
     new_lines = list()
     for line in lines:
         if line.startswith('bind-address'):
             line = 'bind-address = %s' % ('0.0.0.0')
         new_lines.append(line)
     fc = utils.joinlinesep(*new_lines)
     with sh.Rooted(True):
         sh.write_file('/etc/mysql/my.cnf', fc)
コード例 #16
0
 def _configure_db_confs(self):
     LOG.info("Fixing up %r mysql configs.", self.distro.name)
     fc = sh.load_file('/etc/my.cnf')
     lines = fc.splitlines()
     new_lines = list()
     for line in lines:
         if line.startswith('skip-grant-tables'):
             line = '#' + line
         new_lines.append(line)
     fc = utils.joinlinesep(*new_lines)
     with sh.Rooted(True):
         sh.write_file('/etc/my.cnf', fc)
コード例 #17
0
ファイル: rhel6.py プロジェクト: hagleitn/Openstack-Devstack2
 def _configure_db_confs(self):
     LOG.info("Fixing up %s mysql configs.", self.distro.name)
     fc = sh.load_file('/etc/my.cnf')
     lines = fc.splitlines()
     new_lines = list()
     for line in lines:
         if line.startswith('skip-grant-tables'):
             line = '#' + line
         new_lines.append(line)
     fc = utils.joinlinesep(*new_lines)
     with sh.Rooted(True):
         sh.write_file('/etc/my.cnf', fc)
コード例 #18
0
 def _configure_db_confs(self):
     LOG.info("Fixing up %s mysql configs.", self.distro.name)
     fc = sh.load_file('/etc/mysql/my.cnf')
     lines = fc.splitlines()
     new_lines = list()
     for line in lines:
         if line.startswith('bind-address'):
             line = 'bind-address = %s' % ('0.0.0.0')
         new_lines.append(line)
     fc = utils.joinlinesep(*new_lines)
     with sh.Rooted(True):
         sh.write_file('/etc/mysql/my.cnf', fc)
コード例 #19
0
 def _generate_nova_conf(self):
     LOG.debug("Generating dynamic content for nova configuration")
     dirs = dict()
     dirs['app'] = self.appdir
     dirs['cfg'] = self.cfgdir
     dirs['bin'] = self.bindir
     conf_gen = NovaConfigurator(self)
     nova_conf = conf_gen.configure(dirs)
     tgtfn = self._get_target_config_name(API_CONF)
     LOG.info("Writing conf to %s" % (tgtfn))
     LOG.info(nova_conf)
     sh.write_file(tgtfn, nova_conf)
     self.tracewriter.cfg_write(tgtfn)
コード例 #20
0
 def _install_python_setups(self):
     pydirs = self._get_python_directories()
     if pydirs:
         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))
             #do this before write just incase it craps out half way through
             self.tracewriter.file_touched(record_fn)
             self.tracewriter.py_install(name, record_fn, working_dir)
             #now actually do it
             (stdout, stderr) = sh.execute(*PY_INSTALL, cwd=working_dir, run_as_root=True)
             sh.write_file(record_fn, self._format_stderr_out(stderr, stdout))
コード例 #21
0
 def configure(self):
     configs_made = nova.NovaInstaller.configure(self)
     driver_canon = nova.canon_virt_driver(self.cfg.get("nova", "virt_driver"))
     if driver_canon == "libvirt":
         (fn, contents) = self._get_policy(self._get_policy_users())
         dirs_made = list()
         with sh.Rooted(True):
             # TODO check if this dir is restricted before assuming it isn't?
             dirs_made.extend(sh.mkdirslist(sh.dirname(fn)))
             sh.write_file(fn, contents)
         self.tracewriter.cfg_file_written(fn)
         self.tracewriter.dirs_made(*dirs_made)
         configs_made += 1
     return configs_made
コード例 #22
0
 def configure(self):
     configs_made = comp.PythonInstallComponent.configure(self)
     self._generate_nova_conf()
     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
コード例 #23
0
 def configure(self):
     configs_made = nova.NovaInstaller.configure(self)
     driver_canon = nova.canon_virt_driver(self.cfg.get('nova', 'virt_driver'))
     if driver_canon == 'libvirt':
         (fn, contents) = self._get_policy(self._get_policy_users())
         dirs_made = list()
         with sh.Rooted(True):
             # TODO check if this dir is restricted before assuming it isn't?
             dirs_made.extend(sh.mkdirslist(sh.dirname(fn)))
             sh.write_file(fn, contents)
         self.tracewriter.cfg_file_written(fn)
         self.tracewriter.dirs_made(*dirs_made)
         configs_made += 1
     return configs_made
コード例 #24
0
 def _fork_start(self, program, appdir, pid_fn, stdout_fn, stderr_fn, *args):
     #first child, not the real program
     pid = os.fork()
     if pid == 0:
         #upon return the calling process shall be the session
         #leader of this new session,
         #shall be the process group leader of a new process group,
         #and shall have no controlling terminal.
         os.setsid()
         pid = os.fork()
         #fork to get daemon out - this time under init control
         #and now fully detached (no shell possible)
         if pid == 0:
             #move to where application should be
             if appdir:
                 os.chdir(appdir)
             #close other fds
             limits = resource.getrlimit(resource.RLIMIT_NOFILE)
             mkfd = limits[1]
             if mkfd == resource.RLIM_INFINITY:
                 mkfd = MAXFD
             for fd in range(0, mkfd):
                 try:
                     os.close(fd)
                 except OSError:
                     #not open, thats ok
                     pass
             #now adjust stderr and stdout
             if stdout_fn:
                 stdoh = open(stdout_fn, "w")
                 os.dup2(stdoh.fileno(), sys.stdout.fileno())
             if stderr_fn:
                 stdeh = open(stderr_fn, "w")
                 os.dup2(stdeh.fileno(), sys.stderr.fileno())
             #now exec...
             #the arguments to the child process should
             #start with the name of the command being run
             prog_little = os.path.basename(program)
             actualargs = [prog_little] + list(args)
             os.execlp(program, *actualargs)
         else:
             #write out the child pid
             contents = str(pid) + os.linesep
             sh.write_file(pid_fn, contents, quiet=True)
             #not exit or sys.exit, this is recommended
             #since it will do the right cleanups that we want
             #not calling any atexit functions, which would
             #be bad right now
             os._exit(0)
コード例 #25
0
 def _setup_data(self):
     LOG.info("Configuring data setup template %s", MANAGE_DATA_CONF)
     (src_fn, contents) = utils.load_template(self.component_name, MANAGE_DATA_CONF)
     params = self._get_param_map(MANAGE_DATA_CONF)
     contents = utils.param_replace(contents, params, True)
     tgt_fn = sh.joinpths(self.bindir, MANAGE_DATA_CONF)
     sh.write_file(tgt_fn, contents)
     # This environment additions are important
     # in that they eventually affect how this script runs
     env = dict()
     env['ENABLED_SERVICES'] = ",".join(self.instances.keys())
     env['BIN_DIR'] = self.bindir
     setup_cmd = MANAGER_CMD_ROOT + [tgt_fn]
     LOG.info("Running (%s) command to setup keystone." % (" ".join(setup_cmd)))
     sh.execute(*setup_cmd, env_overrides=env)
コード例 #26
0
 def _do_upstart_configure(self, app_name, runtime_info):
     (app_pth, _, program_args) = runtime_info
     # TODO FIXME symlinks won't work. Need to copy the files there.
     # https://bugs.launchpad.net/upstart/+bug/665022
     cfg_fn = sh.joinpths(CONF_ROOT, app_name + CONF_EXT)
     if sh.isfile(cfg_fn):
         LOG.info("Upstart config file already exists: %s" % (cfg_fn))
         return
     LOG.debug("Loading upstart template to be used by: %s" % (cfg_fn))
     (_, contents) = utils.load_template('general', UPSTART_CONF_TMPL)
     params = self._get_upstart_conf_params(app_pth, app_name, *program_args)
     adjusted_contents = utils.param_replace(contents, params)
     LOG.debug("Generated up start config for %s: %s" % (app_name, adjusted_contents))
     with sh.Rooted(True):
         sh.write_file(cfg_fn, adjusted_contents)
         sh.chmod(cfg_fn, 0666)
コード例 #27
0
ファイル: nova.py プロジェクト: hagleitn/Openstack-Devstack2
 def configure(self):
     configs_made = comp.PythonInstallComponent.configure(self)
     self._generate_nova_conf()
     configs_made += 1
     driver_canon = _canon_virt_driver(self.cfg.get('nova', 'virt_driver'))
     # TODO maybe move this??
     if  driver_canon == 'libvirt' and self.distro.get_command('virt-policy', quiet=True):
         (fn, contents) = self.distro.get_command('virt-policy')
         dirs_made = list()
         with sh.Rooted(True):
             dirs_made = sh.mkdirslist(sh.dirname(fn))
             sh.write_file(fn, contents)
         self.tracewriter.dirs_made(*dirs_made)
         self.tracewriter.cfg_file_written(fn)
         configs_made += 1
     return configs_made
コード例 #28
0
 def _generate_nova_conf(self):
     conf_fn = self._get_target_config_name(API_CONF)
     LOG.info("Generating dynamic content for nova: %r" % (conf_fn))
     nova_conf_contents = self.conf_maker.configure()
     self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(conf_fn)))
     self.tracewriter.cfg_file_written(
         sh.write_file(conf_fn, nova_conf_contents))
コード例 #29
0
ファイル: nova.py プロジェクト: hagleitn/Openstack-Devstack2
 def configure(self):
     configs_made = comp.PythonInstallComponent.configure(self)
     self._generate_nova_conf()
     configs_made += 1
     driver_canon = _canon_virt_driver(self.cfg.get('nova', 'virt_driver'))
     # TODO maybe move this??
     if driver_canon == 'libvirt' and self.distro.get_command('virt-policy',
                                                              quiet=True):
         (fn, contents) = self.distro.get_command('virt-policy')
         dirs_made = list()
         with sh.Rooted(True):
             dirs_made = sh.mkdirslist(sh.dirname(fn))
             sh.write_file(fn, contents)
         self.tracewriter.dirs_made(*dirs_made)
         self.tracewriter.cfg_file_written(fn)
         configs_made += 1
     return configs_made
コード例 #30
0
 def post_start(self):
     tgt_fn = sh.joinpths(self.bindir, MANAGE_DATA_CONF)
     if sh.isfile(tgt_fn):
         #still there, run it
         #these environment additions are important
         #in that they eventually affect how this script runs
         LOG.info("Waiting %s seconds so that keystone can start up before running first time init." % (WAIT_ONLINE_TO))
         time.sleep(WAIT_ONLINE_TO)
         env = dict()
         env['ENABLED_SERVICES'] = ",".join(self.instances.keys())
         env['BIN_DIR'] = self.bindir
         setup_cmd = MANAGE_CMD_ROOT + [tgt_fn]
         LOG.info("Running (%s) command to initialize keystone." % (" ".join(setup_cmd)))
         (sysout, _) = sh.execute(*setup_cmd, env_overrides=env, run_as_root=False)
         if sysout:
             sh.write_file(sh.abspth(settings.EC2RC_FN), sysout.strip())
         LOG.debug("Removing (%s) file since we successfully initialized keystone." % (tgt_fn))
         sh.unlink(tgt_fn)
コード例 #31
0
ファイル: nova.py プロジェクト: hagleitn/Openstack-Devstack2
 def _generate_nova_conf(self):
     LOG.info("Generating dynamic content for nova configuration (%s)." % (API_CONF))
     conf_gen = NovaConfConfigurator(self)
     nova_conf_contents = conf_gen.configure()
     conf_fn = self._get_target_config_name(API_CONF)
     LOG.info("Writing nova configuration to %s" % (conf_fn))
     LOG.debug(nova_conf_contents)
     self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(conf_fn)))
     self.tracewriter.cfg_file_written(sh.write_file(conf_fn, nova_conf_contents))
コード例 #32
0
ファイル: rhel6.py プロジェクト: hagleitn/Openstack-Devstack2
 def _config_fixups(self):
     (user, group) = self._get_apache_user_group()
     # This is recorded so it gets cleaned up during uninstall
     self.tracewriter.file_touched(SOCKET_CONF)
     LOG.info("Fixing up %s and %s files" % (SOCKET_CONF, HTTPD_CONF))
     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(SOCKET_CONF, fc)
         # Now adjust the run user and group (of httpd.conf)
         new_lines = list()
         for line in sh.load_file(HTTPD_CONF).splitlines():
             if line.startswith("User "):
                 line = "User %s" % (user)
             if line.startswith("Group "):
                 line = "Group %s" % (group)
             new_lines.append(line)
         sh.write_file(HTTPD_CONF, utils.joinlinesep(*new_lines))
コード例 #33
0
 def _config_fixups(self):
     (user, group) = self._get_apache_user_group()
     # This is recorded so it gets cleaned up during uninstall
     self.tracewriter.file_touched(SOCKET_CONF)
     LOG.info("Fixing up %r and %r files" % (SOCKET_CONF, HTTPD_CONF))
     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(SOCKET_CONF, fc)
         # Now adjust the run user and group (of httpd.conf)
         new_lines = list()
         for line in sh.load_file(HTTPD_CONF).splitlines():
             if line.startswith("User "):
                 line = "User %s" % (user)
             if line.startswith("Group "):
                 line = "Group %s" % (group)
             new_lines.append(line)
         sh.write_file(HTTPD_CONF, utils.joinlinesep(*new_lines))
コード例 #34
0
 def _do_upstart_configure(self, app_name, runtime_info):
     (app_pth, _, program_args) = runtime_info
     # TODO FIXME symlinks won't work. Need to copy the files there.
     # https://bugs.launchpad.net/upstart/+bug/665022
     cfg_fn = sh.joinpths(CONF_ROOT, app_name + CONF_EXT)
     if sh.isfile(cfg_fn):
         LOG.debug("Upstart config file already exists: %s" % (cfg_fn))
         return
     LOG.debug("Loading upstart template to be used by: %s" % (cfg_fn))
     (_, contents) = utils.load_template('general', UPSTART_CONF_TMPL)
     params = self._get_upstart_conf_params(app_pth, app_name,
                                            *program_args)
     adjusted_contents = utils.param_replace(contents, params)
     LOG.debug("Generated up start config for %s: %s" %
               (app_name, adjusted_contents))
     with sh.Rooted(True):
         sh.write_file(cfg_fn, adjusted_contents)
         sh.chmod(cfg_fn, 0666)
コード例 #35
0
ファイル: nova.py プロジェクト: hagleitn/Openstack-Devstack2
 def _generate_nova_conf(self):
     LOG.info("Generating dynamic content for nova configuration (%s)." %
              (API_CONF))
     conf_gen = NovaConfConfigurator(self)
     nova_conf_contents = conf_gen.configure()
     conf_fn = self._get_target_config_name(API_CONF)
     LOG.info("Writing nova configuration to %s" % (conf_fn))
     LOG.debug(nova_conf_contents)
     self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(conf_fn)))
     self.tracewriter.cfg_file_written(
         sh.write_file(conf_fn, nova_conf_contents))
コード例 #36
0
 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)
             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)
             sh.write_file(record_fn, self._format_stderr_out(stderr, stdout))
             self.tracewriter.py_install(name, record_fn, working_dir)
コード例 #37
0
 def _configure_files(self):
     configs = self._get_config_files()
     if configs:
         LOG.info("Configuring %s files" % (len(configs)))
         for fn in configs:
             #get the params and where it should come from and where it should go
             parameters = self._get_param_map(fn)
             tgtfn = self._get_target_config_name(fn)
             #ensure directory is there (if not created previously)
             self.tracewriter.make_dir(sh.dirname(tgtfn))
             #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("Replacements = %s" % (parameters))
             contents = utils.param_replace(contents, parameters)
             LOG.debug("Applying side-effects of param replacement for template %s" % (sourcefn))
             contents = self._config_adjust(contents, fn)
             LOG.info("Writing configuration file %s" % (tgtfn))
             #this trace is used to remove the files configured
             sh.write_file(tgtfn, contents)
             self.tracewriter.cfg_write(tgtfn)
     return len(configs)
コード例 #38
0
 def _config_fixups(self):
     #currently just handling rhel fixups
     #TODO: maybe this should be a subclass that handles these differences
     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_FIXUPS.get("SOCKET_CONF"), fc)
         #now adjust the run user and group
         fc = sh.load_file(RHEL_FIXUPS.get("HTTPD_CONF"))
         lines = fc.splitlines()
         new_lines = list()
         for line in lines:
             if line.startswith("User "):
                 line = "User %s" % (user)
             if line.startswith("Group "):
                 line = "Group %s" % (group)
             new_lines.append(line)
         fc = utils.joinlinesep(*new_lines)
         sh.write_file(RHEL_FIXUPS.get("HTTPD_CONF"), fc)
コード例 #39
0
 def _configure_files(self):
     config_fns = self._get_config_files()
     if config_fns:
         utils.log_iterable(config_fns, logger=LOG,
             header="Configuring %s files" % (len(config_fns)))
         for fn in config_fns:
             tgt_fn = self._get_target_config_name(fn)
             self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(tgt_fn)))
             LOG.info("Configuring file %r", fn)
             (source_fn, contents) = self._get_source_config(fn)
             LOG.debug("Replacing parameters in file %r", source_fn)
             contents = self._config_param_replace(fn, contents, self._get_param_map(fn))
             LOG.debug("Applying final adjustments in file %r", source_fn)
             contents = self._config_adjust(contents, fn)
             LOG.info("Writing configuration file %r => %r", source_fn, tgt_fn)
             self.tracewriter.cfg_file_written(sh.write_file(tgt_fn, contents))
     return len(config_fns)
コード例 #40
0
 def _configure_files(self):
     configs = self._get_config_files()
     if configs:
         LOG.info("Configuring %s files", len(configs))
         for fn in configs:
             parameters = self._get_param_map(fn)
             tgt_fn = self._get_target_config_name(fn)
             self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(tgt_fn)))
             LOG.info("Configuring file %s", fn)
             (source_fn, contents) = self._get_source_config(fn)
             LOG.debug("Replacing parameters in file %s", source_fn)
             LOG.debug("Replacements = %s", parameters)
             contents = utils.param_replace(contents, parameters)
             LOG.debug("Applying side-effects of param replacement for template %s", source_fn)
             contents = self._config_adjust(contents, fn)
             LOG.info("Writing configuration file %s", tgt_fn)
             self.tracewriter.cfg_file_written(sh.write_file(tgt_fn, contents))
     return len(configs)
コード例 #41
0
 def _configure_files(self):
     configs = self._get_config_files()
     if configs:
         LOG.info("Configuring %s files", len(configs))
         for fn in configs:
             parameters = self._get_param_map(fn)
             tgt_fn = self._get_target_config_name(fn)
             self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(tgt_fn)))
             LOG.info("Configuring file %s", fn)
             (source_fn, contents) = self._get_source_config(fn)
             LOG.debug("Replacing parameters in file %s", source_fn)
             LOG.debug("Replacements = %s", parameters)
             contents = utils.param_replace(contents, parameters)
             LOG.debug(
                 "Applying side-effects of param replacement for template %s",
                 source_fn)
             contents = self._config_adjust(contents, fn)
             LOG.info("Writing configuration file %s", tgt_fn)
             self.tracewriter.cfg_file_written(
                 sh.write_file(tgt_fn, contents))
     return len(configs)
コード例 #42
0
 def write(self, fn):
     contents = utils.joinlinesep(*self._generate_lines())
     sh.write_file(fn, contents)
コード例 #43
0
 def write(self, fn):
     contents = utils.joinlinesep(*self._generate_lines())
     sh.write_file(fn, contents)
コード例 #44
0
 def _generate_nova_conf(self):
     conf_fn = self._get_target_config_name(API_CONF)
     LOG.info("Generating dynamic content for nova: %r" % (conf_fn))
     nova_conf_contents = self.conf_maker.configure()
     self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(conf_fn)))
     self.tracewriter.cfg_file_written(sh.write_file(conf_fn, nova_conf_contents))