mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Update GCE driver to return True, False or a new name in __virtual__()
This commit is contained in:
parent
24a4f54f39
commit
78e31585cf
1 changed files with 7 additions and 3 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Reference in a new issue