ia64/xen-unstable

changeset 1471:f6495a180c4d

bitkeeper revision 1.962 (40cd9f1f2QxKhNFa2ms5ieF5zvkihQ)

backwards compatibility with exisiting config files : xenctl.utils -> xenctl.ip
fix readlines breakage
temporailly disable vdisk support to avoid sqlite depnedancy
author iap10@labyrinth.cl.cam.ac.uk
date Mon Jun 14 12:50:39 2004 +0000 (2004-06-14)
parents a53cc9700ac8
children 38d3dc57c133
files tools/examples/xm_dom_create.py tools/xenctl/lib/ip.py tools/xenctl/lib/utils.py tools/xenmgr/lib/server/SrvVdiskDir.py
line diff
     1.1 --- a/tools/examples/xm_dom_create.py	Mon Jun 14 10:43:06 2004 +0000
     1.2 +++ b/tools/examples/xm_dom_create.py	Mon Jun 14 12:50:39 2004 +0000
     1.3 @@ -9,7 +9,8 @@ import socket
     1.4  import getopt
     1.5  import signal
     1.6  import syslog
     1.7 -
     1.8 +import xenctl.ip
     1.9 +import xenctl.utils
    1.10  import xenctl.console_client
    1.11  
    1.12  from xenmgr import sxp
     2.1 --- a/tools/xenctl/lib/ip.py	Mon Jun 14 10:43:06 2004 +0000
     2.2 +++ b/tools/xenctl/lib/ip.py	Mon Jun 14 12:50:39 2004 +0000
     2.3 @@ -10,7 +10,7 @@ def get_current_ipaddr(dev='eth0'):
     2.4      network interface (default 'eth0').
     2.5      """
     2.6      fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
     2.7 -    lines = readlines(fd)
     2.8 +    lines = fd.readlines()
     2.9      for line in lines:
    2.10          m = re.search( '^\s+inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
    2.11                         line )
    2.12 @@ -23,7 +23,7 @@ def get_current_ipmask(dev='eth0'):
    2.13      network interface (default 'eth0').
    2.14      """
    2.15      fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
    2.16 -    lines = readlines(fd)
    2.17 +    lines = fd.readlines()
    2.18      for line in lines:
    2.19          m = re.search( '^.+Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
    2.20                         line )
    2.21 @@ -36,7 +36,7 @@ def get_current_ipgw(dev='eth0'):
    2.22      network interface (default 'eth0').
    2.23      """
    2.24      fd = os.popen( '/sbin/route -n' )
    2.25 -    lines = readlines(fd)
    2.26 +    lines = fd.readlines()
    2.27      for line in lines:
    2.28          m = re.search( '^\S+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' +
    2.29                         '\s+\S+\s+\S*G.*' + dev + '.*', line )
     3.1 --- a/tools/xenctl/lib/utils.py	Mon Jun 14 10:43:06 2004 +0000
     3.2 +++ b/tools/xenctl/lib/utils.py	Mon Jun 14 12:50:39 2004 +0000
     3.3 @@ -1,4 +1,4 @@
     3.4 -import os, re, socket, string, sys, tempfile
     3.5 +import os, re, socket, string, sys, tempfile, xenctl.ip
     3.6  
     3.7  ##### Module variables
     3.8  
     3.9 @@ -28,32 +28,22 @@ except ImportError:
    3.10  
    3.11  ##### Networking-related functions
    3.12  
    3.13 -def get_current_ipgw():
    3.14 -    """Return a string containing the default IP gateway."""
    3.15 -    fd = os.popen( '/sbin/route -n' )
    3.16 -    lines = fd.readlines()
    3.17 -    for line in lines:
    3.18 -        m = re.search( '^0.0.0.0+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' +
    3.19 -                       '\s+0.0.0.0+\s+\S*G.*', line )
    3.20 -        if m:
    3.21 -            return m.group(1)
    3.22 -    return None
    3.23 -
    3.24 +def get_current_ipaddr(dev='eth0'):
    3.25 +    return xenctl.ip.get_current_ipaddr(dev)
    3.26 +def get_current_ipmask(dev='eth0'):
    3.27 +    return xenctl.ip.get_current_ipmask(dev)
    3.28 +def get_current_ipgw(dev='eth0'):
    3.29 +    return xenctl.ip.get_current_ipgw(dev)
    3.30 +def setup_vfr_rules_for_vif(dom,vif,addr):
    3.31 +    return xenctl.ip.setup_vfr_rules_for_vif(dom,vif,addr)
    3.32 +def inet_aton(addr):
    3.33 +    return xenctl.ip.inet_aton(addr)
    3.34 +def inet_ntoa(n):
    3.35 +    return xenctl.ip.inet_ntoa(n)
    3.36 +def add_offset_to_ip(addr, offset):
    3.37 +    return xenctl.ip.add_offset_to_ip(addr, offset)
    3.38  def check_subnet( ip, network, netmask ):
    3.39 -    l = string.split(ip,'.')
    3.40 -    n_ip = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) | 
    3.41 -	   (string.atoi(l[2])<<8)  | string.atoi(l[3]) ) 
    3.42 -
    3.43 -    l = string.split(network,'.')
    3.44 -    n_net = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) | 
    3.45 -	   (string.atoi(l[2])<<8)  | string.atoi(l[3]) )
    3.46 -
    3.47 -    l = string.split(netmask,'.')
    3.48 -    n_mask = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) | 
    3.49 -	   (string.atoi(l[2])<<8)  | string.atoi(l[3]) )
    3.50 -    
    3.51 -    return (n_ip&n_mask)==(n_net&n_mask)
    3.52 -
    3.53 +    return xenctl.ip.check_subnet( ip, network, netmask )
    3.54  
    3.55  ##### VBD-related Functions
    3.56  
     4.1 --- a/tools/xenmgr/lib/server/SrvVdiskDir.py	Mon Jun 14 10:43:06 2004 +0000
     4.2 +++ b/tools/xenmgr/lib/server/SrvVdiskDir.py	Mon Jun 14 12:50:39 2004 +0000
     4.3 @@ -9,7 +9,7 @@ class SrvVdiskDir(SrvDir):
     4.4  
     4.5      def __init__(self):
     4.6          SrvDir.__init__(self)
     4.7 -        self.xvdisk = XendVdisk.instance()
     4.8 +        #self.xvdisk = XendVdisk.instance()
     4.9  
    4.10      def vdisk(self, x):
    4.11          val = None