Exemple #1
0
 def test_expired(self):
     for tag, nvtype in self.tag_type:
         with self.subTest(tag=tag, nvset_type=nvtype):
             xml = etree.fromstring(
                 f"""
                 <{tag} id="my-id" score="150">
                     <rule id="my-id-rule" boolean-op="and">
                         <rsc_expression
                             id="my-id-rule-rsc-ocf-pacemaker-Dummy"
                             class="ocf" provider="pacemaker" type="Dummy"
                         />
                     </rule>
                     <nvpair id="my-id-pair1" name="name1" value="value1" />
                 </{tag}>
             """
             )
             self.assertEqual(
                 nvpair_multi.nvset_element_to_dto(
                     xml,
                     get_in_effect_eval(
                         {"my-id-rule": CibRuleInEffectStatus.EXPIRED}
                     ),
                 ),
                 CibNvsetDto(
                     "my-id",
                     nvtype,
                     {"score": "150"},
                     CibRuleExpressionDto(
                         "my-id-rule",
                         CibRuleExpressionType.RULE,
                         CibRuleInEffectStatus.EXPIRED,
                         {"boolean-op": "and"},
                         None,
                         None,
                         [
                             CibRuleExpressionDto(
                                 "my-id-rule-rsc-ocf-pacemaker-Dummy",
                                 CibRuleExpressionType.RSC_EXPRESSION,
                                 CibRuleInEffectStatus.UNKNOWN,
                                 {
                                     "class": "ocf",
                                     "provider": "pacemaker",
                                     "type": "Dummy",
                                 },
                                 None,
                                 None,
                                 [],
                                 "resource ocf:pacemaker:Dummy",
                             ),
                         ],
                         "resource ocf:pacemaker:Dummy",
                     ),
                     [CibNvpairDto("my-id-pair1", "name1", "value1")],
                 ),
             )
Exemple #2
0
 def test_success(self):
     test_data = [
         # ((class, provider, type), output)
         ((None, None, None), "::"),
         (("ocf", None, None), "ocf::"),
         ((None, "pacemaker", None), ":pacemaker:"),
         ((None, None, "Dummy"), "::Dummy"),
         (("ocf", "pacemaker", None), "ocf:pacemaker:"),
         (("ocf", None, "Dummy"), "ocf::Dummy"),
         ((None, "pacemaker", "Dummy"), ":pacemaker:Dummy"),
         (("ocf", "pacemaker", "Dummy"), "ocf:pacemaker:Dummy"),
     ]
     for in_data, out_data in test_data:
         with self.subTest(in_data=in_data):
             attrs = {}
             if in_data[0] is not None:
                 attrs["class"] = in_data[0]
             if in_data[1] is not None:
                 attrs["provider"] = in_data[1]
             if in_data[2] is not None:
                 attrs["type"] = in_data[2]
             attrs_str = " ".join(
                 [f"{name}='{value}'" for name, value in attrs.items()])
             xml = etree.fromstring(f"""
                 <rule id="my-id">
                     <rsc_expression id="my-id-expr" {attrs_str}/>
                 </rule>
             """)
             self.assertEqual(
                 rule_element_to_dto(get_in_effect_eval(), xml),
                 CibRuleExpressionDto(
                     "my-id",
                     CibRuleExpressionType.RULE,
                     CibRuleInEffectStatus.UNKNOWN,
                     {},
                     None,
                     None,
                     [
                         CibRuleExpressionDto(
                             "my-id-expr",
                             CibRuleExpressionType.RSC_EXPRESSION,
                             CibRuleInEffectStatus.UNKNOWN,
                             attrs,
                             None,
                             None,
                             [],
                             f"resource {out_data}",
                         ),
                     ],
                     f"resource {out_data}",
                 ),
             )
Exemple #3
0
def _rule_to_dto(rule_el: Element) -> CibRuleExpressionDto:
    children_dto_list = [
        _tag_to_export[child.tag](child)
        # The xpath method has a complicated return value, but we know our xpath
        # expression only returns elements.
        for child in cast(Element,
                          cast(_Element, rule_el).xpath(_xpath_for_export))
    ]
    # "and" is a documented pacemaker default
    # https://clusterlabs.org/pacemaker/doc/en-US/Pacemaker/2.0/html-single/Pacemaker_Explained/index.html#_rule_properties
    boolean_op = rule_el.get("boolean-op", "and")
    string_parts = []
    for child_dto in children_dto_list:
        if child_dto.type == CibRuleExpressionType.RULE:
            string_parts.append(f"({child_dto.as_string})")
        else:
            string_parts.append(child_dto.as_string)
    return CibRuleExpressionDto(
        rule_el.get("id", ""),
        _tag_to_type[rule_el.tag],
        False,  # TODO implement is_expired
        export_attributes(rule_el, with_id=False),
        None,
        None,
        children_dto_list,
        f" {boolean_op} ".join(string_parts),
    )
Exemple #4
0
 def test_full(self):
     for tag, nvtype in self.tag_type:
         with self.subTest(tag=tag, nvset_type=nvtype):
             xml = etree.fromstring(f"""
                 <{tag} id="my-id" score="150">
                     <rule id="my-id-rule" boolean-op="or">
                         <op_expression id="my-id-rule-op" name="monitor" />
                     </rule>
                     <nvpair id="my-id-pair1" name="name1" value="value1" />
                     <nvpair id="my-id-pair2" name="name2" value="value2" />
                 </{tag}>
             """)
             self.assertEqual(
                 nvpair_multi.nvset_element_to_dto(xml),
                 CibNvsetDto(
                     "my-id",
                     nvtype,
                     {"score": "150"},
                     CibRuleExpressionDto(
                         "my-id-rule",
                         CibRuleExpressionType.RULE,
                         False,
                         {"boolean-op": "or"},
                         None,
                         None,
                         [
                             CibRuleExpressionDto(
                                 "my-id-rule-op",
                                 CibRuleExpressionType.OP_EXPRESSION,
                                 False,
                                 {"name": "monitor"},
                                 None,
                                 None,
                                 [],
                                 "op monitor",
                             ),
                         ],
                         "op monitor",
                     ),
                     [
                         CibNvpairDto("my-id-pair1", "name1", "value1"),
                         CibNvpairDto("my-id-pair2", "name2", "value2"),
                     ],
                 ),
             )
