コード例 #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 _get_source_config(self, config_fn):
     if config_fn == POLICY_JSON:
         fn = sh.joinpths(self.cfg_dir, POLICY_JSON)
         contents = sh.load_file(fn)
         return (fn, contents)
     elif config_fn == LOGGING_CONF:
         fn = sh.joinpths(self.cfg_dir, LOGGING_SOURCE_FN)
         contents = sh.load_file(fn)
         return (fn, contents)
     return comp.PythonInstallComponent._get_source_config(self, config_fn)
コード例 #3
0
 def _get_source_config(self, config_fn):
     if config_fn == POLICY_JSON:
         fn = sh.joinpths(self.cfgdir, POLICY_JSON)
         contents = sh.load_file(fn)
         return (fn, contents)
     elif config_fn == LOGGING_CONF:
         fn = sh.joinpths(self.cfgdir, LOGGING_SOURCE_FN)
         contents = sh.load_file(fn)
         return (fn, contents)
     return comp.PythonInstallComponent._get_source_config(self, config_fn)
コード例 #4
0
 def _get_source_config(self, config_fn):
     if config_fn == PLUGIN_CONF:
         srcfn = sh.joinpths(self.app_dir, 'etc', config_fn)
         contents = sh.load_file(srcfn)
         return (srcfn, contents)
     elif config_fn == AGENT_CONF:
         # WHY U SO BURIED....
         srcfn = sh.joinpths(self.app_dir, 'etc', 'quantum', 'plugins', 'openvswitch', config_fn)
         contents = sh.load_file(srcfn)
         return (srcfn, contents)
     else:
         return comp.PkgInstallComponent._get_source_config(self, config_fn)
コード例 #5
0
 def _get_source_config(self, config_fn):
     if config_fn == POLICY_JSON:
         # FIXME, maybe we shouldn't be sucking this from the checkout??
         fn = sh.joinpths(self.app_dir, 'etc', POLICY_JSON)
         contents = sh.load_file(fn)
         return (fn, contents)
     elif config_fn == LOGGING_CONF:
         # FIXME, maybe we shouldn't be sucking this from the checkout??
         fn = sh.joinpths(self.app_dir, 'etc', LOGGING_SOURCE_FN)
         contents = sh.load_file(fn)
         return (fn, contents)
     return comp.PythonInstallComponent._get_source_config(self, config_fn)
コード例 #6
0
 def _get_source_config(self, config_fn):
     if config_fn == PLUGIN_CONF:
         srcfn = sh.joinpths(self.app_dir, "etc", config_fn)
         contents = sh.load_file(srcfn)
         return (srcfn, contents)
     elif config_fn == AGENT_CONF:
         # WHY U SO BURIED....
         srcfn = sh.joinpths(self.app_dir, "etc", "quantum", "plugins", "openvswitch", config_fn)
         contents = sh.load_file(srcfn)
         return (srcfn, contents)
     else:
         return comp.PkgInstallComponent._get_source_config(self, config_fn)
コード例 #7
0
 def _get_source_config(self, config_fn):
     if config_fn == PLUGIN_CONF:
         srcloc = [self.appdir] + PLUGIN_LOC + [config_fn]
         srcfn = sh.joinpths(*srcloc)
         contents = sh.load_file(srcfn)
         return (srcfn, contents)
     elif config_fn == AGENT_CONF:
         srcloc = [self.appdir] + AGENT_LOC + [config_fn]
         srcfn = sh.joinpths(*srcloc)
         contents = sh.load_file(srcfn)
         return (srcfn, contents)
     else:
         return comp.PkgInstallComponent._get_source_config(self, config_fn)
コード例 #8
0
 def _get_source_config(self, config_fn):
     if config_fn == PLUGIN_CONF:
         srcloc = [self.app_dir] + PLUGIN_LOC + [config_fn]
         srcfn = sh.joinpths(*srcloc)
         contents = sh.load_file(srcfn)
         return (srcfn, contents)
     elif config_fn == AGENT_CONF:
         srcloc = [self.app_dir] + AGENT_LOC + [config_fn]
         srcfn = sh.joinpths(*srcloc)
         contents = sh.load_file(srcfn)
         return (srcfn, contents)
     else:
         return comp.PkgInstallComponent._get_source_config(self, config_fn)
コード例 #9
0
 def _get_source_config(self, config_fn):
     if config_fn == PASTE_CONF:
         config_fn = PASTE_SOURCE_FN
     elif config_fn == LOGGING_CONF:
         config_fn = LOGGING_SOURCE_FN
     fn = sh.joinpths(self.app_dir, 'etc', "nova", config_fn)
     return (fn, sh.load_file(fn))
