本文整理汇总了Python中nmlib.nm_utils.TypeConvert.ip4address_net2native方法的典型用法代码示例。如果您正苦于以下问题:Python TypeConvert.ip4address_net2native方法的具体用法?Python TypeConvert.ip4address_net2native怎么用?Python TypeConvert.ip4address_net2native使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nmlib.nm_utils.TypeConvert
的用法示例。
在下文中一共展示了TypeConvert.ip4address_net2native方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_ip4_setting
# 需要导入模块: from nmlib.nm_utils import TypeConvert [as 别名]
# 或者: from nmlib.nm_utils.TypeConvert import ip4address_net2native [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: addresses
# 需要导入模块: from nmlib.nm_utils import TypeConvert [as 别名]
# 或者: from nmlib.nm_utils.TypeConvert import ip4address_net2native [as 别名]
def addresses(self, new_addresses):
self.prop_dict["addresses"] = TypeConvert.py2_dbus_array([TypeConvert.ip4address_net2native(x) for x in new_addresses])