Exemple #5
0
 def test_full(self):
     for nvtype, label in type_to_label:
         with self.subTest(nvset_type=nvtype, label=label):
             dto = CibNvsetDto(
                 "my-id",
                 nvtype,
                 {"score": "150"},
                 CibRuleExpressionDto(
                     "my-id-rule",
                     CibRuleExpressionType.RULE,
                     CibRuleInEffectStatus.UNKNOWN,
                     {"boolean-op": "or"},
                     None,
                     None,
                     [
                         CibRuleExpressionDto(
                             "my-id-rule-op",
                             CibRuleExpressionType.OP_EXPRESSION,
                             CibRuleInEffectStatus.UNKNOWN,
                             {"name": "monitor"},
                             None,
                             None,
                             [],
                             "op monitor",
                         ),
                     ],
                     "op monitor",
                 ),
                 [
                     CibNvpairDto("my-id-pair1", "name1", "value1"),
                     CibNvpairDto("my-id-pair2", "name 2", "value 2"),
                     CibNvpairDto("my-id-pair3", "name=3", "value=3"),
                 ],
             )
             output = dedent(f"""\
                 {label}: my-id score=150
                   "name 2"="value 2"
                   name1=value1
                   "name=3"="value=3"
                   Rule: boolean-op=or (id:my-id-rule)
                     Expression: op monitor (id:my-id-rule-op)
                 """)
             self.assert_lines(dto, output)
Exemple #6
0
 def _common_expr_to_dto(self, expr_el: _Element) -> CibRuleExpressionDto:
     return CibRuleExpressionDto(
         str(expr_el.get("id", "")),
         self._tag_to_type[str(expr_el.tag)],
         CibRuleInEffectStatus.UNKNOWN,
         export_attributes(expr_el, with_id=False),
         None,
         None,
         [],
         self._str_eval.get_str(expr_el),
     )
Exemple #7
0
 def test_datespec(self):
     xml = etree.fromstring("""
         <rule id="rule">
             <date_expression id="rule-expr" operation="date_spec">
                 <date_spec id="rule-expr-datespec"
                     hours="1-14" monthdays="20-30" months="1"
                 />
             </date_expression>
         </rule>
     """)
     self.assertEqual(
         rule_element_to_dto(get_in_effect_eval(), xml),
         CibRuleExpressionDto(
             "rule",
             CibRuleExpressionType.RULE,
             CibRuleInEffectStatus.UNKNOWN,
             {},
             None,
             None,
             [
                 CibRuleExpressionDto(
                     "rule-expr",
                     CibRuleExpressionType.DATE_EXPRESSION,
                     CibRuleInEffectStatus.UNKNOWN,
                     {"operation": "date_spec"},
                     CibRuleDateCommonDto(
                         "rule-expr-datespec",
                         {
                             "hours": "1-14",
                             "monthdays": "20-30",
                             "months": "1",
                         },
                     ),
                     None,
                     [],
                     "date-spec hours=1-14 monthdays=20-30 months=1",
                 ),
             ],
             "date-spec hours=1-14 monthdays=20-30 months=1",
         ),
     )
Exemple #8
0
def _common_expr_to_dto(expr_el: Element,
                        as_string: str) -> CibRuleExpressionDto:
    return CibRuleExpressionDto(
        expr_el.get("id", ""),
        _tag_to_type[expr_el.tag],
        False,
        export_attributes(expr_el, with_id=False),
        None,
        None,
        [],
        as_string,
    )
Exemple #9
0
 def test_inrange_start_duration(self):
     xml = etree.fromstring("""
         <rule id="rule">
             <date_expression id="rule-expr"
                 operation="in_range" start="2014-06-26"
             >
                 <duration id="rule-expr-duration" years="1"/>
             </date_expression>
         </rule>
     """)
     self.assertEqual(
         rule_element_to_dto(get_in_effect_eval(), xml),
         CibRuleExpressionDto(
             "rule",
             CibRuleExpressionType.RULE,
             CibRuleInEffectStatus.UNKNOWN,
             {},
             None,
             None,
             [
                 CibRuleExpressionDto(
                     "rule-expr",
                     CibRuleExpressionType.DATE_EXPRESSION,
                     CibRuleInEffectStatus.UNKNOWN,
                     {
                         "operation": "in_range",
                         "start": "2014-06-26",
                     },
                     None,
                     CibRuleDateCommonDto(
                         "rule-expr-duration",
                         {"years": "1"},
                     ),
                     [],
                     "date in_range 2014-06-26 to duration years=1",
                 ),
             ],
             "date in_range 2014-06-26 to duration years=1",
         ),
     )
Exemple #10
0
 def _date_expr_to_dto(self, expr_el: _Element) -> CibRuleExpressionDto:
     date_spec = expr_el.find("./date_spec")
     duration = expr_el.find("./duration")
     return CibRuleExpressionDto(
         str(expr_el.get("id", "")),
         self._tag_to_type[str(expr_el.tag)],
         CibRuleInEffectStatus.UNKNOWN,
         export_attributes(expr_el, with_id=False),
         None if date_spec is None else self._date_common_to_dto(date_spec),
         None if duration is None else self._date_common_to_dto(duration),
         [],
         self._str_eval.get_str(expr_el),
     )
Exemple #11
0
 def fixture_dto(expired):
     return CibRuleExpressionDto(
         "my-id",
         CibRuleExpressionType.RULE,
         expired,
         {},
         None,
         None,
         [
             CibRuleExpressionDto(
                 "my-id-expr",
                 CibRuleExpressionType.EXPRESSION,
                 CibRuleInEffectStatus.UNKNOWN,
                 {"attribute": "pingd", "operation": "defined"},
                 None,
                 None,
                 [],
                 "defined pingd",
             ),
         ],
         "defined pingd",
     )
Exemple #12
0
 def test_value_comparison_with_type(self):
     xml = etree.fromstring("""
         <rule id="my-id">
             <expression id="my-id-expr"
                 attribute="foo" operation="gt" type="version" value="1.2.3"
             />
         </rule>
     """)
     self.assertEqual(
         rule_element_to_dto(get_in_effect_eval(), xml),
         CibRuleExpressionDto(
             "my-id",
             CibRuleExpressionType.RULE,
             CibRuleInEffectStatus.UNKNOWN,
             {},
             None,
             None,
             [
                 CibRuleExpressionDto(
                     "my-id-expr",
                     CibRuleExpressionType.EXPRESSION,
                     CibRuleInEffectStatus.UNKNOWN,
                     {
                         "attribute": "foo",
                         "operation": "gt",
                         "type": "version",
                         "value": "1.2.3",
                     },
                     None,
                     None,
                     [],
                     "foo gt version 1.2.3",
                 ),
             ],
             "foo gt version 1.2.3",
         ),
     )
