def get(self): """Allowed networks""" networks=[] netInterfaces=self.Get("os_net_interfaces") for i in netInterfaces: ipaddr, mask = ip.getIp(i),ip.cidrToMask(ip.getMask(i)) if ipaddr and mask: networks.append(ip.getIpNet(ipaddr, mask)) else: networks.append("") return ",".join(filter(lambda x:x,networks))
def performRouteData(self,performFunc): routeMatrix = zip(self.Get('os_install_net_route_network'), self.Get('os_install_net_route_gw'), self.Get('os_install_net_route_dev'), self.Get('os_install_net_route_src')) DEV,IP,CIDR,NET = 0,1,2,1 return map(lambda x:performFunc(x[DEV],x[NET],routeMatrix), # union ip and mask to ip/net map(lambda x:(x[DEV],ip.getIpNet(x[IP],cidr=x[CIDR])) \ if x[IP] and x[CIDR] else (x[DEV],""), #filter(lambda x:x[IP] and x[CIDR], zip(self.Get('os_install_net_interfaces'), self.Get('os_install_net_ip'), self.Get('os_install_net_cidr'))))
def get(self): return map(lambda x:getIpNet(x[0],x[1]) if x[0] and x[1] else "", zip(self.Get('os_install_net_ip'), self.Get('os_install_net_mask')))