bitkeeper revision 1.1426.1.1 (4289cc8cPUM98bLJs4TV93NHY9LOKg)

Many files:
  Make interface to network/block scripts consistent:
  - output on stdout is returned to the script caller
  - output on stderr is logged at the error level, messages with a '-' prefix
    are logged at the debug level and messages with a '*' prefix are logged
    at the info level.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
This commit is contained in:
cl349@firebug.cl.cam.ac.uk committed 2005-05-17 10:50:52 +00:00
1 parent ca5d3268f9
commit b93e7f7e8b
10 files changed
+40 -32

No files matched your search

+2 -2
View File
@@ -27,7 +27,7 @@ case $1 in
;;
*)
echo 'Unknown command: ' $1
echo 'Valid commands are: bind, unbind'
echo 'Unknown command: ' $1 >&2
echo 'Valid commands are: bind, unbind' >&2
exit 1
esac
+2 -2
View File
@@ -25,7 +25,7 @@ case $1 in
;;
*)
echo 'Unknown command: ' $1
echo 'Valid commands are: bind, unbind'
echo 'Unknown command: ' $1 >&2
echo 'Valid commands are: bind, unbind' >&2
exit 1
esac
+3 -3
View File
@@ -53,7 +53,7 @@ bridge=${bridge:-xen-br0}
netdev=${netdev:-eth0}
antispoof=${antispoof:-yes}
echo "network $OP bridge=$bridge netdev=$netdev antispoof=$antispoof"
echo "*network $OP bridge=$bridge netdev=$netdev antispoof=$antispoof" >&2
# Usage: transfer_addrs src dst
# Copy all IP addresses (including aliases) from device $src to device $dst.
@@ -232,7 +232,7 @@ case ${OP} in
;;
*)
echo 'Unknown command: ' ${OP}
echo 'Valid commands are: start, stop, status'
echo 'Unknown command: ' ${OP} >&2
echo 'Valid commands are: start, stop, status' >&2
exit 1
esac
+3 -3
View File
@@ -32,7 +32,7 @@ netdev=${netdev:-eth0}
# antispoofing not yet implemented
antispoof=${antispoof:-no}
echo "network-nat $OP netdev=$netdev antispoof=$antispoof"
echo "*network-nat $OP netdev=$netdev antispoof=$antispoof" >&2
op_start() {
@@ -71,7 +71,7 @@ case ${OP} in
;;
*)
echo 'Unknown command: ' ${OP}
echo 'Valid commands are: start, stop, status'
echo 'Unknown command: ' ${OP} >&2
echo 'Valid commands are: start, stop, status' >&2
exit 1
esac
+3 -3
View File
@@ -34,7 +34,7 @@
# Exit if anything goes wrong
set -e
echo "vif-bridge $*"
echo "*vif-bridge $*" >&2
# Operation name.
OP=$1
@@ -63,8 +63,8 @@ case $OP in
iptcmd='-D'
;;
*)
echo 'Invalid command: ' $OP
echo 'Valid commands are: up, down'
echo 'Invalid command: ' $OP >&2
echo 'Valid commands are: up, down' >&2
exit 1
;;
esac
+3 -3
View File
@@ -23,7 +23,7 @@
# Exit if anything goes wrong
set -e
echo "vif-nat $*"
echo "*vif-nat $*" >&2
# Operation name.
OP=$1
@@ -56,8 +56,8 @@ case $OP in
ipcmd='d'
;;
*)
echo 'Invalid command: ' $OP
echo 'Valid commands are: up, down'
echo 'Invalid command: ' $OP >&2
echo 'Valid commands are: up, down' >&2
exit 1
;;
esac
+3 -3
View File
@@ -24,7 +24,7 @@
# Exit if anything goes wrong
set -e
echo "vif-route $*"
echo "*vif-route $*" >&2
# Operation name.
OP=$1
@@ -57,8 +57,8 @@ case $OP in
ipcmd='d'
;;
*)
echo 'Invalid command: ' $OP
echo 'Valid commands are: up, down'
echo 'Invalid command: ' $OP >&2
echo 'Valid commands are: up, down' >&2
exit 1
;;
esac
+11 -5
View File
@@ -4,10 +4,11 @@
import popen2
import select
import string
from xen.xend.XendLogging import log
def system(cmd):
def runscript(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
@@ -18,14 +19,19 @@ def system(cmd):
p = select.poll()
p.register(cout)
p.register(cerr)
stdout = ""
while True:
r = p.poll()
for (fd, event) in r:
if event == select.POLLHUP:
return
return stdout
if fd == cout.fileno():
l = cout.readline()
log.info(cmdname + l.rstrip())
stdout = stdout + cout.readline()
if fd == cerr.fileno():
l = cerr.readline()
log.error(cmdname + l.rstrip())
if l[0] == '-':
log.debug(cmdname + l[1:].rstrip())
elif l[0] == '*':
log.info(cmdname + l[1:].rstrip())
else:
log.error(cmdname + l.rstrip())
+4 -5
View File
@@ -4,6 +4,7 @@ import os
import os.path
import sys
import string
import xen.util.process
from xen.xend import XendRoot
@@ -38,8 +39,6 @@ def block(op, type, dets, script=None):
script = os.path.join(SCRIPT_DIR, script)
args = [op] + string.split(dets, ':')
args = ' '.join(args)
out = os.popen(script + ' ' + args)
output = _readline(out)
out.close()
return string.rstrip(output)
ret = xen.util.process.runscript(script + ' ' + args)
if len(ret):
return ret.splitlines()[0]
+6 -3
View File
@@ -36,7 +36,9 @@ def network(op, script=None, bridge=None, antispoof=None):
else:
args.append("antispoof=no")
args = ' '.join(args)
xen.util.process.system(script + ' ' + args)
ret = xen.util.process.runscript(script + ' ' + args)
if len(ret):
return ret.splitlines()[0]
def set_vif_name(vif_old, vif_new):
if vif_old == vif_new:
@@ -81,5 +83,6 @@ def vifctl(op, vif=None, script=None, domain=None, mac=None, bridge=None, ipaddr
ips = ' '.join(ipaddr)
args.append("ip='%s'" % ips)
args = ' '.join(args)
os.system(script + ' ' + args)
ret = xen.util.process.runscript(script + ' ' + args)
if len(ret):
return ret.splitlines()[0]
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.