コード例 #10
0
 def stop(self, app_name):
     with sh.Rooted(ROOT_GO):
         if not sh.isdir(self.trace_dir):
             msg = "No trace directory found from which to stop %s" % (app_name)
             raise excp.StopException(msg)
         fn_name = FORK_TEMPL % (app_name)
         (pid_file, stderr_fn, stdout_fn) = self._form_file_names(fn_name)
         trace_fn = tr.trace_fn(self.trace_dir, fn_name)
         if sh.isfile(pid_file) and sh.isfile(trace_fn):
             pid = int(sh.load_file(pid_file).strip())
             (killed, attempts) = self._stop_pid(pid)
             # Trash the files if it worked
             if killed:
                 LOG.debug("Killed pid %s after %s attempts" % (pid, attempts))
                 LOG.debug("Removing pid file %s" % (pid_file))
                 sh.unlink(pid_file)
                 LOG.debug("Removing stderr file %s" % (stderr_fn))
                 sh.unlink(stderr_fn)
                 LOG.debug("Removing stdout file %s" % (stdout_fn))
                 sh.unlink(stdout_fn)
                 LOG.debug("Removing %s trace file %s" % (app_name, trace_fn))
                 sh.unlink(trace_fn)
             else:
                 msg = "Could not stop %s after %s attempts" % (app_name, attempts)
                 raise excp.StopException(msg)
         else:
             msg = "No pid or trace file could be found to stop %s in directory %s" % (app_name, self.trace_dir)
             raise excp.StopException(msg)
コード例 #11
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))
コード例 #12
0
 def _get_source_config(self, config_fn):
     if config_fn == PASTE_CONF:
         config_fn = PASTE_SOURCE_FN
     elif config_fn == LOGGING_CONF:
         config_fn = LOGGING_SOURCE_FN
     fn = sh.joinpths(self.app_dir, 'etc', "nova", config_fn)
     return (fn, sh.load_file(fn))
コード例 #13
0
 def _get_source_config(self, config_fn):
     if config_fn == ROOT_CONF:
         # FIXME, maybe we shouldn't be sucking this from the checkout??
         fn = sh.joinpths(self.app_dir, 'etc', 'melange', config_fn)
         contents = sh.load_file(fn)
         return (fn, contents)
     return comp.PythonInstallComponent._get_source_config(self, config_fn)
コード例 #14
0
 def _get_source_config(self, config_fn):
     if config_fn == ROOT_CONF:
         srcfn = sh.joinpths(self.cfg_dir, config_fn)
         contents = sh.load_file(srcfn)
         return (srcfn, contents)
     else:
         return comp.PythonInstallComponent._get_source_config(self, config_fn)
コード例 #15
0
 def stop(self, name, *args, **kargs):
     with sh.Rooted(kargs.get("run_as_root", True)):
         trace_dir = kargs.get("trace_dir")
         if not trace_dir or not sh.isdir(trace_dir):
             msg = "No trace directory found from which to stop %s" % (name)
             raise excp.StopException(msg)
         fn_name = FORK_TEMPL % (name)
         (pid_file, stderr_fn, stdout_fn) = self._form_file_names(trace_dir, fn_name)
         trace_fn = tr.trace_fn(trace_dir, fn_name)
         if sh.isfile(pid_file) and sh.isfile(trace_fn):
             pid = int(sh.load_file(pid_file).strip())
             (killed, attempts) = self._stop_pid(pid)
             #trash the files
             if killed:
                 LOG.debug("Killed pid %s after %s attempts" % (pid, attempts))
                 LOG.debug("Removing pid file %s" % (pid_file))
                 sh.unlink(pid_file)
                 LOG.debug("Removing stderr file %s" % (stderr_fn))
                 sh.unlink(stderr_fn)
                 LOG.debug("Removing stdout file %s" % (stdout_fn))
                 sh.unlink(stdout_fn)
                 LOG.debug("Removing %s trace file %s" % (name, trace_fn))
                 sh.unlink(trace_fn)
             else:
                 msg = "Could not stop %s after %s attempts" % (name, attempts)
                 raise excp.StopException(msg)
         else:
             msg = "No pid or trace file could be found to stop %s in directory %s" % (name, trace_dir)
             raise excp.StopException(msg)
