chiark / gitweb /
adt-virt-xenlvm more or less done; needing testing
authorIan Jackson <ian@anarres>
Wed, 1 Nov 2006 16:57:03 +0000 (16:57 +0000)
committerIan Jackson <ian@anarres>
Wed, 1 Nov 2006 16:57:03 +0000 (16:57 +0000)
virt-subproc/VirtSubproc.py
virt-subproc/adt-virt-chroot
virt-subproc/adt-virt-xenlvm

index e30a5fb9f28e40a271208a3109585ae3a73a6746..833cb5d0ea26aa0649035b363d6c9b0b34bf7431 100644 (file)
@@ -53,6 +53,7 @@ def cmdnumargs(c, ce, nargs=0):
 
 def cmd_capabilities(c, ce):
        cmdnumargs(c, ce)
+       return caller.hook_capabilities()
 
 def cmd_quit(c, ce):
        cmdnumargs(c, ce)
@@ -311,6 +312,7 @@ def mainloop():
                sys.exit(16)
 
 def main():
+       debug("down = %s" % string.join(down))
        ok()
        prepare()
        mainloop()
index e5651e195eaac0f8f393109d3de630317743ba81..ffcc39b6dfc7ea057d62c56fc172aa4001e85e3e 100755 (executable)
 
 import sys
 import os
+import string
+from optparse import OptionParser
 
 try: our_base = os.environ['AUTOPKGTEST_BASE']
 except KeyError: our_base = '/usr/share/autopkgtest';
 sys.path.insert(1, our_base+'/python')
 
-import string
-from optparse import OptionParser
 import VirtSubproc as vsp
+capabilities = []
 
 def parse_args():
        global down, debuglevel
 
-       usage = "%prog [options] =<dchroot>|/path/to/chroot"
+       usage = "%prog [<options>] =<dchroot>|/path/to/chroot"
        parser = OptionParser(usage=usage)
        pa = parser.add_option
        pe = parser.error
@@ -57,9 +58,12 @@ def parse_args():
        elif chroot_arg[0] == '/': down = ['chroot',chroot_arg,'--']
        else: pe("chroot spec must be =[DCHROOT] or /PATH/TO/CHROOT")
 
-       if opts.gain_root != None: down = opts.gain_root.split() + down
+       if opts.gain_root != None:
+               down = opts.gain_root.split() + down
+
+       if opts.gain_root or os.getuid()==0:
+               capabilities.append('root-on-testbed')
 
-       vsp.debug("down = %s" % string.join(down))
        vsp.down = down
 
 def hook_open():
@@ -75,5 +79,8 @@ def hook_stop():
 def hook_cleanup():
        vsp.execute('rm -rf --', [downtmp], downp=True)
 
+def hook_capabilities():
+       return capabilities
+
 parse_args()
 vsp.main()
index 366bcbca6ec833560ba272f3dfd1215143aa34df..870afb1631c9bb246eb287c5fb21de2d68cbe34b 100755 (executable)
 
 import sys
 import os
+import re as regexp
+import string
+from optparse import OptionParser
 
 try: our_base = os.environ['AUTOPKGTEST_BASE']
 except KeyError: our_base = '/usr/share/autopkgtest';
 sys.path.insert(1, our_base+'/python')
 
-import string
-from optparse import OptionParser
 import VirtSubproc as vsp
 
 witholder = None
 
 def parse_args():
-       global down, debuglevel, xlargs
+       global debuglevel, xlargs, gain_root
+
+       usage = "%prog <options> [-- <adt-xenlvm options>]"
+       parser = OptionParser(usage=usage)
+       pa = parser.add_option
+       pe = parser.error
+
+       pa('-r', '--gain-root', type='string', dest='gain_root');
+       pa('-d', '--debug', action='store_true', dest='debug');
 
-       usage = "%prog [<adt-xenlvm options>]"
-       for a in 
+       (opts,xlargs) = parser.parse_args()
+       vsp.debuglevel = opts.debug
 
-       fixme must check args fit --<var>=<value> as expected by adt-xenlvm
-       fixme then put set of args into global xlargs
-       fixme fix these next two lines:
-       vsp.debug("down = %s" % string.join(down))
-       vsp.down = down
+       if opts.gain_root = None: gain_root = []
+       else: gain_root = opts.gain_root.split()
+       vsp.down = gain_root + ['adt-xenlvm-on-testbed'] + xlargs + ['--']
 
 def hook_open():
        hook_cleanup()
        withholder = subprocess.Popen(
-               ['adt-xenlvm-with-testbed'] + xlargs +
+               gain_root + ['adt-xenlvm-with-testbed'] + xlargs +
                 ['--','sh','-ec','echo y; exec cat'],
                stdin=subprocess.PIPE, stdout=subprocess.PIPE )
        l = withholder.stdout.readline(2)
        rc = withholder.poll()
-       if rc is not None: bomb("with-testbed failed, code %d" % rc)
-       if l != "y\n": bomb("with-testbed sh gave wrong output `%s', not `l'"
+       if rc is not None:
+               withholder.stdin.close()
+               withholder.stdout.close()
+               withholder = None
+               bomb("with-testbed failed, code %d" % rc)
+       if l != "y\n":
+               bomb("with-testbed sh gave wrong output `%s', not `l'"
                        % l.rstrip("\n"))
        downtmp = '/root/adt-downtmp'
        vsp.execute('mkdir %s' % downtmp, downp=True)
@@ -77,6 +89,9 @@ def hook_cleanup():
                withholder = None
                if rc: print >>sys.stderr, (
                        "with-testbed failed during cleanup, code %d" % rc)
-       
+
+def hook_capabilities():
+       return ('revert','root-on-testbed','suggest-normal-user=adtxenu')
+
 parse_args()
 vsp.main()