def admin_token(config): try: path = os.path.join(config['dir'], 'keystone.conf') keystone_ini = utils.parse_openstack_ini(path) path = os.path.join(config['dir'], 'keystone-paste.ini') paste_ini = utils.parse_openstack_ini(path) except EnvironmentError: return TestResult(Result.SKIP, 'cannot read keystone config files') keystone_req = { "DEFAULT.admin_token": {"disallowed": "*"}, } keystone_res = utils.verify_config("keystone.conf", keystone_ini, keystone_req, needs_parsing=False) paste_req = { "filter:admin_token_auth.AdminTokenAuthMiddleware": {"disallowed": "*"} } paste_res = utils.verify_config("keystone-paste.ini", paste_ini, paste_req, needs_parsing=False) result = GroupTestResult() for res in keystone_res: result.add_result(res[0], res[1]) for res in paste_res: result.add_result(res[0], res[1]) return result
def _check_svc_config(req): """Return a TestResult based on whether the specified service config requirement is met. Since a service config requirement may include multiple settings in a single config file, this will check all requirements individually, and return a list of TestResults. :param req: Requirement specification (one entry from the config file) :return: A list of name, TestResult tuples to add to the group test result """ # the options to check are the items in the requirement other than the name # and config file checked_options = {} for r in req: if r not in ['name', 'config']: checked_options[r] = req[r] config_lines = _read_svc_config(req['config']) if config_lines is None: return [(req['name'], TestResult( Result.SKIP, "Unable to open config file { " + req['config'] + " }"))] return utils.verify_config(req['name'], config_lines, checked_options)
def safe_config(expected_config): if not os.path.exists(CONFIG_PATH): return TestResult(Result.SKIP, "MySQL config not found") try: config_lines = _get_full_config(CONFIG_PATH) except IOError: return TestResult(Result.FAIL, "MySQL config could not be read") results = GroupTestResult() for test, res in utils.verify_config( CONFIG_PATH, config_lines, expected_config, keyval_delim='='): results.add_result(test, res) return results
def safe_config(expected_config): if not os.path.exists(CONFIG_PATH): return TestResult(Result.SKIP, "MySQL config not found") try: config_lines = _get_full_config(CONFIG_PATH) except IOError: return TestResult(Result.FAIL, "MySQL config could not be read") results = GroupTestResult() for test, res in utils.verify_config(CONFIG_PATH, config_lines, expected_config, keyval_delim='='): results.add_result(test, res) return results
def body_size(): try: keystone_ini = _parse_openstack_ini('/etc/keystone/keystone.conf') except EnvironmentError: return TestResult(Result.SKIP, 'cannot read keystone config files') keystone_req = { "DEFAULT.max_request_body_size": {"allowed": "*"}, } keystone_res = utils.verify_config("keystone.conf", keystone_ini, keystone_req, needs_parsing=False) result = GroupTestResult() for res in keystone_res: result.add_result(res[0], res[1]) return result
def php_ini(ini_paths): results = GroupTestResult() for set_name, config_set in ini_paths.items(): inis = _find_all_inis(config_set) if not inis: logger.warning('no php config paths found for %s', set_name) results.add_result(set_name, TestResult(Result.SKIP, 'config not found')) continue config = {} for ini in inis: config = _parse_php_config(ini, config) for test, res in utils.verify_config( set_name, config, config_set['options'], needs_parsing=False): results.add_result(test, res) return results
def php_ini(ini_paths): results = GroupTestResult() for set_name, config_set in ini_paths.items(): inis = _find_all_inis(config_set) if not inis: logger.warning('no php config paths found for %s', set_name) results.add_result(set_name, TestResult(Result.SKIP, 'config not found')) continue config = {} for ini in inis: config = _parse_php_config(ini, config) for test, res in utils.verify_config(set_name, config, config_set['options'], needs_parsing=False): results.add_result(test, res) return results
def _check_svc_config(req): """Return a TestResult based on whether the specified service config requirement is met. Since a service config requirement may include multiple settings in a single config file, this will check all requirements individually, and return a list of TestResults. :param req: Requirement specification (one entry from the config file) :return: A list of name, TestResult tuples to add to the group test result """ # the options to check are the items in the requirement other than the name # and config file checked_options = {} for r in req: if r not in ['name', 'config']: checked_options[r] = req[r] config_lines = _read_svc_config(req['config']) if config_lines is None: return [(req['name'], TestResult(Result.SKIP, "Unable to open config file { " + req['config'] + " }"))] return utils.verify_config(req['name'], config_lines, checked_options)