summaryrefslogtreecommitdiff
path: root/tests/unittests/test_cli.py
Commit message (Collapse)AuthorAgeFilesLines
* chore: fix style tip (#2071)Alberto Contreras2023-03-141-5/+3
| | | | - remove too broad exceptions - ignore dynamic base types in templater
* dhclient_hook: remove vestigal dhclient_hook command (#2015)Brett Holman2023-02-281-14/+0
| | | | | | | | | At inception[1], dhclient hooks were used to filter environment variables into /run/cloud-init/dhclient.hooks/<interface>.json which was consumed by WALinuxAgentShim. The fallback method was to parse the dhcp client lease file. Today the Azure datasource directly uses the parsed lease file[2], and loading /run/cloud-init/dhclient.hook/<interface>.json file was removed in 22.2[3]. With no other consumers, we can remove this. [1] https://github.com/canonical/cloud-init/commit/648dbbf6b090c81e989f1ab70bf99f4de16a6a70 [2] https://github.com/canonical/cloud-init/blob/main/cloudinit/sources/DataSourceAzure.py#L447 [3] https://github.com/canonical/cloud-init/commit/5ad0768a796bc07232476d0d29b5225f1e6e131c
* add OpenCloudOS and TencentOS support (#1964)wynnfeng2023-02-181-2/+2
|
* Recognize opensuse-microos, dev tooling fixesRobert Schweikert2023-02-161-1/+3
| | | | | | | | | | | | Update the distro selection code to recognize opensuse-microos as a SUSE based distribution. Also in this commit: * unittest mock OpenNebula of pwd.getpwnam to avoid test leaks on SuSE * tooling fixes to build and test opensuse - read-dependencies fix jinja2 and PyYAML pkg aliases for opensuse - Consolidate package operations based on OS family instead of distro flavor to cut down on duplication of command definitions. - format read-dependencies and run-container with black
* add mariner support (#1780)Minghe Ren2022-11-071-1/+2
|
* add support for Container-Optimized OS (#1748)vteratipally2022-10-201-1/+1
| | | Signed-off-by: varsha teratipally <teratipally@google.com>
* cc_ntp: add support for BSDs (#1759)Mina Galić2022-10-141-3/+3
| | | | | | | | | | | | | | | | | cc_ntp: add support for BSDs *BSDs have ntpd installed in base the base system This PR extends cc_ntp to add support for ntpd, openntpd, and chrony on the FreeBSD, and OpenBSD. To make tests pass, we ensure that we are mocking functions, not entire classes. Co-authored-by: Ryan Harper <rharper@woxford.com> Co-authored-by: James Falcon <james.falcon@canonical.com> Sponsored by: FreeBSD Foundation LP: #1990041
* cloud-config: honor cloud_dir setting (#1523)Alberto Contreras2022-06-221-256/+223
| | | | | | | | | | | Ensure cloud_dir setting is respected rather than hardcoding "/var/lib/cloud" - Modules affected: cmd.main, apport, devel.logs (collect-logs), cc_snap, sources.DataSourceAzure, sources.DataSourceBigstep, util:fetch_ssl_details. - testing: Extend and port to pytest unit tests, add integration test. LP: #1976564
* Add support for OpenMandriva (https://openmandriva.org/) (#1520)Bernhard Rosenkraenzer2022-06-171-2/+2
| | | Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
* Remove xenial references (#1472)Alberto Contreras2022-06-081-7/+7
| | | | | | - Remove references and dead code to Xenial, Eoan, Python < 3.7 - cc_ubuntu_drivers: Use python3-debconf instead of shell script - add integration test for ubuntu_drivers - bump pycloudlib for OCI subnet/jammy fixes
* Promote cloud-init schema from devel to top level subcommand (#1402)Brett Holman2022-04-271-15/+15
|
* schema: add JSON defs for modules cc_users_groups (#1379)Chad Smith2022-04-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Given the complexity of users and groups schema a number of additional improvements were needed for rendering markdown docs. - Render property docs based on each "enum" or "oneOf" value instead of reporting "string" - Decorate "enum" values with double-ticks `` - Add "hidden" property to schema to omit specific objects from docs Any key which has "hidden": true will not have docs. The "hidden" key can also provide a list of properties to omit. - New function _sort_property_order: ordering schema "type" as a list while sorting lists and objects last in docs. - Add _flatten_schema_refs support for extracting $defs into schema = for references nested under "items" and "oneOf" keys - schema: disk_setup.fs_setup.partition drop incorrect integer type - Add deprecation warnings and schema docs for certain uses of user/users/groups keys Fixes: SC-928 Fixes: SC-846 Fixes: SC-897 LP: #1858930
* Adopt Black and isort (SC-700) (#1157)James Falcon2021-12-151-97/+117
| | | | | Applied Black and isort, fixed any linting issues, updated tox.ini and CI.
* Add miraclelinux support (#1128)Haruki TSURUMOTO2021-12-071-2/+3
|
* Add Strict Metaschema Validation (#1101)Brett Holman2021-12-061-12/+93
| | | | | | | | | | | | | | | | | | Improve schema validation. This adds strict validation of config module definitions at testing time, with plumbing included for future runtime validation. This eliminates a class of bugs resulting from schemas that have definitions that are incorrect, but get interpreted by jsonschema as "additionalProperties" that are therefore ignored. - Add strict meta-schema for jsonschema unit test validation - Separate schema from module metadata structure - Improve type annotations for various functions and data types Cleanup: - Remove unused jsonschema "required" elements - Eliminate manual memoization in schema.py:get_schema(), reference module.__doc__ directly
* Reorganize unit test locations under tests/unittests (#1126)Brett Holman2021-12-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This attempts to standardize unit test file location under test/unittests/ such that any source file located at cloudinit/path/to/file.py may have a corresponding unit test file at test/unittests/path/to/test_file.py. Noteworthy Comments: ==================== Four different duplicate test files existed: test_{gpg,util,cc_mounts,cc_resolv_conf}.py Each of these duplicate file pairs has been merged together. This is a break in git history for these files. The test suite appears to have a dependency on test order. Changing test order causes some tests to fail. This should be rectified, but for now some tests have been modified in tests/unittests/config/test_set_passwords.py. A helper class name starts with "Test" which causes pytest to try executing it as a test case, which then throws warnings "due to Class having __init__()". Silence by changing the name of the class. # helpers.py is imported in many test files, import paths change cloudinit/tests/helpers.py -> tests/unittests/helpers.py # Move directories: cloudinit/distros/tests -> tests/unittests/distros cloudinit/cmd/devel/tests -> tests/unittests/cmd/devel cloudinit/cmd/tests -> tests/unittests/cmd/ cloudinit/sources/helpers/tests -> tests/unittests/sources/helpers cloudinit/sources/tests -> tests/unittests/sources cloudinit/net/tests -> tests/unittests/net cloudinit/config/tests -> tests/unittests/config cloudinit/analyze/tests/ -> tests/unittests/analyze/ # Standardize tests already in tests/unittests/ test_datasource -> sources test_distros -> distros test_vmware -> sources/vmware test_handler -> config # this contains cloudconfig module tests test_runs -> runs
* Support openEuler OS (#1012)zhuzaifangxuele2021-09-131-2/+2
| | | openEuler Homepage: https://www.openeuler.org/en/
* Add CloudLinux OS support (#1003)Alexandr Kravchenko2021-09-011-3/+3
| | | https://www.cloudlinux.com/
* Add support for EuroLinux 7 && EuroLinux 8 (#957)Aleksander Baranowski2021-08-051-1/+2
|
* Add VZLinux support (#951)eb30952021-07-211-1/+1
| | | Virtuozzo Linux is a distro based off of CentOS 8, similar to Alma Linux and Rocky Linux.
* Add support for VMware PhotonOS (#909)sshedi2021-06-181-1/+1
| | | | | Also added a new (currently experimental) systemd-networkd renderer, and includes a small refactor to cc_resolv_conf.py to support the resolved.conf used by systemd-resolved.
* Add Rocky Linux support to cloud-init (#906)Louis Abel2021-05-251-1/+2
| | | | Rocky Linux is a RHEL-compatible distribution so all changes that have been made should be trivial.
* Add AlmaLinux OS support (#872)Andrew Lukoshko2021-05-071-1/+1
| | | AlmaLinux OS is RHEL-compatible so all the changes needed are trivial.
* cli: add --system param to allow validating system user-data on a machine (#575)Chad Smith2020-11-181-1/+1
| | | | Allow root user to validate the userdata provided to the launched machine using `cloud-init devel schema --system`
* Add Alpine Linux support. (#535)dermotbradley2020-08-191-1/+1
| | | | | | | | Add new module cc_apk_configure for creating Alpine /etc/apk/repositories file. Modify cc_ca_certs, cc_ntp, cc_power_state_change, and cc_resolv_conf for Alpine. Add Alpine template files for Chrony and Busybox NTP support. Add Alpine template file for /etc/hosts.
* schema: add json schema for write_files module (#152)Chad Smith2020-04-241-2/+2
| | | | | | | | | | | | | | | | | Add schema definition to cc_write_files.py Cloud-config containing write_files config directives will now emit warnings for invalid config keys or values for the write_files module. Add an extension to JSON schema's draft4validator to permit either binary or text values for 'string' objects. This allows for JSON schema validating the YAML declaration of binary valiues in cloud-config using YAML's '!!binary' syntax. Add the ability to pass a specific module name to `cloud-init devel schema --docs <module_name>|all` to optionally limit doc output during development to a single schema doc.
* Drop most of the remaining use of six (#179)Daniel Watkins2020-01-211-8/+8
|
* dhclient-hook: cleanups, tests and fix a bug on 'down' event.Scott Moser2018-12-031-8/+8
| | | | | | | | | | | | | I noticed a bug in dhclient_hook on the 'down' event, using 'is' operator rather than '==' (if self.net_action is 'down'). This refactors/simplifies the code a bit for easier testing and adds tests. The reason for the rename of 'action' to 'event' is to just be internally consistent. The word and Namespace 'action' is used by cloud-init main, so it was not really usable here. Also adds a main which can easily be debugged with: CI_DHCP_HOOK_DATA_D=./my.d python -m cloudinit.dhclient_hook up eth0
* tools: Add 'net-convert' subcommand command to 'cloud-init devel'.Scott Moser2018-08-061-2/+1
| | | | | | | | | | | | Move the tools/net-convert.py to be exposed as part of 'cloud-init devel' subcommands. It can now be called like: $ cloud-init devel net-convert Or, if you just have checked out source (and no cli executable):   $ python3 -m cloudinit.cmd.devel.net_convert or   $ python3 -m cloudinit.cmd.main devel net-convert
* cli: Fix error in cloud-init modules --mode=init.Chad Smith2017-12-141-0/+75
| | | | | | | | | | | | | | | | The cli help docs and argument parser allow the 'init' mode value which caused a traceback. Fix the cli to support 'init', 'config' and 'final' modes for the cloud-init modules subcommand. Add a check in the cli to raise a ValueError if a new subcommand ends up allowing an unsupported/unimplemented modes. Drive by unit test additions for a bit better coverage of error handling. LP: #1736600
* cli: Add clean and status subcommandsChad Smith2017-12-051-6/+24
| | | | | | | | | | | | | The 'cloud-init clean' command allows a user or script to clear cloud-init artifacts from the system so that cloud-init sees the system as unconfigured upon reboot. Optional parameters can be provided to remove cloud-init logs and reboot after clean. The 'cloud-init status' command allows the user or script to check whether cloud-init has finished all configuration stages and whether errors occurred. An optional --wait argument will poll on a 0.25 second interval until cloud-init configuration is complete. The benefit here is scripts can block on cloud-init completion before performing post-config tasks.
* docs: fix sphinx module schema documentationChad Smith2017-09-201-0/+15
| | | | | | | | | Create a copy of each modules schema attribute when generating sphinx docs to avoid altering the actual module dict in memory. This avoids illegible rendering of module examples and distros where each character of a list was represented on a separate line by itself. Fixes ntp, resizefs, runcmd and bootcmd docs.
* cmdline: add collect-logs subcommand.Chad Smith2017-09-151-5/+17
| | | | | | | | | | | | | | | | Add a new collect-logs sub command to the cloud-init CLI. This script will collect all logs pertinent to a cloud-init run and store them in a compressed tar-gzipped file. This tarfile can be attached to any cloud-init bug filed in order to aid in bug triage and resolution. A cloudinit.apport module is also added that allows apport interaction. Here is an example bug filed via ubuntu-bug cloud-init: LP: #1716975. Once the apport launcher is packaged in cloud-init, bugs can be filed against cloud-init with the following command: ubuntu-bug cloud-init LP: #1607345
* relocate tests/unittests/helpers.py to cloudinit/testsLars Kellogg-Stedman2017-09-051-1/+1
| | | | | This moves the base test case classes into into cloudinit/tests and updates all the corresponding imports.
* cli: Fix command line parsing of coniditionally loaded subcommands.Chad Smith2017-08-251-0/+15
| | | | | | | | | | | In an effort to save file load cost during system boot, certain subcommands, analyze and devel, do not get loaded unless the subcommand is specified on the commandline. Because setup.py entrypoint for cloud-init script doesn't specify sysv_args parameter when calling the CLI's main() we need main to read sys.argv into sysv_args so our subparser loading continues to work. LP: #1712676
* schema cli: Add schema subcommand to cloud-init cli and cc_runcmd schemaChad Smith2017-08-221-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This branch does a few things: - Add 'schema' subcommand to cloud-init CLI for validating cloud-config files against strict module jsonschema definitions - Add --annotate parameter to 'cloud-init schema' to annotate existing cloud-config file content with validation errors - Add jsonschema definition to cc_runcmd - Add unit test coverage for cc_runcmd - Update CLI capabilities documentation This branch only imports development (and analyze) subparsers when the specific subcommand is provided on the CLI to avoid adding costly unused file imports during cloud-init system boot. The schema command allows a person to quickly validate a cloud-config text file against cloud-init's known module schemas to avoid costly roundtrips deploying instances in their cloud of choice. As of this branch, only cc_ntp and cc_runcmd cloud-config modules define schemas. Schema validation will ignore all undefined config keys until all modules define a strict schema. To perform validation of runcmd and ntp sections of a cloud-config file: $ cat > cloud.cfg <<EOF runcmd: bogus EOF $ python -m cloudinit.cmd.main schema --config-file cloud.cfg $ python -m cloudinit.cmd.main schema --config-file cloud.cfg \ --annotate Once jsonschema is defined for all ~55 cc modules, we will move this schema subcommand up as a proper subcommand of the cloud-init CLI.
* tools: Add tooling for basic cloud-init performance analysis.Chad Smith2017-08-211-3/+84
| | | | | | | | | | | | | | | | | | | | | | | | | This branch adds cloudinit-analyze into cloud-init proper. It adds an "analyze" subcommand to the cloud-init command line utility for quick performance assessment of cloud-init stages and events. On a cloud-init configured instance, running "cloud-init analyze blame" will now report which cloud-init events cost the most wall time. This allows for quick assessment of the most costly stages of cloud-init. This functionality is pulled from Ryan Harper's analyze work. The cloudinit-analyze main script itself has been refactored a bit for inclusion as a subcommand of cloud-init CLI. There will be a followup branch at some point which will optionally instrument detailed strace profiling, but that approach needs a bit more discussion first. This branch also adds: * additional debugging topic to the sphinx-generated docs describing cloud-init analyze, dump and show as well as cloud-init single usage. * Updates the Makefile unittests target to include cloudinit directory because we now have unittests within that package. LP: #1709761
* LICENSE: Allow dual licensing GPL-3 or Apache 2.0Jon Grimm2016-12-221-0/+5
| | | | | | | | | | | | | | | | | | This has been a recurring ask and we had initially just made the change to the cloud-init 2.0 codebase. As the current thinking is we'll just continue to enhance the current codebase, its desirable to relicense to match what we'd intended as part of the 2.0 plan here. - put a brief description of license in LICENSE file - put full license versions in LICENSE-GPLv3 and LICENSE-Apache2.0 - simplify the per-file header to reference LICENSE - tox: ignore H102 (Apache License Header check) Add license header to files that ship. Reformat headers, make sure everything has vi: at end of file. Non-shipping files do not need the copyright header, but at the moment tests/ have it.
* Remove some unused importsJoshua Harlow2016-06-151-3/+0
|
* Fix a few tools and tests for newer pep8Joshua Harlow2016-06-151-1/+2
|
* Make the bin/cloud-init an actual console entrypointJoshua Harlow2016-06-141-25/+12
| | | | This allows for the test_cli test to be more sane.
* Remerge against head/masterJoshua Harlow2016-05-191-6/+1
|\
| * Fix py26 for rhel (and older versions of python)Joshua Harlow2016-05-111-6/+1
| |
* | run flake8 instead of pyflakes in tox. expect tests/ to pass flake8.Scott Moser2016-05-121-2/+2
|/
* temporarily disasble test if no bin/cloud-initScott Moser2015-05-151-2/+8
| | | | | the tests of bin/cloud-init would fail in a package build environment. so, temporariliy skip them in that environment.
* Fix traceback with no arguments on Python 3.Daniel Watkins2015-02-261-0/+48
Fixes bug 1424277.