Exemple #13
0
 def test_value_comparison(self):
     xml = etree.fromstring("""
         <rule id="my-id">
             <expression id="my-id-expr"
                 attribute="my-attr" operation="eq" value="my value"
             />
         </rule>
     """)
     self.assertEqual(
         rule_element_to_dto(get_in_effect_eval(), xml),
         CibRuleExpressionDto(
             "my-id",
             CibRuleExpressionType.RULE,
             CibRuleInEffectStatus.UNKNOWN,
             {},
             None,
             None,
             [
                 CibRuleExpressionDto(
                     "my-id-expr",
                     CibRuleExpressionType.EXPRESSION,
                     CibRuleInEffectStatus.UNKNOWN,
                     {
                         "attribute": "my-attr",
                         "operation": "eq",
                         "value": "my value",
                     },
                     None,
                     None,
                     [],
                     'my-attr eq "my value"',
                 ),
             ],
             'my-attr eq "my value"',
         ),
     )
Exemple #14
0
 def test_inrange(self):
     xml = etree.fromstring("""
         <rule id="rule">
             <date_expression id="rule-expr"
                 operation="in_range" start="2014-06-26" end="2014-07-26"
             />
         </rule>
     """)
     self.assertEqual(
         rule_element_to_dto(xml),
         CibRuleExpressionDto(
             "rule",
             CibRuleExpressionType.RULE,
             False,
             {},
             None,
             None,
             [
                 CibRuleExpressionDto(
                     "rule-expr",
                     CibRuleExpressionType.DATE_EXPRESSION,
                     False,
                     {
                         "operation": "in_range",
                         "start": "2014-06-26",
                         "end": "2014-07-26",
                     },
                     None,
                     None,
                     [],
                     "date in_range 2014-06-26 to 2014-07-26",
                 ),
             ],
             "date in_range 2014-06-26 to 2014-07-26",
         ),
     )
Exemple #15
0
 def _rule_to_dto(self, rule_el: _Element) -> CibRuleExpressionDto:
     children_dto_list = [
         self._tag_to_export[str(child.tag)](self, child)
         # The xpath method has a complicated return value, but we know our
         # xpath expression only returns elements.
         for child in cast(_Element, rule_el.xpath(self._xpath_for_export))
     ]
     rule_id = str(rule_el.get("id", ""))
     return CibRuleExpressionDto(
         rule_id,
         self._tag_to_type[str(rule_el.tag)],
         self._in_effect_eval.get_rule_status(rule_id),
         export_attributes(rule_el, with_id=False),
         None,
         None,
         children_dto_list,
         self._str_eval.get_str(rule_el),
     )
Exemple #16
0
def _date_expr_to_dto(expr_el: Element) -> CibRuleExpressionDto:
    date_spec = expr_el.find("./date_spec")
    duration = expr_el.find("./duration")

    string_parts = []
    # "operation" is defined as mandatory in CIB schema
    operation = expr_el.get("operation", "")
    if operation == "date_spec":
        string_parts.append("date-spec")
        if date_spec is not None:
            string_parts.append(_attrs_to_str(date_spec))
    elif operation == "in_range":
        string_parts.extend(["date", "in_range"])
        # CIB schema allows "start" + "duration" or optional "start" + "end"
        if "start" in expr_el.attrib:
            string_parts.extend([expr_el.get("start", ""), "to"])
        if "end" in expr_el.attrib:
            string_parts.append(expr_el.get("end", ""))
        if duration is not None:
            string_parts.append("duration")
            string_parts.append(_attrs_to_str(duration))
    else:
        # CIB schema allows operation=="gt" + "start" or operation=="lt" + "end"
        string_parts.extend(["date", expr_el.get("operation", "")])
        if "start" in expr_el.attrib:
            string_parts.append(expr_el.get("start", ""))
        if "end" in expr_el.attrib:
            string_parts.append(expr_el.get("end", ""))

    return CibRuleExpressionDto(
        expr_el.get("id", ""),
        _tag_to_type[expr_el.tag],
        False,
        export_attributes(expr_el, with_id=False),
        None if date_spec is None else _date_common_to_dto(date_spec),
        None if duration is None else _date_common_to_dto(duration),
        [],
        " ".join(string_parts),
    )
Exemple #17
0
 def test_full(self):
     defaults_xml = f"""
         <{self.tag}>
             <meta_attributes id="{self.tag}-meta_attributes">
                 <rule id="{self.tag}-meta_attributes-rule"
                     boolean-op="and" score="INFINITY"
                 >
                     <rsc_expression
                         id="{self.tag}-meta_attributes-rule-rsc-Dummy"
                         class="ocf" provider="pacemaker" type="Dummy"
                     />
                 </rule>
                 <nvpair id="my-id-pair1" name="name1" value="value1" />
                 <nvpair id="my-id-pair2" name="name2" value="value2" />
             </meta_attributes>
             <instance_attributes id="instance">
                 <nvpair id="instance-pair" name="inst" value="ance" />
             </instance_attributes>
             <meta_attributes id="meta-plain" score="123">
                 <nvpair id="my-id-pair3" name="name1" value="value1" />
             </meta_attributes>
         </{self.tag}>
     """
     self.config.runner.cib.load(filename="cib-empty-3.4.xml",
                                 optional_in_conf=defaults_xml)
     self.assertEqual(
         [
             CibNvsetDto(
                 f"{self.tag}-meta_attributes",
                 CibNvsetType.META,
                 {},
                 CibRuleExpressionDto(
                     f"{self.tag}-meta_attributes-rule",
                     CibRuleExpressionType.RULE,
                     False,
                     {
                         "boolean-op": "and",
                         "score": "INFINITY"
                     },
                     None,
                     None,
                     [
                         CibRuleExpressionDto(
                             f"{self.tag}-meta_attributes-rule-rsc-Dummy",
                             CibRuleExpressionType.RSC_EXPRESSION,
                             False,
                             {
                                 "class": "ocf",
                                 "provider": "pacemaker",
                                 "type": "Dummy",
                             },
                             None,
                             None,
                             [],
                             "resource ocf:pacemaker:Dummy",
                         ),
                     ],
                     "resource ocf:pacemaker:Dummy",
                 ),
                 [
                     CibNvpairDto("my-id-pair1", "name1", "value1"),
                     CibNvpairDto("my-id-pair2", "name2", "value2"),
                 ],
             ),
             CibNvsetDto(
                 "instance",
                 CibNvsetType.INSTANCE,
                 {},
                 None,
                 [CibNvpairDto("instance-pair", "inst", "ance")],
             ),
             CibNvsetDto(
                 "meta-plain",
                 CibNvsetType.META,
                 {"score": "123"},
                 None,
                 [CibNvpairDto("my-id-pair3", "name1", "value1")],
             ),
         ],
         self.command(self.env_assist.get_env()),
     )
