def test_keep_values_if_is_not_pair(self): self.assertEqual({ "first": "A", "second": "B", }, validate.pairs_to_values({ "first": "A", "second": "B", }))
def test_extract_normalized_values(self): self.assertEqual( {"first": "aaa", "second": "B",}, validate.pairs_to_values( { "first": validate.ValuePair(original="A", normalized="aaa"), "second": "B", } ), )
def _normalized_to_operations(normalized_pairs, new_role_names_supported): def _replace_role(op_dict): if "role" in op_dict: op_dict["role"] = pacemaker.role.get_value_for_cib( op_dict["role"], new_role_names_supported) return op_dict return [ _replace_role(validate.pairs_to_values(op)) for op in normalized_pairs ]
def test_keep_values_if_is_not_pair(self): self.assertEqual( { "first": "A", "second": "B", }, validate.pairs_to_values( { "first": "A", "second": "B", } ) )
def _normalized_to_operations( normalized_pairs: Iterable[validate.TypeOptionNormalizedMap], new_role_names_supported: bool, ) -> List[ResourceOperationFilteredOut]: def _replace_role(op_dict): if "role" in op_dict: op_dict["role"] = pacemaker.role.get_value_for_cib( op_dict["role"], new_role_names_supported) return op_dict return [ _replace_role(validate.pairs_to_values(op)) for op in normalized_pairs ]
def prepare( report_processor, raw_operation_list, default_operation_list, allowed_operation_name_list, allow_invalid=False ): """ Return operation_list prepared from raw_operation_list and default_operation_list. report_processor is tool for warning/info/error reporting list of dicts raw_operation_list are entered operations that require follow-up care list of dicts default_operation_list are operations defined as default by (most probably) resource agent bool allow_invalid is flag for validation skipping """ operations_to_validate = [ validate.values_to_pairs(op, normalize) for op in raw_operation_list ] report_list = [] options_validators = OPERATION_OPTIONS_VALIDATORS + [ validate.value_in( "name", allowed_operation_name_list, option_name_for_report="operation name", code_to_allow_extra_values=report_codes.FORCE_OPTIONS, allow_extra_values=allow_invalid, ) ] for operation in operations_to_validate: report_list.extend( validate_operation(operation, options_validators) ) operation_list = [ validate.pairs_to_values(op) for op in operations_to_validate ] report_list.extend(validate_different_intervals(operation_list)) #can raise LibraryError report_processor.process_list(report_list) return complete_all_intervals(operation_list) + get_remaining_defaults( report_processor, operation_list, default_operation_list )
def test_extract_normalized_values(self): self.assertEqual( { "first": "aaa", "second": "B", }, validate.pairs_to_values( { "first": validate.ValuePair( original="A", normalized="aaa" ), "second": "B", } ) )
def normalized_to_operations(normalized_pairs): return [validate.pairs_to_values(op) for op in normalized_pairs]