mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
bitkeeper revision 1.959.1.2 (40cec47bY9QNauJ8KR9IhT-ZdJCb-A)
Fix domain start problem for dom create - id was an int. Make IP default adressing tolerate eth0 not having an address.
This commit is contained in:
1 parent
c6edccf293
commit
0f48aa43d8
3 files changed
+60
-67
No files matched your search
@@ -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"
|
||||
|
||||
+42
-24
@@ -3,8 +3,44 @@ import re
|
||||
import socket
|
||||
import struct
|
||||
|
||||
def readlines(fd):
|
||||
"""Version of readlines safe against EINTR.
|
||||
"""
|
||||
import errno
|
||||
|
||||
lines = []
|
||||
while 1:
|
||||
try:
|
||||
line = fd.readline()
|
||||
except IOError, ex:
|
||||
if ex.errno == errno.EINTR:
|
||||
continue
|
||||
else:
|
||||
raise
|
||||
if line == '': break
|
||||
lines.append(line)
|
||||
return lines
|
||||
|
||||
def readline(fd):
|
||||
"""Version of readline safe against EINTR.
|
||||
"""
|
||||
while 1:
|
||||
try:
|
||||
return fd.readline()
|
||||
except IOError, ex:
|
||||
if ex.errno == errno.EINTR:
|
||||
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').
|
||||
@@ -16,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'):
|
||||
@@ -29,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'):
|
||||
@@ -42,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):
|
||||
|
||||
@@ -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())
|
||||
|
||||
|
||||