Exemple #18
0
 def test_complex_rule(self):
     dto = CibRuleExpressionDto(
         "complex",
         CibRuleExpressionType.RULE,
         CibRuleInEffectStatus.UNKNOWN,
         {"boolean-op": "or", "score": "INFINITY"},
         None,
         None,
         [
             CibRuleExpressionDto(
                 "complex-rule-1",
                 CibRuleExpressionType.RULE,
                 CibRuleInEffectStatus.UNKNOWN,
                 {"boolean-op": "and", "score": "0"},
                 None,
                 None,
                 [
                     CibRuleExpressionDto(
                         "complex-rule-1-expr",
                         CibRuleExpressionType.DATE_EXPRESSION,
                         CibRuleInEffectStatus.UNKNOWN,
                         {"operation": "date_spec"},
                         CibRuleDateCommonDto(
                             "complex-rule-1-expr-datespec",
                             {"hours": "12-23", "weekdays": "1-5"},
                         ),
                         None,
                         [],
                         "date-spec hours=12-23 weekdays=1-5",
                     ),
                     CibRuleExpressionDto(
                         "complex-rule-1-expr-1",
                         CibRuleExpressionType.DATE_EXPRESSION,
                         CibRuleInEffectStatus.UNKNOWN,
                         {
                             "operation": "in_range",
                             "start": "2014-07-26",
                         },
                         None,
                         CibRuleDateCommonDto(
                             "complex-rule-1-expr-1-durat",
                             {"months": "1"},
                         ),
                         [],
                         "date in_range 2014-07-26 to duration months=1",
                     ),
                 ],
                 "date-spec hours=12-23 weekdays=1-5 and date in_range "
                 "2014-07-26 to duration months=1",
             ),
             CibRuleExpressionDto(
                 "complex-rule",
                 CibRuleExpressionType.RULE,
                 CibRuleInEffectStatus.UNKNOWN,
                 {"boolean-op": "and", "score": "0"},
                 None,
                 None,
                 [
                     CibRuleExpressionDto(
                         "complex-rule-expr-1",
                         CibRuleExpressionType.EXPRESSION,
                         CibRuleInEffectStatus.UNKNOWN,
                         {
                             "attribute": "foo",
                             "operation": "gt",
                             "type": "version",
                             "value": "1.2",
                         },
                         None,
                         None,
                         [],
                         "foo gt version 1.2",
                     ),
                     CibRuleExpressionDto(
                         "complex-rule-expr",
                         CibRuleExpressionType.EXPRESSION,
                         CibRuleInEffectStatus.UNKNOWN,
                         {
                             "attribute": "#uname",
                             "operation": "eq",
                             "value": "node3 4",
                         },
                         None,
                         None,
                         [],
                         "#uname eq 'node3 4'",
                     ),
                     CibRuleExpressionDto(
                         "complex-rule-expr-2",
                         CibRuleExpressionType.EXPRESSION,
                         CibRuleInEffectStatus.UNKNOWN,
                         {
                             "attribute": "#uname",
                             "operation": "eq",
                             "value": "nodeA",
                         },
                         None,
                         None,
                         [],
                         "#uname eq nodeA",
                     ),
                 ],
                 "foo gt version 1.2 and #uname eq 'node3 4' and #uname "
                 "eq nodeA",
             ),
         ],
         "(date-spec hours=12-23 weekdays=1-5 and date in_range "
         "2014-07-26 to duration months=1) or (foo gt version 1.2 and "
         "#uname eq 'node3 4' and #uname eq nodeA)",
     )
     output = dedent(
         """\
         Rule: boolean-op=or score=INFINITY (id:complex)
           Rule: boolean-op=and score=0 (id:complex-rule-1)
             Expression: (id:complex-rule-1-expr)
               Date Spec: hours=12-23 weekdays=1-5 (id:complex-rule-1-expr-datespec)
             Expression: date in_range 2014-07-26 to duration (id:complex-rule-1-expr-1)
               Duration: months=1 (id:complex-rule-1-expr-1-durat)
           Rule: boolean-op=and score=0 (id:complex-rule)
             Expression: foo gt version 1.2 (id:complex-rule-expr-1)
             Expression: #uname eq 'node3 4' (id:complex-rule-expr)
             Expression: #uname eq nodeA (id:complex-rule-expr-2)
         """
     )
     self.assert_lines(dto, output)
Exemple #19
0
class DefaultsConfigMixin(DefaultsBaseMixin):
    dto_list = [
        CibNvsetDto(
            "my-meta_attributes",
            CibNvsetType.META,
            {},
            CibRuleExpressionDto(
                "my-meta-rule",
                CibRuleExpressionType.RULE,
                CibRuleInEffectStatus.EXPIRED,
                {
                    "boolean-op": "and",
                    "score": "INFINITY"
                },
                None,
                None,
                [
                    CibRuleExpressionDto(
                        "my-meta-rule-rsc",
                        CibRuleExpressionType.RSC_EXPRESSION,
                        CibRuleInEffectStatus.UNKNOWN,
                        {
                            "class": "ocf",
                            "provider": "pacemaker",
                            "type": "Dummy",
                        },
                        None,
                        None,
                        [],
                        "resource ocf:pacemaker:Dummy",
                    ),
                ],
                "resource ocf:pacemaker:Dummy",
            ),
            [
                CibNvpairDto("my-id-pair1", "name1", "value1"),
                CibNvpairDto("my-id-pair2", "name2", "value2"),
            ],
        ),
        CibNvsetDto(
            "instance",
            CibNvsetType.INSTANCE,
            {},
            None,
            [CibNvpairDto("instance-pair", "inst", "ance")],
        ),
        CibNvsetDto(
            "meta-plain",
            CibNvsetType.META,
            {"score": "123"},
            None,
            [CibNvpairDto("my-id-pair3", "name 1", "value 1")],
        ),
    ]

    def test_no_args(self, mock_print):
        self.lib_command.return_value = []
        self._call_cmd([])
        self.lib_command.assert_called_once_with(True)
        mock_print.assert_called_once_with("No defaults set")

    def test_usage(self, mock_print):
        with self.assertRaises(CmdLineInputError) as cm:
            self._call_cmd(["arg"])
        self.assertIsNone(cm.exception.message)
        self.lib_command.assert_not_called()
        mock_print.assert_not_called()

    def test_full(self, mock_print):
        self.lib_command.return_value = []
        self._call_cmd([], {"full": True})
        self.lib_command.assert_called_once_with(True)
        mock_print.assert_called_once_with("No defaults set")

    def test_no_expire_check(self, mock_print):
        self.lib_command.return_value = []
        self._call_cmd([], {"no-expire-check": True})
        self.lib_command.assert_called_once_with(False)
        mock_print.assert_called_once_with("No defaults set")

    def test_print(self, mock_print):
        self.lib_command.return_value = self.dto_list
        self._call_cmd([], {"all": True})
        self.lib_command.assert_called_once_with(True)
        mock_print.assert_called_once_with(
            dedent('''\
                Meta Attrs (expired): my-meta_attributes
                  name1=value1
                  name2=value2
                  Rule (expired): boolean-op=and score=INFINITY
                    Expression: resource ocf:pacemaker:Dummy
                Attributes: instance
                  inst=ance
                Meta Attrs: meta-plain score=123
                  "name 1"="value 1"'''))

    def test_print_exclude_expired(self, mock_print):
        self.lib_command.return_value = self.dto_list
        self._call_cmd([], {"all": False})
        self.lib_command.assert_called_once_with(True)
        mock_print.assert_called_once_with(
            dedent('''\
                Attributes: instance
                  inst=ance
                Meta Attrs: meta-plain score=123
                  "name 1"="value 1"'''))

    def test_print_full(self, mock_print):
        self.lib_command.return_value = self.dto_list
        self._call_cmd([], {"all": True, "full": True})
        self.lib_command.assert_called_once_with(True)
        mock_print.assert_called_once_with(
            dedent('''\
                Meta Attrs (expired): my-meta_attributes
                  name1=value1
                  name2=value2
                  Rule (expired): boolean-op=and score=INFINITY (id:my-meta-rule)
                    Expression: resource ocf:pacemaker:Dummy (id:my-meta-rule-rsc)
                Attributes: instance
                  inst=ance
                Meta Attrs: meta-plain score=123
                  "name 1"="value 1"'''))
