def getIpLocal(): for interface in ip.getInterfaces(): try: return ip.getIp(interface) except: continue else: return ""
def get(self): """All computer ip addresses, comma delimeter""" IPs = [] netInterfaces=self.Get("os_net_interfaces") for i in netInterfaces: ipaddr = ip.getIp(i) if ipaddr: IPs.append(ipaddr) return ",".join(IPs)
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 getDefaultValue(self,iface): def statusValue(ipaddr,dhcp): if dhcp == "on": return "dhcp" elif ipaddr: return ipaddr else: if getOperState(iface) == 'down': return "off" else: return "dhcp" rootDevNfs = self.Get('os_root_dev') == '/dev/nfs' return statusValue(getIp(iface),"on" \ if rootDevNfs or isDhcpIp(iface) else "off")
def get(self): return map(lambda x:"" if x[1].lower() == "off" else getIp(x[0]) if x[1].lower() == "dhcp" else x[1], zip(self.Get('os_install_net_interfaces'), self.Get('os_install_net_status')))