diff options
author | Ethan Apodaca <papodaca@gmail.com> | 2017-09-13 22:18:26 -0600 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2017-09-13 22:22:25 -0600 |
commit | cf10a2ff2e2f666d9370f38297a5a105e809ea3c (patch) | |
tree | 3e6cd9cf6062564ba9548c34f017ea42976301d1 /cloudinit/util.py | |
parent | 1ac4bc2a4758d330bb94cd1b2391121cf461ff6a (diff) | |
download | vyos-cloud-init-cf10a2ff2e2f666d9370f38297a5a105e809ea3c.tar.gz vyos-cloud-init-cf10a2ff2e2f666d9370f38297a5a105e809ea3c.zip |
chef: Add option to pin chef omnibus install version
Most users of chef will want to pin the version that is installed.
Typically new versions of chef have to be evaluated for breakage etc.
This change proposes a new optional `omnibus_version` field to the chef
configuration. The changeset also adds documentation referencing the new
field.
LP: #1462693
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index ae5cda8d..7e9d94fc 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1742,6 +1742,31 @@ def delete_dir_contents(dirname): del_file(node_fullpath) +def subp_blob_in_tempfile(blob, *args, **kwargs): + """Write blob to a tempfile, and call subp with args, kwargs. Then cleanup. + + 'basename' as a kwarg allows providing the basename for the file. + The 'args' argument to subp will be updated with the full path to the + filename as the first argument. + """ + basename = kwargs.pop('basename', "subp_blob") + + if len(args) == 0 and 'args' not in kwargs: + args = [tuple()] + + # Use tmpdir over tmpfile to avoid 'text file busy' on execute + with temp_utils.tempdir() as tmpd: + tmpf = os.path.join(tmpd, basename) + if 'args' in kwargs: + kwargs['args'] = [tmpf] + list(kwargs['args']) + else: + args = list(args) + args[0] = [tmpf] + args[0] + + write_file(tmpf, blob, mode=0o700) + return subp(*args, **kwargs) + + def subp(args, data=None, rcs=None, env=None, capture=True, shell=False, logstring=False, decode="replace", target=None, update_env=None): |