Exemple #20
0
 def test_success(self):
     xml = etree.fromstring("""
         <rule id="rule1" boolean-op="or" score="INFINITY">
             <rule id="rule2" boolean-op="and" score="0">
                 <rule id="rule3" boolean-op="or" score="0">
                     <op_expression id="id1" name="start" />
                 </rule>
                 <rsc_expression id="id2" type="Dummy" />
             </rule>
             <rule id="rule4" boolean-op="and" score="0">
                 <rsc_expression id="id3" type="Stateful" />
             </rule>
         </rule>
     """)
     rules_status = {
         "rule1": CibRuleInEffectStatus.UNKNOWN,
         "rule2": CibRuleInEffectStatus.EXPIRED,
         "rule3": CibRuleInEffectStatus.IN_EFFECT,
         "rule4": CibRuleInEffectStatus.NOT_YET_IN_EFFECT,
     }
     self.assertEqual(
         rule_element_to_dto(get_in_effect_eval(rules_status), xml),
         CibRuleExpressionDto(
             "rule1",
             CibRuleExpressionType.RULE,
             CibRuleInEffectStatus.UNKNOWN,
             {
                 "boolean-op": "or",
                 "score": "INFINITY"
             },
             None,
             None,
             [
                 CibRuleExpressionDto(
                     "rule2",
                     CibRuleExpressionType.RULE,
                     CibRuleInEffectStatus.EXPIRED,
                     {
                         "boolean-op": "and",
                         "score": "0"
                     },
                     None,
                     None,
                     [
                         CibRuleExpressionDto(
                             "rule3",
                             CibRuleExpressionType.RULE,
                             CibRuleInEffectStatus.IN_EFFECT,
                             {
                                 "boolean-op": "or",
                                 "score": "0"
                             },
                             None,
                             None,
                             [
                                 CibRuleExpressionDto(
                                     "id1",
                                     CibRuleExpressionType.OP_EXPRESSION,
                                     CibRuleInEffectStatus.UNKNOWN,
                                     {"name": "start"},
                                     None,
                                     None,
                                     [],
                                     "op start",
                                 ),
                             ],
                             "op start",
                         ),
                         CibRuleExpressionDto(
                             "id2",
                             CibRuleExpressionType.RSC_EXPRESSION,
                             CibRuleInEffectStatus.UNKNOWN,
                             {"type": "Dummy"},
                             None,
                             None,
                             [],
                             "resource ::Dummy",
                         ),
                     ],
                     "(op start) and resource ::Dummy",
                 ),
                 CibRuleExpressionDto(
                     "rule4",
                     CibRuleExpressionType.RULE,
                     CibRuleInEffectStatus.NOT_YET_IN_EFFECT,
                     {
                         "boolean-op": "and",
                         "score": "0"
                     },
                     None,
                     None,
                     [
                         CibRuleExpressionDto(
                             "id3",
                             CibRuleExpressionType.RSC_EXPRESSION,
                             CibRuleInEffectStatus.UNKNOWN,
                             {"type": "Stateful"},
                             None,
                             None,
                             [],
                             "resource ::Stateful",
                         ),
                     ],
                     "resource ::Stateful",
                 ),
             ],
             "((op start) and resource ::Dummy) or (resource ::Stateful)",
         ),
     )
