ia64/xen-unstable

changeset 14574:3b2efc3cf6b6

Add option to xm create to skip DTD checks.

signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
author Tom Wilkie <tom.wilkie@gmail.com>
date Mon Mar 26 15:09:24 2007 +0100 (2007-03-26)
parents d01e7ace9d2c
children effef488d448
files tools/python/xen/xm/create.py tools/python/xen/xm/xenapi_create.py
line diff
     1.1 --- a/tools/python/xen/xm/create.py	Mon Mar 26 14:57:12 2007 +0100
     1.2 +++ b/tools/python/xen/xm/create.py	Mon Mar 26 15:09:24 2007 +0100
     1.3 @@ -104,6 +104,11 @@ gopts.opt('xmldryrun', short='x',
     1.4            use="XML dry run - prints the resulting configuration in XML but "
     1.5            "does not create the domain.")
     1.6  
     1.7 +gopts.opt('skipdtd', short='s',
     1.8 +          fn=set_true, default=0,
     1.9 +          use="Skip DTD checking - skips checks on XML before creating. "
    1.10 +          " Experimental.  Can decreate create time." )
    1.11 +
    1.12  gopts.opt('paused', short='p',
    1.13            fn=set_true, default=0,
    1.14            use='Leave the domain paused after it is created.')
    1.15 @@ -1279,9 +1284,11 @@ def main(argv):
    1.16          from xen.xm.xenapi_create import xenapi_create
    1.17          xenapi_create_inst = xenapi_create()
    1.18          if opts.is_xml:
    1.19 -            vm_refs = xenapi_create_inst.create(filename = config)
    1.20 +            vm_refs = xenapi_create_inst.create(filename = config,
    1.21 +                                                skipdtd = opts.vals.skipdtd)
    1.22          else:
    1.23 -            vm_refs = xenapi_create_inst.create(document = doc)
    1.24 +            vm_refs = xenapi_create_inst.create(document = doc,
    1.25 +                                                skipdtd = opts.vals.skipdtd)
    1.26  
    1.27          map(lambda vm_ref: server.xenapi.VM.start(vm_ref, 0), vm_refs)
    1.28      elif not opts.is_xml:
     2.1 --- a/tools/python/xen/xm/xenapi_create.py	Mon Mar 26 14:57:12 2007 +0100
     2.2 +++ b/tools/python/xen/xm/xenapi_create.py	Mon Mar 26 15:09:24 2007 +0100
     2.3 @@ -75,15 +75,20 @@ class xenapi_create:
     2.4  
     2.5          self.dtd = "/usr/lib/python/xen/xm/create.dtd"
     2.6  
     2.7 -    def create(self, filename=None, document=None):
     2.8 +    def create(self, filename=None, document=None, skipdtd=False):
     2.9          """
    2.10          Create a domain from an XML file or DOM tree
    2.11          """
    2.12 +        if skipdtd:
    2.13 +            print "Skipping DTD checks.  Dangerous!"
    2.14 +        
    2.15          if filename is not None:
    2.16 -            self.check_dtd(filename)
    2.17 +            if not skipdtd:
    2.18 +                self.check_dtd(filename)
    2.19              document = parse(filename)
    2.20          elif document is not None:
    2.21 -            self.check_dom_against_dtd(document)
    2.22 +            if not skipdtd:
    2.23 +                self.check_dom_against_dtd(document)
    2.24  
    2.25          self.check_doc(document)
    2.26