diff options
author | Scott Moser <smoser@ubuntu.com> | 2014-03-04 14:35:29 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-03-04 14:35:29 -0500 |
commit | 3997ae9f49caede4bea7da4c0cd1c7d30d36fe0a (patch) | |
tree | ecdcf5232c9b5d2d0d0145cf1ce5ea3d7170d567 /cloudinit/config | |
parent | 5c95d6817a4aea17054addceef5d955c75390aa1 (diff) | |
parent | a9c7562ff3be9c552d757f24cfa61ef8985fe2e2 (diff) | |
download | vyos-cloud-init-3997ae9f49caede4bea7da4c0cd1c7d30d36fe0a.tar.gz vyos-cloud-init-3997ae9f49caede4bea7da4c0cd1c7d30d36fe0a.zip |
seed_random: do not capture command output, provide env RANDOM_SEED_FILE
call the command without capturing output, and provide RANDOM_SEED_FILE
to the environment that it is run in.
Diffstat (limited to 'cloudinit/config')
-rw-r--r-- | cloudinit/config/cc_seed_random.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/cloudinit/config/cc_seed_random.py b/cloudinit/config/cc_seed_random.py index 599280f6..49a6b3e8 100644 --- a/cloudinit/config/cc_seed_random.py +++ b/cloudinit/config/cc_seed_random.py @@ -20,6 +20,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import base64 +import os from StringIO import StringIO from cloudinit.settings import PER_INSTANCE @@ -43,7 +44,7 @@ def _decode(data, encoding=None): raise IOError("Unknown random_seed encoding: %s" % (encoding)) -def handle_random_seed_command(command, required): +def handle_random_seed_command(command, required, env=None): if not command and required: raise ValueError("no command found but required=true") elif not command: @@ -57,7 +58,7 @@ def handle_random_seed_command(command, required): else: LOG.debug("command '%s' not found for seed_command", cmd) return - util.subp(command) + util.subp(command, env=env, capture=False) def handle(name, cfg, cloud, log, _args): @@ -84,7 +85,9 @@ def handle(name, cfg, cloud, log, _args): command = mycfg.get('command', ['pollinate', '-q']) req = mycfg.get('command_required', False) try: - handle_random_seed_command(command=command, required=req) + env = os.environ.copy() + env['RANDOM_SEED_FILE'] = seed_path + handle_random_seed_command(command=command, required=req, env=env) except ValueError as e: log.warn("handling random command [%s] failed: %s", command, e) raise e |