diff --git a/cloudinit/cmd/clean.py b/cloudinit/cmd/clean.py index 81c81f19027..d852ab711cc 100755 --- a/cloudinit/cmd/clean.py +++ b/cloudinit/cmd/clean.py @@ -4,7 +4,7 @@ # # This file is part of cloud-init. See LICENSE file for license information. -"""Define 'clean' utility and handler as part of cloud-init commandline.""" +"""Define 'clean' utility and handler as part of cloud-init command line.""" import argparse import glob diff --git a/cloudinit/cmd/devel/__init__.py b/cloudinit/cmd/devel/__init__.py index cd218bce146..9c50ddfa150 100644 --- a/cloudinit/cmd/devel/__init__.py +++ b/cloudinit/cmd/devel/__init__.py @@ -1,6 +1,6 @@ # This file is part of cloud-init. See LICENSE file for license information. -"""Common cloud-init devel commandline utility functions.""" +"""Common cloud-init devel command line utility functions.""" from cloudinit.helpers import Paths from cloudinit.stages import Init diff --git a/cloudinit/cmd/query.py b/cloudinit/cmd/query.py index cf85003bb94..e1ce54ea1c0 100644 --- a/cloudinit/cmd/query.py +++ b/cloudinit/cmd/query.py @@ -281,7 +281,7 @@ def handle_args(name, args): try: rendered_payload = render_jinja_payload( payload=payload, - payload_fn="query commandline", + payload_fn="query command line", instance_data=instance_data, debug=True if args.debug else False, ) diff --git a/cloudinit/cmd/status.py b/cloudinit/cmd/status.py index 33f697566c7..39089802984 100644 --- a/cloudinit/cmd/status.py +++ b/cloudinit/cmd/status.py @@ -4,7 +4,7 @@ # # This file is part of cloud-init. See LICENSE file for license information. -"""Define 'status' utility and handler as part of cloud-init commandline.""" +"""Define 'status' utility and handler as part of cloud-init command line.""" import argparse import enum @@ -48,11 +48,11 @@ class EnabledStatus(enum.Enum): """Enum representing user-visible cloud-init boot status codes.""" DISABLED_BY_GENERATOR = "disabled-by-generator" - DISABLED_BY_KERNEL_CMDLINE = "disabled-by-kernel-cmdline" + DISABLED_BY_KERNEL_CMDLINE = "disabled-by-kernel-command-line" DISABLED_BY_MARKER_FILE = "disabled-by-marker-file" DISABLED_BY_ENV_VARIABLE = "disabled-by-environment-variable" ENABLED_BY_GENERATOR = "enabled-by-generator" - ENABLED_BY_KERNEL_CMDLINE = "enabled-by-kernel-cmdline" + ENABLED_BY_KERNEL_CMDLINE = "enabled-by-kernel-command-line" ENABLED_BY_SYSVINIT = "enabled-by-sysvinit" UNKNOWN = "unknown" diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py index 39457946798..c3910a40dbc 100644 --- a/cloudinit/config/cc_resizefs.py +++ b/cloudinit/config/cc_resizefs.py @@ -193,7 +193,7 @@ def maybe_get_writable_device_path(devpath, info): @param info: String representing information about the requested device. @param log: Logger to which logs will be added upon error. - @returns devpath or updated devpath per kernel commandline if the device + @returns devpath or updated devpath per kernel command line if the device path is a writable block device, returns None otherwise. """ container = util.is_container() diff --git a/cloudinit/config/cc_ubuntu_pro.py b/cloudinit/config/cc_ubuntu_pro.py index 36bceb9dea0..de372d635b3 100644 --- a/cloudinit/config/cc_ubuntu_pro.py +++ b/cloudinit/config/cc_ubuntu_pro.py @@ -261,7 +261,7 @@ def set_pro_config(pro_config: Any = None): def configure_pro(token, enable=None): - """Call ua commandline client to attach and/or enable services.""" + """Call ua command line client to attach and/or enable services.""" if enable is None: enable = [] elif isinstance(enable, str): diff --git a/cloudinit/config/schema.py b/cloudinit/config/schema.py index 054bdab18c9..8d294c303e1 100644 --- a/cloudinit/config/schema.py +++ b/cloudinit/config/schema.py @@ -1735,7 +1735,7 @@ def get_config_paths_from_args( ) -> Tuple[str, List[InstanceDataPart]]: """Return appropriate instance-data.json and instance data parts - Based on commandline args, and user permissions, determine the + Based on command line args, and user permissions, determine the appropriate instance-data.json to source for jinja templates and a list of applicable InstanceDataParts such as user-data, vendor-data and network-config for which to validate schema. Avoid returning any diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py index 903300fbb16..62abe78b4bf 100644 --- a/cloudinit/net/cmdline.py +++ b/cloudinit/net/cmdline.py @@ -261,7 +261,7 @@ def _b64dgz(data): blob = base64.b64decode(data) except (TypeError, ValueError): LOG.error( - "Expected base64 encoded kernel commandline parameter" + "Expected base64 encoded kernel command line parameter" " network-config. Ignoring network-config=%s.", data, ) diff --git a/cloudinit/sources/DataSourceNoCloud.py b/cloudinit/sources/DataSourceNoCloud.py index 25766fd1bfd..a7d3f3adfaa 100644 --- a/cloudinit/sources/DataSourceNoCloud.py +++ b/cloudinit/sources/DataSourceNoCloud.py @@ -67,7 +67,7 @@ def _get_data(self): try: # Parse the system serial label from dmi. If not empty, try parsing - # like the commandline + # like the command line md = {} serial = dmi.read_dmi_data("system-serial-number") if serial and load_cmdline_data(md, serial): @@ -375,7 +375,7 @@ def __init__(self, sys_cfg, distro, paths): ) def ds_detect(self): - """Check dmi and kernel commandline for dsname + """Check dmi and kernel command line for dsname NoCloud historically used "nocloud-net" as its dsname for network timeframe (DEP_NETWORK), which supports http(s) urls. diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index 43b7b340af3..ecdab82c30f 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -386,7 +386,7 @@ def ds_detect(self) -> bool: def override_ds_detect(self) -> bool: """Override if either: - only a single datasource defined (nothing to fall back to) - - commandline argument is used (ci.ds=OpenStack) + - command line argument is used (ci.ds=OpenStack) Note: get_cmdline() is required for the general case - when ds-identify does not run, _something_ needs to detect the kernel command line @@ -394,7 +394,7 @@ def override_ds_detect(self) -> bool: """ if self.dsname.lower() == parse_cmdline().lower(): LOG.debug( - "Machine is configured by the kernel commandline to run on " + "Machine is configured by the kernel command line to run on " "single datasource %s.", self, ) @@ -1232,7 +1232,7 @@ def parse_cmdline_or_dmi(input: str) -> str: dsname = deprecated.group(1).strip() util.deprecate( deprecated=( - f"Defining the datasource on the commandline using " + f"Defining the datasource on the command line using " f"ci.ds={dsname} or " f"ci.datasource={dsname}" ), diff --git a/doc/examples/kernel-cmdline.txt b/doc/examples/kernel-command-line.txt similarity index 100% rename from doc/examples/kernel-cmdline.txt rename to doc/examples/kernel-command-line.txt diff --git a/doc/rtd/explanation/format.rst b/doc/rtd/explanation/format.rst index 26bfe6657d0..befd9bb64b5 100644 --- a/doc/rtd/explanation/format.rst +++ b/doc/rtd/explanation/format.rst @@ -70,7 +70,8 @@ Kernel command line When using the NoCloud datasource, users can pass user data via the kernel command line parameters. See the :ref:`NoCloud datasource` -and :ref:`kernel_cmdline` documentation for more details. +and :ref:`explanation/kernel-command-line:Kernel command line` documentation +for more details. Gzip compressed content ======================= diff --git a/doc/rtd/explanation/index.rst b/doc/rtd/explanation/index.rst index 2d481ff212a..503c7098a00 100644 --- a/doc/rtd/explanation/index.rst +++ b/doc/rtd/explanation/index.rst @@ -19,7 +19,7 @@ knowledge and become better at using and configuring ``cloud-init``. vendordata.rst security.rst analyze.rst - kernel-cmdline.rst + kernel-command-line.rst failure_states.rst exported_errors.rst return_codes.rst diff --git a/doc/rtd/explanation/instancedata.rst b/doc/rtd/explanation/instancedata.rst index 37331958260..650efa79452 100644 --- a/doc/rtd/explanation/instancedata.rst +++ b/doc/rtd/explanation/instancedata.rst @@ -8,7 +8,7 @@ Instance metadata :maxdepth: 1 :hidden: - kernel-cmdline.rst + kernel-command-line.rst What is ``instance-data?`` ========================== diff --git a/doc/rtd/explanation/kernel-cmdline.rst b/doc/rtd/explanation/kernel-command-line.rst similarity index 99% rename from doc/rtd/explanation/kernel-cmdline.rst rename to doc/rtd/explanation/kernel-command-line.rst index a252aeebfd6..501812b8c75 100644 --- a/doc/rtd/explanation/kernel-cmdline.rst +++ b/doc/rtd/explanation/kernel-command-line.rst @@ -1,5 +1,3 @@ -.. _kernel_cmdline: - Kernel command line ******************* diff --git a/doc/rtd/howto/disable_cloud_init.rst b/doc/rtd/howto/disable_cloud_init.rst index 721e20c2c06..686e48a888b 100644 --- a/doc/rtd/howto/disable_cloud_init.rst +++ b/doc/rtd/howto/disable_cloud_init.rst @@ -22,10 +22,10 @@ Example: $ touch /etc/cloud/cloud-init.disabled -Method 2: kernel commandline -============================ +Method 2: kernel command line +============================= -To disable cloud-init, add ``cloud-init=disabled`` to the kernel commandline. +To disable cloud-init, add ``cloud-init=disabled`` to the kernel command line. Example (using GRUB2 with Ubuntu): diff --git a/doc/rtd/howto/status.rst b/doc/rtd/howto/status.rst index d6cdbe09212..b39a55d3bc2 100644 --- a/doc/rtd/howto/status.rst +++ b/doc/rtd/howto/status.rst @@ -107,11 +107,11 @@ contain any of the following states: which prevents cloud-init from ever running - ``'disabled-by-generator'``: ``ds-identify`` determined no applicable cloud-init datasources -- ``'disabled-by-kernel-cmdline'``: kernel command line contained +- ``'disabled-by-kernel-command-line'``: kernel command line contained cloud-init=disabled - ``'disabled-by-environment-variable'``: environment variable ``KERNEL_CMDLINE`` contained ``cloud-init=disabled`` -- ``'enabled-by-kernel-cmdline'``: kernel command line contained +- ``'enabled-by-kernel-command-line'``: kernel command line contained cloud-init=enabled - ``'enabled-by-generator'``: ``ds-identify`` detected possible cloud-init datasources diff --git a/doc/rtd/reference/breaking_changes.rst b/doc/rtd/reference/breaking_changes.rst index 93c4ff3710e..0df6fcfde58 100644 --- a/doc/rtd/reference/breaking_changes.rst +++ b/doc/rtd/reference/breaking_changes.rst @@ -83,10 +83,10 @@ which will be returned when cloud-init experiences an error that it can recover from. See :ref:`this page which documents the change `. -23.2 - kernel commandline -========================= +23.2 - kernel command line +========================== -The ``ds=`` kernel commandline value is used to forcibly select a specific +The ``ds=`` kernel command line value is used to forcibly select a specific datasource in cloud-init. Prior to 23.2, this only optionally selected the ``NoCloud`` datasource. @@ -94,5 +94,5 @@ Anyone that previously had a matching ``ds=nocloud*`` in their kernel command line that did not want to use the ``NoCloud`` datasource may experience broken behavior as a result of this change. -Workarounds include updating the kernel commandline and optionally configuring +Workarounds include updating the kernel command line and optionally configuring a ``datasource_list`` in ``/etc/cloud/cloud.cfg.d/*.cfg``. diff --git a/doc/rtd/reference/cli.rst b/doc/rtd/reference/cli.rst index 441d415bd19..0a6bc55ff1f 100644 --- a/doc/rtd/reference/cli.rst +++ b/doc/rtd/reference/cli.rst @@ -212,7 +212,7 @@ Example output: Generally run by OS init systems to execute ``cloud-init``'s stages: *init* and *init-local*. See :ref:`boot_stages` for more info. -Can be run on the commandline, but is generally gated to run only once +Can be run on the command line, but is generally gated to run only once due to semaphores in :file:`/var/lib/cloud/instance/sem/` and :file:`/var/lib/cloud/sem`. diff --git a/doc/rtd/reference/datasource_dsname_map.rst b/doc/rtd/reference/datasource_dsname_map.rst index 552a7f9de24..3861ec3491f 100644 --- a/doc/rtd/reference/datasource_dsname_map.rst +++ b/doc/rtd/reference/datasource_dsname_map.rst @@ -4,7 +4,7 @@ Datasource dsname ***************** Each datasource has an attribute called dsname. This may be used in the -kernel commandline to +kernel command line to :ref:`override datasource detection`. The ``dsname`` on the kernel command line may be a case-insensitive match. See the mapping between datasource module names and ``dsname`` in the table below. diff --git a/doc/rtd/reference/datasources.rst b/doc/rtd/reference/datasources.rst index c886c4ab784..9826fa56314 100644 --- a/doc/rtd/reference/datasources.rst +++ b/doc/rtd/reference/datasources.rst @@ -26,7 +26,7 @@ There are exceptions, however, when the :ref:`datasource does not identify` itself to ``cloud-init``. For these exceptions, one can override datasource detection either by configuring a single datasource in the :ref:`datasource_list`, -or by using :ref:`kernel commandline arguments`. +or by using :ref:`kernel command line arguments`. .. _datasources_supported: diff --git a/doc/rtd/reference/datasources/nocloud.rst b/doc/rtd/reference/datasources/nocloud.rst index 0306f79ffbf..618473a925a 100644 --- a/doc/rtd/reference/datasources/nocloud.rst +++ b/doc/rtd/reference/datasources/nocloud.rst @@ -4,10 +4,10 @@ NoCloud ******* The data source ``NoCloud`` is a flexible datasource that can be used in -multiple different ways. With NoCloud, the user can provide user data and -metadata to the instance without running a network service (or even without -having a network at all). Alternatively, one may use a custom webserver to -provide configurations. +multiple different ways. With NoCloud, one can provide configurations to +the instance without running a network service (or even without having a +network at all). Alternatively, one can use HTTP/HTTPS or FTP/FTPS to provide +a configuration. Configuration Methods: ====================== @@ -21,8 +21,8 @@ Configuration Methods: Method 1: Labeled filesystem ---------------------------- -A labeled `vfat`_ or `iso9660` filesystem containing user data and metadata -files may be used. The filesystem volume must be labelled ``CIDATA``. +A labeled `vfat`_ or `iso9660` filesystem may be used. The filesystem volume +must be labelled ``CIDATA``. Method 2: Custom webserver @@ -30,7 +30,7 @@ Method 2: Custom webserver Configuration files can be provided to cloud-init over HTTP(s). To tell cloud-init the URI to use, arguments must be passed to the instance via the -kernel commandline or SMBIOS serial number. This argument might look like: :: +kernel command line or SMBIOS serial number. This argument might look like: :: ds=nocloud;s=https://10.42.42.42/cloud-init/configs/ @@ -40,47 +40,82 @@ kernel commandline or SMBIOS serial number. This argument might look like: :: Consider using single-quotes to avoid this pitfall. See: `GRUB quoting`_ ds=nocloud;s=http://10.42.42.42/cloud-init/configs/ +Alternatively, this URI may be defined in a configuration in a file +:file:`/etc/cloud/cloud.cfg.d/*.cfg` like this: :: + + datasource: + NoCloud: + seedfrom: https://10.42.42.42/cloud-init/configs/ + Method 3: FTP Server -------------------- Configuration files can be provided to cloud-init over unsecured FTP or alternatively with FTP over TLS. To tell cloud-init the URL to use, -arguments must be passed to the instance via the kernel commandline or SMBIOS +arguments must be passed to the instance via the kernel command line or SMBIOS serial number. This argument might look like: :: ds=nocloud;s=ftps://10.42.42.42/cloud-init/configs/ +Alternatively, this URI may be defined in a configuration in a file +:file:`/etc/cloud/cloud.cfg.d/*.cfg` like this: :: -Method 4: Local filesystem, kernel commandline or SMBIOS --------------------------------------------------------- + datasource: + NoCloud: + seedfrom: ftps://10.42.42.42/cloud-init/configs/ + +Method 4: Local filesystem +-------------------------- Configuration files can be provided on the local filesystem at specific -filesystem paths using kernel commandline arguments or SMBIOS serial number to +filesystem paths using kernel command line arguments or SMBIOS serial number to tell cloud-init where on the filesystem to look. .. note:: Unless arbitrary filesystem paths are required, one might prefer to use :ref:`DataSourceNone`, since it does not require - modifying the kernel commandline or SMBIOS. + modifying the kernel command line or SMBIOS. This argument might look like: :: - ds=nocloud;s=file://path/to/directory/;h=node-42 + ds=nocloud;s=file://path/to/directory/ + +Alternatively, this URI may be defined in a configuration in a file +:file:`/etc/cloud/cloud.cfg.d/*.cfg` like this: :: + + datasource: + NoCloud: + seedfrom: file://10.42.42.42/cloud-init/configs/ + Permitted keys ============== -The permitted keys are: +Currently three keys (and their aliases) are permitted for configuring +cloud-init. -* ``h`` or ``local-hostname`` -* ``i`` or ``instance-id`` -* ``s`` or ``seedfrom`` +The only required key is: -A valid ``seedfrom`` value consists of a URI which must contain a -trailing ``/``. +* ``seedfrom`` alias: ``s`` -HTTP and HTTPS --------------- +A valid ``seedfrom`` value consists of a URI which must contain a trailing +``/``. + +Some optional keys may be used, but their use is discouraged and may +be removed in the future. + +* ``local-hostname`` alias: ``h`` (:ref:`cloud-config` + preferred) +* ``instance-id`` alias: ``i`` (set instance id in :file:`meta-data` instead) + +.. note:: + + The aliases ``s`` , ``h`` and ``i`` are only supported by kernel + command line or SMBIOS. When configured in a ``*.cfg`` file, the long key + name is required. + +Seedfrom: HTTP and HTTPS +------------------------ The URI elements supported by NoCloud's HTTP and HTTPS implementations include: :: @@ -90,8 +125,8 @@ include: :: Where ``scheme`` can be ``http`` or ``https`` and ``host`` can be an IP address or DNS name. -FTP and FTP over TLS --------------------- +Seedfrom: FTP and FTP over TLS +------------------------------ The URI elements supported by NoCloud's FTP and FTPS implementation include: :: @@ -103,21 +138,29 @@ Where ``scheme`` can be ``ftp`` or ``ftps``, ``userinfo`` will be ``host`` can be an IP address or DNS name, and ``port`` is which network port to use (default is ``21``). -Path Resource -------------- +Seedfrom: Files +--------------- -The path pointed to by the URI will contain the following files: +The path pointed to by the URI can contain the following +files: ``user-data`` (required) ``meta-data`` (required) ``vendor-data`` (optional) +``network-config`` (optional) + +If the seedfrom URI doesn't contain the required files, this datasource +will be skipped. The ``user-data`` file uses :ref:`user data format`. The -``meta-data`` file is a YAML-formatted file. The vendor data file adheres to -:ref:`user data formats` at the same base URL. +``meta-data`` file is a YAML-formatted file. + +The ``vendor-data`` file adheres to +:ref:`user data formats`. The ``network-config`` file +follows cloud-init's :ref:`Network Configuration Formats`. -DMI-specific kernel commandline -=============================== +DMI-specific kernel command line +================================ Cloud-init performs variable expansion of the ``seedfrom`` URL for any DMI kernel variables present in :file:`/sys/class/dmi/id` (kenv on FreeBSD). diff --git a/doc/rtd/reference/datasources/openstack.rst b/doc/rtd/reference/datasources/openstack.rst index 7bb52e4aa82..7072c4ea1b1 100644 --- a/doc/rtd/reference/datasources/openstack.rst +++ b/doc/rtd/reference/datasources/openstack.rst @@ -148,7 +148,7 @@ Explicitly set ``datasource_list`` to only ``openstack``, such as: Method 2: Kernel command line ----------------------------- -Set the kernel commandline to configure +Set the kernel command line to configure :ref:`datasource override `. Example using Ubuntu + GRUB2: diff --git a/doc/rtd/reference/modules.rst b/doc/rtd/reference/modules.rst index a30b0639741..67961f664e0 100644 --- a/doc/rtd/reference/modules.rst +++ b/doc/rtd/reference/modules.rst @@ -73,6 +73,9 @@ date. A 5 year timeline may also be expected for changed keys. .. automodule:: cloudinit.config.cc_scripts_user .. automodule:: cloudinit.config.cc_scripts_vendor .. automodule:: cloudinit.config.cc_seed_random + +.. _mod-set_hostname: + .. automodule:: cloudinit.config.cc_set_hostname .. _mod-set_passwords: diff --git a/doc/rtd/spelling_word_list.txt b/doc/rtd/spelling_word_list.txt index c38daee28a2..28d53c05aba 100644 --- a/doc/rtd/spelling_word_list.txt +++ b/doc/rtd/spelling_word_list.txt @@ -61,7 +61,7 @@ dotnet downstreams dpkg dropbearssh -ds +ds-identify dsa dsmode dsname diff --git a/systemd/cloud-init-generator.tmpl b/systemd/cloud-init-generator.tmpl index 3c9ca16958c..e55ece6d276 100644 --- a/systemd/cloud-init-generator.tmpl +++ b/systemd/cloud-init-generator.tmpl @@ -68,7 +68,7 @@ main() { if [ "$ds" = "1" ]; then debug 1 "cloud-init is enabled but no datasource found, disabling" else - debug 1 "cloud-init is disabled by kernel commandline or etc_file" + debug 1 "cloud-init is disabled by kernel command line or etc_file" fi if [ -f "$link_path" ]; then if rm -f "$link_path"; then diff --git a/tests/integration_tests/datasources/test_nocloud.py b/tests/integration_tests/datasources/test_nocloud.py index 91aee0140e2..a21f91cfa21 100644 --- a/tests/integration_tests/datasources/test_nocloud.py +++ b/tests/integration_tests/datasources/test_nocloud.py @@ -10,7 +10,7 @@ from tests.integration_tests.integration_settings import PLATFORM from tests.integration_tests.releases import CURRENT_RELEASE, FOCAL from tests.integration_tests.util import ( - override_kernel_cmdline, + override_kernel_command_line, verify_clean_boot, verify_clean_log, ) @@ -223,7 +223,7 @@ def _boot_with_cmdline( """configure an ftp server to start prior to network timeframe optionally install certs and make the server support only FTP over TLS - cmdline: a string containing the kernel commandline set on reboot + cmdline: a string containing the kernel command line set on reboot client: an instance to configure encrypted: a boolean which modifies the configured ftp server """ @@ -379,8 +379,8 @@ def _boot_with_cmdline( ) client.write_to_file("/vendor-data", "") - # set the kernel commandline, reboot with it - override_kernel_cmdline(cmdline, client) + # set the kernel command line, reboot with it + override_kernel_command_line(cmdline, client) def test_nocloud_ftp_unencrypted_server_succeeds( self, client: IntegrationInstance diff --git a/tests/integration_tests/test_kernel_commandline_match.py b/tests/integration_tests/test_kernel_command_line_match.py similarity index 88% rename from tests/integration_tests/test_kernel_commandline_match.py rename to tests/integration_tests/test_kernel_command_line_match.py index 8b17905f000..60bda90726c 100644 --- a/tests/integration_tests/test_kernel_commandline_match.py +++ b/tests/integration_tests/test_kernel_command_line_match.py @@ -8,7 +8,7 @@ from tests.integration_tests.integration_settings import PLATFORM from tests.integration_tests.util import ( lxd_has_nocloud, - override_kernel_cmdline, + override_kernel_command_line, wait_for_cloud_init, ) @@ -32,25 +32,25 @@ def test_lxd_datasource_kernel_override( ds_str, configured, cmdline_configured, client: IntegrationInstance ): - """This test is twofold: it tests kernel commandline override, which also + """This test is twofold: it tests kernel command line override, which also validates OpenStack Ironic requirements. OpenStack Ironic does not advertise itself to cloud-init via any of the conventional methods: DMI, etc. - On systemd, ds-identify is able to grok kernel commandline, however to + On systemd, ds-identify is able to grok kernel command line, however to support cloud-init kernel command line parsing on non-systemd, parsing - kernel commandline in Python code is required. + kernel command line in Python code is required. """ if configured == "lxd_or_nocloud": configured = ( "DataSourceNoCloud" if lxd_has_nocloud(client) else "DataSourceLXD" ) - override_kernel_cmdline(ds_str, client) + override_kernel_command_line(ds_str, client) if cmdline_configured: assert ( - "Machine is configured by the kernel commandline to run on single " - f"datasource {configured}" + "Machine is configured by the kernel command line to run on single" + f" datasource {configured}" ) in client.execute("cat /var/log/cloud-init.log") else: # verify that no plat @@ -58,7 +58,7 @@ def test_lxd_datasource_kernel_override( assert (f"Detected platform: {configured}") in log assert ( "Machine is configured by the kernel " - "commandline to run on single " + "command line to run on single " ) not in log @@ -98,7 +98,7 @@ def test_lxd_datasource_kernel_override_nocloud_net( assert wait_for_cloud_init(client, num_retries=60).ok if source.installs_new_version(): client.install_new_cloud_init(source, clean=False) - override_kernel_cmdline(ds_str, client) + override_kernel_command_line(ds_str, client) logs = client.execute("cat /var/log/cloud-init.log") assert ( @@ -115,9 +115,9 @@ def test_lxd_datasource_kernel_override_nocloud_net( @pytest.mark.skipif(PLATFORM != "lxd_vm", reason="Modifies grub config") @pytest.mark.lxd_use_exec def test_lxd_disable_cloud_init_cmdline(client: IntegrationInstance): - """Verify cloud-init disablement via kernel commandline works.""" + """Verify cloud-init disablement via kernel command line works.""" - override_kernel_cmdline("cloud-init=disabled", client) + override_kernel_command_line("cloud-init=disabled", client) assert "Active: inactive (dead)" in client.execute( "systemctl status cloud-init" ) diff --git a/tests/integration_tests/util.py b/tests/integration_tests/util.py index f8b750ca022..a3cc471f07b 100644 --- a/tests/integration_tests/util.py +++ b/tests/integration_tests/util.py @@ -355,21 +355,21 @@ def get_feature_flag_value(client: "IntegrationInstance", key): return value -def override_kernel_cmdline(ds_str: str, instance: "IntegrationInstance"): - """set the kernel commandline and reboot, return after boot done +def override_kernel_command_line(ds_str: str, instance: "IntegrationInstance"): + """set the kernel command line and reboot, return after boot done This will not work with containers. This is only tested with lxd vms but in theory should work on any virtual machine using grub. ds_str: the string that will be inserted into /proc/cmdline - instance: instance to set kernel commandline for + instance: instance to set kernel command line for """ # The final output in /etc/default/grub should be: # # GRUB_CMDLINE_LINUX="'ds=nocloud;s=http://my-url/'" # - # That ensures that the kernel commandline passed into + # That ensures that the kernel command line passed into # /boot/efi/EFI/ubuntu/grub.cfg will be properly single-quoted # # Example: diff --git a/tests/unittests/cmd/test_status.py b/tests/unittests/cmd/test_status.py index 971104336ab..ddf738560f8 100644 --- a/tests/unittests/cmd/test_status.py +++ b/tests/unittests/cmd/test_status.py @@ -186,7 +186,7 @@ def test_get_status_systemd_failure( lambda config: f"Cloud-init disabled by {config.disable_file}", id="true_on_disable_file", ), - # Not disabled when using systemd and enabled via commandline. + # Not disabled when using systemd and enabled via command line. pytest.param( lambda config: config.disable_file, True, @@ -309,7 +309,7 @@ def test_status_returns_disabled_long_on_presence_of_disable_file( """\ status: disabled extended_status: disabled - boot_status_code: disabled-by-kernel-cmdline + boot_status_code: disabled-by-kernel-command-line detail: disabled for some reason errors: [] recoverable_errors: {} @@ -452,7 +452,7 @@ def test_status_returns_disabled_long_on_presence_of_disable_file( """\ status: error extended_status: error - running - boot_status_code: enabled-by-kernel-cmdline + boot_status_code: enabled-by-kernel-command-line last_update: Thu, 01 Jan 1970 00:02:05 +0000 detail: DataSourceNoCloud [seed=/var/.../seed/nocloud-net][dsmode=net] errors: @@ -482,7 +482,7 @@ def test_status_returns_disabled_long_on_presence_of_disable_file( """\ status: running extended_status: running - boot_status_code: enabled-by-kernel-cmdline + boot_status_code: enabled-by-kernel-command-line last_update: Thu, 01 Jan 1970 00:02:04 +0000 detail: Running in stage: init errors: [] @@ -507,7 +507,7 @@ def test_status_returns_disabled_long_on_presence_of_disable_file( dedent( """\ --- - boot_status_code: enabled-by-kernel-cmdline + boot_status_code: enabled-by-kernel-command-line datasource: '' detail: 'Running in stage: init' errors: [] @@ -542,7 +542,7 @@ def test_status_returns_disabled_long_on_presence_of_disable_file( MyArgs(long=False, wait=False, format="json"), 0, { - "boot_status_code": "enabled-by-kernel-cmdline", + "boot_status_code": "enabled-by-kernel-command-line", "datasource": "", "detail": "Running in stage: init", "errors": [], @@ -583,7 +583,7 @@ def test_status_returns_disabled_long_on_presence_of_disable_file( MyArgs(long=False, wait=False, format="json"), 1, { - "boot_status_code": "enabled-by-kernel-cmdline", + "boot_status_code": "enabled-by-kernel-command-line", "datasource": "nocloud", "detail": ( "DataSourceNoCloud [seed=/var/.../seed/" @@ -666,7 +666,7 @@ def test_status_returns_disabled_long_on_presence_of_disable_file( MyArgs(long=False, wait=False, format="json"), 2, { - "boot_status_code": "enabled-by-kernel-cmdline", + "boot_status_code": "enabled-by-kernel-command-line", "datasource": "nocloud", "detail": ( "DataSourceNoCloud [seed=/var/.../" diff --git a/tests/unittests/config/test_cc_resizefs.py b/tests/unittests/config/test_cc_resizefs.py index f6443af902c..36daf9f8952 100644 --- a/tests/unittests/config/test_cc_resizefs.py +++ b/tests/unittests/config/test_cc_resizefs.py @@ -113,10 +113,10 @@ def test_handle_warns_on_unknown_mount_info(self, m_log, m_get_mount_info): ) @mock.patch("cloudinit.config.cc_resizefs.LOG") - def test_handle_warns_on_undiscoverable_root_path_in_commandline( + def test_handle_warns_on_undiscoverable_root_path_in_command_line( self, m_log ): - """handle noops when the root path is not found on the commandline.""" + """handle noops when the root path is not found on the command line.""" cfg = {"resize_rootfs": True} exists_mock_path = "cloudinit.config.cc_resizefs.os.path.exists" @@ -421,8 +421,8 @@ def test_maybe_get_writable_device_path_non_block_on_container(self): self.logs.getvalue(), ) - def test_maybe_get_writable_device_path_returns_cmdline_root(self): - """When root device is UUID in kernel commandline, update devpath.""" + def test_maybe_get_writable_device_path_returns_command_line_root(self): + """When root device is UUID in kernel command_line, update devpath.""" # XXX Long-term we want to use FilesystemMocking test to avoid # touching os.stat. FakeStat = namedtuple( diff --git a/tests/unittests/sources/test___init__.py b/tests/unittests/sources/test___init__.py index f33d0010316..2c214aeed66 100644 --- a/tests/unittests/sources/test___init__.py +++ b/tests/unittests/sources/test___init__.py @@ -44,8 +44,8 @@ ("foo bonding.max_bonds=0 ds=nocloud-net bar", "nocloud-net"), ), ) -def test_ds_detect_kernel_commandline(m_cmdline, expected_ds): - """check commandline match""" +def test_ds_detect_kernel_command_line(m_cmdline, expected_ds): + """check command line match""" with mock.patch( "cloudinit.util.get_cmdline", return_value=m_cmdline, diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index d036378880b..8af6439f101 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -3552,7 +3552,7 @@ def test_cmdline_with_net_config_unencoded_logs_error(self, caplog): found = cmdline.read_kernel_cmdline_config(cmdline=raw_cmdline) assert found is None expected_log = ( - "Expected base64 encoded kernel commandline parameter" + "Expected base64 encoded kernel command line parameter" " network-config. Ignoring network-config={config:disabled}." ) assert expected_log in caplog.text