コード例 #16
0
 def _get_source_config(self, config_fn):
     if config_fn == ROOT_CONF:
         srcfn = sh.joinpths(self.cfgdir, config_fn)
         contents = sh.load_file(srcfn)
         return (srcfn, contents)
     else:
         return comp.PythonInstallComponent._get_source_config(self, config_fn)
コード例 #17
0
 def _get_source_config(self, config_fn):
     if config_fn == PASTE_CONF:
         #this is named differently than what it will be stored as... arg...
         srcfn = sh.joinpths(self.appdir, "etc", "nova", 'api-paste.ini')
         contents = sh.load_file(srcfn)
         return (srcfn, contents)
     else:
         return comp.PythonInstallComponent._get_source_config(self, config_fn)
コード例 #18
0
 def _get_source_config(self, config_fn):
     if config_fn == PASTE_CONF:
         return comp.PythonInstallComponent._get_source_config(self, PASTE_SOURCE_FN)
     if config_fn == LOGGING_CONF:
         config_fn = LOGGING_SOURCE_FN
     # FIXME, maybe we shouldn't be sucking these from checked out code?
     fn = sh.joinpths(self.app_dir, 'etc', "nova", config_fn)
     contents = sh.load_file(fn)
     return (fn, contents)
コード例 #19
0
 def _get_source_config(self, config_fn):
     if config_fn == CATALOG_CONF:
         return comp.PythonInstallComponent._get_source_config(self, config_fn)
     else:
         real_fn = config_fn
         if config_fn == LOGGING_CONF:
             real_fn = LOGGING_SOURCE_FN
         fn = sh.joinpths(self.app_dir, 'etc', real_fn)
         return (fn, sh.load_file(fn))
コード例 #20
0
 def _get_source_config(self, config_fn):
     name = config_fn
     if config_fn == PASTE_CONF:
         name = PASTE_SOURCE_FN
     elif config_fn == LOGGING_CONF:
         name = LOGGING_SOURCE_FN
     srcfn = sh.joinpths(self.cfgdir, "nova", name)
     contents = sh.load_file(srcfn)
     return (srcfn, contents)
コード例 #21
0
 def _get_source_config(self, config_fn):
     if config_fn == CATALOG_CONF:
         return comp.PythonInstallComponent._get_source_config(
             self, config_fn)
     else:
         real_fn = config_fn
         if config_fn == LOGGING_CONF:
             real_fn = LOGGING_SOURCE_FN
         fn = sh.joinpths(self.app_dir, 'etc', real_fn)
         return (fn, sh.load_file(fn))
コード例 #22
0
def load_json(fn):
    data = sh.load_file(fn)
    lines = data.splitlines()
    new_lines = list()
    for line in lines:
        if line.lstrip().startswith('#'):
            continue
        new_lines.append(line)
    data = joinlinesep(*new_lines)
    return json.loads(data)
コード例 #23
0
ファイル: nova.py プロジェクト: hagleitn/Openstack-Devstack2
 def _get_source_config(self, config_fn):
     name = config_fn
     if config_fn == PASTE_CONF:
         # Return the paste api template
         return comp.PythonInstallComponent._get_source_config(self, PASTE_SOURCE_FN)
     elif config_fn == LOGGING_CONF:
         name = LOGGING_SOURCE_FN
     srcfn = sh.joinpths(self.cfg_dir, "nova", name)
     contents = sh.load_file(srcfn)
     return (srcfn, contents)
コード例 #24
0
 def _get_source_config(self, config_fn):
     if config_fn == API_CONF:
         (fn, top) = utils.load_template(self.component_name, API_CONF)
         (_, bottom) = self._get_source_config(API_PASTE_CONF)
         combined = [top, "### Joined here on %s with file %s" % (date.rcf8222date(), API_PASTE_CONF), bottom]
         return (fn, utils.joinlinesep(*combined))
     elif config_fn == REG_CONF:
         (fn, top) = utils.load_template(self.component_name, REG_CONF)
         (_, bottom) = self._get_source_config(REG_PASTE_CONF)
         combined = [top, "### Joined here on %s with file %s" % (date.rcf8222date(), REG_PASTE_CONF), bottom]
         return (fn, utils.joinlinesep(*combined))
     elif config_fn == POLICY_JSON:
         fn = sh.joinpths(self.cfgdir, POLICY_JSON)
         contents = sh.load_file(fn)
         return (fn, contents)
     elif config_fn == LOGGING_CONF:
         fn = sh.joinpths(self.cfgdir, LOGGING_SOURCE_FN)
         contents = sh.load_file(fn)
         return (fn, contents)
     return comp.PythonInstallComponent._get_source_config(self, config_fn)