Exemple #21
0
 def test_complex_rule(self):
     xml = etree.fromstring("""
         <rule id="complex" boolean-op="or" score="INFINITY">
             <rule id="complex-rule-1" boolean-op="and" score="0">
                 <date_expression id="complex-rule-1-expr"
                     operation="date_spec"
                 >
                     <date_spec id="complex-rule-1-expr-datespec"
                         weekdays="1-5" hours="12-23"
                     />
                 </date_expression>
                 <date_expression id="complex-rule-1-expr-1"
                     operation="in_range" start="2014-07-26"
                 >
                     <duration id="complex-rule-1-expr-1-durat" months="1"/>
                 </date_expression>
             </rule>
             <rule id="complex-rule" boolean-op="and" score="0">
                 <expression id="complex-rule-expr-1"
                     attribute="foo" operation="gt" type="version" value="1.2"
                 />
                 <expression id="complex-rule-expr"
                     attribute="#uname" operation="eq" value="node3 4"
                 />
                 <expression id="complex-rule-expr-2"
                     attribute="#uname" operation="eq" value="nodeA"
                 />
             </rule>
         </rule>
     """)
     self.assertEqual(
         rule_element_to_dto(get_in_effect_eval(), xml),
         CibRuleExpressionDto(
             "complex",
             CibRuleExpressionType.RULE,
             CibRuleInEffectStatus.UNKNOWN,
             {
                 "boolean-op": "or",
                 "score": "INFINITY"
             },
             None,
             None,
             [
                 CibRuleExpressionDto(
                     "complex-rule-1",
                     CibRuleExpressionType.RULE,
                     CibRuleInEffectStatus.UNKNOWN,
                     {
                         "boolean-op": "and",
                         "score": "0"
                     },
                     None,
                     None,
                     [
                         CibRuleExpressionDto(
                             "complex-rule-1-expr",
                             CibRuleExpressionType.DATE_EXPRESSION,
                             CibRuleInEffectStatus.UNKNOWN,
                             {"operation": "date_spec"},
                             CibRuleDateCommonDto(
                                 "complex-rule-1-expr-datespec",
                                 {
                                     "hours": "12-23",
                                     "weekdays": "1-5"
                                 },
                             ),
                             None,
                             [],
                             "date-spec hours=12-23 weekdays=1-5",
                         ),
                         CibRuleExpressionDto(
                             "complex-rule-1-expr-1",
                             CibRuleExpressionType.DATE_EXPRESSION,
                             CibRuleInEffectStatus.UNKNOWN,
                             {
                                 "operation": "in_range",
                                 "start": "2014-07-26",
                             },
                             None,
                             CibRuleDateCommonDto(
                                 "complex-rule-1-expr-1-durat",
                                 {"months": "1"},
                             ),
                             [],
                             "date in_range 2014-07-26 to duration months=1",
                         ),
                     ],
                     "date-spec hours=12-23 weekdays=1-5 and date in_range "
                     "2014-07-26 to duration months=1",
                 ),
                 CibRuleExpressionDto(
                     "complex-rule",
                     CibRuleExpressionType.RULE,
                     CibRuleInEffectStatus.UNKNOWN,
                     {
                         "boolean-op": "and",
                         "score": "0"
                     },
                     None,
                     None,
                     [
                         CibRuleExpressionDto(
                             "complex-rule-expr-1",
                             CibRuleExpressionType.EXPRESSION,
                             CibRuleInEffectStatus.UNKNOWN,
                             {
                                 "attribute": "foo",
                                 "operation": "gt",
                                 "type": "version",
                                 "value": "1.2",
                             },
                             None,
                             None,
                             [],
                             "foo gt version 1.2",
                         ),
                         CibRuleExpressionDto(
                             "complex-rule-expr",
                             CibRuleExpressionType.EXPRESSION,
                             CibRuleInEffectStatus.UNKNOWN,
                             {
                                 "attribute": "#uname",
                                 "operation": "eq",
                                 "value": "node3 4",
                             },
                             None,
                             None,
                             [],
                             '#uname eq "node3 4"',
                         ),
                         CibRuleExpressionDto(
                             "complex-rule-expr-2",
                             CibRuleExpressionType.EXPRESSION,
                             CibRuleInEffectStatus.UNKNOWN,
                             {
                                 "attribute": "#uname",
                                 "operation": "eq",
                                 "value": "nodeA",
                             },
                             None,
                             None,
                             [],
                             "#uname eq nodeA",
                         ),
                     ],
                     'foo gt version 1.2 and #uname eq "node3 4" and #uname '
                     "eq nodeA",
                 ),
             ],
             "(date-spec hours=12-23 weekdays=1-5 and date in_range "
             "2014-07-26 to duration months=1) or (foo gt version 1.2 and "
             '#uname eq "node3 4" and #uname eq nodeA)',
         ),
     )
