Merge pull request #23530 from dr4Ke/fix_salt-ssh_to_include_pkg_sources

salt-ssh state: fix including all salt:// references
This commit is contained in:
Thomas S Hatch 2015-05-12 09:13:43 -06:00
commit a664a3c6fd

View File

@ -99,20 +99,22 @@ def lowstate_file_refs(chunks, extras=''):
return refs return refs
def salt_refs(data): def salt_refs(data, ret=None):
''' '''
Pull salt file references out of the states Pull salt file references out of the states
''' '''
proto = 'salt://' proto = 'salt://'
ret = [] if ret is None:
ret = []
if isinstance(data, str): if isinstance(data, str):
if data.startswith(proto): if data.startswith(proto) and data not in ret:
return [data] ret.append(data)
if isinstance(data, list): if isinstance(data, list):
for comp in data: for comp in data:
if isinstance(comp, str): salt_refs(comp, ret)
if comp.startswith(proto): if isinstance(data, dict):
ret.append(comp) for comp in data:
salt_refs(data[comp], ret)
return ret return ret
@ -154,7 +156,7 @@ def prep_trans_tar(file_client, chunks, file_refs, pillar=None):
if not os.path.isdir(tgt_dir): if not os.path.isdir(tgt_dir):
os.makedirs(tgt_dir) os.makedirs(tgt_dir)
shutil.copy(path, tgt) shutil.copy(path, tgt)
break continue
files = file_client.cache_dir(name, saltenv) files = file_client.cache_dir(name, saltenv)
if files: if files:
for filename in files: for filename in files:
@ -170,7 +172,7 @@ def prep_trans_tar(file_client, chunks, file_refs, pillar=None):
if not os.path.isdir(tgt_dir): if not os.path.isdir(tgt_dir):
os.makedirs(tgt_dir) os.makedirs(tgt_dir)
shutil.copy(filename, tgt) shutil.copy(filename, tgt)
break continue
cwd = os.getcwd() cwd = os.getcwd()
os.chdir(gendir) os.chdir(gendir)
with closing(tarfile.open(trans_tar, 'w:gz')) as tfp: with closing(tarfile.open(trans_tar, 'w:gz')) as tfp: