本文整理汇总了Python中nmlib.nm_utils.TypeConvert.is_valid_ip4方法的典型用法代码示例。如果您正苦于以下问题:Python TypeConvert.is_valid_ip4方法的具体用法?Python TypeConvert.is_valid_ip4怎么用?Python TypeConvert.is_valid_ip4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nmlib.nm_utils.TypeConvert
的用法示例。
在下文中一共展示了TypeConvert.is_valid_ip4方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_ip4_setting
# 需要导入模块: from nmlib.nm_utils import TypeConvert [as 别名]
# 或者: from nmlib.nm_utils.TypeConvert import is_valid_ip4 [as 别名]
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: check_valid
# 需要导入模块: from nmlib.nm_utils import TypeConvert [as 别名]
# 或者: from nmlib.nm_utils.TypeConvert import is_valid_ip4 [as 别名]
def check_valid(self, name):
if name == "ip4":
return TypeConvert.is_valid_ip4(self.ip[0])
elif name == "netmask":
return TypeConvert.is_valid_netmask(self.ip[1])
elif name == "gw":
return TypeConvert.is_valid_gw(self.ip[0], self.ip[1], self.ip[2])
示例3: check_complete_dns
# 需要导入模块: from nmlib.nm_utils import TypeConvert [as 别名]
# 或者: from nmlib.nm_utils.TypeConvert import is_valid_ip4 [as 别名]
def check_complete_dns(self):
dns = []
for address in self.dns:
if TypeConvert.is_valid_ip4(address):
dns.append(address)
else:
return dns
return dns
示例4: set_dns_address
# 需要导入模块: from nmlib.nm_utils import TypeConvert [as 别名]
# 或者: from nmlib.nm_utils.TypeConvert import is_valid_ip4 [as 别名]
def set_dns_address(self, widget, content, index):
self.dns[index] = content
names = ["master", "slaver"]
dns = self.check_complete_dns()
#print "set dns address:", dns, content
if dns:
is_valid = True
self.setting.clear_dns()
for d in dns:
self.setting.add_dns(d)
else:
is_valid = False
self.setting.clear_dns()
if TypeConvert.is_valid_ip4(content):
setattr(self, names[index] + "_flag", True)
else:
setattr(self, names[index] + "_flag", False)
############
# 检查dns
if self.settings_obj:
self.settings_obj.ipv4_dns_is_valid = is_valid
self.settings_obj.set_button("save", is_valid)