Beispiel #1
0
def get_config(lib_env: LibraryEnvironment):
    """
    Get fencing levels configuration.

    Return a list of levels where each level is a dict with keys: target_type,
    target_value. level and devices. Devices is a list of stonith device ids.

    LibraryEnvironment lib_env -- environment
    """
    cib = lib_env.get_cib()
    return cib_fencing_topology.export(get_fencing_topology(cib))
Beispiel #2
0
def get_config(lib_env):
    """
    Get fencing levels configuration.

    Return a list of levels where each level is a dict with keys: target_type,
    target_value. level and devices. Devices is a list of stonith device ids.

    LibraryEnvironment lib_env -- environment
    """
    cib = lib_env.get_cib()
    return cib_fencing_topology.export(get_fencing_topology(cib))
Beispiel #3
0
 def test_success(self):
     self.assertEqual(lib.export(self.get_cib()),
                      [{
                          "level": "1",
                          "target_type": "node",
                          "target_value": "nodeA",
                          "devices": ["d1", "d2"],
                      }, {
                          "level": "2",
                          "target_type": "node",
                          "target_value": "nodeA",
                          "devices": ["d3"],
                      }, {
                          "level": "1",
                          "target_type": "node",
                          "target_value": "nodeB",
                          "devices": ["d2", "d1"],
                      }, {
                          "level": "2",
                          "target_type": "node",
                          "target_value": "nodeB",
                          "devices": ["d3"],
                      }, {
                          "level": "1",
                          "target_type": "regexp",
                          "target_value": "node\d+",
                          "devices": ["d3", "d4"],
                      }, {
                          "level": "2",
                          "target_type": "regexp",
                          "target_value": "node\d+",
                          "devices": ["d1"],
                      }, {
                          "level": "3",
                          "target_type": "attribute",
                          "target_value": ("fencing", "improved"),
                          "devices": ["d3", "d4"],
                      }, {
                          "level": "4",
                          "target_type": "attribute",
                          "target_value": ("fencing", "improved"),
                          "devices": ["d5"],
                      }, {
                          "level": "3",
                          "target_type": "regexp",
                          "target_value": "node-R.*",
                          "devices": ["dR"],
                      }, {
                          "level": "4",
                          "target_type": "attribute",
                          "target_value": ("fencing", "remote-special"),
                          "devices": ["dR-special"],
                      }])
Beispiel #4
0
 def test_empty(self):
     self.assertEqual(lib.export(etree.fromstring("<fencing-topology />")),
                      [])
 def test_success(self):
     self.assertEqual(
         lib.export(self.get_cib()),
         [
             {
                 "level": "1",
                 "target_type": "node",
                 "target_value": "nodeA",
                 "devices": ["d1", "d2"],
             },
             {
                 "level": "2",
                 "target_type": "node",
                 "target_value": "nodeA",
                 "devices": ["d3"],
             },
             {
                 "level": "1",
                 "target_type": "node",
                 "target_value": "nodeB",
                 "devices": ["d2", "d1"],
             },
             {
                 "level": "2",
                 "target_type": "node",
                 "target_value": "nodeB",
                 "devices": ["d3"],
             },
             {
                 "level": "1",
                 "target_type": "regexp",
                 "target_value": "node\d+",
                 "devices": ["d3", "d4"],
             },
             {
                 "level": "2",
                 "target_type": "regexp",
                 "target_value": "node\d+",
                 "devices": ["d1"],
             },
             {
                 "level": "3",
                 "target_type": "attribute",
                 "target_value": ("fencing", "improved"),
                 "devices": ["d3", "d4"],
             },
             {
                 "level": "4",
                 "target_type": "attribute",
                 "target_value": ("fencing", "improved"),
                 "devices": ["d5"],
             },
             {
                 "level": "3",
                 "target_type": "regexp",
                 "target_value": "node-R.*",
                 "devices": ["dR"],
             },
             {
                 "level": "4",
                 "target_type": "attribute",
                 "target_value": ("fencing", "remote-special"),
                 "devices": ["dR-special"],
             }
         ]
     )
 def test_empty(self):
     self.assertEqual(
         lib.export(etree.fromstring("<fencing-topology />")),
         []
     )