diff options
author | zdc <zdc@users.noreply.github.com> | 2022-03-26 15:41:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-26 15:41:59 +0200 |
commit | aa60d48c2711cdcd9f88a4e5c77379adb0408231 (patch) | |
tree | 349631a02467dae0158f6f663cc8aa8537974a97 /cloudinit/handlers/boot_hook.py | |
parent | 5c4b3943343a85fbe517e5ec1fc670b3a8566b4b (diff) | |
parent | 31448cccedd8f841fb3ac7d0f2e3cdefe08a53ba (diff) | |
download | vyos-cloud-init-aa60d48c2711cdcd9f88a4e5c77379adb0408231.tar.gz vyos-cloud-init-aa60d48c2711cdcd9f88a4e5c77379adb0408231.zip |
Merge pull request #51 from zdc/T2117-sagitta-22.1
T2117: Cloud-init updated to 22.1
Diffstat (limited to 'cloudinit/handlers/boot_hook.py')
-rw-r--r-- | cloudinit/handlers/boot_hook.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/cloudinit/handlers/boot_hook.py b/cloudinit/handlers/boot_hook.py index c6205097..602800ed 100644 --- a/cloudinit/handlers/boot_hook.py +++ b/cloudinit/handlers/boot_hook.py @@ -12,10 +12,8 @@ import os from cloudinit import handlers from cloudinit import log as logging -from cloudinit import subp -from cloudinit import util - -from cloudinit.settings import (PER_ALWAYS) +from cloudinit import subp, util +from cloudinit.settings import PER_ALWAYS LOG = logging.getLogger(__name__) @@ -23,7 +21,7 @@ LOG = logging.getLogger(__name__) class BootHookPartHandler(handlers.Handler): # The content prefixes this handler understands. - prefixes = ['#cloud-boothook'] + prefixes = ["#cloud-boothook"] def __init__(self, paths, datasource, **_kwargs): handlers.Handler.__init__(self, PER_ALWAYS) @@ -35,8 +33,9 @@ class BootHookPartHandler(handlers.Handler): def _write_part(self, payload, filename): filename = util.clean_filename(filename) filepath = os.path.join(self.boothook_dir, filename) - contents = util.strip_prefix_suffix(util.dos2unix(payload), - prefix=self.prefixes[0]) + contents = util.strip_prefix_suffix( + util.dos2unix(payload), prefix=self.prefixes[0] + ) util.write_file(filepath, contents.lstrip(), 0o700) return filepath @@ -48,12 +47,14 @@ class BootHookPartHandler(handlers.Handler): try: env = os.environ.copy() if self.instance_id is not None: - env['INSTANCE_ID'] = str(self.instance_id) + env["INSTANCE_ID"] = str(self.instance_id) subp.subp([filepath], env=env) except subp.ProcessExecutionError: util.logexc(LOG, "Boothooks script %s execution error", filepath) except Exception: - util.logexc(LOG, "Boothooks unknown error when running %s", - filepath) + util.logexc( + LOG, "Boothooks unknown error when running %s", filepath + ) + # vi: ts=4 expandtab |