ia64/xen-unstable

changeset 13200:069d1364af53

Added Brctl.get_state, to support upcoming PIF implementation.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Wed Dec 27 15:39:32 2006 +0000 (2006-12-27)
parents 088752354770
children a8e853aecb3e
files tools/python/xen/util/Brctl.py
line diff
     1.1 --- a/tools/python/xen/util/Brctl.py	Wed Dec 27 15:39:04 2006 +0000
     1.2 +++ b/tools/python/xen/util/Brctl.py	Wed Dec 27 15:39:32 2006 +0000
     1.3 @@ -28,6 +28,31 @@ def cmd(p, s):
     1.4      if not opts.dryrun:
     1.5          os.system(c)
     1.6  
     1.7 +bridgeRE = re.compile(r'([^\t]*)\t*[^\t]*\t*[^\t]*\t*([^\t]*)')
     1.8 +def get_state():
     1.9 +    fin = os.popen(CMD_BRCTL + ' show', 'r')
    1.10 +    try:
    1.11 +        bridges = {}
    1.12 +        brlist = None
    1.13 +        brname = None
    1.14 +        first = True
    1.15 +        for line in fin:
    1.16 +            if first:
    1.17 +                first = False
    1.18 +            elif line[0] == '\t':
    1.19 +                brlist.append(line.strip())
    1.20 +            else:
    1.21 +                if brname:
    1.22 +                    bridges[brname] = brlist
    1.23 +                m = bridgeRE.match(line)
    1.24 +                brname = m.group(1)
    1.25 +                brlist = [m.group(2).strip()]
    1.26 +        if brname:
    1.27 +            bridges[brname] = brlist
    1.28 +        return bridges
    1.29 +    finally:
    1.30 +        fin.close()
    1.31 +
    1.32  def vif_bridge_add(params):
    1.33      """Add the network interface for vif on dom to a bridge.
    1.34      """