Ejemplo n.º 1
0
 def test_returns_true_for_equivalent_new_role_new_roles_supported(self):
     self.assertTrue(
         ticket.get_duplicit_checker_callback(True)(
             self.first,
             self.second.update({"rsc-role": const.PCMK_ROLE_PROMOTED}),
         )
     )
Ejemplo n.º 2
0
def create(
    env,
    ticket_key,
    resource_id,
    options,
    resource_in_clone_alowed=False,
    duplication_alowed=False,
):
    """
    create ticket constraint
    string ticket_key ticket for constraining resource
    dict options desired constraint attributes
    bool resource_in_clone_alowed flag for allowing to reference id which is
        in tag clone or master
    bool duplication_alowed flag for allowing create duplicate element
    callable duplicate_check takes two elements and decide if they are
        duplicates
    """
    cib = env.get_cib()

    options = ticket.prepare_options_plain(
        cib,
        env.report_processor,
        options,
        ticket_key,
        constraint.find_valid_resource_id(env.report_processor, cib,
                                          resource_in_clone_alowed,
                                          resource_id),
    )

    constraint_section = get_constraints(cib)
    constraint_element = ticket.create_plain(constraint_section, options)

    constraint.check_is_without_duplication(
        env.report_processor,
        constraint_section,
        constraint_element,
        are_duplicate=ticket.get_duplicit_checker_callback(
            are_new_role_names_supported(constraint_section)),
        export_element=constraint.export_plain,
        duplication_alowed=duplication_alowed,
    )

    env.push_cib()
Ejemplo n.º 3
0
 def test_returns_false_for_different_elements(self):
     self.second.update({"ticket": "X", "rsc": "Y", "rsc-role": "Z"})
     self.assertFalse(
         ticket.get_duplicit_checker_callback(False)(self.first,
                                                     self.second))
Ejemplo n.º 4
0
 def test_returns_false_for_different_role(self):
     self.assertFalse(
         ticket.get_duplicit_checker_callback(False)(
             self.first, self.second.update({"rsc-role": "Z"})))
Ejemplo n.º 5
0
 def test_returns_true_for_duplicate_elements(self):
     self.assertTrue(
         ticket.get_duplicit_checker_callback(False)(self.first,
                                                     self.second))