* [PATCH] Expose lifecycle APIs via SEXPR protocol
@ 2006-12-07 1:20 Daniel P. Berrange
2006-12-07 12:15 ` Ewan Mellor
0 siblings, 1 reply; 2+ messages in thread
From: Daniel P. Berrange @ 2006-12-07 1:20 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: Type: text/plain, Size: 1135 bytes --]
The new lifecycle patches in xen-unstable added 3 new operations which can
be performed on domains - new, start and delete. libvirt has had no-op
stub implementations of these APIs for a while & thus we'd enable their
use for Xen 3.0.4 builds. The new APIs are not currently exposed via the
existing SEXPR protocol, and since the new Xen-API protocol is unsupported
tech-preview for 3.0.4 we don't want to re-write against that just yet.
Thus the attached patch adds the 3 neccessary bindings for the SEXPR protocol
to allow the lifecycle functionality to be invoked. It also allows the 'state'
parameter to be specified when listing domains, so we can explicitly request
inactive domains if we know we're running against a 3.0.4 era XenD
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
[-- Attachment #2: xen-3.0.4-lifecycle.patch --]
[-- Type: text/plain, Size: 3545 bytes --]
diff -r 937c821b2310 tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Wed Dec 06 20:03:53 2006 -0500
+++ b/tools/python/xen/xend/server/SrvDomain.py Wed Dec 06 20:04:00 2006 -0500
@@ -21,6 +21,7 @@ from xen.xend import sxp
from xen.xend import sxp
from xen.xend import XendDomain
from xen.xend.Args import FormFn
+from xen.xend.XendLogging import log
from xen.web.SrvDir import SrvDir
@@ -62,6 +63,18 @@ class SrvDomain(SrvDir):
def op_shutdown(self, _, req):
self.acceptCommand(req)
return self.dom.shutdown(req.args['reason'][0])
+
+ def op_delete(self, _, req):
+ self.acceptCommand(req)
+ return self.xd.domain_delete(self.dom.getName())
+
+ def op_start(self, _, req):
+ self.acceptCommand(req)
+ paused = False
+ if 'paused' in req.args and req.args['paused'] == [1]:
+ paused = True
+ log.debug("Starting domain " + self.dom.getName() + " " + str(paused))
+ return self.xd.domain_start(self.dom.getName(), paused)
def op_sysrq(self, _, req):
self.acceptCommand(req)
diff -r 937c821b2310 tools/python/xen/xend/server/SrvDomainDir.py
--- a/tools/python/xen/xend/server/SrvDomainDir.py Wed Dec 06 20:03:53 2006 -0500
+++ b/tools/python/xen/xend/server/SrvDomainDir.py Wed Dec 06 20:04:00 2006 -0500
@@ -25,6 +25,8 @@ from xen.xend.XendDomainInfo import Xend
from xen.xend.XendDomainInfo import XendDomainInfo
from xen.xend.Args import FormFn
from xen.xend.XendError import XendError
+from xen.xend.XendLogging import log
+from xen.xend.XendConstants import DOM_STATE_RUNNING
from xen.web.SrvDir import SrvDir
from SrvDomain import SrvDomain
@@ -101,6 +103,35 @@ class SrvDomainDir(SrvDir):
out.close()
return val
+ def op_new(self, _, req):
+ """Define a new domain.
+ Expects the domain config in request parameter 'config' in SXP format.
+ """
+ ok = 0
+ errmsg = ''
+ try:
+ configstring = req.args.get('config')[0]
+ #print 'op_create>', 'config:', configstring
+ pin = sxp.Parser()
+ pin.input(configstring)
+ pin.input_eof()
+ config = pin.get_val()
+ ok = 1
+ except sxp.ParseError, ex:
+ errmsg = 'Invalid configuration ' + str(ex)
+ except Exception, ex:
+ print 'op_create> Exception in config', ex
+ traceback.print_exc()
+ errmsg = 'Configuration error ' + str(ex)
+ if not ok:
+ raise XendError(errmsg)
+ try:
+ self.xd.domain_new(config)
+ except Exception, ex:
+ print 'op_create> Exception creating domain:'
+ traceback.print_exc()
+ raise XendError("Error creating domain: " + str(ex))
+
def op_restore(self, op, req):
"""Restore a domain from file.
@@ -159,7 +190,11 @@ class SrvDomainDir(SrvDir):
if detail:
sxp.show(map(XendDomainInfo.sxpr, self.xd.list()), out=req)
else:
- sxp.show(self.xd.list_names(), out=req)
+ state = DOM_STATE_RUNNING
+ if 'state' in req.args and len(req.args['state']) > 0:
+ state = req.args['state'][0]
+ log.debug("Listing domains in state " + str(state))
+ sxp.show(self.xd.list_names(state), out=req)
else:
domains = self.xd.list_sorted()
req.write('<ul>')
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Expose lifecycle APIs via SEXPR protocol
2006-12-07 1:20 [PATCH] Expose lifecycle APIs via SEXPR protocol Daniel P. Berrange
@ 2006-12-07 12:15 ` Ewan Mellor
0 siblings, 0 replies; 2+ messages in thread
From: Ewan Mellor @ 2006-12-07 12:15 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: xen-devel
On Thu, Dec 07, 2006 at 01:20:18AM +0000, Daniel P. Berrange wrote:
> The new lifecycle patches in xen-unstable added 3 new operations which can
> be performed on domains - new, start and delete. libvirt has had no-op
> stub implementations of these APIs for a while & thus we'd enable their
> use for Xen 3.0.4 builds. The new APIs are not currently exposed via the
> existing SEXPR protocol, and since the new Xen-API protocol is unsupported
> tech-preview for 3.0.4 we don't want to re-write against that just yet.
>
> Thus the attached patch adds the 3 neccessary bindings for the SEXPR protocol
> to allow the lifecycle functionality to be invoked. It also allows the 'state'
> parameter to be specified when listing domains, so we can explicitly request
> inactive domains if we know we're running against a 3.0.4 era XenD
>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Applied, thank you.
Ewan.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-12-07 12:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-07 1:20 [PATCH] Expose lifecycle APIs via SEXPR protocol Daniel P. Berrange
2006-12-07 12:15 ` Ewan Mellor
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.