summaryrefslogtreecommitdiff
path: root/cloudinit/net
AgeCommit message (Collapse)Author
2021-09-17Add connectivity_url to Oracle's EphemeralDHCPv4 (#988)James Falcon
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
2021-09-13Support openEuler OS (#1012)zhuzaifangxuele
openEuler Homepage: https://www.openeuler.org/en/
2021-09-01Add CloudLinux OS support (#1003)Alexandr Kravchenko
https://www.cloudlinux.com/
2021-08-30Add support to accept-ra in networkd renderer (#999)Shreenidhi Shedi
Also fix search path in networkd
2021-08-12cc_resolv_conf: fix typos (#969)Shreenidhi Shedi
Add tests for cc_resolv_conf handler
2021-08-12Azure: Logging the detected interfaces (#968)Moustafa Moustafa
2021-08-10Update inconsistent indentation (#962)Andrew Kutz
This patch updates some indentation in a comment that prevented an attempt to run the Black formatter (https://github.com/psf/black) against the cloud-init codebase: $ find cloudinit -name '*.py' -type f | xargs black -l 79 --check ... Oh no! 💥 💔 💥 262 files would be reformatted, 19 files would be left unchanged, 1 file would fail to reformat. The one file that fails to format is cloudinit/net/__init__.py. With this fix in place, the black command can successfully parse the file into AST and back again: $ black -l 79 --check cloudinit/net/__init__.py would reformat cloudinit/net/__init__.py Oh no! 💥 💔 💥 1 file would be reformatted. Normally this patch would be part of such an overall effort, but since this is the only location that interrupted running the black command, this author felt it was worth addressing this discrepancy sooner than later in the case there is subsequent desire to use a standard format tool such as black.
2021-08-09photon: refactor hostname handling and add networkd activator (#958)sshedi
2021-08-05Add support for EuroLinux 7 && EuroLinux 8 (#957)Aleksander Baranowski
2021-07-21Add VZLinux support (#951)eb3095
Virtuozzo Linux is a distro based off of CentOS 8, similar to Alma Linux and Rocky Linux.
2021-07-19Initial hotplug support (#936)James Falcon
Adds a udev script which will invoke a hotplug hook script on all net add events. The script will write some udev arguments to a systemd FIFO socket (to ensure we have only instance of cloud-init running at a time), which is then read by a new service that calls a new 'cloud-init devel hotplug-hook' command to handle the new event. This hotplug-hook command will: - Fetch the pickled datsource - Verify that the hotplug event is supported/enabled - Update the metadata for the datasource - Ensure the hotplugged device exists within the datasource - Apply the config change on the datasource metadata - Bring up the new interface (or apply global network configuration) - Save the updated metadata back to the pickle cache Also scattered in some unrelated typing where helpful
2021-07-01freebsd/net_v1 format: read MTU from root (#930)Gonéri Le Bouder
We read the MTU from the subnet entries. With the v1 format, the MTU can be set at the root level of the interface entry in the `config` section. Limitation, we won't set the MTU if the interface use DHCP. This would require a bit of refactoring. Also simplify/clarify how we pass the target variable in `cloudinit.net.bsd`. See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256309 Reported-by: Andrey Fesenko
2021-07-01Add new network activators to bring up interfaces (#919)James Falcon
Currently _bring_up_interfaces() is a no-op for any distro using renderers. We need to be able to support bringing up a single interfaces, a list of interfaces, and all interfaces. This should be independent of the renderers, as the network config is often generated independent of the mechanism used to apply it. Additionally, I included a refactor to remove "_supported_write_network_config". We had a confusing call chain of apply_network_config->_write_network_config->_supported_write_network_config. The last two have been combined.
2021-06-28Removed distro specific network code from Photon (#929)sshedi
Minor fixes in networkd renderer & fixed corresponding tests Removed datasource_list for Photon from cloud.cfg.tmpl & added a comment in cloud.cfg.tmpl about not to use multiline array for datasource_list. Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
2021-06-18Add support for VMware PhotonOS (#909)sshedi
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.
2021-06-17Fix DNS in NetworkState (SC-133) (#923)James Falcon
v1 network config currently has no concept of interface-specific DNS, which is required for certain renderers. To fix this, added an optional 'interface' key on the v1 nameserver definition. If specified, it makes the DNS settings specific to the interface. Otherwise, it will be defined as global DNS as it always has. Additionally, DNS for v2 wasn't being recognized correctly. For DNS defined on a particular interface, these settings now also go into the global DNS settings as they were intended.
2021-06-14add DragonFlyBSD support (#904)Gonéri Le Bouder
- Mostly based on FreeBSD, the main exception is that `find_devs_with_on_freebsd` does not work. - Since we cannot get the CDROM or the partition labels, `find_devs_with_on_dragonflybsd()` has a more naive approach and returns all the block devices.
2021-06-01Allow braces to appear in dhclient output (#911)eb3095
dhclient output that contains brackets for pxe variables will break the dhclient parsing regex line. This fix retains the current functionality while fixing this particular issue.
2021-05-25openbsd/net: flush the route table on net restart (#908)Gonéri Le Bouder
Ensure we've got a clean environment before we restart the network. In some cases, the `sh /etc/netstart` is not enough to restart the network. A previous default route remains in the route table and as a result the network is broken. Also `sh /netstart` does not kill `dhclient`. The problen happens for instance with OVH OpenStack SBG3.
2021-05-25Add Rocky Linux support to cloud-init (#906)Louis Abel
Rocky Linux is a RHEL-compatible distribution so all changes that have been made should be trivial.
2021-05-14BSD: static network, set the mtu (#894)Gonéri Le Bouder
In the case of a static network, we now set the MTU according to the meta-data.
2021-05-07Add AlmaLinux OS support (#872)Andrew Lukoshko
AlmaLinux OS is RHEL-compatible so all the changes needed are trivial.
2021-04-09sysconfig: use BONDING_MODULE_OPTS on SUSE (#831)Jens Sandmann
Update sysconfig configuration to use BONDING_MODULES_OPTS instead of BONDING_OPTS when on a SUSE system. The sysconfig support requires use of BONDING_MODULE_OPTS whereas the initscript support that rhel uses requires BONDING_OPTS.
2021-04-07bringup_static_routes: fix gateway check (#850)Petr Fedchenkov
When bringing up DHCP-provided static routes, we check for "0.0.0.0/0" to indicate an unspecified gateway. However, when parsing the static route in `parse_static_routes`, the gateway is never specified with a net length, so the "/0" will never happen. This change updates the gateway check to check only for "0.0.0.0".
2021-03-29Fix mis-detecting network configuration in initramfs cmdline (#844)James Falcon
klibc initramfs in debian allows the 'iscsi_target_ip=' cmdline parameter to specify an iscsi device attachment. This can cause cloud-init to mis-detect the cmdline paramter as a networking config. LP: #1919188
2021-03-08net: exclude OVS internal interfaces in get_interfaces (#829)Daniel Watkins
`get_interfaces` is used to in two ways, broadly: firstly, to determine the available interfaces when converting cloud network configuration formats to cloud-init's network configuration formats; and, secondly, to ensure that any interfaces which are specified in network configuration are (a) available, and (b) named correctly. The first of these is unaffected by this commit, as no clouds support Open vSwitch configuration in their network configuration formats. For the second, we check that MAC addresses of physical devices are unique. In some OVS configurations, there are OVS-created devices which have duplicate MAC addresses, either with each other or with physical devices. As these interfaces are created by OVS, we can be confident that (a) they will be available when appropriate, and (b) that OVS will name them correctly. As such, this commit excludes any OVS-internal interfaces from the set of interfaces returned by `get_interfaces`. LP: #1912844
2021-01-13net: Fix static routes to host in eni renderer (#668)Pavel Abalikhin
Route '-net' parameter is incompatible with /32 IPv4 addresses so we have to use '-host' in that case.
2021-01-07Missing IPV6_AUTOCONF=no to render sysconfig dhcp6 stateful on RHEL (#753)Eduardo Otubo
IPV6_AUTOCONF needs to be set to 'no' on RHEL so NetworkManager can properly acquire ipv6 address. rhbz: #1859695 Signed-off-by: Eduardo Otubo <otubo@redhat.com>
2020-12-01Adding BOOTPROTO = dhcp to render sysconfig dhcp6 stateful on RHEL (#685)Eduardo Otubo
BOOTPROTO needs to be set to 'dhcp' on RHEL so NetworkManager can properly acquire ipv6 address. rhbz: #1859695 Signed-off-by: Eduardo Otubo <otubo@redhat.com> Co-authored-by: Daniel Watkins <oddbloke@ubuntu.com> Co-authored-by: Scott Moser <smoser@brickies.net>
2020-11-09Make wakeonlan Network Config v2 setting actually work (#626)dermotbradley
Add code so that specifying "wakeonlan: true" actually results in relevant configuration entry appearing in /etc/network/interfaces, Netplan, and sysconfig for RHEL and OpenSuse. Add testcases for the above.
2020-10-29Explicit set IPV6_AUTOCONF and IPV6_FORCE_ACCEPT_RA on static6 (#634)Eduardo Otubo
The static and static6 subnet types for network_data.json were being ignored by the Openstack handler, this would cause the code to break and not function properly. As of today, if a static6 configuration is chosen, the interface will still eventually be available to receive router advertisements or be set from NetworkManager to wait for them and cycle the interface in negative case. It is safe to assume that if the interface is manually configured to use static ipv6 address, there's no need to wait for router advertisements. This patch will set automatically IPV6_AUTOCONF and IPV6_FORCE_ACCEPT_RA both to "no" in this case. This patch fixes the specific behavior only for RHEL flavor and sysconfig renderer. It also introduces new unit tests for the specific case as well as adjusts some existent tests to be compatible with the new options. This patch also addresses this problem by assigning the appropriate subnet type for each case on the openstack handler. rhbz: #1889635 rhbz: #1889635 Signed-off-by: Eduardo Otubo otubo@redhat.com
2020-10-29get_interfaces: don't exclude Open vSwitch bridge/bond members (#608)Lukas Märdian
If an OVS bridge was used as the only/primary interface, the 'init' stage failed with a "Not all expected physical devices present" error, leaving the system with a broken SSH setup. LP: #1898997
2020-10-13net: add the ability to blacklist network interfaces based on driver during ↵Anh Vo
enumeration of physical network devices (#591)
2020-09-15network: Fix type and respect name when rendering vlan in sysconfig. (#541)Eduardo Otubo
Prior to this change, vlans were rendered in sysconfig with 'TYPE=Ethernet', and incorrectly rendered the PHYSDEV based on the name of the vlan device rather than the 'link' provided in the network config. The change here fixes: * rendering of TYPE=Ethernet for a vlan * adds a warning if the configured device name is not supported per the RHEL 7 docs "11.5. Naming Scheme for VLAN Interfaces" LP: #1788915 LP: #1826608 RHBZ: #1861871
2020-08-25tox: bump the pylint version to 2.6.0 in the default run (#544)Paride Legovini
Changes: tox: bump the pylint version to 2.6.0 in the default run Fix pylint 2.6.0 W0707 warnings (raise-missing-from)
2020-08-24DHCP sandboxing failing on noexec mounted /var/tmp (#521)Eduardo Otubo
* DHCP sandboxing failing on noexec mounted /var/tmp If /var/tmp is mounted with noexec option the DHCP sandboxing will fail with Permission Denied. This patch simply avoids this error by checking the exec permission updating the dhcp path in negative case. rhbz: https://bugzilla.redhat.com/show_bug.cgi?id=1857309 Signed-off-by: Eduardo Otubo <otubo@redhat.com> * Replacing with os.* calls * Adding test and removing isfile() useless call. Co-authored-by: Rick Harding <rharding@mitechie.com>
2020-07-15cloudinit: remove global disable of pylint W0107 and fix errors (#489)Daniel Watkins
* cloudinit: remove global disable of pylint W0107 and fix errors This includes removing a test class which contained no tests but wasn't detected as empty because of an errant pass statement. * .pylintrc: update disable comment to match arguments
2020-07-14networking: refactor wait_for_physdevs from cloudinit.net (#466)Daniel Watkins
* Refactor `cloudinit.net.wait_for_physdevs` to `cloudinit.distros.networking.Networking.wait_for_physdevs` * Split the Linux-specific `udevadm_settle` call out to a separate abstract `Networking.settle` method; implement it on `LinuxNetworking` and add a `NotImplementedError` implementation to `BSDNetworking` * Modify `wait_for_physdevs`s one callsite to use the new location LP: #1884626
2020-07-13cloudinit: remove global disable of pylint W0105 and fix errors (#480)Daniel Watkins
This includes a fix to a test that had a string concatenation issue, and so was only testing a prefix of what was intended.
2020-06-30networking: refactor is_physical from cloudinit.net (#457)Daniel Watkins
As the first refactor PR, this also includes the initial structure for tests. LP: #1884619
2020-06-24net/networking: remove unused functions/methods (#453)Daniel Watkins
Namely, is_connected, is_wireless and is_present. None of these are used in the cloud-init codebase, so remove the dead code (instead of refactoring it).
2020-06-19printing the error stream of the dhclient process before killing it (#369)Moustafa Moustafa
This introduces a way to log the dhclient error stream, and uses it for the Azure datasource (where we have a specific requirement for this data to be logged).
2020-06-10test: fix all flake8 E126 errors (#425)Joshua Powers
2020-06-09Fixes KeyError for bridge with no "parameters:" setting (#423)Brian Candler
Reason: commit ded1ec8 introduced a regression whereby a bridge with no "parameters:" setting caused a KeyError exception. LP: #1879673
2020-06-08Move subp into its own module. (#416)Scott Moser
This was painful, but it finishes a TODO from cloudinit/subp.py. It moves the following from util to subp: ProcessExecutionError subp which target_path I moved subp_blob_in_tempfile into cc_chef, which is its only caller. That saved us from having to deal with it using write_file and temp_utils from subp (which does not import any cloudinit things now). It is arguable that 'target_path' could be moved to a 'path_utils' or something, but in order to use it from subp and also from utils, we had to get it out of utils.
2020-06-02test: fix all flake8 E121 and E123 errors (#404)Joshua Powers
This fixes issues with closing brackets not matching the opening bracket's line and continuation line under-idented for hanging indent.
2020-06-02test: fix all flake8 E241 (#403)Joshua Powers
Remove extra spaces after a ','
2020-06-01test: fix all flake8 E741 errors (#401)Joshua Powers
This removes the use of variables named ‘l’, ‘O’, or ‘I’. Generally these are used in list comprehension to read the line of lines.
2020-04-24cloudinit: drop dependencies on unittest2 and contextlib2 (#322)Daniel Watkins
These libraries provide backports of Python 3's stdlib components to Python 2. As we only support Python 3, we can simply use the stdlib now. This pull request does the following: * removes some unneeded compatibility code for the old spelling of `assertRaisesRegex` * replaces invocations of the Python 2-only `assertItemsEqual` with its new name, `assertCountEqual` * replaces all usage of `unittest2` with `unittest` * replaces all usage of `contextlib2` with `contextlib` * drops `unittest2` and `contextlib2` from requirements files and tox.ini It also rewrites some `test_azure` helpers to use bare asserts. We were seeing a strange error in xenial builds of this branch which appear to be stemming from the AssertionError that pytest produces being _different_ from the standard AssertionError. This means that the modified helpers weren't behaving correctly, because they weren't catching AssertionErrors as one would expect. (I believe this is related, in some way, to https://github.com/pytest-dev/pytest/issues/645, but the only version of pytest where we're affected is so far in the past that it's not worth pursuing it any further as we have a workaround.)
2020-04-21network_state: add missing space to log message (#325)Daniel Watkins