WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Many files:

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Many files:
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Tue, 17 May 2005 10:50:52 +0000
Delivery-date: Tue, 17 May 2005 14:04:05 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
ChangeSet 1.1426.1.1, 2005/05/17 11:50:52+01:00, cl349@xxxxxxxxxxxxxxxxxxxx

        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@xxxxxxxxxxxx>



 examples/block-enbd        |    4 ++--
 examples/block-file        |    4 ++--
 examples/network           |    6 +++---
 examples/network-nat       |    6 +++---
 examples/vif-bridge        |    6 +++---
 examples/vif-nat           |    6 +++---
 examples/vif-route         |    6 +++---
 python/xen/util/process.py |   16 +++++++++++-----
 python/xen/xend/Blkctl.py  |    9 ++++-----
 python/xen/xend/Vifctl.py  |    9 ++++++---
 10 files changed, 40 insertions(+), 32 deletions(-)


diff -Nru a/tools/examples/block-enbd b/tools/examples/block-enbd
--- a/tools/examples/block-enbd 2005-05-17 10:04:39 -04:00
+++ b/tools/examples/block-enbd 2005-05-17 10:04:39 -04:00
@@ -27,7 +27,7 @@
        ;;
 
        *)
-               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
diff -Nru a/tools/examples/block-file b/tools/examples/block-file
--- a/tools/examples/block-file 2005-05-17 10:04:39 -04:00
+++ b/tools/examples/block-file 2005-05-17 10:04:39 -04:00
@@ -25,7 +25,7 @@
        ;;
 
        *)
-               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
diff -Nru a/tools/examples/network b/tools/examples/network
--- a/tools/examples/network    2005-05-17 10:04:39 -04:00
+++ b/tools/examples/network    2005-05-17 10:04:39 -04:00
@@ -53,7 +53,7 @@
 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 @@
        ;;
 
     *)
-       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
diff -Nru a/tools/examples/network-nat b/tools/examples/network-nat
--- a/tools/examples/network-nat        2005-05-17 10:04:39 -04:00
+++ b/tools/examples/network-nat        2005-05-17 10:04:39 -04:00
@@ -32,7 +32,7 @@
 # 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 @@
        ;;
 
     *)
-       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
diff -Nru a/tools/examples/vif-bridge b/tools/examples/vif-bridge
--- a/tools/examples/vif-bridge 2005-05-17 10:04:39 -04:00
+++ b/tools/examples/vif-bridge 2005-05-17 10:04:39 -04:00
@@ -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 @@
         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
diff -Nru a/tools/examples/vif-nat b/tools/examples/vif-nat
--- a/tools/examples/vif-nat    2005-05-17 10:04:39 -04:00
+++ b/tools/examples/vif-nat    2005-05-17 10:04:39 -04:00
@@ -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 @@
         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
diff -Nru a/tools/examples/vif-route b/tools/examples/vif-route
--- a/tools/examples/vif-route  2005-05-17 10:04:39 -04:00
+++ b/tools/examples/vif-route  2005-05-17 10:04:39 -04:00
@@ -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 @@
         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
diff -Nru a/tools/python/xen/util/process.py b/tools/python/xen/util/process.py
--- a/tools/python/xen/util/process.py  2005-05-17 10:04:39 -04:00
+++ b/tools/python/xen/util/process.py  2005-05-17 10:04:39 -04:00
@@ -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 @@
     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())
diff -Nru a/tools/python/xen/xend/Blkctl.py b/tools/python/xen/xend/Blkctl.py
--- a/tools/python/xen/xend/Blkctl.py   2005-05-17 10:04:39 -04:00
+++ b/tools/python/xen/xend/Blkctl.py   2005-05-17 10:04:39 -04:00
@@ -4,6 +4,7 @@
 import os.path
 import sys
 import string
+import xen.util.process
 
 from xen.xend import XendRoot
 
@@ -38,8 +39,6 @@
     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]
diff -Nru a/tools/python/xen/xend/Vifctl.py b/tools/python/xen/xend/Vifctl.py
--- a/tools/python/xen/xend/Vifctl.py   2005-05-17 10:04:39 -04:00
+++ b/tools/python/xen/xend/Vifctl.py   2005-05-17 10:04:39 -04:00
@@ -36,7 +36,9 @@
     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 @@
         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]

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>