Mailing List Archive

[PATCH][crmsh] converts "bool" data into "string" data when generating xml
Hi,

Recent crmsh becomes the error when "order" with "symmetrical" is specified..

$ crm --version
1.2.6 (Build d20853fe7966)

crm(live)configure# order o1 0: p1 p2 symmetrical=false
Traceback (most recent call last):
File "/usr/sbin/crm", line 44, in <module>
main.run()
File "/usr/lib64/python2.6/site-packages/crmsh/main.py", line 482, in run
do_work(user_args)
File "/usr/lib64/python2.6/site-packages/crmsh/main.py", line 407, in do_work
if not parse_line(levels, shlex.split(inp)):
File "/usr/lib64/python2.6/site-packages/crmsh/main.py", line 177, in parse_line
retval = execute_command(lvl, cmd, line[i:])
File "/usr/lib64/python2.6/site-packages/crmsh/main.py", line 139, in execute_command
rv = fn(*args) # execute the command
File "/usr/lib64/python2.6/site-packages/crmsh/ui.py", line 2078, in conf_order
return self.__conf_object(cmd, *args)
File "/usr/lib64/python2.6/site-packages/crmsh/ui.py", line 2005, in __conf_object
return f()
File "/usr/lib64/python2.6/site-packages/crmsh/ui.py", line 2004, in <lambda>
f = lambda: cib_factory.create_object(cmd, *args)
File "/usr/lib64/python2.6/site-packages/crmsh/cibconfig.py", line 2881, in create_object
return self.create_from_cli(out) is not None
File "/usr/lib64/python2.6/site-packages/crmsh/cibconfig.py", line 2952, in create_from_cli
node = obj.cli2node(cli_list)
File "/usr/lib64/python2.6/site-packages/crmsh/cibconfig.py", line 991, in cli2node
node = self._cli_list2node(cli_list, oldnode)
File "/usr/lib64/python2.6/site-packages/crmsh/cibconfig.py", line 1753, in _cli_list2node
headnode = mkxmlsimple(head, oldnode, '')
File "/usr/lib64/python2.6/site-packages/crmsh/cibconfig.py", line 631, in mkxmlsimple
node.set(n, v)
File "lxml.etree.pyx", line 634, in lxml.etree._Element.set (src/lxml/lxml.etree.c:31548)
File "apihelpers.pxi", line 487, in lxml.etree._setAttributeValue (src/lxml/lxml.etree.c:13896)
File "apihelpers.pxi", line 1240, in lxml.etree._utf8 (src/lxml/lxml.etree.c:19826)
TypeError: Argument must be string or unicode.


How is this patch?

$ diff -r d20853fe7966 modules/cibconfig.py
--- a/modules/cibconfig.py Tue Oct 08 11:42:18 2013 +0200
+++ b/modules/cibconfig.py Wed Oct 09 16:32:50 2013 +0900
@@ -626,6 +626,8 @@ def mkxmlsimple(e, oldnode, id_hint):
v = v.lower()
if n.startswith('$'):
n = n.lstrip('$')
+ if isinstance(v, bool):
+ v = "true" if v else "false"
if (type(v) != type('') and type(v) != type(u'')) \
or v: # skip empty strings
node.set(n, v)

Best Regards,
Kazunori INOUE
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/