Example #1
0
def _find_resource_elements_for_operation(env, name, allow_multiple):
    booth_element_list = resource.find_for_config(
        get_resources(env.get_cib()),
        get_config_file_name(name),
    )

    if not booth_element_list:
        raise LibraryError(booth_reports.booth_not_exists_in_cib(name))

    if len(booth_element_list) > 1:
        if not allow_multiple:
            raise LibraryError(booth_reports.booth_multiple_times_in_cib(name))
        env.report_processor.process(
            booth_reports.booth_multiple_times_in_cib(
                name,
                severity=ReportItemSeverity.WARNING,
            ))

    return booth_element_list
Example #2
0
File: booth.py Project: wyatt88/pcs
def remove_from_cluster(env, name, resource_remove):
    #TODO resource_remove is provisional hack until resources are not moved to
    #lib
    try:
        num_of_removed_booth_resources = resource.get_remover(resource_remove)(
            get_resources(env.get_cib()),
            get_config_file_name(name),
        )
        if num_of_removed_booth_resources > 1:
            env.report_processor.process(
                booth_reports.booth_multiple_times_in_cib(
                    name,
                    severity=ReportItemSeverity.WARNING,
                )
            )
    except resource.BoothNotFoundInCib:
        raise LibraryError(booth_reports.booth_not_exists_in_cib(name))
    except resource.BoothMultipleOccurenceFoundInCib:
        raise LibraryError(booth_reports.booth_multiple_times_in_cib(name))
Example #3
0
def _find_resource_elements_for_operation(env, name, allow_multiple):
    booth_element_list = resource.find_for_config(
        get_resources(env.get_cib()),
        get_config_file_name(name),
    )

    if not booth_element_list:
        raise LibraryError(booth_reports.booth_not_exists_in_cib(name))

    if len(booth_element_list) > 1:
        if not allow_multiple:
            raise LibraryError(booth_reports.booth_multiple_times_in_cib(name))
        env.report_processor.process(
            booth_reports.booth_multiple_times_in_cib(
                name,
                severity=ReportItemSeverity.WARNING,
            )
        )

    return booth_element_list
Example #4
0
def _find_resource_elements_for_operation(report_processor, resources_section,
                                          booth_env, allow_multiple):
    booth_element_list = resource.find_for_config(
        resources_section,
        booth_env.config_path,
    )

    if not booth_element_list:
        report_processor.report(
            booth_reports.booth_not_exists_in_cib(booth_env.instance_name))
    elif len(booth_element_list) > 1:
        report_processor.report(
            booth_reports.booth_multiple_times_in_cib(
                booth_env.instance_name,
                severity=(ReportItemSeverity.WARNING
                          if allow_multiple else ReportItemSeverity.ERROR)))
    if report_processor.has_errors:
        raise LibraryError()

    return booth_element_list
Example #5
0
 def test_success(self):
     self.assert_message_from_report(
         "found more than one booth instance 'name' in cib",
         reports.booth_multiple_times_in_cib("name"))