• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.is_ip函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.is_ip函数的典型用法代码示例。如果您正苦于以下问题:Python is_ip函数的具体用法?Python is_ip怎么用?Python is_ip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了is_ip函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_matching

 def test_matching(self):
     self.assertTrue(utils.is_mac("00:C0:B7:7E:55:50"))
     self.assertTrue(utils.is_mac("00:c0:b7:7E:55:50"))
     self.assertFalse(utils.is_mac("00.D0.B7.7E.55.50"))
     self.assertFalse(utils.is_mac("testsystem0"))
     self.assertTrue(utils.is_ip("127.0.0.1"))
     self.assertTrue(utils.is_ip("192.168.1.1"))
     self.assertFalse(utils.is_ip("00:C0:B7:7E:55:50"))
     self.assertFalse(utils.is_ip("testsystem0"))
开发者ID:bluemutedwisdom,项目名称:cobbler-2.x,代码行数:9,代码来源:test_basic.py


示例2: set_name

    def set_name(self,name):
        """
        Set the name.  If the name is a MAC or IP, and the first MAC and/or IP is not defined, go ahead
        and fill that value in.  
        """

        if self.name not in ["",None] and self.parent not in ["",None] and self.name == self.parent:
            raise CX(_("self parentage is weird"))
        if not isinstance(name, basestring):
            raise CX(_("name must be a string"))
        for x in name:
            if not x.isalnum() and not x in [ "_", "-", ".", ":", "+" ] :
                raise CX(_("invalid characters in name: %s") % x)

        # Stuff here defaults to eth0. Yes, it's ugly and hardcoded, but so was
        # the default interface behaviour that's now removed. ;)
        # --Jasper Capel
        if utils.is_mac(name):
           intf = self.__get_interface("eth0")
           if intf["mac_address"] == "":
               intf["mac_address"] = name
        elif utils.is_ip(name):
           intf = self.__get_interface("eth0")
           if intf["ip_address"] == "":
               intf["ip_address"] = name
        self.name = name 

        return True
开发者ID:aquette,项目名称:cobbler,代码行数:28,代码来源:item_system.py


示例3: set_gateway

 def set_gateway(self,gateway):
     if gateway is None:
        gateway = ""
     if utils.is_ip(gateway) or gateway == "":
        self.gateway = gateway
     else:
        raise CX(_("invalid format for gateway IP address (%s)") % gateway)
     return True
开发者ID:aquette,项目名称:cobbler,代码行数:8,代码来源:item_system.py


示例4: set_ipv6_address

 def set_ipv6_address(self,address,interface):
     """
     Assign a IP or hostname in DHCP when this MAC boots.
     Only works if manage_dhcp is set in /etc/cobbler/settings
     """
     intf = self.__get_interface(interface)
     if address == "" or utils.is_ip(address):
        intf["ipv6_address"] = address.strip()
        return True
     raise CX(_("invalid format for IPv6 IP address (%s)") % address)
开发者ID:aquette,项目名称:cobbler,代码行数:10,代码来源:item_system.py


示例5: set_ipv6_secondaries

    def set_ipv6_secondaries(self,addresses,interface):
        intf = self.__get_interface(interface)
        data = utils.input_string_or_list(addresses)
        secondaries = []
        for address in data:
           if address == "" or utils.is_ip(address):
               secondaries.append(address)
           else:
               raise CX(_("invalid format for IPv6 IP address (%s)") % address)

        intf["ipv6_secondaries"] = secondaries
        return True
开发者ID:aquette,项目名称:cobbler,代码行数:12,代码来源:item_system.py


示例6: set_ip_address

    def set_ip_address(self, address, interface):
        """
        Assign a IP or hostname in DHCP when this MAC boots.
        Only works if manage_dhcp is set in /etc/cobbler/settings
        """
        intf = self.__get_interface(interface)

        # FIXME: move duplicate supression code to the object validation
        # functions to take a harder line on supression?
        if address != "" and not str(self.config._settings.allow_duplicate_ips).lower() in ["1", "y", "yes"]:
            matched = self.config.api.find_items("system", {"ip_address": address})
            for x in matched:
                if x.name != self.name:
                    raise CX("IP address duplicated: %s" % address)

        if address == "" or utils.is_ip(address):
            intf["ip_address"] = address.strip()
            return True
        raise CX(_("invalid format for IP address (%s)") % address)
开发者ID:aronparsons,项目名称:cobbler,代码行数:19,代码来源:item_system.py


示例7: set_name

    def set_name(self, name):
        """
        Set the name.  If the name is a MAC or IP, and the first MAC and/or IP is not defined, go ahead
        and fill that value in.
        """

        if self.name not in ["", None] and self.parent not in ["", None] and self.name == self.parent:
            raise CX(_("self parentage is weird"))
        self.validate_name(name)

        # Stuff here defaults to eth0. Yes, it's ugly and hardcoded, but so was
        # the default interface behaviour that's now removed. ;)
        # --Jasper Capel
        if utils.is_mac(name):
            intf = self.__get_interface("eth0")
            if intf["mac_address"] == "":
                intf["mac_address"] = name
        elif utils.is_ip(name):
            intf = self.__get_interface("eth0")
            if intf["ip_address"] == "":
                intf["ip_address"] = name
        self.name = name

        return True
开发者ID:aronparsons,项目名称:cobbler,代码行数:24,代码来源:item_system.py


示例8: set_ipv6_default_gateway

 def set_ipv6_default_gateway(self,address,interface):
     intf = self.__get_interface(interface)
     if address == "" or utils.is_ip(address):
        intf["ipv6_default_gateway"] = address.strip()
        return True
     raise CX(_("invalid format for IPv6 IP address (%s)") % address)
开发者ID:aquette,项目名称:cobbler,代码行数:6,代码来源:item_system.py


示例9: ip_address

 def ip_address(self, ip_address):
     if is_ip(ip_address):
         self._ip_address = ip_address
     else:
         raise ValueError("Not an IP address")
开发者ID:Kremmin,项目名称:st2contrib,代码行数:5,代码来源:node.py


示例10: set_if_gateway

 def set_if_gateway(self,gateway,interface):
     intf = self.__get_interface(interface)
     if gateway == "" or utils.is_ip(gateway):
         intf["if_gateway"] = gateway
         return True
     raise CX(_("invalid gateway: %s" % gateway))
开发者ID:cspargo,项目名称:cobbler,代码行数:6,代码来源:item_system.py


示例11: whois

def whois(indicator):
    if is_ip(indicator):
        return ip_whois(indicator)
    else:
        return domain_whois(indicator)
开发者ID:BoriBori,项目名称:cassava,代码行数:5,代码来源:whois.py



注:本文中的utils.is_ip函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.is_login函数代码示例发布时间:2022-05-26
下一篇:
Python utils.intify函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap