def test_simple(self):
     self.config.runner.cib.load(
         resources="<resources>{}</resources>".format(
             fixture_primitive_xml("d1") + fixture_primitive_xml("d2")),
         constraints="""
         <constraints>
             <rsc_order first="d1" first-action="start"
                 id="order-d1-d2" then="d2" then-action="start"
                 kind="Mandatory"/>
         </constraints>
         """,
     )
     prim_members = ["order-d1-d2"]
     expected = fixture_node(
         fixture_primitive("d1", prim_members),
         [
             fixture_node(
                 fixture_order("d1", "d2"),
                 [fixture_node(fixture_primitive("d2", prim_members))],
             )
         ],
     )
     self.assertEqual(
         expected,
         resource.get_resource_relations_tree(self.env_assist.get_env(),
                                              "d1"))
Esempio n. 2
0
 def test_not_existing_resource(self):
     self.config.runner.cib.load()
     resource_id = "not_existing"
     self.env_assist.assert_raise_library_error(
         lambda: resource.get_resource_relations_tree(
             self.env_assist.get_env(),
             resource_id,
         ))
     self.env_assist.assert_reports(
         [fixture.report_not_found(resource_id, context_type="resources")])
 def test_d1(self):
     outer_cg = dict(
         id="outer:cg",
         type=ResourceRelationType.OUTER_RESOURCE,
         members=["cg"],
         metadata=dict(id="cg"),
     )
     order_opt = fixture_order("cgd1", "d2", kind="Optional", score="10")
     expected = fixture_node(
         fixture_primitive("d1", self.d1_members),
         [
             fixture_node(fixture_order("d1", "d2"), [
                 fixture_node(
                     fixture_primitive("d2", self.d2_members),
                     [
                         fixture_node(
                             order_opt,
                             [
                                 fixture_node(
                                     fixture_primitive(
                                         "cgd1",
                                         ["order-cgd1-d2", "outer:cg"],
                                     ), [
                                         fixture_node(
                                             outer_cg, [
                                                 fixture_node(
                                                     self.cg_ent,
                                                     leaf=True,
                                                 ),
                                             ])
                                     ]),
                             ],
                         ),
                         fixture_node(self.order_set, leaf=True)
                     ],
                 )
             ]),
             fixture_node(
                 self.order_set,
                 [
                     fixture_node(
                         self.cg_ent,
                         [
                             fixture_node(
                                 dict(
                                     id="inner:cg",
                                     type=(ResourceRelationType.
                                           INNER_RESOURCES),
                                     members=["cgd1", "cgd2", "cgd0"],
                                     metadata=dict(id="cg"),
                                 ), [
                                     fixture_node(
                                         fixture_primitive(
                                             "cgd1",
                                             ["order-cgd1-d2", "outer:cg"],
                                         ),
                                         leaf=True,
                                     ),
                                     fixture_node(
                                         fixture_primitive(
                                             "cgd2", ["outer:cg"]), ),
                                     fixture_node(
                                         fixture_primitive(
                                             "cgd0", ["outer:cg"]), ),
                                 ]),
                             fixture_node(
                                 dict(id="outer:c",
                                      type=(ResourceRelationType.
                                            OUTER_RESOURCE),
                                      members=["c"],
                                      metadata=dict(id="c")), [
                                          fixture_node(
                                              dict(
                                                  id="c",
                                                  type="clone",
                                                  members=["inner:c"],
                                                  metadata=dict(id="c"),
                                              ), [])
                                      ])
                         ],
                     ),
                     fixture_node(fixture_primitive("d2", self.d2_members),
                                  leaf=True),
                     fixture_node(
                         fixture_primitive("d3", ["pcs_rsc_order_set_1"]), )
                 ],
             )
         ],
     )
     self.assertEqual(
         expected,
         resource.get_resource_relations_tree(self.env_assist.get_env(),
                                              "d1"))