[PATCH 1/2] Improve and document network.sanityCheckHostname

Brian C. Lane bcl at redhat.com
Thu Nov 29 22:23:29 UTC 2012


On Thu, Nov 29, 2012 at 03:30:43PM +0100, Vratislav Podzimek wrote:
> The rules for hostname are more strict. Also, it was not easy to use
> this function because of its return values.
> 
> Related: rhbz#865869
> 
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>  pyanaconda/network.py | 37 +++++++++++++++++++++++++++++--------
>  1 file changed, 29 insertions(+), 8 deletions(-)
> -    return None
> +    if any(not HOSTNAME_PART_RE.match(part) for part in hostname.split(".")):
> +        return (False, _("Hostnames can only contain the characters 'a-z', "
> +                         "'A-Z', '0-9', '-', or '.', and parts between periods "
> +                         "must contain something and cannot start or end with "
> +                         "'-'."))

I think 'not all(HOSTNAME_PART_RE...)' would be easier to read. You want
all of the parts to match so if they don't all match return an error.

Other than that, looks good.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20121129/384b2b9f/attachment.sig>


More information about the anaconda-patches mailing list