From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jim Fehlig Subject: [PATCH] fix domain exit actions that contain hyphen Date: Tue, 02 Mar 2010 15:55:47 -0700 Message-ID: <4B8D9773.8020407@novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000706050603080409040401" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------000706050603080409040401 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: Please report to xen-devel@lists.xensource.com Traceback (most recent call last): File "/usr/sbin/xm", line 7, in 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 "", line 1, in 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 Signed-off-by: Jim Fehlig --------------000706050603080409040401 Content-Type: text/x-patch; name="xm-fix.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xm-fix.patch" Index: xen-4.0.0-testing/tools/python/xen/xm/xenapi_create.py =================================================================== --- xen-4.0.0-testing.orig/tools/python/xen/xm/xenapi_create.py +++ xen-4.0.0-testing/tools/python/xen/xm/xenapi_create.py @@ -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) --------------000706050603080409040401 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------000706050603080409040401--