Update GCE driver to return True, False or a new name in __virtual__()

This commit is contained in:
rallytime 2015-08-27 12:04:06 -06:00
parent 24a4f54f39
commit 78e31585cf

View file

@ -108,6 +108,8 @@ from salt.exceptions import (
# Get logging started
log = logging.getLogger(__name__)
__virtualname__ = 'gce'
# Redirect GCE functions to this module namespace
avail_locations = namespaced_function(avail_locations, globals())
script = namespaced_function(script, globals())
@ -138,20 +140,21 @@ def __virtual__():
pathname = os.path.expanduser(parameters['service_account_private_key'])
if not os.path.exists(pathname):
raise SaltCloudException(
log.error(
'The GCE service account private key {0!r} used in '
'the {1!r} provider configuration does not exist\n'.format(
parameters['service_account_private_key'],
provider
)
)
return False
keymode = str(
oct(stat.S_IMODE(os.stat(pathname).st_mode))
)
if keymode not in ('0400', '0600'):
raise SaltCloudException(
log.error(
'The GCE service account private key {0!r} used in '
'the {1!r} provider configuration needs to be set to '
'mode 0400 or 0600\n'.format(
@ -159,8 +162,9 @@ def __virtual__():
provider
)
)
return False
return True
return __virtualname__
def get_configured_provider():