fix domain exit actions that contain hyphen
PATCH 1/1 fix domain exit actions that contain hyphen
Domain exit actions that contain a hyphen (e.g. rename-restart) were not being detected properly when xm is configured to use xenapi. Domain config containing on_crash="rename-restart" results in
xen53:~ # xm new /tmp/domU.config
Using config file "/tmp/domU.config".
Unexpected error: <type 'exceptions.TypeError'>
Please report to [email protected]
Traceback (most recent call last):
File "/usr/sbin/xm", line 7, in <module>
main.main(sys.argv)
File "/usr/lib64/python2.6/site-packages/xen/xm/main.py", line 3937,
in main
_, rc = _run_cmd(cmd, cmd_name, args)
File "/usr/lib64/python2.6/site-packages/xen/xm/main.py", line 3961,
in _run_cmd
return True, cmd(args)
File "<string>", line 1, in <lambda>
File "/usr/lib64/python2.6/site-packages/xen/xm/main.py", line 1582,
in xm_importcommand
cmd.main([command] + args)
File "/usr/lib64/python2.6/site-packages/xen/xm/new.py", line 69, in main
doc = sxp2xml_inst.convert_sxp_to_xml(config)
File "/usr/lib64/python2.6/site-packages/xen/xm/xenapi_create.py",
line 680, in convert_sxp_to_xml
XEN_API_ON_CRASH_BEHAVIOUR)
File "/usr/lib64/python2.6/site-packages/xen/xm/xenapi_create.py",
line 671, in conv_chk
raise "Invalid value: " + val
TypeError: exceptions must be classes or instances, not str
The attached patch fixes the raised exception and at the same time handles the replacement of hyphen with underscore properly.
Regards,
Jim
tools/python/xen/xm/xenapi_create.py +4 -4
@@ -666,11 +666,11 @@ class sxp2xml: = get_child_by_name(config, "on_crash", "restart") def conv_chk(val, vals): - val.replace("-", "_") - if val not in vals: - raise "Invalid value: " + val + lval = val.replace("-", "_") + if lval not in vals: + raise ValueError("Invalid value: %s" % val) else: - return val + return lval actions_after_shutdown = conv_chk(actions_after_shutdown,\ XEN_API_ON_NORMAL_EXIT)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel