Пример #1
0
def getIpLocal():
    for interface in ip.getInterfaces():
        try:
            return ip.getIp(interface)
        except:
            continue
    else:
        return ""
Пример #2
0
 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)
Пример #3
0
 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))
Пример #4
0
 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")
Пример #5
0
 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')))