mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
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>
This commit is contained in:
1 parent
a511447ae4
commit
e17de76e38
3 files changed
+34
-1
No files matched your search
@@ -0,0 +1,31 @@
|
||||
# Copyright (C) 2005 Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
|
||||
|
||||
# os.system() replacement which outputs through the logger
|
||||
|
||||
import popen2
|
||||
import select
|
||||
|
||||
from xen.xend.XendLogging import log
|
||||
|
||||
def system(cmd):
|
||||
# split after first space, then grab last component of path
|
||||
cmdname = "[%s] " % cmd.split()[0].split('/')[-1]
|
||||
# run command and grab stdin, stdout and stderr
|
||||
cout, cin, cerr = popen2.popen3(cmd)
|
||||
# close stdin to get command to terminate if it waits for input
|
||||
cin.close()
|
||||
# wait for output and process
|
||||
p = select.poll()
|
||||
p.register(cout)
|
||||
p.register(cerr)
|
||||
while True:
|
||||
r = p.poll()
|
||||
for (fd, event) in r:
|
||||
if event == select.POLLHUP:
|
||||
return
|
||||
if fd == cout.fileno():
|
||||
l = cout.readline()
|
||||
log.info(cmdname + l.rstrip())
|
||||
if fd == cerr.fileno():
|
||||
l = cerr.readline()
|
||||
log.error(cmdname + l.rstrip())
|
||||
@@ -3,6 +3,7 @@
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import xen.util.process
|
||||
|
||||
from xen.xend import XendRoot
|
||||
xroot = XendRoot.instance()
|
||||
@@ -35,7 +36,7 @@ def network(op, script=None, bridge=None, antispoof=None):
|
||||
else:
|
||||
args.append("antispoof=no")
|
||||
args = ' '.join(args)
|
||||
os.system(script + ' ' + args)
|
||||
xen.util.process.system(script + ' ' + args)
|
||||
|
||||
def set_vif_name(vif_old, vif_new):
|
||||
if vif_old == vif_new:
|
||||
|
||||