ia64/xen-unstable

changeset 4937:b233317fe94b

bitkeeper revision 1.1420 (4288c742JYmWjAz3bZlZhafhzuQ73w)

Vifctl.py:
Pass script output through logger.
process.py:
os.system() replacement which outputs through the logger
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Mon May 16 16:16:02 2005 +0000 (2005-05-16)
parents e208b160c5f5
children f849286c8a79
files .rootkeys tools/python/xen/util/process.py tools/python/xen/xend/Vifctl.py
line diff
     1.1 --- a/.rootkeys	Mon May 16 14:55:11 2005 +0000
     1.2 +++ b/.rootkeys	Mon May 16 16:16:02 2005 +0000
     1.3 @@ -908,6 +908,7 @@ 4270e4efFg3wHCCxXpA0h6yoMTkeSQ tools/pyt
     1.4  4055ee4dwy4l0MghZosxoiu6zmhc9Q tools/python/xen/util/console_client.py
     1.5  40c9c468IienauFHQ_xJIcqnPJ8giQ tools/python/xen/util/ip.py
     1.6  41dde8b0yuJX-S79w4xJKxBQ-Mhp1A tools/python/xen/util/memmap.py
     1.7 +4288c6fcB1kUAqX0gzU85GGxmamS4Q tools/python/xen/util/process.py
     1.8  4059c6a0pnxhG8hwSOivXybbGOwuXw tools/python/xen/util/tempfile.py
     1.9  4267a9b16u4IEPhjRryesk6A17sobA tools/python/xen/web/SrvBase.py
    1.10  4267a9b1FfCUjW7m9anLERcx9lwhJg tools/python/xen/web/SrvDir.py
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/python/xen/util/process.py	Mon May 16 16:16:02 2005 +0000
     2.3 @@ -0,0 +1,31 @@
     2.4 +# Copyright (C) 2005 Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
     2.5 +
     2.6 +# os.system() replacement which outputs through the logger
     2.7 +
     2.8 +import popen2
     2.9 +import select
    2.10 +
    2.11 +from xen.xend.XendLogging import log
    2.12 +
    2.13 +def system(cmd):
    2.14 +    # split after first space, then grab last component of path
    2.15 +    cmdname = "[%s] " % cmd.split()[0].split('/')[-1]
    2.16 +    # run command and grab stdin, stdout and stderr
    2.17 +    cout, cin, cerr = popen2.popen3(cmd)
    2.18 +    # close stdin to get command to terminate if it waits for input
    2.19 +    cin.close()
    2.20 +    # wait for output and process
    2.21 +    p = select.poll()
    2.22 +    p.register(cout)
    2.23 +    p.register(cerr)
    2.24 +    while True:
    2.25 +        r = p.poll()
    2.26 +        for (fd, event) in r:
    2.27 +            if event == select.POLLHUP:
    2.28 +                return
    2.29 +            if fd == cout.fileno():
    2.30 +                l = cout.readline()
    2.31 +                log.info(cmdname + l.rstrip())
    2.32 +            if fd == cerr.fileno():
    2.33 +                l = cerr.readline()
    2.34 +                log.error(cmdname + l.rstrip())
     3.1 --- a/tools/python/xen/xend/Vifctl.py	Mon May 16 14:55:11 2005 +0000
     3.2 +++ b/tools/python/xen/xend/Vifctl.py	Mon May 16 16:16:02 2005 +0000
     3.3 @@ -3,6 +3,7 @@
     3.4  import os
     3.5  import os.path
     3.6  import sys
     3.7 +import xen.util.process
     3.8  
     3.9  from xen.xend import XendRoot
    3.10  xroot = XendRoot.instance()
    3.11 @@ -35,7 +36,7 @@ def network(op, script=None, bridge=None
    3.12      else:
    3.13          args.append("antispoof=no")
    3.14      args = ' '.join(args)
    3.15 -    os.system(script + ' ' + args)
    3.16 +    xen.util.process.system(script + ' ' + args)
    3.17  
    3.18  def set_vif_name(vif_old, vif_new):
    3.19      if vif_old == vif_new: