示例#1
0
def test_nothing_then_bad(current_actor_context):
    bad_config = MultipathConfig(pathname='all_bad.conf',
                                 default_path_checker='directio',
                                 reassign_maps=True,
                                 default_detect_checker=False,
                                 default_detect_prio=False,
                                 default_retain_hwhandler=False)
    none_config = MultipathConfig(pathname='none.conf')
    facts = MultipathConfFacts(configs=[none_config, bad_config])

    current_actor_context.feed(facts)
    current_actor_context.run()
    reports = list(current_actor_context.consume(Report))
    assert reports and len(reports) == 3
    _assert_default_checker_report(reports[0].report, 'all_bad.conf')
    _assert_default_detect_report(reports[1].report, 'all_bad.conf')
    _assert_reassign_maps(reports[2].report, 'all_bad.conf')
示例#2
0
def test_bad_then_good(current_actor_context):
    bad_config = MultipathConfig(pathname='all_bad.conf',
                                 default_path_checker='directio',
                                 reassign_maps=True,
                                 default_detect_checker=False,
                                 default_detect_prio=False,
                                 default_retain_hwhandler=False)
    good_config = MultipathConfig(pathname='all_good.conf',
                                  default_path_checker='tur',
                                  reassign_maps=False,
                                  default_detect_checker=True,
                                  default_detect_prio=True,
                                  default_retain_hwhandler=True)
    facts = MultipathConfFacts(configs=[bad_config, good_config])

    current_actor_context.feed(facts)
    current_actor_context.run()
    assert not current_actor_context.consume(Report)
示例#3
0
def test_different_files(current_actor_context):
    bad_detect_checker_config = MultipathConfig(
        pathname='bad_detect_checker.conf', default_detect_checker=False)
    bad_detect_prio_config = MultipathConfig(pathname='bad_detect_prio.conf',
                                             default_detect_prio=False)
    bad_retain_hwhandler_config = MultipathConfig(
        pathname='bad_retain_hwhandler.conf', default_retain_hwhandler=False)
    facts = MultipathConfFacts(configs=[
        bad_detect_checker_config, bad_detect_prio_config,
        bad_retain_hwhandler_config
    ])

    current_actor_context.feed(facts)
    current_actor_context.run()
    reports = list(current_actor_context.consume(Report))
    assert reports and len(reports) == 1
    _assert_default_detect_report(
        reports[0].report, 'bad_detect_checker.conf, bad_detect_prio.conf and '
        'bad_retain_hwhandler.conf')
示例#4
0
def test_only_bad_reassign(current_actor_context):
    bad_reassign_config = MultipathConfig(pathname='bad_reassign.conf',
                                          reassign_maps=True)
    facts = MultipathConfFacts(configs=[bad_reassign_config])

    current_actor_context.feed(facts)
    current_actor_context.run()
    reports = list(current_actor_context.consume(Report))
    assert reports and len(reports) == 1
    _assert_reassign_maps(reports[0].report, 'bad_reassign.conf')
示例#5
0
def test_only_bad_detect(current_actor_context):
    bad_detect_config = MultipathConfig(pathname='bad_detect.conf',
                                        default_detect_prio=True,
                                        default_detect_checker=False)
    facts = MultipathConfFacts(configs=[bad_detect_config])

    current_actor_context.feed(facts)
    current_actor_context.run()
    reports = list(current_actor_context.consume(Report))
    assert reports and len(reports) == 1
    _assert_default_detect_report(reports[0].report, 'bad_detect.conf')
示例#6
0
def test_only_bad_checker(current_actor_context):
    bad_checker_config = MultipathConfig(pathname='bad_checker.conf',
                                         default_path_checker='rdac',
                                         default_retain_hwhandler=True)
    facts = MultipathConfFacts(configs=[bad_checker_config])

    current_actor_context.feed(facts)
    current_actor_context.run()
    reports = list(current_actor_context.consume(Report))
    assert reports and len(reports) == 1
    _assert_default_checker_report(reports[0].report, 'bad_checker.conf')
