Example #1
0
def test_is_ip(testvalue, expected_result):
    # Arrange

    # Act
    result = utils.is_ip(testvalue)

    # Assert
    assert expected_result == result
Example #2
0
 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)
Example #3
0
    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
Example #4
0
    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
Example #5
0
    def ipv6_default_gateway(self, address: str):
        """
        TODO

        :param address:
        """
        if not isinstance(address, str):
            raise TypeError(
                "Field ipv6_default_gateway of object NetworkInterface needs to be of type str!"
            )
        if address == "" or utils.is_ip(address):
            self._ipv6_default_gateway = address.strip()
            return
        raise AddressValueError("invalid format of IPv6 IP address (%s)" %
                                address)
Example #6
0
    def ipv6_secondaries(self, addresses: list):
        """
        TODO

        :param addresses:
        """
        data = utils.input_string_or_list(addresses)
        secondaries = []
        for address in data:
            if address == "" or utils.is_ip(address):
                secondaries.append(address)
            else:
                raise AddressValueError(
                    "invalid format for IPv6 IP address (%s)" % address)
        self._ipv6_secondaries = secondaries
Example #7
0
 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)
Example #8
0
 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))