|
|
|
@ -1118,21 +1118,20 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
def setNetwork(self,ipaddrs,dhcps,routes):
|
|
|
|
|
"""Set network configuration"""
|
|
|
|
|
def changeIpData(ipdata):
|
|
|
|
|
iface,ipaddr,mask,dhcpset = ipdata
|
|
|
|
|
iface,ipaddr,cidr,dhcpset = ipdata
|
|
|
|
|
if iface in dhcps:
|
|
|
|
|
if dhcpset == "off":
|
|
|
|
|
invalidRouteIface.append(iface)
|
|
|
|
|
dhcpset = "on"
|
|
|
|
|
mask = ""
|
|
|
|
|
cidr = ""
|
|
|
|
|
ipaddr = ""
|
|
|
|
|
elif iface in dictIpAddr:
|
|
|
|
|
newipaddr,op,cidr = dictIpAddr[iface].partition('/')
|
|
|
|
|
newmask = ip.netToMask(int(cidr))
|
|
|
|
|
if dhcpset == "on" or newipaddr != ipaddr or newmask != mask:
|
|
|
|
|
newipaddr,op,newcidr = dictIpAddr[iface].partition('/')
|
|
|
|
|
if dhcpset == "on" or newipaddr != ipaddr or newcidr != cidr:
|
|
|
|
|
invalidRouteIface.append(iface)
|
|
|
|
|
ipaddr,mask = newipaddr,mask
|
|
|
|
|
ipaddr,cidr = newipaddr,newcidr
|
|
|
|
|
dhcpset = "off"
|
|
|
|
|
return (iface,ipaddr,mask,dhcpset)
|
|
|
|
|
return (iface,ipaddr,cidr,dhcpset)
|
|
|
|
|
|
|
|
|
|
def removeInvalidRoutes(routedata):
|
|
|
|
|
"""Remove route for device with new ip"""
|
|
|
|
@ -1149,16 +1148,20 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
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))
|
|
|
|
|
NET,GW,DEV,SRC=0,1,2,3
|
|
|
|
|
nets = filter(lambda net:net != "default",
|
|
|
|
|
map(lambda x:x[NET],routes)+map(lambda x:x[NET],routedata))
|
|
|
|
|
routes = filter(lambda x:x[GW] or x[SRC],routes)
|
|
|
|
|
wrongGws = map(lambda x:x[GW],
|
|
|
|
|
filter(lambda x:not ip.isIpInNet(x[GW],*nets),
|
|
|
|
|
filter(lambda x:x[GW],
|
|
|
|
|
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)))
|
|
|
|
|
wrongIps = map(lambda x:x[SRC],
|
|
|
|
|
filter(lambda x:not x[SRC] in ipAddrs,
|
|
|
|
|
filter(lambda x:x[SRC],routes)))
|
|
|
|
|
if wrongIps:
|
|
|
|
|
raise InstallError(_("Wrong ip addresses %s in source IP")%
|
|
|
|
|
(",".join(wrongIps)))
|
|
|
|
@ -1166,14 +1169,18 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
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]
|
|
|
|
|
dev = filter(lambda x:x[NET]==gwnetwork,
|
|
|
|
|
routedata+newroutes)[0][DEV]
|
|
|
|
|
if not gw and not src:
|
|
|
|
|
continue
|
|
|
|
|
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,
|
|
|
|
|
IFACE,IP,CIDR,DHCP = 0,1,2,3
|
|
|
|
|
return map(lambda x:(ip.getIpNet(x[IP],cidr=x[CIDR]),
|
|
|
|
|
"",x[IFACE],x[IP]),
|
|
|
|
|
filter(lambda x:x[DHCP] =="off" and x[IFACE] in needDev,
|
|
|
|
|
ipMatrix))
|
|
|
|
|
|
|
|
|
|
# check interfaces
|
|
|
|
@ -1197,7 +1204,7 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
|
|
|
|
|
# set user data to variables
|
|
|
|
|
ipVars = map(lambda x:'os_install_net_%s'%x,
|
|
|
|
|
('interfaces', 'ip', 'mask', 'dhcp_set'))
|
|
|
|
|
('interfaces', 'ip', 'cidr', 'dhcp_set'))
|
|
|
|
|
invalidRouteIface = []
|
|
|
|
|
self.setVarList(ipVars, map(changeIpData, self.clVars.zipVars(*ipVars)))
|
|
|
|
|
specifedNet = map(lambda x:x[0],routes)
|
|
|
|
@ -1780,11 +1787,11 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
def generateTableNetworkData(self):
|
|
|
|
|
"""Get bind data for print table"""
|
|
|
|
|
def ipInformation(listIpMaskDhcp):
|
|
|
|
|
ipaddr,mask,dhcp = listIpMaskDhcp
|
|
|
|
|
ipaddr,cidr,dhcp = listIpMaskDhcp
|
|
|
|
|
if dhcp == "on":
|
|
|
|
|
return _("DHCP")
|
|
|
|
|
elif ipaddr:
|
|
|
|
|
return "{ip}/{net}".format(ip=ipaddr,net=ip.maskToNet(mask))
|
|
|
|
|
return "{ip}/{cidr}".format(ip=ipaddr,cidr=cidr)
|
|
|
|
|
else:
|
|
|
|
|
return _("Off")
|
|
|
|
|
clGet = self.clVars.Get
|
|
|
|
@ -1795,7 +1802,7 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
clGet('os_install_net_mac'),
|
|
|
|
|
map(ipInformation,
|
|
|
|
|
zip(clGet('os_install_net_ip'),
|
|
|
|
|
clGet('os_install_net_mask'),
|
|
|
|
|
clGet('os_install_net_cidr'),
|
|
|
|
|
clGet('os_install_net_dhcp_set'))))
|
|
|
|
|
|
|
|
|
|
def generateTableRouteData(self):
|
|
|
|
|