Skip to content

Commit

Permalink
Allow empty fencing_topology (bsc#1025393)
Browse files Browse the repository at this point in the history
  • Loading branch information
krig committed Feb 15, 2017
1 parent 73551e6 commit 834ac8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crmsh/parse.py
Expand Up @@ -1070,7 +1070,7 @@ class FencingOrderParser(BaseParser):
"""
def parse(self, cmd):
self.begin(cmd, min_args=1)
self.begin(cmd)
if not self.try_match("fencing-topology"):
self.match("fencing_topology")
target = "@@"
Expand All @@ -1085,15 +1085,17 @@ def parse(self, cmd):
target = self.matched(1)
else:
raw_levels.append((target, self.match_any()))
if len(raw_levels) == 0:
self.err("Missing list of devices")
return self._postprocess_levels(raw_levels)

def _postprocess_levels(self, raw_levels):
from collections import defaultdict
from itertools import repeat
from .cibconfig import cib_factory
if raw_levels[0][0] == "@@":
if len(raw_levels) == 0:
def no_levels():
return []
lvl_generator = no_levels
elif raw_levels[0][0] == "@@":
def node_levels():
for node in cib_factory.node_id_list():
for target, devices in raw_levels:
Expand Down
4 changes: 4 additions & 0 deletions test/unittests/test_parse.py
Expand Up @@ -434,6 +434,10 @@ def test_empty_property_sets(self):
def test_fencing(self):
# num test nodes are 3

out = self._parse('fencing_topology')
expect = '<fencing-topology/>'
self.assertEqual(expect, etree.tostring(out))

out = self._parse('fencing_topology poison-pill power')
expect = '<fencing-topology><fencing-level devices="poison-pill" index="1" target="ha-one"/><fencing-level devices="power" index="2" target="ha-one"/><fencing-level devices="poison-pill" index="1" target="ha-three"/><fencing-level devices="power" index="2" target="ha-three"/><fencing-level devices="poison-pill" index="1" target="ha-two"/><fencing-level devices="power" index="2" target="ha-two"/></fencing-topology>'
self.assertEqual(expect, etree.tostring(out))
Expand Down

0 comments on commit 834ac8c

Please sign in to comment.