summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceOracle.py
Commit message (Collapse)AuthorAgeFilesLines
* [1/2] DHCP: Refactor dhcp client code (#2122)Brett Holman2023-04-191-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-3/+2
| | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | 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-1/+0
| | | Usage was dropped in de7851b93c5a2d4658.
* Fix Oracle DS primary interface when using IMDS (#1757)James Falcon2022-09-301-20/+29
| | | | | | | | 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
* Fix Oracle DS not setting subnet when using IMDS (#1735)James Falcon2022-09-161-2/+6
| | | | | | | | | 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/+1
| | | | | | | | 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-2/+2
| | | | | | | | | | | | | | | | | | | 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-75/+97
| | | | | | | | | | | | | | | 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-5/+6
| | | | | | | | 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-1/+1
| | | | | | | | 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-1/+1
| | | | | | | | | | | 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
* Adopt Black and isort (SC-700) (#1157)James Falcon2021-12-151-57/+68
| | | | | Applied Black and isort, fixed any linting issues, updated tox.ini and CI.
* Add connectivity_url to Oracle's EphemeralDHCPv4 (#988)James Falcon2021-09-171-4/+9
| | | | | | | | | | | | | Add connectivity_url to Oracle's EphemeralDHCPv4 On bionic, when trying to bring up the EphemeralDHCPv4, it's possible that we already have a route defined, which will result in an error when trying to add the DHCP route. Use the connectivity_url to check if we can reach the metadata service, and if so, skip the EphemeralDHCPv4. The has_url_connectivity function has also been modified to take a dict of kwargs to send to readurl. LP: #1939603
* cloudinit: move dmi functions out of util (#622)Scott Moser2020-11-021-2/+3
| | | | | | | | | This just separates the reading of dmi values into its own file. Some things of note: * left import of util in dmi.py only for 'is_container' It'd be good if is_container was not in util. * just the use of 'util.is_x86' to dmi.py * open() is used directly rather than load_file.
* DataSourceOracle: retry twice (and document why we retry at all) (#536)Daniel Watkins2020-08-141-1/+4
|
* Support Oracle IMDSv2 API (#528)James Falcon2020-08-131-92/+129
| | | | * v2 of the API is now default with fallback to v1. * Refactored the Oracle datasource to fetch version, instance, and vnic metadata simultaneously.
* DataSourceOracle: refactor to use only OPC v1 endpoint (#493)Daniel Watkins2020-08-101-123/+55
| | | | | | | | | The /opc/v1/ metadata endpoints[0] are universally available in Oracle Cloud Infrastructure and the OpenStack endpoints are considered deprecated, so we can refactor the data source to use the OPC endpoints exclusively. This simplifies the datasource code substantially, and enables use of OPC-specific attributes in future. [0] https://docs.cloud.oracle.com/en-us/iaas/Content/Compute/Tasks/gettingmetadata.htm
* test_oracle,DataSourceOracle: sort imports (#266)Daniel Watkins2020-03-201-8/+10
| | | | | * test_oracle: sort imports * DataSourceOracle: sort imports
* DataSourceOracle: update .network_config docstring (#257)Daniel Watkins2020-03-191-8/+2
| | | | Bring it into line with the current state of the code (by dropping the now-untrue caveat).
* net,Oracle: Add support for netfailover detectionRyan Harper2019-09-091-1/+61
| | | | | | | | | | Add support for detecting netfailover[1] device 3-tuple in networking layer. In the Oracle datasource ensure that if a provided network config, either fallback or provided config includes a netfailover master to remove any MAC address value as this can break under 3-netdev as the other two devices have the same MAC. 1. https://www.kernel.org/doc/html/latest/networking/net_failover.html
* Oracle: Render secondary vnic IP and MTU values onlyRyan Harper2019-08-281-16/+20
| | | | | | When rendering secondary vnic configuration from IMDS, only emit configuration for the IP and MTU values only. Add support to mutate either a v1 or a v2 network_config input.
* DataSourceOracle: prefer DS network config over initramfsDaniel Watkins2019-08-191-0/+7
| | | | | | | | | | | | | | | | | | | | | | The Oracle platform provides networking configuration from two sources: * the primary interface configuration comes from the initramfs, because Oracle instance all iSCSI boot * secondary interface configuration comes from an IMDS accessed over HTTP As we need to combine these two sources of network configuration, the default "prefer initramfs config over data source config" behaviour isn't appropriate; we would never get the IMDS interfaces via that route. Instead, the Oracle data source has code to combine these two sources, so we prefer its network configuration over the initramfs configuration. (This is not appropriate default behaviour, because _in general_ data sources won't know how to merge initramfs-provided configuration into their provided configuration, so switching this order for all data sources would result in initramfs configuration being discarded on any data source that implements network_config.)
* DataSourceOracle: configure secondary NICs on Virtual MachinesDaniel Watkins2019-08-141-1/+88
| | | | | | | | | | | | | | | | | | | | | | | | Oracle Cloud Infrastructure's Instance Metadata Service provides network configuration information for non-primary NICs. This commit introduces support, on Virtual Machines[0], for fetching that network metadata, converting it to v1 network-config[1] and combining it into the network configuration generated for the primary interface. By default, this behaviour is not enabled. Configuring the Oracle datasource to `configure_secondary_nics` enables it: datasource: Oracle: configure_secondary_nics: true Failures to fetch and generate secondary NIC configuration will log a warning, but otherwise will not affect boot. [0] The expected use of the IMDS-provided network configuration is substantially different on Bare Metal Machines, so support for that will be addressed separately. [1] This is v1 config, because cloudinit.net.cmdline generates v1 config and we need to integrate the secondary NICs into that configuration.
* net/cmdline: split interfaces_by_mac and init network config determinationDaniel Watkins2019-07-261-6/+4
| | | | | | | | | | | | | | | | | | | Previously "cmdline" network configuration could be either user-specified network-config=... configuration data, or initramfs-provided configuration data. Before data sources could modify the order in which network config sources were considered, this conflation didn't matter (and, indeed, in the default data source configuration it will continue to not matter). However, it _is_ desirable for a data source to be able to specify that its network configuration should be preferred over the initramfs-provided network configuration but still allow explicit network-config=... configuration passed to the kernel cmdline to continue to override both of those sources. (This also modifies the Oracle data source to use read_initramfs_config directly, which is effectively what it was using read_kernel_cmdline_config for previously.)
* instance-data: Add standard keys platform and subplatform. Refactor ec2.Chad Smith2018-10-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the following instance-data.json standardized keys: * v1._beta_keys: List any v1 keys in beta development, e.g. ['subplatform']. * v1.public_ssh_keys: List of any cloud-provided ssh keys for the instance. * v1.platform: String representing the cloud platform api supporting the datasource. For example: 'ec2' for aws, aliyun and brightbox cloud names. * v1.subplatform: String with more details about the source of the metadata consumed. For example, metadata uri, config drive device path or seed directory. To support the new platform and subplatform standardized instance-data, DataSource and its subclasses grew platform and subplatform attributes. The platform attribute defaults to the lowercase string datasource name at self.dsname. This method is overridden in NoCloud, Ec2 and ConfigDrive datasources. The subplatform attribute calls a _get_subplatform method which will return a string containing a simple slug for subplatform type such as metadata, seed-dir or config-drive followed by a detailed uri, device or directory path where the datasource consumed its configuration. As part of this work, DatasourceEC2 methods _get_data and _crawl_metadata have been refactored for a few reasons: - crawl_metadata is now a read-only operation, persisting no attributes on the datasource instance and returns a dictionary of consumed metadata. - crawl_metadata now closely represents the raw stucture of the ec2 metadata consumed, so that end-users can leverage public ec2 metadata documentation where possible. - crawl_metadata adds a '_metadata_api_version' key to the crawled ds.metadata to advertise what version of EC2's api was consumed by cloud-init. - _get_data now does all the processing of crawl_metadata and saves datasource instance attributes userdata_raw, metadata etc. Additional drive-bys: * unit test rework for test_altcloud and test_azure to simplify mocks and make use of existing util and test_helpers functions.
* Add datasource Oracle Compute Infrastructure (OCI).Scott Moser2018-08-171-0/+233
This adds a Oracle specific datasource that functions with OCI. It is a simplified version of the OpenStack metadata server with support for vendor-data. It does not support the OCI-C (classic) platform. Also here is a move of BrokenMetadata to common 'sources' as this was the third occurrence of that class.