Exemple #22
0
 def test_full(self):
     defaults_xml = f"""
         <{self.tag}>
             <meta_attributes id="{self.tag}-meta_attributes">
                 <rule id="{self.tag}-meta_attributes-rule"
                     boolean-op="and" score="INFINITY"
                 >
                     <rsc_expression
                         id="{self.tag}-meta_attributes-rule-rsc-Dummy"
                         class="ocf" provider="pacemaker" type="Dummy"
                     />
                     <rule id="{self.tag}-meta_attributes-rule-rule"
                         boolean-op="or"
                     >
                         <expression
                             id="{self.tag}-meta_attributes-rule-rule-expr"
                             operation="defined" attribute="attr1"
                         />
                         <expression
                             id="{self.tag}-meta_attributes-rule-rule-expr-1"
                             attribute="attr2" operation="gt"
                             type="integer" value="5"
                         />
                         <date_expression
                             id="{self.tag}-meta_attributes-rule-rule-expr-2"
                             operation="lt" end="2020-08-07"
                         />
                         <date_expression
                             id="{self.tag}-meta_attributes-rule-rule-expr-3"
                             operation="in_range"
                             start="2020-09-01" end="2020-09-11"
                         />
                         <date_expression
                             id="{self.tag}-meta_attributes-rule-rule-expr-4"
                             operation="in_range" start="2020-10-01"
                         >
                             <duration
                                 id="{self.tag}-meta_attributes-rule-rule-expr-4-duration"
                                 months="1"
                             />
                         </date_expression>
                         <date_expression
                             id="{self.tag}-meta_attributes-rule-rule-expr-5"
                             operation="date_spec"
                         >
                             <date_spec
                                 id="{self.tag}-meta_attributes-rule-rule-expr-5-datespec"
                                 years="2021-2022"
                             />
                         </date_expression>
                         <date_expression
                             id="{self.tag}-meta_attributes-rule-rule-expr-6"
                             operation="in_range" end="2020-12-11"
                         />
                     </rule>
                 </rule>
                 <nvpair id="my-id-pair1" name="name1" value="value1" />
                 <nvpair id="my-id-pair2" name="name2" value="value2" />
             </meta_attributes>
             <instance_attributes id="instance">
                 <nvpair id="instance-pair" name="inst" value="ance" />
             </instance_attributes>
             <meta_attributes id="meta-plain" score="123">
                 <nvpair id="my-id-pair3" name="name1" value="value1" />
             </meta_attributes>
         </{self.tag}>
     """
     self.config.runner.cib.load(
         filename="cib-empty-3.4.xml", optional_in_conf=defaults_xml
     )
     self.config.fs.isfile(
         (os.path.join(settings.pacemaker_binaries, "crm_rule")),
         return_value=False,
     )
     self.assertEqual(
         [
             CibNvsetDto(
                 f"{self.tag}-meta_attributes",
                 CibNvsetType.META,
                 {},
                 CibRuleExpressionDto(
                     f"{self.tag}-meta_attributes-rule",
                     CibRuleExpressionType.RULE,
                     CibRuleInEffectStatus.UNKNOWN,
                     {"boolean-op": "and", "score": "INFINITY"},
                     None,
                     None,
                     [
                         CibRuleExpressionDto(
                             f"{self.tag}-meta_attributes-rule-rsc-Dummy",
                             CibRuleExpressionType.RSC_EXPRESSION,
                             CibRuleInEffectStatus.UNKNOWN,
                             {
                                 "class": "ocf",
                                 "provider": "pacemaker",
                                 "type": "Dummy",
                             },
                             None,
                             None,
                             [],
                             "resource ocf:pacemaker:Dummy",
                         ),
                         CibRuleExpressionDto(
                             f"{self.tag}-meta_attributes-rule-rule",
                             CibRuleExpressionType.RULE,
                             CibRuleInEffectStatus.UNKNOWN,
                             {"boolean-op": "or"},
                             None,
                             None,
                             [
                                 CibRuleExpressionDto(
                                     f"{self.tag}-meta_attributes-rule-rule-expr",
                                     CibRuleExpressionType.EXPRESSION,
                                     CibRuleInEffectStatus.UNKNOWN,
                                     {
                                         "operation": "defined",
                                         "attribute": "attr1",
                                     },
                                     None,
                                     None,
                                     [],
                                     "defined attr1",
                                 ),
                                 CibRuleExpressionDto(
                                     f"{self.tag}-meta_attributes-rule-rule-expr-1",
                                     CibRuleExpressionType.EXPRESSION,
                                     CibRuleInEffectStatus.UNKNOWN,
                                     {
                                         "attribute": "attr2",
                                         "operation": "gt",
                                         "type": "integer",
                                         "value": "5",
                                     },
                                     None,
                                     None,
                                     [],
                                     "attr2 gt integer 5",
                                 ),
                                 CibRuleExpressionDto(
                                     f"{self.tag}-meta_attributes-rule-rule-expr-2",
                                     CibRuleExpressionType.DATE_EXPRESSION,
                                     CibRuleInEffectStatus.UNKNOWN,
                                     {
                                         "operation": "lt",
                                         "end": "2020-08-07",
                                     },
                                     None,
                                     None,
                                     [],
                                     "date lt 2020-08-07",
                                 ),
                                 CibRuleExpressionDto(
                                     f"{self.tag}-meta_attributes-rule-rule-expr-3",
                                     CibRuleExpressionType.DATE_EXPRESSION,
                                     CibRuleInEffectStatus.UNKNOWN,
                                     {
                                         "operation": "in_range",
                                         "start": "2020-09-01",
                                         "end": "2020-09-11",
                                     },
                                     None,
                                     None,
                                     [],
                                     "date in_range 2020-09-01 to 2020-09-11",
                                 ),
                                 CibRuleExpressionDto(
                                     f"{self.tag}-meta_attributes-rule-rule-expr-4",
                                     CibRuleExpressionType.DATE_EXPRESSION,
                                     CibRuleInEffectStatus.UNKNOWN,
                                     {
                                         "operation": "in_range",
                                         "start": "2020-10-01",
                                     },
                                     None,
                                     CibRuleDateCommonDto(
                                         f"{self.tag}-meta_attributes-rule-rule-expr-4-duration",
                                         {"months": "1"},
                                     ),
                                     [],
                                     "date in_range 2020-10-01 to duration months=1",
                                 ),
                                 CibRuleExpressionDto(
                                     f"{self.tag}-meta_attributes-rule-rule-expr-5",
                                     CibRuleExpressionType.DATE_EXPRESSION,
                                     CibRuleInEffectStatus.UNKNOWN,
                                     {"operation": "date_spec"},
                                     CibRuleDateCommonDto(
                                         f"{self.tag}-meta_attributes-rule-rule-expr-5-datespec",
                                         {"years": "2021-2022"},
                                     ),
                                     None,
                                     [],
                                     "date-spec years=2021-2022",
                                 ),
                                 CibRuleExpressionDto(
                                     f"{self.tag}-meta_attributes-rule-rule-expr-6",
                                     CibRuleExpressionType.DATE_EXPRESSION,
                                     CibRuleInEffectStatus.UNKNOWN,
                                     {
                                         "operation": "in_range",
                                         "end": "2020-12-11",
                                     },
                                     None,
                                     None,
                                     [],
                                     "date in_range to 2020-12-11",
                                 ),
                             ],
                             "defined attr1 or attr2 gt integer 5 or "
                             "date lt 2020-08-07 or "
                             "date in_range 2020-09-01 to 2020-09-11 or "
                             "date in_range 2020-10-01 to duration months=1 "
                             "or date-spec years=2021-2022 or "
                             "date in_range to 2020-12-11",
                         ),
                     ],
                     "resource ocf:pacemaker:Dummy and "
                     "(defined attr1 or attr2 gt integer 5 or "
                     "date lt 2020-08-07 or "
                     "date in_range 2020-09-01 to 2020-09-11 or "
                     "date in_range 2020-10-01 to duration months=1 or "
                     "date-spec years=2021-2022 or "
                     "date in_range to 2020-12-11)",
                 ),
                 [
                     CibNvpairDto("my-id-pair1", "name1", "value1"),
                     CibNvpairDto("my-id-pair2", "name2", "value2"),
                 ],
             ),
             CibNvsetDto(
                 "instance",
                 CibNvsetType.INSTANCE,
                 {},
                 None,
                 [CibNvpairDto("instance-pair", "inst", "ance")],
             ),
             CibNvsetDto(
                 "meta-plain",
                 CibNvsetType.META,
                 {"score": "123"},
                 None,
                 [CibNvpairDto("my-id-pair3", "name1", "value1")],
             ),
         ],
         self.command(self.env_assist.get_env(), True),
     )
     self.env_assist.assert_reports(
         [
             fixture.warn(
                 reports.codes.RULE_IN_EFFECT_STATUS_DETECTION_NOT_SUPPORTED
             ),
         ]
     )
