ia64/xen-unstable

view tools/python/xen/xm/new.py @ 15718:c2d4efc2c8f9

xm: pass --skipdtd parameter through to 'xm new'

Pass the command line parameter '--skipdtd|-s' through to the actual
'xm new' command.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kfraser@localhost.localdomain
date Mon Aug 06 13:39:20 2007 +0100 (2007-08-06)
parents 6b2875302558
children beb28a3975bd
line source
1 #============================================================================
2 # This library is free software; you can redistribute it and/or
3 # modify it under the terms of version 2.1 of the GNU Lesser General Public
4 # License as published by the Free Software Foundation.
5 #
6 # This library is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 # Lesser General Public License for more details.
10 #
11 # You should have received a copy of the GNU Lesser General Public
12 # License along with this library; if not, write to the Free Software
13 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 #============================================================================
15 # Copyright (C) 2006 XenSource Ltd
16 #============================================================================
18 import os
19 import xmlrpclib
21 from xen.xend import PrettyPrint
22 from xen.xend import sxp
23 from xen.xend import XendClient
25 from xen.xm.main import serverType, SERVER_XEN_API
26 from xen.xm.xenapi_create import *
28 from opts import *
29 from create import *
31 def make_unstarted_domain(opts, config):
32 """Create an unstarted domain.
34 @param opts: options
35 @param config: configuration
36 """
37 try:
38 server.xend.domain.new(config)
39 except xmlrpclib.Fault, ex:
40 import signal
41 if vncpid:
42 os.kill(vncpid, signal.SIGKILL)
43 if ex.faultCode == XendClient.ERROR_INVALID_DOMAIN:
44 err("the domain '%s' does not exist." % ex.faultString)
45 else:
46 err("%s" % ex.faultString)
47 except Exception, ex:
48 import signal
49 if vncpid:
50 os.kill(vncpid, signal.SIGKILL)
51 err(str(ex))
54 def main(argv):
55 try:
56 (opts, config) = parseCommandLine(argv)
57 except StandardError, ex:
58 err(str(ex))
60 if not opts:
61 return
63 if type(config) == str:
64 try:
65 config = sxp.parse(file(config))[0]
66 except IOError, exn:
67 raise OptionError("Cannot read file %s: %s" % (config, exn[1]))
69 if opts.vals.dryrun:
70 PrettyPrint.prettyprint(config)
71 return
73 if serverType == SERVER_XEN_API:
74 sxp2xml_inst = sxp2xml()
75 doc = sxp2xml_inst.convert_sxp_to_xml(config)
77 xenapi_create_inst = xenapi_create()
78 vm_refs = xenapi_create_inst.create(document = doc,
79 skipdtd=opts.vals.skipdtd)
80 else:
81 make_unstarted_domain(opts, config)
83 if __name__ == '__main__':
84 main(sys.argv)