salt/saltcloud/config.py
2012-06-22 21:52:25 -06:00

62 lines
1.2 KiB
Python

'''
Manage configuration files in salt-cloud
'''
# Import python libs
import os
# Import salt libs
import salt.config
def cloud_config(path):
'''
Read in the salt cloud config and return the dict
'''
opts = {# Provider defaults
'provider': '',
'location': '',
# User/Passwords/keys
'RACKSPACE.key': '',
'RACKSPACE.user': '',
'LINODE.apikey': '',
'EC2.id': '',
'EC2.key': '',
'EC2.keyname': '',
'EC2.securitygroup': '',
# Global defaults
'ssh_auth': '',
'keysize': 4096,
'os': '',
}
salt.config.load_config(opts, path, 'SALT_CLOUD_CONFIG')
if 'include' in opts:
opts = salt.config.include_config(opts, path)
return opts
def vm_config(path):
'''
Read in the salt cloud vm config file
'''
# No defaults
opts = {}
salt.config.load_config(opts, path, 'SALT_CLOUDVM_CONFIG')
if 'include' in opts:
opts = salt.config.include_config(opts, path)
vms = []
if 'conf_file' in opts:
opts.pop('conf_file')
for key, val in opts.items():
val['name'] = key
vms.append(val)
return vms