示例#7
0
def test_config_unimportant(current_actor_context):
    option = MultipathConfigOption(name='path_checker', value='rdac')
    config = MultipathConfig(pathname='unimportant.conf',
                             hw_str_match_exists=True,
                             ignore_new_boot_devs_exists=True,
                             new_bindings_in_boot_exists=True,
                             unpriv_sgio_exists=True,
                             detect_path_checker_exists=True,
                             overrides_hwhandler_exists=True,
                             overrides_pg_timeout_exists=True,
                             queue_if_no_path_exists=True,
                             all_devs_section_exists=True,
                             all_devs_options=[option])
    facts = MultipathConfFacts(configs=[config])

    current_actor_context.feed(facts)
    current_actor_context.run()
    assert not current_actor_context.consume(Report)
示例#8
0
def build_config(val):
    all_devs_options_val = []
    for name_val, value_val in val[16]:
        option = MultipathConfigOption(name=name_val, value=value_val)
        all_devs_options_val.append(option)
    return MultipathConfig(pathname=val[0],
                           default_path_checker=val[1],
                           config_dir=val[2],
                           default_retain_hwhandler=val[3],
                           default_detect_prio=val[4],
                           default_detect_checker=val[5],
                           reassign_maps=val[6],
                           hw_str_match_exists=val[7],
                           ignore_new_boot_devs_exists=val[8],
                           new_bindings_in_boot_exists=val[9],
                           unpriv_sgio_exists=val[10],
                           detect_path_checker_exists=val[11],
                           overrides_hwhandler_exists=val[12],
                           overrides_pg_timeout_exists=val[13],
                           queue_if_no_path_exists=val[14],
                           all_devs_section_exists=val[15],
                           all_devs_options=all_devs_options_val)
示例#9
0
def _parse_config(path):
    contents = multipathutil.read_config(path)
    if contents is None:
        return None
    conf = MultipathConfig(pathname=path)
    conf.all_devs_options = []
    section = None
    in_subsection = False
    device_options = []
    overrides_options = []
    in_all_devs = False
    for line in contents.split('\n'):
        try:
            data = multipathutil.LineData(line, section, in_subsection)
        except ValueError:
            continue
        if data.type == data.TYPE_BLANK:
            continue
        if data.type == data.TYPE_SECTION_END:
            if in_subsection:
                in_subsection = False
                if in_all_devs:
                    _add_options(conf.all_devs_options, device_options)
                in_all_devs = False
                device_options = []
            elif section:
                section = None
            continue
        if data.type == data.TYPE_SECTION_START:
            if not section:
                section = data.section
            elif not in_subsection:
                in_subsection = True
            continue
        if data.type != data.TYPE_OPTION:
            continue
        if section == 'defaults':
            if data.option == 'path_checker' or data.option == 'checker':
                conf.default_path_checker = data.value
            elif data.option == 'config_dir':
                conf.config_dir = data.value
            elif data.option == 'retain_attached_hw_handler':
                conf.default_retain_hwhandler = data.is_enabled()
            elif data.option == 'detect_prio':
                conf.default_detect_prio = data.is_enabled()
            elif data.option == 'detect_path_checker':
                conf.default_detect_checker = data.is_enabled()
            elif data.option == 'reassign_maps':
                conf.reassign_maps = data.is_enabled()
            elif data.option == 'hw_str_match':
                conf.hw_str_match_exists = True
            elif data.option == 'ignore_new_boot_devs':
                conf.ignore_new_boot_devs_exists = True
            elif data.option == 'new_bindings_in_boot':
                conf.new_bindings_in_boot_exists = True
        if section == 'devices' and in_subsection:
            if data.option == 'all_devs' and data.is_enabled():
                conf.all_devs_section_exists = True
                in_all_devs = True
            else:
                device_options.append((data.option, data.value))
        if section == 'overrides':
            if data.option == 'hardware_handler':
                conf.overrides_hwhandler_exists = True
            elif data.option == 'pg_timeout':
                conf.overrides_pg_timeout_exists = True
            else:
                overrides_options.append((data.option, data.value))
        if data.option == 'unpriv_sgio':
            conf.unpriv_sgio_exists = True
        if data.option == 'detect_path_checker':
            conf.detect_path_checker_exists = True
        if data.option == 'features' and 'queue_if_no_path' in data.value:
            conf.queue_if_no_path_exists = True

    if in_subsection and in_all_devs:
        _add_options(conf.all_devs_options, device_options)
    _fix_qinp_options(conf.all_devs_options)
    _filter_options(conf.all_devs_options, overrides_options)
    return conf