def partition_hostname(hostname):
    """Return a hostname separated into host and domain parts."""

    parts = hostname.partition('.')
    return dict(hostname=parts[0],
                domainname=parts[2] if parts[1] == '.' else None)