summaryrefslogtreecommitdiff
path: root/tests/unittests/sources/test_oracle.py
Commit message (Collapse)AuthorAgeFilesLines
* [1/2] DHCP: Refactor dhcp client code (#2122)Brett Holman2023-04-191-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move isc-dhclient code to dhcp.py In support of the upcoming deprecation of isc-dhcp-client, this code refactors current dhcp code into classes in dhcp.py. The primary user-visible change should be the addition of the following log: dhcp.py[DEBUG]: DHCP client selected: dhclient This code lays groundwork to enable alternate implementations to live side by side in the codebase to be selected with distro-defined priority fallback. Note that maybe_perform_dhcp_discovery() now selects which dhcp client to call, and then runs the corresponding client's dhcp_discovery() method. Currently only class IscDhclient is implemented, however a yet-to-be-implemented class Dhcpcd exists to test fallback behavior and this will be implemented in part two of this series. Part of this refactor includes shifting dhclient service management from hardcoded calls to the distro-defined manage_service() method in the *BSDs. Future work is required in this area to support multiple clients via select_dhcp_client().
* datasource: Optimize datasource detection, fix bugs (#2060)Brett Holman2023-03-191-15/+15
| | | | | | | | | | | | | | | | | | Commit d1ffbea556a06105 enabled skipping python datasource detection on OpenStack when no other datasources (besides DataSourceNone) can be discovered. This allowed one to override detection, which is a requirement for OpenStack Ironic which does not advertise itself to cloud-init. Since no further datasources can be detected at this stage in the code, this pattern can be generalized to other datasources to facilitate troubleshooting or providing a general workaround to runtime detection bugs. Additionally, this pattern can be extended to kernel commandline datasource definition. Since kernel commandline is highest priority of the configurations, it makes sense to override python code datasource detection as well. Include an integration test on LXD for this behavior that configures kernel commandline and reboots to verify that the specified datasource is forced.
* oracle-ds: prefer system_cfg over ds network config source (#1998)Alberto Contreras2023-03-041-0/+9
| | | | | | | | | | | Bump system_cfg over ds network_config_source for Oracle DS, so that if network config is defined under /etc/cloud, it will be honored. In a previous change, we moved the initramfs and system_cfg bellow ds to favor ds, but this implied system-wide configs were always not honored. LP: #1956788
* dhcp: Cleanup unused kwarg (#2037)Brett Holman2023-02-281-2/+0
| | | Usage was dropped in de7851b93c5a2d4658.
* Fix Oracle DS primary interface when using IMDS (#1757)James Falcon2022-09-301-35/+67
| | | | | | | | If /run/net* files aren't available, we use IMDS for configuring the default interface. Rather than attempt a static configuration, grab the MAC and let DHCP do the rest (as it does when /run/net* is available). LP: #1989686
* tests: Drop httpretty in favor of responses (#1720)Alberto Contreras2022-09-191-37/+63
|
* Fix Oracle DS not setting subnet when using IMDS (#1735)James Falcon2022-09-161-2/+2
| | | | | | | | | Previous to 6270b50, if iSCSI config was not available, we used the ephemeral DHCP4 address as the primary address on Oracle. After 6270b50, we instead used the IMDS address configuration. However, the parsing of IMDS ignored the "subnetCidrBlock" field, causing the resulting network config to have the wrong subnet. LP: #1989686
* net: Ensure a tmp with exec permissions for dhcp (#1690)Alberto Contreras2022-09-011-0/+2
| | | | | | | | In the case cloudinit.temp_utils points to a fs mounted as noexec and needs_exe=True, fallback to use os.join.path(Distro.usr_lib_exec, "cloud-init/clouddir) that will be mounted with exec perms. LP: #1962343
* net: Implement link-local ephemeral ipv6Brett Holman2022-06-101-4/+4
| | | | | | | | | | | | | | | | | | | Also refactor network context managers into net.ephemeral Currently EC2 is the only IMDS to make use of this. IPv6 requires a link local address on interfaces. A link local address is sufficient for the EC2 IMDS, so no dhcp6 assignment is required for early boot IMDS queries. The kernel assigns this address using RFC 4291 [1] during link initialization, so all cloud-init needs to do is ensure that link is up. This means that even if dhcp4 fails, an ipv6-enabled instance may still succeed at crawling metadata. [1] https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.6
* Oracle ds changes (#1474)Alberto Contreras2022-06-081-270/+486
| | | | | | | | | | | | | | | For primary network config: - Use `iSCSI` config if some `/run/net*` file exists, even if `/run/initramfs/open-iscsi.interface` does not. - If the instance is not an `iSCSI` one, then crawl the network config from `IMDS` instead of falling back to "best guess". - Remove unnecessary conditional use of dhcp.EphemeralDHCPv4 and use it always to crawl `IMDS`. - Migrate tests to pytest. - Extend unit test coverage. - Add some types for mypy. LP: #1967942
* Refactor cloudinit.sources.NetworkConfigSource to enum (#1413)Alberto Contreras2022-04-281-2/+2
| | | | | | | | It was implemented as a namedtuple, because it was written when the codebase supported Python 2 (where using an enum would have introduced a new dependency). As enum is in the stdlib in all our supported Python releases, we can now use it without that constraint. LP: #1874875
* Revert "Ensure system_cfg read before ds net config on Oracle (#1174)" (#1326)James Falcon2022-03-111-5/+3
| | | | | | | | This reverts commit b306633fd17e5ba0173ad3c41add59cb11884757. While this ultimately seems like a better solution, currently the file /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg exists on all Oracle launched instances which will prevent networking from being properly initialized.
* Ensure system_cfg read before ds net config on Oracle (SC-720) (#1174)James Falcon2022-01-151-3/+5
| | | | | | | | | | | In 2c52e6e88b19f5db8d55eb7280ee27703e05d75f, the order of reading network config was changed for Oracle due to initramfs needing to take lower precedence than the datasource. However, this also bumped system_cfg to a lower precedence than ds, which means that any network configuration specified in /etc/cloud will not be applied. system_cfg should instead be moved above ds so network configuration in /etc/cloud takes precedence. LP: #1956788
* Remove 3.5 and xenial support (SC-711) (#1167)James Falcon2022-01-101-2/+2
| | | | | | | | | | | | Includes: - Update tox.ini and .travis.yml accordingly - Cleanup tox.ini with new tox syntax and cloud-init dependencies - Update documentation accordingly - Replace/remove xenial references where additional testing isn't required - Remove xenial checks in integration tests - Replace yield_fixture with fixture in pytest tests Sections of code commented with lines like "Remove when Xenial is no longer supported" still exist as they're require additional testing.
* Adopt Black and isort (SC-700) (#1157)James Falcon2021-12-151-139/+273
| | | | | Applied Black and isort, fixed any linting issues, updated tox.ini and CI.
* Reorganize unit test locations under tests/unittests (#1126)Brett Holman2021-12-031-0/+797
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