[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Implement VM_BAD_POWER_STATE handling.
# HG changeset patch # User Ewan Mellor <ewan@xxxxxxxxxxxxx> # Date 1167074945 0 # Node ID ce4e548f42b89f0c716f2fbe812c9172b28e7469 # Parent 6533ebfc25e13b7dcce82e486f22b7c3ab9ed4d3 Implement VM_BAD_POWER_STATE handling. Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx> --- tools/python/xen/xend/XendAPI.py | 12 ++++++++---- tools/python/xen/xend/XendDomain.py | 13 ++++++++++--- tools/python/xen/xend/XendError.py | 10 ++++++++++ tools/python/xen/xm/messages/en/xen-xm.po | 4 +++- 4 files changed, 31 insertions(+), 8 deletions(-) diff -r 6533ebfc25e1 -r ce4e548f42b8 tools/python/xen/xend/XendAPI.py --- a/tools/python/xen/xend/XendAPI.py Mon Dec 25 18:44:27 2006 +0000 +++ b/tools/python/xen/xend/XendAPI.py Mon Dec 25 19:29:05 2006 +0000 @@ -260,10 +260,14 @@ def do_vm_func(fn_name, vm_ref, *args, * @param *args: more arguments @type *args: tuple """ - xendom = XendDomain.instance() - fn = getattr(xendom, fn_name) - xendom.do_legacy_api_with_uuid(fn, vm_ref, *args, **kwargs) - return xen_api_success_void() + try: + xendom = XendDomain.instance() + fn = getattr(xendom, fn_name) + xendom.do_legacy_api_with_uuid(fn, vm_ref, *args, **kwargs) + return xen_api_success_void() + except VMBadState, exn: + return xen_api_error(['VM_BAD_POWER_STATE', vm_ref, exn.expected, + exn.actual]) class XendAPI: diff -r 6533ebfc25e1 -r ce4e548f42b8 tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Mon Dec 25 18:44:27 2006 +0000 +++ b/tools/python/xen/xend/XendDomain.py Mon Dec 25 19:29:05 2006 +0000 @@ -36,6 +36,7 @@ from xen.xend.PrettyPrint import prettyp from xen.xend.PrettyPrint import prettyprint from xen.xend.XendConfig import XendConfig from xen.xend.XendError import XendError, XendInvalidDomain, VmError +from xen.xend.XendError import VMBadState from xen.xend.XendLogging import log from xen.xend.XendAPIConstants import XEN_API_VM_POWER_STATE from xen.xend.XendConstants import XS_VMROOT @@ -782,7 +783,9 @@ class XendDomain: raise XendError("Cannot save privileged domain %s" % domname) if dominfo.state != DOM_STATE_RUNNING: - raise XendError("Cannot suspend domain that is not running.") + raise VMBadState("Domain is not running", + POWER_STATE_NAMES[DOM_STATE_RUNNING], + POWER_STATE_NAMES[dominfo.state]) dom_uuid = dominfo.get_uuid() @@ -932,7 +935,9 @@ class XendDomain: raise XendInvalidDomain(str(domid)) if dominfo.state != DOM_STATE_HALTED: - raise XendError("Domain is already running") + raise VMBadState("Domain is already running", + POWER_STATE_NAMES[DOM_STATE_HALTED], + POWER_STATE_NAMES[dominfo.state]) dominfo.start(is_managed = True) self._add_domain(dominfo) @@ -960,7 +965,9 @@ class XendDomain: raise XendInvalidDomain(str(domid)) if dominfo.state != DOM_STATE_HALTED: - raise XendError("Domain is still running") + raise VMBadState("Domain is still running", + POWER_STATE_NAMES[DOM_STATE_HALTED], + POWER_STATE_NAMES[dominfo.state]) log.info("Domain %s (%s) deleted." % (dominfo.getName(), dominfo.info.get('uuid'))) diff -r 6533ebfc25e1 -r ce4e548f42b8 tools/python/xen/xend/XendError.py --- a/tools/python/xen/xend/XendError.py Mon Dec 25 18:44:27 2006 +0000 +++ b/tools/python/xen/xend/XendError.py Mon Dec 25 19:29:05 2006 +0000 @@ -32,6 +32,16 @@ class XendError(Fault): def __str__(self): return self.value +class VMBadState(XendError): + + def __init__(self, value, expected, actual): + XendError.__init__(self, value) + self.expected = expected + self.actual = actual + + def __str__(self): + return self.value + class VmError(XendError): """Vm construction error.""" pass diff -r 6533ebfc25e1 -r ce4e548f42b8 tools/python/xen/xm/messages/en/xen-xm.po --- a/tools/python/xen/xm/messages/en/xen-xm.po Mon Dec 25 18:44:27 2006 +0000 +++ b/tools/python/xen/xm/messages/en/xen-xm.po Mon Dec 25 19:29:05 2006 +0000 @@ -19,7 +19,7 @@ msgid "" msgid "" msgstr "" "Project-Id-Version: Xen-xm 3.0\n" -"PO-Revision-Date: 2006-12-23 11:04+0000\n" +"PO-Revision-Date: 2006-12-25 19:24+0000\n" "Last-Translator: Ewan Mellor <ewan@xxxxxxxxxxxxx>\n" "Language-Team: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>\n" "MIME-Version: 1.0\n" @@ -65,3 +65,5 @@ msgid "VTPM_HANDLE_INVALID" msgid "VTPM_HANDLE_INVALID" msgstr "The VTPM handle %(1)s is invalid." +msgid "VM_BAD_POWER_STATE" +msgstr "The VM must be %(2)s to perform the requested operation (it is currently %(3)s)." _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |