diff options
Diffstat (limited to 'cloudinit/config/cc_update_hostname.py')
-rw-r--r-- | cloudinit/config/cc_update_hostname.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/cloudinit/config/cc_update_hostname.py b/cloudinit/config/cc_update_hostname.py index 8a99297f..8de51147 100644 --- a/cloudinit/config/cc_update_hostname.py +++ b/cloudinit/config/cc_update_hostname.py @@ -8,8 +8,8 @@ """Update Hostname: Update hostname and fqdn""" +import logging import os -from logging import Logger from textwrap import dedent from cloudinit import util @@ -80,13 +80,12 @@ meta: MetaSchema = { } __doc__ = get_meta_doc(meta) +LOG = logging.getLogger(__name__) -def handle( - name: str, cfg: Config, cloud: Cloud, log: Logger, args: list -) -> None: +def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None: if util.get_cfg_option_bool(cfg, "preserve_hostname", False): - log.debug( + LOG.debug( "Configuration option 'preserve_hostname' is set," " not updating the hostname in module %s", name, @@ -103,16 +102,16 @@ def handle( (hostname, fqdn, is_default) = util.get_hostname_fqdn(cfg, cloud) if is_default and hostname == "localhost": # https://github.com/systemd/systemd/commit/d39079fcaa05e23540d2b1f0270fa31c22a7e9f1 - log.debug("Hostname is localhost. Let other services handle this.") + LOG.debug("Hostname is localhost. Let other services handle this.") return try: prev_fn = os.path.join(cloud.get_cpath("data"), "previous-hostname") - log.debug("Updating hostname to %s (%s)", fqdn, hostname) + LOG.debug("Updating hostname to %s (%s)", fqdn, hostname) cloud.distro.update_hostname(hostname, fqdn, prev_fn) except Exception: util.logexc( - log, "Failed to update the hostname to %s (%s)", fqdn, hostname + LOG, "Failed to update the hostname to %s (%s)", fqdn, hostname ) raise |