# Buggy code
def __virtual__():
    """
    Set up the libcloud functions and check for GCE configurations.
    """
    if get_configured_provider() is False:
        return False

    if get_dependencies() is False:
        return False

    for provider, details in __opts__["providers"].items():
        if "gce" not in details:
            continue

        parameters = details["gce"]
        pathname = os.path.expanduser(parameters["service_account_private_key"])
        # empty pathname will tell libcloud to use instance credentials
        if (
            pathname
            and salt.utils.cloud.check_key_path_and_mode(provider, pathname) is False
        ):
            return False

    return __virtualname__


# Traceback (ResourceNotFoundError)
WARNING: CONFIG '/etc/salt/cloud' file does not exist. Falling back to default '/etc/salt/cloud'.
[DEBUG   ] Missing configuration file: /etc/salt/cloud
[DEBUG   ] Missing configuration file: /etc/salt/master
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: tmp-salt-master-02.c.covidpr-271900.internal
[DEBUG   ] Missing configuration file: /etc/salt/cloud.providers
[DEBUG   ] Including configuration from '/etc/salt/cloud.providers.d/google.conf'
[DEBUG   ] Reading configuration from /etc/salt/cloud.providers.d/google.conf
[DEBUG   ] Missing configuration file: /etc/salt/cloud.profiles
[DEBUG   ] Configuration file path: /etc/salt/master
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[INFO    ] salt-cloud starting
[DEBUG   ] Could not LazyLoad parallels.avail_sizes: 'parallels' __virtual__ returned False
[DEBUG   ] LazyLoaded parallels.avail_locations
[DEBUG   ] LazyLoaded proxmox.avail_sizes
[DEBUG   ] Starting new HTTP connection (1): metadata
[DEBUG   ] http://metadata:80 "GET /computeMetadata/v1/ HTTP/1.1" 200 28
[DEBUG   ] Starting new HTTPS connection (1): www.googleapis.com
[DEBUG   ] https://www.googleapis.com:443 "GET /compute/v1/projects/covidpr-271900/zones HTTP/1.1" 200 None
[DEBUG   ] https://www.googleapis.com:443 "GET /compute/v1/projects/covidpr-271900/regions HTTP/1.1" 200 None
[DEBUG   ] https://www.googleapis.com:443 "GET /compute/v1/projects/c/global/images HTTP/1.1" 404 None
[ERROR   ] Failed to get the output of 'gce.avail_images()': {u'reason': u'notFound', u'message': u"The resource
'projects/c' was not found. A missing project error may be an authentication issue. Please  ensure your auth cr
edentials match your project. ", u'domain': u'global'}
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 866, in image_list
data[alias][driver] = self.clouds[fun]()
File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/gce.py", line 363, in avail_images
all_images.extend(conn.list_images(project))
File "/usr/lib/python2.7/dist-packages/libcloud/compute/drivers/gce.py", line 2217, in list_images
ex_include_deprecated=dep)
File "/usr/lib/python2.7/dist-packages/libcloud/compute/drivers/gce.py", line 2269, in ex_list_project_images
method='GET').object
File "/usr/lib/python2.7/dist-packages/libcloud/compute/drivers/gce.py", line 121, in request
response = super(GCEConnection, self).request(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/libcloud/common/google.py", line 808, in request
*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/libcloud/common/base.py", line 637, in request
response = responseCls(**kwargs)
File "/usr/lib/python2.7/dist-packages/libcloud/common/base.py", line 159, in __init__
self.object = self.parse_body()
File "/usr/lib/python2.7/dist-packages/libcloud/common/google.py", line 280, in parse_body
raise ResourceNotFoundError(message, self.status, code)
ResourceNotFoundError: {u'reason': u'notFound', u'message': u"The resource 'projects/c' was not found. A missing
project error may be an authentication issue. Please  ensure your auth credentials match your project. ", u'dom
ain': u'global'}
[DEBUG   ] LazyLoaded nested.output

# Fixed code
def __virtual__():
    """
    Set up the libcloud functions and check for GCE configurations.
    """
    if not HAS_LIBCLOUD:
        return False, "apache-libcloud is not installed"

    if _LooseVersion(libcloud.__version__) < _LooseVersion("2.5.0"):
        return False, "The salt-cloud GCE driver requires apache-libcloud>=2.5.0"

    if get_configured_provider() is False:
        return False

    if get_dependencies() is False:
        return False

    for provider, details in __opts__["providers"].items():
        if "gce" not in details:
            continue

        parameters = details["gce"]
        pathname = os.path.expanduser(parameters["service_account_private_key"])
        # empty pathname will tell libcloud to use instance credentials
        if (
            pathname
            and salt.utils.cloud.check_key_path_and_mode(provider, pathname) is False
        ):
            return False

    return __virtualname__