コード例 #1
0
    def check_ip4_setting(self, info_dict):
        if "ipv4" in info_dict.keys():
            if info_dict["ipv4"]["method"] == "manual":

                if not info_dict["ipv4"]["addresses"]:
                    print "ipv4 addresses not complete"
                    return False
                else:
                    [address, netmask,
                     gateway] = TypeConvert.ip4address_net2native(
                         info_dict["ipv4"]["addresses"][0])

                    if not TypeConvert.is_valid_ip4(address):
                        print "ipv4 invalid address"
                        return False

                    if not TypeConvert.is_valid_netmask(netmask):
                        print "ipv4 invalid netmask"
                        return False

                    if not TypeConvert.is_valid_gw(address, netmask, gateway):
                        print "ipv4 invalid gateway"
                        return False

            if "dns" in info_dict["ipv4"].keys() and len(
                    info_dict["ipv4"]["dns"]) > 0:
                for dns in info_dict["ipv4"]["dns"]:
                    if not TypeConvert.is_valid_ip4(
                            TypeConvert.ip4_net2native(dns)):
                        print "ipv4 invalid dns"
                        return False
        return True
コード例 #2
0
    def check_ip4_setting(self, info_dict):
        if "ipv4" in info_dict.keys():
            if info_dict["ipv4"]["method"] == "manual":

                if not info_dict["ipv4"]["addresses"]:
                    print "ipv4 addresses not complete"
                    return False
                else:
                    [address, netmask, gateway] = TypeConvert.ip4address_net2native(info_dict["ipv4"]["addresses"][0])

                    if not TypeConvert.is_valid_ip4(address):
                        print "ipv4 invalid address"
                        return False

                    if not TypeConvert.is_valid_netmask(netmask):
                        print "ipv4 invalid netmask"
                        return False

                    if not TypeConvert.is_valid_gw(address, netmask, gateway):
                        print "ipv4 invalid gateway"
                        return False

            if "dns" in info_dict["ipv4"].keys() and len(info_dict["ipv4"]["dns"]) > 0:
                for dns in info_dict["ipv4"]["dns"]:
                    if not TypeConvert.is_valid_ip4(TypeConvert.ip4_net2native(dns)):
                        print "ipv4 invalid dns"
                        return False
        return True
コード例 #3
0
 def dns(self):
     if "dns" not in self.prop_dict.iterkeys():
         self.clear_dns()
     return map(lambda x: TypeConvert.ip4_net2native(x),
                self.prop_dict["dns"])
コード例 #4
0
 def dns(self):
     if "dns" not in self.prop_dict.iterkeys():
         self.clear_dns()
     return map(lambda x: TypeConvert.ip4_net2native(x), self.prop_dict["dns"])