Merge pull request #13548 from gtmanfred/apply_sdb

add apply_sdb function
This commit is contained in:
Joseph Hall 2014-06-18 19:37:00 -06:00
commit 75f2da81e0
2 changed files with 32 additions and 8 deletions

View file

@ -4,6 +4,7 @@ All salt configuration loading and defaults should be in this module
'''
# Import python libs
from __future__ import generators
import glob
import os
import re
@ -894,6 +895,28 @@ def syndic_config(master_config_path,
# ----- Salt Cloud Configuration Functions ---------------------------------->
def apply_sdb(opts, sdb_opts=None):
'''
Recurse for sdb:// links for opts
'''
if sdb_opts is None:
sdb_opts = opts
if isinstance(sdb_opts, string_types) and sdb_opts.startswith('sdb://'):
return salt.utils.sdb.sdb_get(sdb_opts, opts)
elif isinstance(sdb_opts, dict):
for key, value in sdb_opts.items():
if value is None:
continue
sdb_opts[key] = apply_sdb(opts, value)
elif isinstance(sdb_opts, list):
for key, value in enumerate(sdb_opts):
if value is None:
continue
sdb_opts[key] = apply_sdb(opts, value)
return sdb_opts
def cloud_config(path, env_var='SALT_CLOUD_CONFIG', defaults=None,
master_config_path=None, master_config=None,
providers_config_path=None, providers_config=None,
@ -1141,6 +1164,9 @@ def cloud_config(path, env_var='SALT_CLOUD_CONFIG', defaults=None,
providers_config)
opts['profiles'] = profiles_config
# recurse opts for sdb configs
apply_sdb(opts)
# Return the final options
return opts

View file

@ -1458,19 +1458,17 @@ class CloudCredentialsMixIn(object):
' PROVIDER can be specified with or without a driver, for example:'
' "--set-password bob rackspace"'
' or more specific'
' "--set-password bob rackspace:openstack"')
' "--set-password bob rackspace:openstack"'
' DEPRECATED!')
)
self.add_option_group(group)
def process_set_password(self):
if self.options.set_password:
self.credential_username, self.credential_provider = self.options.set_password
if self.credential_provider.startswith('-') or \
'=' in self.credential_provider:
self.error(
'--set-password expects two arguments: <username> '
'<provider>'
)
raise RuntimeError(
'This functionality is not supported; '
'please see the keyring module at http://docs.saltstack.com/en/latest/topics/sdb/'
)
class MasterOptionParser(OptionParser, ConfigDirMixIn, MergeConfigMixIn,