mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
parent
f4cdcc0d66
commit
d2db4ea7a2
4 changed files with 28 additions and 19 deletions
|
@ -4492,7 +4492,7 @@ def _parse_pricing(url, name):
|
|||
regions[region['region']] = sizes
|
||||
|
||||
outfile = os.path.join(
|
||||
__opts__['cachedir'], 'cloud', 'ec2-pricing-{0}.p'.format(name)
|
||||
__opts__['cachedir'], 'ec2-pricing-{0}.p'.format(name)
|
||||
)
|
||||
with salt.utils.fopen(outfile, 'w') as fho:
|
||||
msgpack.dump(regions, fho)
|
||||
|
@ -4556,7 +4556,7 @@ def show_pricing(kwargs=None, call=None):
|
|||
name = 'linux'
|
||||
|
||||
pricefile = os.path.join(
|
||||
__opts__['cachedir'], 'cloud', 'ec2-pricing-{0}.p'.format(name)
|
||||
__opts__['cachedir'], 'ec2-pricing-{0}.p'.format(name)
|
||||
)
|
||||
|
||||
if not os.path.isfile(pricefile):
|
||||
|
|
|
@ -2160,7 +2160,7 @@ def update_pricing(kwargs=None, call=None):
|
|||
price_json = http.query(url, decode=True, decode_type='json')
|
||||
|
||||
outfile = os.path.join(
|
||||
__opts__['cachedir'], 'cloud', 'gce-pricing.p'
|
||||
__opts__['cachedir'], 'gce-pricing.p'
|
||||
)
|
||||
with salt.utils.fopen(outfile, 'w') as fho:
|
||||
msgpack.dump(price_json['dict'], fho)
|
||||
|
@ -2196,7 +2196,7 @@ def show_pricing(kwargs=None, call=None):
|
|||
|
||||
size = 'CP-COMPUTEENGINE-VMIMAGE-{0}'.format(profile['size'].upper())
|
||||
pricefile = os.path.join(
|
||||
__opts__['cachedir'], 'cloud', 'gce-pricing.p'
|
||||
__opts__['cachedir'], 'gce-pricing.p'
|
||||
)
|
||||
if not os.path.exists(pricefile):
|
||||
update_pricing()
|
||||
|
|
|
@ -1265,6 +1265,7 @@ CLOUD_CONFIG_DEFAULTS = {
|
|||
'default_include': 'cloud.conf.d/*.conf',
|
||||
# Global defaults
|
||||
'ssh_auth': '',
|
||||
'cachedir': os.path.join(salt.syspaths.CACHE_DIR, 'cloud'),
|
||||
'keysize': 4096,
|
||||
'os': '',
|
||||
'script': 'bootstrap-salt',
|
||||
|
@ -1808,17 +1809,18 @@ def cloud_config(path, env_var='SALT_CLOUD_CONFIG', defaults=None,
|
|||
'''
|
||||
Read in the salt cloud config and return the dict
|
||||
'''
|
||||
# Load the cloud configuration
|
||||
overrides = load_config(
|
||||
path,
|
||||
env_var,
|
||||
os.path.join(salt.syspaths.CONFIG_DIR, 'cloud')
|
||||
)
|
||||
if path:
|
||||
config_dir = os.path.dirname(path)
|
||||
else:
|
||||
config_dir = salt.syspaths.CONFIG_DIR
|
||||
|
||||
# Load the cloud configuration
|
||||
overrides = load_config(
|
||||
path,
|
||||
env_var,
|
||||
os.path.join(config_dir, 'cloud')
|
||||
)
|
||||
|
||||
if defaults is None:
|
||||
defaults = CLOUD_CONFIG_DEFAULTS
|
||||
|
||||
|
@ -1931,6 +1933,9 @@ def cloud_config(path, env_var='SALT_CLOUD_CONFIG', defaults=None,
|
|||
elif master_config_path is not None and master_config is None:
|
||||
master_config = salt.config.master_config(master_config_path)
|
||||
|
||||
# cloud config has a seperate cachedir
|
||||
del master_config['cachedir']
|
||||
|
||||
# 2nd - salt-cloud configuration which was loaded before so we could
|
||||
# extract the master configuration file if needed.
|
||||
|
||||
|
@ -2013,6 +2018,10 @@ def cloud_config(path, env_var='SALT_CLOUD_CONFIG', defaults=None,
|
|||
# recurse opts for sdb configs
|
||||
apply_sdb(opts)
|
||||
|
||||
# prepend root_dir
|
||||
prepend_root_dirs = ['cachedir']
|
||||
prepend_root_dir(opts, prepend_root_dirs)
|
||||
|
||||
# Return the final options
|
||||
return opts
|
||||
|
||||
|
|
|
@ -2478,7 +2478,7 @@ def init_cachedir(base=None):
|
|||
Initialize the cachedir needed for Salt Cloud to keep track of minions
|
||||
'''
|
||||
if base is None:
|
||||
base = os.path.join(__opts__['cachedir'], 'cloud')
|
||||
base = __opts__['cachedir']
|
||||
needed_dirs = (base,
|
||||
os.path.join(base, 'requested'),
|
||||
os.path.join(base, 'active'))
|
||||
|
@ -2508,7 +2508,7 @@ def request_minion_cachedir(
|
|||
will be set to None.
|
||||
'''
|
||||
if base is None:
|
||||
base = os.path.join(__opts__['cachedir'], 'cloud')
|
||||
base = __opts__['cachedir']
|
||||
|
||||
if not fingerprint:
|
||||
if pubkey is not None:
|
||||
|
@ -2551,7 +2551,7 @@ def change_minion_cachedir(
|
|||
return False
|
||||
|
||||
if base is None:
|
||||
base = os.path.join(__opts__['cachedir'], 'cloud')
|
||||
base = __opts__['cachedir']
|
||||
|
||||
fname = '{0}.p'.format(minion_id)
|
||||
path = os.path.join(base, cachedir, fname)
|
||||
|
@ -2572,7 +2572,7 @@ def activate_minion_cachedir(minion_id, base=None):
|
|||
exists, and should be expected to exist from here on out.
|
||||
'''
|
||||
if base is None:
|
||||
base = os.path.join(__opts__['cachedir'], 'cloud')
|
||||
base = __opts__['cachedir']
|
||||
|
||||
fname = '{0}.p'.format(minion_id)
|
||||
src = os.path.join(base, 'requested', fname)
|
||||
|
@ -2590,7 +2590,7 @@ def delete_minion_cachedir(minion_id, provider, opts, base=None):
|
|||
return
|
||||
|
||||
if base is None:
|
||||
base = os.path.join(__opts__['cachedir'], 'cloud')
|
||||
base = __opts__['cachedir']
|
||||
|
||||
driver = next(six.iterkeys(opts['providers'][provider]))
|
||||
fname = '{0}.p'.format(minion_id)
|
||||
|
@ -2610,7 +2610,7 @@ def list_cache_nodes_full(opts, provider=None, base=None):
|
|||
return
|
||||
|
||||
if base is None:
|
||||
base = os.path.join(__opts__['cachedir'], 'cloud', 'active')
|
||||
base = os.path.join(__opts__['cachedir'], 'active')
|
||||
|
||||
minions = {}
|
||||
# First, get a list of all drivers in use
|
||||
|
@ -2641,7 +2641,7 @@ def cache_nodes_ip(opts, base=None):
|
|||
addresses. Returns a dict.
|
||||
'''
|
||||
if base is None:
|
||||
base = os.path.join(__opts__['cachedir'], 'cloud')
|
||||
base = __opts__['cachedir']
|
||||
|
||||
minions = list_cache_nodes_full(opts, base=base)
|
||||
|
||||
|
@ -2821,10 +2821,10 @@ def cache_node(node, provider, opts):
|
|||
if 'update_cachedir' not in opts or not opts['update_cachedir']:
|
||||
return
|
||||
|
||||
if not os.path.exists(os.path.join(__opts__['cachedir'], 'cloud', 'active')):
|
||||
if not os.path.exists(os.path.join(__opts__['cachedir'], 'active')):
|
||||
init_cachedir()
|
||||
|
||||
base = os.path.join(__opts__['cachedir'], 'cloud', 'active')
|
||||
base = os.path.join(__opts__['cachedir'], 'active')
|
||||
provider, driver = provider.split(':')
|
||||
prov_dir = os.path.join(base, driver, provider)
|
||||
if not os.path.exists(prov_dir):
|
||||
|
|
Loading…
Add table
Reference in a new issue