コード例 #25
0
ファイル: nova.py プロジェクト: hagleitn/Openstack-Devstack2
 def _get_source_config(self, config_fn):
     name = config_fn
     if config_fn == PASTE_CONF:
         # Return the paste api template
         return comp.PythonInstallComponent._get_source_config(
             self, PASTE_SOURCE_FN)
     elif config_fn == LOGGING_CONF:
         name = LOGGING_SOURCE_FN
     srcfn = sh.joinpths(self.cfg_dir, "nova", name)
     contents = sh.load_file(srcfn)
     return (srcfn, contents)
コード例 #26
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)
コード例 #27
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)
コード例 #28
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)
コード例 #29
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)
コード例 #30
0
def parse_fn(fn):
    if not sh.isfile(fn):
        msg = "No trace found at filename %s" % (fn)
        raise excp.NoTraceException(msg)
    contents = sh.load_file(fn)
    lines = contents.splitlines()
    accum = list()
    for line in lines:
        ep = split_line(line)
        if ep is None:
            continue
        accum.append(tuple(ep))
    return accum
コード例 #31
0
 def _parse(self):
     fn = self.trace_fn
     if not sh.isfile(fn):
         msg = "No trace found at filename %s" % (fn)
         raise excp.NoTraceException(msg)
     contents = sh.load_file(fn)
     lines = contents.splitlines()
     accum = list()
     for line in lines:
         ep = self._split_line(line)
         if ep is None:
             continue
         accum.append(tuple(ep))
     return accum
コード例 #32
0
 def extract(self, fn):
     extracted_vars = dict()
     contents = sh.load_file(fn)
     for line in contents.splitlines():
         if line.lstrip().startswith("#"):
             continue
         m = EXP_PAT.search(line)
         if m:
             key = m.group(1).strip()
             value = m.group(2).strip()
             quoted_mtch = QUOTED_PAT.match(value)
             if quoted_mtch:
                 value = quoted_mtch.group(1).decode('string_escape').strip()
             extracted_vars[key] = value
     return extracted_vars
コード例 #33
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))
コード例 #34
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))
コード例 #35
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)
コード例 #36
0
ファイル: utils.py プロジェクト: hagleitn/Openstack-Devstack2
def load_template(component, template_name):
    full_pth = sh.joinpths(settings.STACK_TEMPLATE_DIR, component,
                           template_name)
    contents = sh.load_file(full_pth)
    return (full_pth, contents)
コード例 #37
0
def load_template(component, fn):
    actual_fn = fn + TEMPLATE_EXT
    full_pth = os.path.join(settings.STACK_CONFIG_DIR, component, actual_fn)
    contents = sh.load_file(full_pth)
    return (full_pth, contents)
コード例 #38
0
 def _get_source_config(self, config_fn):
     real_fn = config_fn
     if config_fn == LOGGING_CONF:
         real_fn = LOGGING_SOURCE_FN
     fn = sh.joinpths(self.app_dir, 'etc', real_fn)
     return (fn, sh.load_file(fn))
コード例 #39
0
def read(rootdir, name):
    pth = trace_fn(rootdir, name)
    contents = sh.load_file(pth)
    lines = contents.splitlines()
    return lines
コード例 #40
0
def load_template(component, template_name):
    templ_pth = sh.joinpths(settings.STACK_TEMPLATE_DIR, component, template_name)
    return (templ_pth, sh.load_file(templ_pth))
コード例 #41
0
def load_template(component, fn):
    full_pth = sh.joinpths(settings.STACK_CONFIG_DIR, component, fn + TEMPLATE_EXT)
    contents = sh.load_file(full_pth)
    return (full_pth, contents)
コード例 #42
0
def load_template(component, template_name):
    full_pth = sh.joinpths(settings.STACK_TEMPLATE_DIR, component, template_name)
    contents = sh.load_file(full_pth)
    return (full_pth, contents)
コード例 #43
0
 def _get_source_config(self, config_fn):
     real_fn = config_fn
     if config_fn == LOGGING_CONF:
         real_fn = LOGGING_SOURCE_FN
     fn = sh.joinpths(self.app_dir, 'etc', real_fn)
     return (fn, sh.load_file(fn))
コード例 #44
0
def load_template(component, template_name):
    templ_pth = sh.joinpths(settings.STACK_TEMPLATE_DIR, component,
                            template_name)
    return (templ_pth, sh.load_file(templ_pth))