Exemple #23
0
 def test_full(self):
     for tag, nvtype in self.tag_type:
         with self.subTest(tag=tag, nvset_type=nvtype):
             xml = etree.fromstring(
                 f"""
                 <{tag} id="my-id" score="150">
                     <rule id="my-id-rule" boolean-op="and">
                         <rsc_expression
                             id="my-id-rule-rsc-ocf-pacemaker-Dummy"
                             class="ocf" provider="pacemaker" type="Dummy"
                         />
                         <op_expression id="my-id-rule-op" name="monitor" />
                         <rule id="my-id-rule-rule" boolean-op="or">
                             <expression id="my-id-rule-rule-expr"
                                 operation="defined" attribute="attr1"
                             />
                             <expression id="my-id-rule-rule-expr-1"
                                 attribute="attr2" operation="gt"
                                 type="integer" value="5"
                             />
                             <date_expression id="my-id-rule-rule-expr-2"
                                 operation="lt" end="2020-08-07"
                             />
                             <date_expression id="my-id-rule-rule-expr-3"
                                 operation="in_range"
                                 start="2020-09-01" end="2020-09-11"
                             />
                             <date_expression id="my-id-rule-rule-expr-4"
                                 operation="in_range" start="2020-10-01"
                             >
                                 <duration id="my-id-rule-rule-expr-4-duration"
                                     months="1"
                                 />
                             </date_expression>
                             <date_expression id="my-id-rule-rule-expr-5"
                                 operation="date_spec"
                             >
                                 <date_spec id="my-id-rule-rule-expr-5-datespec"
                                     years="2021-2022"
                                 />
                             </date_expression>
                             <date_expression id="my-id-rule-rule-expr-6"
                                 operation="in_range" end="2020-09-11"
                             />
                         </rule>
                     </rule>
                     <nvpair id="my-id-pair1" name="name1" value="value1" />
                     <nvpair id="my-id-pair2" name="name2" value="value2" />
                 </{tag}>
             """
             )
             self.assertEqual(
                 nvpair_multi.nvset_element_to_dto(
                     xml, get_in_effect_eval()
                 ),
                 CibNvsetDto(
                     "my-id",
                     nvtype,
                     {"score": "150"},
                     CibRuleExpressionDto(
                         "my-id-rule",
                         CibRuleExpressionType.RULE,
                         CibRuleInEffectStatus.UNKNOWN,
                         {"boolean-op": "and"},
                         None,
                         None,
                         [
                             CibRuleExpressionDto(
                                 "my-id-rule-rsc-ocf-pacemaker-Dummy",
                                 CibRuleExpressionType.RSC_EXPRESSION,
                                 CibRuleInEffectStatus.UNKNOWN,
                                 {
                                     "class": "ocf",
                                     "provider": "pacemaker",
                                     "type": "Dummy",
                                 },
                                 None,
                                 None,
                                 [],
                                 "resource ocf:pacemaker:Dummy",
                             ),
                             CibRuleExpressionDto(
                                 "my-id-rule-op",
                                 CibRuleExpressionType.OP_EXPRESSION,
                                 CibRuleInEffectStatus.UNKNOWN,
                                 {"name": "monitor"},
                                 None,
                                 None,
                                 [],
                                 "op monitor",
                             ),
                             CibRuleExpressionDto(
                                 "my-id-rule-rule",
                                 CibRuleExpressionType.RULE,
                                 CibRuleInEffectStatus.UNKNOWN,
                                 {"boolean-op": "or"},
                                 None,
                                 None,
                                 [
                                     CibRuleExpressionDto(
                                         "my-id-rule-rule-expr",
                                         CibRuleExpressionType.EXPRESSION,
                                         CibRuleInEffectStatus.UNKNOWN,
                                         {
                                             "operation": "defined",
                                             "attribute": "attr1",
                                         },
                                         None,
                                         None,
                                         [],
                                         "defined attr1",
                                     ),
                                     CibRuleExpressionDto(
                                         "my-id-rule-rule-expr-1",
                                         CibRuleExpressionType.EXPRESSION,
                                         CibRuleInEffectStatus.UNKNOWN,
                                         {
                                             "attribute": "attr2",
                                             "operation": "gt",
                                             "type": "integer",
                                             "value": "5",
                                         },
                                         None,
                                         None,
                                         [],
                                         "attr2 gt integer 5",
                                     ),
                                     CibRuleExpressionDto(
                                         "my-id-rule-rule-expr-2",
                                         CibRuleExpressionType.DATE_EXPRESSION,
                                         CibRuleInEffectStatus.UNKNOWN,
                                         {
                                             "operation": "lt",
                                             "end": "2020-08-07",
                                         },
                                         None,
                                         None,
                                         [],
                                         "date lt 2020-08-07",
                                     ),
                                     CibRuleExpressionDto(
                                         "my-id-rule-rule-expr-3",
                                         CibRuleExpressionType.DATE_EXPRESSION,
                                         CibRuleInEffectStatus.UNKNOWN,
                                         {
                                             "operation": "in_range",
                                             "start": "2020-09-01",
                                             "end": "2020-09-11",
                                         },
                                         None,
                                         None,
                                         [],
                                         "date in_range 2020-09-01 to 2020-09-11",
                                     ),
                                     CibRuleExpressionDto(
                                         "my-id-rule-rule-expr-4",
                                         CibRuleExpressionType.DATE_EXPRESSION,
                                         CibRuleInEffectStatus.UNKNOWN,
                                         {
                                             "operation": "in_range",
                                             "start": "2020-10-01",
                                         },
                                         None,
                                         CibRuleDateCommonDto(
                                             "my-id-rule-rule-expr-4-duration",
                                             {"months": "1"},
                                         ),
                                         [],
                                         "date in_range 2020-10-01 to duration months=1",
                                     ),
                                     CibRuleExpressionDto(
                                         "my-id-rule-rule-expr-5",
                                         CibRuleExpressionType.DATE_EXPRESSION,
                                         CibRuleInEffectStatus.UNKNOWN,
                                         {"operation": "date_spec"},
                                         CibRuleDateCommonDto(
                                             "my-id-rule-rule-expr-5-datespec",
                                             {"years": "2021-2022"},
                                         ),
                                         None,
                                         [],
                                         "date-spec years=2021-2022",
                                     ),
                                     CibRuleExpressionDto(
                                         "my-id-rule-rule-expr-6",
                                         CibRuleExpressionType.DATE_EXPRESSION,
                                         CibRuleInEffectStatus.UNKNOWN,
                                         {
                                             "operation": "in_range",
                                             "end": "2020-09-11",
                                         },
                                         None,
                                         None,
                                         [],
                                         "date in_range to 2020-09-11",
                                     ),
                                 ],
                                 "defined attr1 or attr2 gt integer 5 or "
                                 "date lt 2020-08-07 or "
                                 "date in_range 2020-09-01 to 2020-09-11 or "
                                 "date in_range 2020-10-01 to duration months=1 or "
                                 "date-spec years=2021-2022 or "
                                 "date in_range to 2020-09-11",
                             ),
                         ],
                         "resource ocf:pacemaker:Dummy and op monitor and "
                         "(defined attr1 or attr2 gt integer 5 or "
                         "date lt 2020-08-07 or "
                         "date in_range 2020-09-01 to 2020-09-11 or "
                         "date in_range 2020-10-01 to duration months=1 "
                         "or date-spec years=2021-2022 or "
                         "date in_range to 2020-09-11)",
                     ),
                     [
                         CibNvpairDto("my-id-pair1", "name1", "value1"),
                         CibNvpairDto("my-id-pair2", "name2", "value2"),
                     ],
                 ),
             )