aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/examples/xm_dom_create.py3
-rw-r--r--tools/xenctl/lib/ip.py6
-rw-r--r--tools/xenctl/lib/utils.py42
-rw-r--r--tools/xenmgr/lib/server/SrvVdiskDir.py2
4 files changed, 22 insertions, 31 deletions
diff --git a/tools/examples/xm_dom_create.py b/tools/examples/xm_dom_create.py
index ce89426f9d..c7cd8d6701 100755
--- a/tools/examples/xm_dom_create.py
+++ b/tools/examples/xm_dom_create.py
@@ -9,7 +9,8 @@ import socket
import getopt
import signal
import syslog
-
+import xenctl.ip
+import xenctl.utils
import xenctl.console_client
from xenmgr import sxp
diff --git a/tools/xenctl/lib/ip.py b/tools/xenctl/lib/ip.py
index 0f7f61e3f8..bf5a6a2dff 100644
--- a/tools/xenctl/lib/ip.py
+++ b/tools/xenctl/lib/ip.py
@@ -10,7 +10,7 @@ def get_current_ipaddr(dev='eth0'):
network interface (default 'eth0').
"""
fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
- lines = readlines(fd)
+ lines = fd.readlines()
for line in lines:
m = re.search( '^\s+inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
line )
@@ -23,7 +23,7 @@ def get_current_ipmask(dev='eth0'):
network interface (default 'eth0').
"""
fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
- lines = readlines(fd)
+ lines = fd.readlines()
for line in lines:
m = re.search( '^.+Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
line )
@@ -36,7 +36,7 @@ def get_current_ipgw(dev='eth0'):
network interface (default 'eth0').
"""
fd = os.popen( '/sbin/route -n' )
- lines = readlines(fd)
+ lines = fd.readlines()
for line in lines:
m = re.search( '^\S+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' +
'\s+\S+\s+\S*G.*' + dev + '.*', line )
diff --git a/tools/xenctl/lib/utils.py b/tools/xenctl/lib/utils.py
index 8391ff590c..69bf779333 100644
--- a/tools/xenctl/lib/utils.py
+++ b/tools/xenctl/lib/utils.py
@@ -1,4 +1,4 @@
-import os, re, socket, string, sys, tempfile
+import os, re, socket, string, sys, tempfile, xenctl.ip
##### Module variables
@@ -28,32 +28,22 @@ except ImportError:
##### Networking-related functions
-def get_current_ipgw():
- """Return a string containing the default IP gateway."""
- fd = os.popen( '/sbin/route -n' )
- lines = fd.readlines()
- for line in lines:
- m = re.search( '^0.0.0.0+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' +
- '\s+0.0.0.0+\s+\S*G.*', line )
- if m:
- return m.group(1)
- return None
-
+def get_current_ipaddr(dev='eth0'):
+ return xenctl.ip.get_current_ipaddr(dev)
+def get_current_ipmask(dev='eth0'):
+ return xenctl.ip.get_current_ipmask(dev)
+def get_current_ipgw(dev='eth0'):
+ return xenctl.ip.get_current_ipgw(dev)
+def setup_vfr_rules_for_vif(dom,vif,addr):
+ return xenctl.ip.setup_vfr_rules_for_vif(dom,vif,addr)
+def inet_aton(addr):
+ return xenctl.ip.inet_aton(addr)
+def inet_ntoa(n):
+ return xenctl.ip.inet_ntoa(n)
+def add_offset_to_ip(addr, offset):
+ return xenctl.ip.add_offset_to_ip(addr, offset)
def check_subnet( ip, network, netmask ):
- l = string.split(ip,'.')
- n_ip = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) |
- (string.atoi(l[2])<<8) | string.atoi(l[3]) )
-
- l = string.split(network,'.')
- n_net = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) |
- (string.atoi(l[2])<<8) | string.atoi(l[3]) )
-
- l = string.split(netmask,'.')
- n_mask = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) |
- (string.atoi(l[2])<<8) | string.atoi(l[3]) )
-
- return (n_ip&n_mask)==(n_net&n_mask)
-
+ return xenctl.ip.check_subnet( ip, network, netmask )
##### VBD-related Functions
diff --git a/tools/xenmgr/lib/server/SrvVdiskDir.py b/tools/xenmgr/lib/server/SrvVdiskDir.py
index a6a9e55782..67d0955259 100644
--- a/tools/xenmgr/lib/server/SrvVdiskDir.py
+++ b/tools/xenmgr/lib/server/SrvVdiskDir.py
@@ -9,7 +9,7 @@ class SrvVdiskDir(SrvDir):
def __init__(self):
SrvDir.__init__(self)
- self.xvdisk = XendVdisk.instance()
+ #self.xvdisk = XendVdisk.instance()
def vdisk(self, x):
val = None