ia64/xen-unstable

changeset 7478:17a9f111fa93

Temporary workaround to xend start problem.

Signed-off-by: James Bulpin <james@xensource.com>
author jrb44@plym.cl.cam.ac.uk
date Fri Oct 21 18:51:42 2005 +0100 (2005-10-21)
parents 2d5b92e7c79a
children 21a211649fe2
files tools/python/xen/util/process.py tools/python/xen/xend/Vifctl.py
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/python/xen/util/process.py	Fri Oct 21 18:51:42 2005 +0100
     1.3 @@ -0,0 +1,39 @@
     1.4 +# Copyright (C) 2005 Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
     1.5 +
     1.6 +# os.system() replacement which outputs through the logger
     1.7 +
     1.8 +import popen2
     1.9 +import select
    1.10 +import string
    1.11 +
    1.12 +from xen.xend.XendLogging import log
    1.13 +
    1.14 +def runscript(cmd):
    1.15 +    # split after first space, then grab last component of path
    1.16 +    cmdname = "[%s] " % cmd.split()[0].split('/')[-1]
    1.17 +    # run command and grab stdin, stdout and stderr
    1.18 +    cout, cin, cerr = popen2.popen3(cmd)
    1.19 +    # close stdin to get command to terminate if it waits for input
    1.20 +    cin.close()
    1.21 +    # wait for output and process
    1.22 +    p = select.poll()
    1.23 +    p.register(cout)
    1.24 +    p.register(cerr)
    1.25 +    stdout = ""
    1.26 +    while True:
    1.27 +        r = p.poll()
    1.28 +        for (fd, event) in r:
    1.29 +            if event == select.POLLHUP:
    1.30 +                cout.close()
    1.31 +                cerr.close()
    1.32 +                return stdout
    1.33 +            if fd == cout.fileno():
    1.34 +                stdout = stdout + cout.readline()
    1.35 +            if fd == cerr.fileno():
    1.36 +                l = cerr.readline()
    1.37 +                if l[0] == '-':
    1.38 +                    log.debug(cmdname + l[1:].rstrip())
    1.39 +                elif l[0] == '*':
    1.40 +                    log.info(cmdname + l[1:].rstrip())
    1.41 +                else:
    1.42 +                    log.error(cmdname + l.rstrip())
     2.1 --- a/tools/python/xen/xend/Vifctl.py	Fri Oct 21 18:29:26 2005 +0100
     2.2 +++ b/tools/python/xen/xend/Vifctl.py	Fri Oct 21 18:51:42 2005 +0100
     2.3 @@ -20,9 +20,9 @@
     2.4  """
     2.5  import os
     2.6  
     2.7 +import xen.util.process
     2.8  import XendRoot
     2.9  
    2.10 -
    2.11  def network(op):
    2.12      """Call a network control script.
    2.13  
    2.14 @@ -32,4 +32,6 @@ def network(op):
    2.15          raise ValueError('Invalid operation: ' + op)
    2.16      script = XendRoot.instance().get_network_script()
    2.17      if script:
    2.18 -        os.spawnl(os.P_WAIT, script, script, op)
    2.19 +        xen.util.process.runscript(script + " " + op)
    2.20 +        #os.spawnl(os.P_WAIT, script, script, op)
    2.21 +