import re


def get_protocol_and_host(url):
    """Validate a given url and extract the protocol and
       host from given url.
       If the url if invalid, a tuple of (None, None) is
       returned to the caller.

       param url: Input url to be parsed

       returns: Tuple of protocol and host. So if input is
            https://compute.jiocloud.com, the method returns
            (https, compute.jiocloud.com)
    """

    url_regex = re.compile('(http[s]?)://((?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)')
    url_parts = url_regex.match(url)
    if not url_parts:
        return (None, None)
    else:
        return (url_parts.group(1), url_parts.group(2))