ia64/xen-unstable

changeset 2874:2364cd863c91

bitkeeper revision 1.1159.1.364 (418a057eM4RcTJveJTOXENObPg0_SQ)

Cset exclude: mwilli2@equilibrium.research|ChangeSet|20041103171613|48470
author iap10@labyrinth.cl.cam.ac.uk
date Thu Nov 04 10:33:34 2004 +0000 (2004-11-04)
parents f52231be6806
children 5141b544ca25
files tools/python/xen/sv/Daemon.py tools/python/xen/util/Brctl.py tools/python/xen/util/ip.py tools/python/xen/xend/Blkctl.py tools/python/xen/xend/server/SrvDaemon.py tools/python/xen/xend/server/blkif.py tools/python/xen/xend/util.py
line diff
     1.1 --- a/tools/python/xen/sv/Daemon.py	Thu Nov 04 10:33:25 2004 +0000
     1.2 +++ b/tools/python/xen/sv/Daemon.py	Thu Nov 04 10:33:34 2004 +0000
     1.3 @@ -11,7 +11,6 @@ import sys
     1.4  import re
     1.5  
     1.6  from xen.sv.params import *
     1.7 -from xen.xend import util
     1.8  
     1.9  from twisted.internet import reactor
    1.10  from twisted.web import static, server, script
    1.11 @@ -30,7 +29,7 @@ class Daemon:
    1.12          cmdex = '(?P<cmd>.*)'
    1.13          procre = re.compile('^\s*' + pidex + '\s*' + pythonex + '\s*' + cmdex + '$')
    1.14          xendre = re.compile('^/usr/sbin/xend\s*(start|restart)\s*.*$')
    1.15 -        procs = util.popen('ps -e -o pid,args 2>/dev/null')
    1.16 +        procs = os.popen('ps -e -o pid,args 2>/dev/null')
    1.17          for proc in procs:
    1.18              pm = procre.match(proc)
    1.19              if not pm: continue
    1.20 @@ -58,7 +57,7 @@ class Daemon:
    1.21              return 0
    1.22          # Read the pid of the previous invocation and search active process list.
    1.23          pid = open(PID_FILE, 'r').read()
    1.24 -        lines = util.popen('ps ' + pid + ' 2>/dev/null').readlines()
    1.25 +        lines = os.popen('ps ' + pid + ' 2>/dev/null').readlines()
    1.26          for line in lines:
    1.27              if re.search('^ *' + pid + '.+xensv', line):
    1.28                  if not kill:
     2.1 --- a/tools/python/xen/util/Brctl.py	Thu Nov 04 10:33:25 2004 +0000
     2.2 +++ b/tools/python/xen/util/Brctl.py	Thu Nov 04 10:33:34 2004 +0000
     2.3 @@ -5,8 +5,6 @@ import os.path
     2.4  import re
     2.5  import sys
     2.6  
     2.7 -from xen.xend import util
     2.8 -
     2.9  os.defpath = os.defpath + ':/sbin:/usr/sbin:/usr/local/sbin'
    2.10  CMD_IFCONFIG = 'ifconfig'
    2.11  CMD_ROUTE    = 'route'
    2.12 @@ -83,7 +81,7 @@ def bridge_del(bridge):
    2.13  def routes():
    2.14      """Return a list of the routes.
    2.15      """
    2.16 -    fin = util.popen(CMD_ROUTE + ' -n', 'r')
    2.17 +    fin = os.popen(CMD_ROUTE + ' -n', 'r')
    2.18      routes = []
    2.19      for x in fin:
    2.20          if x.startswith('Kernel'): continue
    2.21 @@ -104,7 +102,7 @@ def routes():
    2.22  def ifconfig(interface):
    2.23      """Return the ip config for an interface,
    2.24      """
    2.25 -    fin = util.popen(CMD_IFCONFIG + ' %s' % interface, 'r')
    2.26 +    fin = os.popen(CMD_IFCONFIG + ' %s' % interface, 'r')
    2.27      inetre = re.compile('\s*inet\s*addr:(?P<address>\S*)\s*Bcast:(?P<broadcast>\S*)\s*Mask:(?P<mask>\S*)')
    2.28      info = None
    2.29      for x in fin:
     3.1 --- a/tools/python/xen/util/ip.py	Thu Nov 04 10:33:25 2004 +0000
     3.2 +++ b/tools/python/xen/util/ip.py	Thu Nov 04 10:33:34 2004 +0000
     3.3 @@ -4,8 +4,6 @@ import socket
     3.4  import struct
     3.5  import errno
     3.6  
     3.7 -from xen.xend import util
     3.8 -
     3.9  def _readlines(fd):
    3.10      """Version of readlines safe against EINTR.
    3.11      """
    3.12 @@ -51,7 +49,7 @@ def get_current_ipaddr(dev='eth0'):
    3.13  
    3.14      returns interface address as a string
    3.15      """
    3.16 -    fd = util.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
    3.17 +    fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
    3.18      lines = _readlines(fd)
    3.19      for line in lines:
    3.20          m = re.search( '^\s+inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
    3.21 @@ -69,7 +67,7 @@ def get_current_ipmask(dev='eth0'):
    3.22  
    3.23      returns interface netmask as a string
    3.24      """
    3.25 -    fd = util.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
    3.26 +    fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
    3.27      lines = _readlines(fd)
    3.28      for line in lines:
    3.29          m = re.search( '^.+Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
    3.30 @@ -87,7 +85,7 @@ def get_current_ipgw(dev='eth0'):
    3.31  
    3.32      returns gateway address as a string
    3.33      """
    3.34 -    fd = util.popen( '/sbin/route -n' )
    3.35 +    fd = os.popen( '/sbin/route -n' )
    3.36      lines = _readlines(fd)
    3.37      for line in lines:
    3.38          m = re.search( '^\S+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' +
     4.1 --- a/tools/python/xen/xend/Blkctl.py	Thu Nov 04 10:33:25 2004 +0000
     4.2 +++ b/tools/python/xen/xend/Blkctl.py	Thu Nov 04 10:33:34 2004 +0000
     4.3 @@ -5,7 +5,6 @@ import os.path
     4.4  import sys
     4.5  import string
     4.6  
     4.7 -from xen.xend import util
     4.8  from xen.xend import XendRoot
     4.9  xroot = XendRoot.instance()
    4.10  
    4.11 @@ -36,7 +35,7 @@ def block(op, type, dets, script=None):
    4.12      script = os.path.join(SCRIPT_DIR, script)
    4.13      args = [op] + string.split(dets, ':')
    4.14      args = ' '.join(args)
    4.15 -    out = util.popen(script + ' ' + args)
    4.16 +    out = os.popen(script + ' ' + args)
    4.17  
    4.18      output = out.readline()
    4.19      out.close()
     5.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Thu Nov 04 10:33:25 2004 +0000
     5.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Thu Nov 04 10:33:34 2004 +0000
     5.3 @@ -34,7 +34,6 @@ from xen.xend.XendError import XendError
     5.4  from xen.xend.server import SrvServer
     5.5  from xen.xend import XendRoot
     5.6  from xen.xend.XendLogging import log
     5.7 -from xen.xend import util
     5.8  
     5.9  import channel
    5.10  import blkif
    5.11 @@ -337,7 +336,7 @@ class Daemon:
    5.12          cmdex = '(?P<cmd>.*)'
    5.13          procre = re.compile('^\s*' + pidex + '\s*' + pythonex + '\s*' + cmdex + '$')
    5.14          xendre = re.compile('^/usr/sbin/xend\s*(start|restart)\s*.*$')
    5.15 -        procs = util.popen('ps -e -o pid,args 2>/dev/null')
    5.16 +        procs = os.popen('ps -e -o pid,args 2>/dev/null')
    5.17          for proc in procs:
    5.18              pm = procre.match(proc)
    5.19              if not pm: continue
    5.20 @@ -383,7 +382,7 @@ class Daemon:
    5.21          """
    5.22          running = 0
    5.23          if pid:
    5.24 -            lines = util.popen('ps %d 2>/dev/null' % pid).readlines()
    5.25 +            lines = os.popen('ps %d 2>/dev/null' % pid).readlines()
    5.26              exp = '^ *%d.+%s' % (pid, name)
    5.27              for line in lines:
    5.28                  if re.search(exp, line):
     6.1 --- a/tools/python/xen/xend/server/blkif.py	Thu Nov 04 10:33:25 2004 +0000
     6.2 +++ b/tools/python/xen/xend/server/blkif.py	Thu Nov 04 10:33:34 2004 +0000
     6.3 @@ -8,7 +8,6 @@ from xen.xend import sxp
     6.4  from xen.xend import Blkctl
     6.5  from xen.xend.XendLogging import log
     6.6  from xen.xend.XendError import XendError, VmError
     6.7 -from xen.xend import util
     6.8  
     6.9  import os
    6.10  import re
    6.11 @@ -26,7 +25,7 @@ def expand_dev_name(name):
    6.12  def check_mounted(self, name):
    6.13      mode = None
    6.14      name = expand_dev_name(name)
    6.15 -    lines = util.popen('mount 2>/dev/null').readlines()
    6.16 +    lines = os.popen('mount 2>/dev/null').readlines()
    6.17      exp = re.compile('^' + name + ' .*[\(,]r(?P<mode>[ow])[,\)]')
    6.18      for line in lines:
    6.19          pm = exp.match(line)
     7.1 --- a/tools/python/xen/xend/util.py	Thu Nov 04 10:33:25 2004 +0000
     7.2 +++ b/tools/python/xen/xend/util.py	Thu Nov 04 10:33:34 2004 +0000
     7.3 @@ -1,36 +0,0 @@
     7.4 -# Misc utility functions for Xend
     7.5 -# (c) 2004 Mark A. Williamson <mark.williamson@cl.cam.ac.uk>
     7.6 -
     7.7 -from twisted.internet import utils
     7.8 -from twisted.internet import reactor
     7.9 -from XendLogging import log
    7.10 -from StringIO import StringIO
    7.11 -
    7.12 -# This is rather distasteful.  Twisted doesn't play nicely with Python's
    7.13 -# standard os.popen, so here's an implementation of a synchronous popen that
    7.14 -# should work reliably. - MAW
    7.15 -def popen(cmd):
    7.16 -    global done_flag, result
    7.17 -
    7.18 -    done_flag = False
    7.19 -    result = ''
    7.20 -    
    7.21 -    def done(output):
    7.22 -        global done_flag, result
    7.23 -        done_flag = True
    7.24 -        result = output
    7.25 -
    7.26 -    def err(output):
    7.27 -        global done_flag
    7.28 -# For normal use, suppress debug output here.  It grumbles about stderr if the
    7.29 -# program exits with $? != 0, even if stderr is redirected.  Grrr!
    7.30 -#        log.debug("util.popen(\'%s\'): %s" % (cmd, output))
    7.31 -        done_flag = True
    7.32 -
    7.33 -    d = utils.getProcessOutput(cmd)
    7.34 -    d.addCallbacks(done, err)
    7.35 -
    7.36 -    while not done_flag:
    7.37 -        reactor.iterate()
    7.38 -
    7.39 -    return StringIO(result)