ia64/xen-unstable
changeset 12093:edb546bbfff0
[XM] new.py that implements adding an unstarted domain
Signed-off-by: Alastair Tse <atse@xensource.com>
Signed-off-by: Alastair Tse <atse@xensource.com>
author | acnt2@huggins.lce.cl.cam.ac.uk |
---|---|
date | Thu Oct 05 17:29:19 2006 +0100 (2006-10-05) |
parents | 2bc0831859cb |
children | f297eef12823 |
files | tools/python/xen/xm/new.py |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/python/xen/xm/new.py Thu Oct 05 17:29:19 2006 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +#============================================================================ 1.5 +# This library is free software; you can redistribute it and/or 1.6 +# modify it under the terms of version 2.1 of the GNU Lesser General Public 1.7 +# License as published by the Free Software Foundation. 1.8 +# 1.9 +# This library is distributed in the hope that it will be useful, 1.10 +# but WITHOUT ANY WARRANTY; without even the implied warranty of 1.11 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1.12 +# Lesser General Public License for more details. 1.13 +# 1.14 +# You should have received a copy of the GNU Lesser General Public 1.15 +# License along with this library; if not, write to the Free Software 1.16 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1.17 +#============================================================================ 1.18 +# Copyright (C) 2006 XenSource Ltd 1.19 +#============================================================================ 1.20 + 1.21 +import os 1.22 +import xmlrpclib 1.23 + 1.24 +from xen.xend import PrettyPrint 1.25 +from xen.xend import sxp 1.26 +from xen.xend import XendClient 1.27 +from xen.xend.XendClient import server 1.28 + 1.29 +from xen.xm.opts import * 1.30 +from xen.xm.create import * 1.31 + 1.32 +def make_unstarted_domain(opts, config): 1.33 + """Create an unstarted domain. 1.34 + 1.35 + @param opts: options 1.36 + @param config: configuration 1.37 + """ 1.38 + try: 1.39 + server.xend.domain.new(config) 1.40 + except xmlrpclib.Fault, ex: 1.41 + import signal 1.42 + if vncpid: 1.43 + os.kill(vncpid, signal.SIGKILL) 1.44 + if ex.faultCode == XendClient.ERROR_INVALID_DOMAIN: 1.45 + err("the domain '%s' does not exist." % ex.faultString) 1.46 + else: 1.47 + err("%s" % ex.faultString) 1.48 + except Exception, ex: 1.49 + import signal 1.50 + if vncpid: 1.51 + os.kill(vncpid, signal.SIGKILL) 1.52 + err(str(ex)) 1.53 + 1.54 + 1.55 +def main(argv): 1.56 + try: 1.57 + (opts, config) = parseCommandLine(argv) 1.58 + except StandardError, ex: 1.59 + err(str(ex)) 1.60 + 1.61 + if not opts: 1.62 + return 1.63 + 1.64 + if opts.vals.dryrun: 1.65 + PrettyPrint.prettyprint(config) 1.66 + else: 1.67 + make_unstarted_domain(opts, config) 1.68 + 1.69 +if __name__ == '__main__': 1.70 + main(sys.argv) 1.71 +