aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/examples/defaults9
-rw-r--r--tools/xenctl/lib/ip.py42
-rw-r--r--tools/xenmgr/lib/XendClient.py52
3 files changed, 33 insertions, 70 deletions
diff --git a/tools/examples/defaults b/tools/examples/defaults
index d391eb1d1e..336be7cede 100644
--- a/tools/examples/defaults
+++ b/tools/examples/defaults
@@ -1,3 +1,4 @@
+import xenctl.ip
##### Edit this python file to reflect the configuration of your system
@@ -45,8 +46,8 @@ cpu = vmid # set based on vmid (mod number of CPUs)
# appropriately.
#vfr_ipaddr = ["111.222.333.444","222.333.444.555"]
-vfr_ipaddr = [xenctl.utils.add_offset_to_ip(xenctl.utils.get_current_ipaddr(),vmid),
- xenctl.utils.add_offset_to_ip('169.254.1.0',vmid),]
+vfr_ipaddr = [xenctl.ip.add_offset_to_ip(xenctl.ip.get_current_ipaddr(),vmid),
+ xenctl.ip.add_offset_to_ip('169.254.1.0',vmid),]
# STEP 6. Identify any physcial partitions or virtual disks you want the
@@ -75,8 +76,8 @@ vbd_expert = 0
# You can use 'extrabit' to set the runlevel and custom environment
# variables used by custom rc scripts (e.g. VMID=, usr= )
-netmask = xenctl.utils.get_current_ipmask()
-gateway = xenctl.utils.get_current_ipgw()
+netmask = xenctl.ip.get_current_ipmask()
+gateway = xenctl.ip.get_current_ipgw()
nfsserv = '169.254.1.0'
cmdline_ip = "ip="+vfr_ipaddr[0]+":"+nfsserv+":"+gateway+":"+netmask+"::eth0:off"
diff --git a/tools/xenctl/lib/ip.py b/tools/xenctl/lib/ip.py
index 301e3654b2..8396e0d014 100644
--- a/tools/xenctl/lib/ip.py
+++ b/tools/xenctl/lib/ip.py
@@ -3,8 +3,6 @@ import re
import socket
import struct
-##### Networking-related functions
-
def readlines(fd):
"""Version of readlines safe against EINTR.
"""
@@ -34,7 +32,15 @@ def readline(fd):
continue
else:
raise
-
+
+##### Networking-related functions
+
+"""Bridge for network backend.
+When bridging is used, eth0 may not have an IP address,
+as it may have been moved onto the bridge.
+"""
+NBE_BRIDGE = 'nbe-br'
+
def get_current_ipaddr(dev='eth0'):
"""Return a string containing the primary IP address for the given
network interface (default 'eth0').
@@ -46,6 +52,8 @@ def get_current_ipaddr(dev='eth0'):
line )
if m:
return m.group(1)
+ if dev == 'eth0':
+ return get_current_ipaddr(NBE_BRIDGE)
return None
def get_current_ipmask(dev='eth0'):
@@ -59,6 +67,8 @@ def get_current_ipmask(dev='eth0'):
line )
if m:
return m.group(1)
+ if dev == 'eth0':
+ return get_current_ipmask(NBE_BRIDGE)
return None
def get_current_ipgw(dev='eth0'):
@@ -72,30 +82,8 @@ def get_current_ipgw(dev='eth0'):
'\s+\S+\s+\S*G.*' + dev + '.*', line )
if m:
return m.group(1)
- return None
-
-def setup_vfr_rules_for_vif(dom,vif,addr):
- """Takes a tuple ( domain-id, vif-id, ip-addr ), where the ip-addr
- is expressed as a textual dotted quad, and set up appropriate routing
- rules in Xen. No return value.
- """
- fd = os.open( '/proc/xen/vfr', os.O_WRONLY )
- if ( re.search( '169\.254', addr) ):
- os.write( fd, 'ADD ACCEPT srcaddr=' + addr +
- ' srcaddrmask=255.255.255.255' +
- ' srcdom=' + str(dom) + ' srcidx=' + str(vif) +
- ' dstdom=0 dstidx=0 proto=any\n' )
- else:
- os.write( fd, 'ADD ACCEPT srcaddr=' + addr +
- ' srcaddrmask=255.255.255.255' +
- ' srcdom=' + str(dom) + ' srcidx=' + str(vif) +
- ' dst=PHYS proto=any\n' )
- os.write( fd, 'ADD ACCEPT dstaddr=' + addr +
- ' dstaddrmask=255.255.255.255' +
- ' src=ANY' +
- ' dstdom=' + str(dom) + ' dstidx=' + str(vif) +
- ' proto=any\n' )
- os.close( fd )
+ if dev == 'eth0':
+ return get_current_ipgw(NBE_BRIDGE)
return None
def inet_aton(addr):
diff --git a/tools/xenmgr/lib/XendClient.py b/tools/xenmgr/lib/XendClient.py
index aa88d99e46..feed16a7de 100644
--- a/tools/xenmgr/lib/XendClient.py
+++ b/tools/xenmgr/lib/XendClient.py
@@ -12,7 +12,7 @@ from encode import *
import sxp
import PrettyPrint
-DEBUG = 1
+DEBUG = 0
class Foo(httplib.HTTPResponse):
@@ -55,6 +55,8 @@ def fileof(val):
# And should accept urls for ids?
def urljoin(location, root, prefix='', rest=''):
+ prefix = str(prefix)
+ rest = str(rest)
base = 'http://' + location + root + prefix
url = urlparse.urljoin(base, rest)
return url
@@ -68,9 +70,6 @@ def domainurl(location, root, id=''):
def consoleurl(location, root, id=''):
return urljoin(location, root, 'console/', id)
-def vbdurl(location, root, id=''):
- return urljoin(location, root, 'vbd/', id)
-
def deviceurl(location, root, id=''):
return urljoin(location, root, 'device/', id)
@@ -155,9 +154,6 @@ class Xend:
def consoleurl(self, id=''):
return consoleurl(self.location, self.root, id)
- def vbdurl(self, id=''):
- return vbdurl(self.location, self.root, id)
-
def deviceurl(self, id=''):
return deviceurl(self.location, self.root, id)
@@ -283,17 +279,17 @@ class Xend:
{'op' : 'vbd',
'vbd' : vbd})
- def xend_domain_vbd_add(self, id, uname, dev, mode):
- return xend_call(self.domainurl(id),
- {'op' : 'vbd_add',
- 'uname' : uname,
- 'dev' : dev,
- 'mode' : mode})
+## def xend_domain_vbd_add(self, id, uname, dev, mode):
+## return xend_call(self.domainurl(id),
+## {'op' : 'vbd_add',
+## 'uname' : uname,
+## 'dev' : dev,
+## 'mode' : mode})
- def xend_domain_vbd_remove(self, id, dev):
- return xend_call(self.domainurl(id),
- {'op' : 'vbd_remove',
- 'dev' : dev})
+## def xend_domain_vbd_remove(self, id, dev):
+## return xend_call(self.domainurl(id),
+## {'op' : 'vbd_remove',
+## 'dev' : dev})
def xend_consoles(self):
return xend_get(self.consoleurl())
@@ -301,28 +297,6 @@ class Xend:
def xend_console(self, id):
return xend_get(self.consoleurl(id))
- def xend_vbds(self):
- return xend_get(self.vbdurl())
-
- def xend_vbd_create(self, conf):
- return xend_call(self.vbdurl(),
- {'op': 'create', 'config': fileof(conf) })
-
- def xend_vbd(self, id):
- return xend_get(self.vbdurl(id))
-
- def xend_vbd_delete(self, id):
- return xend_call(self.vbdurl(id),
- {'op': 'delete'})
-
- def xend_vbd_refresh(self, id, expiry):
- return xend_call(self.vbdurl(id),
- {'op': 'refresh', 'expiry': expiry })
-
- def xend_vbd_expand(self, id, size):
- return xend_call(self.vbdurl(id),
- {'op': 'expand', 'size': size})
-
def xend_vnets(self):
return xend_get(self.vneturl())