# HG changeset patch
# User Lutz Dube <lutz.dube@xxxxxxxxxxxxxx>
# Date 1280245980 -3600
# Node ID e017930af272c888f2a562f842af4e142a973d5f
# Parent 5078f2c1e3d6a3a06ecf352a068eb496f09a2a98
xend (XenAPI): Error in Xend-API method VM_set_actions_after_crash
Xend-API defines the method VM_set_actions_after_crash with valid
action names coredump_and_destroy, coredump_and_restart,... . These
values have to be converted into internal representation
"coredump-destroy", "coredump-restart", ... otherwise start of the
domain is rejected. Same error occurs, if I try to create a VM using
the Xend-API with actions_after_crash set to coredump_and_destroy.
Could you please apply my patch to xen-4-0-testing, too.
Signed-off-by: Lutz Dube Lutz.Dube@xxxxxxxxxxxxxx
Acked-by: Jim Fehlig <jfehlig@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
tools/python/xen/xend/XendAPI.py | 3 ++-
tools/python/xen/xend/XendAPIConstants.py | 12 ++++++++++++
tools/python/xen/xend/XendConfig.py | 8 +++++++-
3 files changed, 21 insertions(+), 2 deletions(-)
diff -r 5078f2c1e3d6 -r e017930af272 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py Tue Jul 27 16:23:04 2010 +0100
+++ b/tools/python/xen/xend/XendAPI.py Tue Jul 27 16:53:00 2010 +0100
@@ -1701,7 +1701,8 @@ class XendAPI(object):
def VM_set_actions_after_crash(self, session, vm_ref, action):
if action not in XEN_API_ON_CRASH_BEHAVIOUR:
return xen_api_error(['VM_ON_CRASH_BEHAVIOUR_INVALID', vm_ref])
- return self.VM_set('actions_after_crash', session, vm_ref, action)
+ return self.VM_set('actions_after_crash', session, vm_ref,
+ XEN_API_ON_CRASH_BEHAVIOUR_LEGACY[action])
def VM_set_HVM_boot_policy(self, session, vm_ref, value):
if value != "" and value != "BIOS order":
diff -r 5078f2c1e3d6 -r e017930af272 tools/python/xen/xend/XendAPIConstants.py
--- a/tools/python/xen/xend/XendAPIConstants.py Tue Jul 27 16:23:04 2010 +0100
+++ b/tools/python/xen/xend/XendAPIConstants.py Tue Jul 27 16:53:00 2010 +0100
@@ -63,6 +63,18 @@ XEN_API_ON_CRASH_BEHAVIOUR_FILTER = {
'rename_restart' : 'rename_restart',
}
+XEN_API_ON_CRASH_BEHAVIOUR_LEGACY = {
+ 'destroy' : 'destroy',
+ 'coredump-destroy' : 'coredump-destroy',
+ 'coredump_and_destroy' : 'coredump-destroy',
+ 'restart' : 'restart',
+ 'coredump-restart' : 'coredump-restart',
+ 'coredump_and_restart' : 'coredump-restart',
+ 'preserve' : 'preserve',
+ 'rename-restart' : 'rename-restart',
+ 'rename_restart' : 'rename-restart',
+}
+
XEN_API_VBD_MODE = ['RO', 'RW']
XEN_API_VDI_TYPE = ['system', 'user', 'ephemeral']
XEN_API_VBD_TYPE = ['CD', 'Disk']
diff -r 5078f2c1e3d6 -r e017930af272 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py Tue Jul 27 16:23:04 2010 +0100
+++ b/tools/python/xen/xend/XendConfig.py Tue Jul 27 16:53:00 2010 +0100
@@ -41,6 +41,7 @@ from xen.xend.XendSXPDev import dev_dict
from xen.xend.XendSXPDev import dev_dict_to_sxp
from xen.util import xsconstants
from xen.util import auxbin
+from xen.xend.XendAPIConstants import *
import xen.util.fileuri
log = logging.getLogger("xend.XendConfig")
@@ -61,6 +62,11 @@ def reverse_dict(adict):
def bool0(v):
return v != '0' and v != 'False' and bool(v)
+
+def convert_on_crash(v):
+ v = str(v)
+ return XEN_API_ON_CRASH_BEHAVIOUR_LEGACY[v] \
+ if v in XEN_API_ON_CRASH_BEHAVIOUR else v
# Recursively copy a data struct, scrubbing out VNC passwords.
# Will scrub any dict entry with a key of 'vncpasswd' or any
@@ -212,7 +218,7 @@ XENAPI_CFG_TYPES = {
'VCPUs_live': int,
'actions_after_shutdown': str,
'actions_after_reboot': str,
- 'actions_after_crash': str,
+ 'actions_after_crash': convert_on_crash,
'PV_bootloader': str,
'PV_kernel': str,
'PV_ramdisk': str,
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|