Merge pull request #8982 from s0undt3ch/hotfix/salt-cloud-merge

Missed `vm_config` to `profiles_config` and tests
This commit is contained in:
Thomas S Hatch 2013-12-03 11:13:50 -08:00
commit ef40793106
5 changed files with 34 additions and 4 deletions

View File

@ -568,6 +568,7 @@ def include_config(include, orig_path, verbose):
main config file.
'''
# Protect against empty option
if not include:
return {}
@ -833,12 +834,13 @@ def cloud_config(path, env_var='SALT_CLOUD_CONFIG', defaults=None,
and not providers_config_path:
providers_config_path = os.path.join(config_dir, 'cloud.providers')
if 'vm_config' in overrides and vm_config_path is None:
if 'profiles_config' in overrides and profiles_config_path is None:
# The configuration setting is being specified in the main cloud
# configuration file
vm_config_path = overrides['vm_config']
elif 'vm_config' not in overrides and not vm_config and not vm_config_path:
providers_config_path = os.path.join(config_dir, 'cloud.providers')
profiles_config_path = overrides['profiles_config']
elif 'profiles_config' not in overrides and not profiles_config \
and not profiles_config_path:
profiles_config_path = os.path.join(config_dir, 'cloud.profiles')
# Prepare the deploy scripts search path
deploy_scripts_search_path = overrides.get(

View File

@ -602,6 +602,8 @@ class AdaptedConfigurationTestCaseMixIn(object):
return integration_config_dir
for fname in os.listdir(integration_config_dir):
if fname.startswith(('.', '_')):
continue
self.get_config_file_path(fname)
return TMP_CONF_DIR

View File

@ -0,0 +1,9 @@
# vim: filetype=yaml sw=2 ts=2 fenc=utf-8 et
Ubuntu-13.04-AMD64:
image: ami-c30360aa
provider: ec2-config
size: Micro Instance
ssh_username: ubuntu
securitygroup:
- default

View File

@ -0,0 +1,10 @@
# vim: filetype=yaml sw=2 ts=2 fenc=utf-8 et
---
ec2-config:
id: AAAAAABBBBBCCCCCDDDDDDFFFFF
key: AAAAAABBBBBCCCCCDDDDDDFFFFF
provider: ec2
keyname: salttest
securitygroup: default
private_key: salttest

View File

@ -105,6 +105,13 @@ class CloudConfigTestCase(TestCase):
if os.path.isdir(temp_conf_dir):
shutil.rmtree(temp_conf_dir)
def test_includes_load(self):
'''cloud.{providers,profiles}.d directories are loaded even if not directly passed'''
config_path = os.path.join(integration.FILES, 'conf', 'cloud')
config = cloudconfig.cloud_config(config_path)
self.assertIn('ec2-config', config['providers'])
self.assertIn('Ubuntu-13.04-AMD64', config['profiles'])
if __name__ == '__main__':
from salttesting.parser import run_testcase