|
|
|
@ -1134,16 +1134,53 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
return (iface,ipaddr,mask,dhcpset)
|
|
|
|
|
|
|
|
|
|
def removeInvalidRoutes(routedata):
|
|
|
|
|
"""Remove route for device with new ip"""
|
|
|
|
|
network,gw,dev,src = routedata
|
|
|
|
|
if dev in invalidRouteIface:
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def removeSpecifiedRoutes(routedata):
|
|
|
|
|
"""Remove route for user specified"""
|
|
|
|
|
network,gw,dev,src = routedata
|
|
|
|
|
if network in specifedNet:
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def specifedRoutes(routes,ipAddrs,routedata):
|
|
|
|
|
nets = filter(lambda x:x != "default",
|
|
|
|
|
map(lambda x:x[0],routes)+map(lambda x:x[0],routedata))
|
|
|
|
|
wrongGws = map(lambda x:x[1],
|
|
|
|
|
filter(lambda x:not ip.isIpInNet(x[1],*nets),routes))
|
|
|
|
|
if wrongGws:
|
|
|
|
|
raise InstallError(_("Gateways %s is unreachable")%
|
|
|
|
|
(",".join(wrongGws)))
|
|
|
|
|
wrongIps = map(lambda x:x[3],
|
|
|
|
|
filter(lambda x:not x[3] in ipAddrs,
|
|
|
|
|
filter(lambda x:x[3],routes)))
|
|
|
|
|
if wrongIps:
|
|
|
|
|
raise InstallError(_("Wrong ip addresses %s in source IP")%
|
|
|
|
|
(",".join(wrongIps)))
|
|
|
|
|
newroutes = []
|
|
|
|
|
for network,gw,dev,src in routedata+routes:
|
|
|
|
|
if not dev:
|
|
|
|
|
gwnetwork = ip.isIpInNet(gw,*nets)[0]
|
|
|
|
|
dev = filter(lambda x:x[0]==gwnetwork,
|
|
|
|
|
routedata+newroutes)[0][2]
|
|
|
|
|
newroutes.append((network,gw,dev,src))
|
|
|
|
|
return newroutes
|
|
|
|
|
|
|
|
|
|
def standardRoutes(ipMatrix,needDev):
|
|
|
|
|
return map(lambda x:(ip.getIpNet(x[1],x[2]),"",x[0],x[1]),
|
|
|
|
|
filter(lambda x:x[3] =="off" and x[0] in needDev,
|
|
|
|
|
ipMatrix))
|
|
|
|
|
|
|
|
|
|
# check interfaces
|
|
|
|
|
getVar = self.clVars.Get
|
|
|
|
|
interfaces = getVar('os_install_net_interfaces')
|
|
|
|
|
specifiedIface = dhcps + map(lambda x:x[0],ipaddrs)
|
|
|
|
|
routeIface = map(lambda x:x[2],filter(lambda x:len(x)>2,routes))
|
|
|
|
|
routeIface = filter(lambda x:x,
|
|
|
|
|
map(lambda x:x[2],filter(lambda x:len(x)>2,routes)))
|
|
|
|
|
wrongIface = set(specifiedIface+routeIface)-set(interfaces)
|
|
|
|
|
# check correct iface
|
|
|
|
|
if wrongIface:
|
|
|
|
@ -1162,14 +1199,20 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
('interfaces', 'ip', 'mask', 'dhcp_set'))
|
|
|
|
|
invalidRouteIface = []
|
|
|
|
|
self.setVarList(ipVars, map(changeIpData, self.clVars.zipVars(*ipVars)))
|
|
|
|
|
staticIps = filter(lambda x:x,getVar('os_install_net_ip'))
|
|
|
|
|
specifedNet = map(lambda x:x[0],routes)
|
|
|
|
|
|
|
|
|
|
routeVars = map(lambda x:'os_install_net_route_%s'%x,
|
|
|
|
|
('network', 'gw', 'dev', 'src'))
|
|
|
|
|
self.setVarList(routeVars,
|
|
|
|
|
#map(changeRouteData
|
|
|
|
|
filter(removeInvalidRoutes,
|
|
|
|
|
self.clVars.zipVars(*routeVars)))
|
|
|
|
|
try:
|
|
|
|
|
self.setVarList(routeVars,
|
|
|
|
|
specifedRoutes(routes,getVar('os_install_net_ip'),
|
|
|
|
|
filter(removeSpecifiedRoutes,
|
|
|
|
|
standardRoutes(self.clVars.zipVars(*ipVars),invalidRouteIface)+
|
|
|
|
|
filter(removeInvalidRoutes,
|
|
|
|
|
self.clVars.zipVars(*routeVars)))))
|
|
|
|
|
except InstallError,e:
|
|
|
|
|
self.printERROR(str(e))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# check dup nets
|
|
|
|
|
if not self.checkDuplicate(routes,_("networks"),key=lambda x:x[0]):
|
|
|
|
|