summaryrefslogtreecommitdiff
path: root/cloudinit/net/sysconfig.py
AgeCommit message (Collapse)Author
2022-02-08Fix IPv6 netmask format for sysconfig (#1215)Harald
This change converts the IPv6 netmask from the network_data.json[1] format to the CIDR style, <IPv6_addr>/<prefix>. Using an IPv6 address like ffff:ffff:ffff:ffff:: does not work with NetworkManager, nor networkscripts. NetworkManager will ignore the route, logging: ifcfg-rh: ignoring invalid route at \ "::/:: via fd00:fd00:fd00:2::fffe dev $DEV" \ (/etc/sysconfig/network-scripts/route6-$DEV:3): \ Argument for "::/::" is not ADDR/PREFIX format Similarly if using networkscripts, ip route fail with error: Error: inet6 prefix is expected rather than \ "fd00:fd00:fd00::/ffff:ffff:ffff:ffff::". Also a bit of refactoring ... cloudinit.net.sysconfig.Route.to_string: * Move a couple of lines around to reduce repeated code. * if "ADDRESS" not in key -> continute, so that the code block following it can be de-indented. cloudinit.net.network_state: * Refactors the ipv4_mask_to_net_prefix, ipv6_mask_to_net_prefix removes mask_to_net_prefix methods. Utilize ipaddress library to do some of the heavy lifting. LP: #1959148
2021-12-15Adopt Black and isort (SC-700) (#1157)James Falcon
Applied Black and isort, fixed any linting issues, updated tox.ini and CI.
2021-12-07Add miraclelinux support (#1128)Haruki TSURUMOTO
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-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-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-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-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-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-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-06-10test: fix all flake8 E126 errors (#425)Joshua Powers
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-02-03sysconfig: distro-specific config rendering for BOOTPROTO option (#162)Robert Schweikert
- Introduce the "flavor" configuration option for the sysconfig renderer this is necessary to account for differences in the handling of the BOOTPROTO setting between distributions (lp#1858808) + Thanks to Petr Pavlu for the idea - Network config clean up for sysconfig renderer + The introduction of the "flavor" renderer configuration allows us to only write values that are pertinent for the given distro - Set the DHCPv6 client mode on SUSE (lp#1800854) Co-authored-by: Chad Smith <chad.smith@canonical.com> LP: #1800854
2020-01-21Drop most of the remaining use of six (#179)Daniel Watkins
2020-01-08net: fix rendering of 'static6' in network config (#77)Ryan Harper
* net: fix rendering of 'static6' in network config A V1 static6 network typo was misrendered in eni, it's not valid. It was ignored in sysconfig and netplan. This branch fixes eni, updates sysconfig, netplan to render it correctly and adds unittests for all cases. Reported-by: Raphaël Enrici LP: #1850988 * net: add comment about static6 type in subnet_is_ipv6 Co-authored-by: Chad Smith <blackboxsw@gmail.com> Co-authored-by: Daniel Watkins <daniel@daniel-watkins.co.uk>
2019-11-20net: IPv6, accept_ra, slaac, stateless (#51)Harald
Router advertisements are required for the default route to be set up, thus accept_ra should be enabled for dhcpv6-stateful. sysconf: IPV6_FORCE_ACCEPT_RA controls accept_ra sysctl. eni: mode static and mode dhcp 'accept_ra' controls sysctl. Add 'accept-ra: true|false' parameter to config v1 and v2. When True: accept_ra is set to '1'. When False: accept_ra is set to '0'. When not defined in config the value is left to the operating system default. This change also extend the IPv6 support to distinguish between slaac and dhcpv6-stateless. SLAAC is autoconfig without any options from DHCP, while stateless auto-configures the address and the uses DHCP for other options. LP: #1806014 LP: #1808647
2019-11-04azure: support matching dhcp route-metrics for dual-stack ipv4 ipv6Chad Smith
Network v2 configuration for Azure will set both dhcp4 and dhcp6 to False by default. When IPv6 privateIpAddresses are present for an interface in Azure's Instance Metadata Service (IMDS), set dhcp6: True and provide a route-metric value that will match the corresponding dhcp4 route-metric. The route-metric value will increase by 100 for each additional interface present to ensure the primary interface has a route to IMDS. Also fix dhcp route-metric rendering for eni and sysconfig distros. LP: #1850308
2019-10-23net/sysconfig: fix available check on SUSE distrosRobert Schweikert
In addition to ifup/ifdown the sysconfig renderer looks for evidence that the sysconfig directory is properly populated. This secondary check only considered RedHat specific location. Fix this by adding a SUSE specific file and returning True if either RedHat or SUSE file is present. LP: #1849378
2019-10-21net: enable infiniband support in eni and sysconfig renderersDarren Birkett
Commit e7b0e5f72 added support for configuring infiniband devices by adding a new infiniband 'type'. This commit updates eni and sysconfig renderers to consume this new type and configure infiniband devices correctly. LP: #1847114
2019-10-16net: handle openstack dhcpv6-stateless configurationHarald Jensås
Openstack subnets can be configured to use SLAAC by setting ipv6_address_mode=dhcpv6-stateless. When this is the case the sysconfig interface configuration should use IPV6_AUTOCONF=yes and not set DHCPV6C=yes. This change sets the subnets type property to the full network['type'] from openstack metadata. cloudinit/net/sysconfig.py and cloudinit/net/eni.py are updated to support new subnet types: - 'ipv6_dhcpv6-stateless' => IPV6_AUTOCONF=yes - 'ipv6_dhcpv6-stateful' => DHCPV6C=yes Type 'dhcp6' in sysconfig is kept for backward compatibility with any implementations that set subnet_type == 'dhcp6'. LP: #1847517
2019-09-26sysconfig: only write resolv.conf if network_state has DNS valuesRyan Harper
If an OS image provided an /etc/resolv.conf file that was not empty cloud-init would read and re-write it with a cloud-init header even if no DNS network configuration was provided (e.g. DHCP only). This can cause problems for some network services which don't ignore cloud-init's header. LP: #1843634
2019-09-26sysconfig: use distro variant to check if availableRyan Harper
The sysconfig renderer used the distro name directly which mean some variants of distros were not considered supported. Fix this by using util.system_info()['variant'] instead. Fix the list of KNOWN_DISTROS value for redhat -> rhel. LP: #1843584
2019-06-21sysconfig: support more bonding optionsPenghui Liao
Currently, only a few bonding parameters can be configured on sysconfig systems. This patch aims to support more parameters documented on the docs site.
2019-04-22net/sysconfig: only indicate available on known sysconfig distrosRyan Harper
Restrict the sysconfig renderer availabily to known distros. Ubuntu/Debian systems may include network-manager but they do not have support for reading sysconfig network output; that is enabled via a Network-Manager plugin: ifcfg-rh which is not available in Ubuntu/Debian. LP: #1819994
2019-03-25net/sysconfig: write out SUSE-compatible IPv6 configRobert Schweikert
For writing IPv6 addresses to ifcfg-* the name "IPV6ADDR" is used. For secondary IPs the value for "IPV6ADDR_SECONDARIES" is set. On SUSE based distributions the names "IPADDR6" and "IPADDR6_$SOMELABEL" need to be used.
2019-03-12net/sysconfig: Handle default route setup for dhcp configured NICsRobert Schweikert
When the network configuration has a default route configured and another network device that is configured with dhcp, SUSE sysconfig output should not accept the default route provided by the dhcp server. LP: #1812117
2019-01-28sysconfig: On SUSE, use STARTMODE instead of ONBOOTRobert Schweikert
ONBOOT is not recognized on openSUSE and SUSE Linux Enterprise, add the STARTMODE setting LP: #1799540
2019-01-23net/sysconfig: do not write a resolv.conf file with only the header.Robert Schweikert
Writing the file with no dns information may prevent distro tools from writing a resolv.conf file with dns information obtained from a dhcp server.
2019-01-18net: Make sysconfig renderer compatible with Network Manager.Eduardo Otubo
The 'sysconfig' renderer is activated if, and only if, there's ifup and ifdown commands present in its search dictonary or the network-scripts configuration files are found. This patch adds a check for Network- Manager configuration file as well. This solution is based on the use of the plugin 'ifcfg-rh' present in Network-Manager and is designed to support Fedora 29 or other distributions that also replaced network-scripts by Network-Manager.
2018-12-11net: render 'metric' values in per-subnet routesRyan Harper
It is possible to have a metric value in a per-subnet route. This is currently missing in all renderers. Update each renderer to emit the correct metric value from the config. LP: #1805871
2018-09-26Add support for Infiniband network interfaces (IPoIB).Mark Goddard
OpenStack ironic references Infiniband interfaces via a 6 byte 'MAC address' formed from bytes 13-15 and 18-20 of interface's hardware address. This address is used as the ethernet_mac_address of Infiniband links in network_data.json in configdrives generated by OpenStack nova. We can use this address to map links in network_data.json to their corresponding interface names. When generating interface configuration files, we need to use the interface's full hardware address as the HWADDR, rather than the 6 byte MAC address provided by network_data.json. This change allows IB interfaces to be referenced in this dual mode - by MAC address and hardware address, depending on the context. Support TYPE=InfiniBand for sysconfig configuration of IB interfaces.
2018-09-05sysconfig: refactor sysconfig to accept distro specific templates pathsRyan Harper
Multiple distros use sysconfig format but have different content and paths to certain files. Update distros to specify these template paths in their renderer_configs dictionary.
2018-06-12netplan: fix mtu if provided by network config for all rendered typesChad Smith
When network configuration for any interface defines maximum transmission values (MTU) the netplan, eni and sysconfig renders will take into account any device-level, or subnet-level mtu values. When network configuration has conflicting device-level and ipv4 subnet mtu values, the subnet-specific value is honored and a warning will be logged about any ignored device-level setting. LP: #1774666
2018-04-25sysconfig: dhcp6 subnet type should not imply dhcpv4Vitaly Kuznetsov
BOOTPROTO=dhcp in sysconfig enables DHCPv4 and we should not do this implicitly when 'dhcp6' subnet is specified. In case both dhcpv4 and dhcpv6 are needed users should specify both: subnets: - type: dhcp6 - type: dhcp Fix the current code and add a dhcpv6 only test. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
2018-04-19pylint: pay attention to unused variable warnings.Scott Moser
This enables warnings produced by pylint for unused variables (W0612), and fixes the existing errors.
2017-11-21sysconfig: Correctly render dns and dns search info.Ryan McCabe
Currently when dns and dns search info is provided, it is not rendered when outputting to sysconfig format. This patch causes the DNS and DOMAIN lines to be written out rendering sysconfig. LP: #1705804
2017-08-01sysconfig: Dont repeat header when rendering resolv.confRyan Harper
The sysconfig renderer duplicates the cloud-init header string when rendering resolv.conf file. This leads to resolv.conf file growing with every reboot of a system. Fix this by checking for the header when loading content from existing file. Update one of the sysconfig unittests with multiple render calls to simulate the reboot to check that we don't repeat the header. LP: #1701420
2017-07-22sysconfig: support subnet type of 'manual'.Scott Moser
The subnet type 'manual' was used as a way to declare a device and set an MTU for it but not assign network addresses. This updates the manual example config to handle that case and provides expected rendered output for sysconfig, eni, and netplan.
2017-07-20sysconfig: use MACADDR on bonds/bridges to configure mac_addressRyan Harper
Previously, sysconfig rendered HWADDR for all interface types, but that value is only used to identify physical devices. Instead use MACADDR to configure the MAC on virtual devices, like bonds and bridges. - Sort bond slave list to ensure consistent ordering in sysconfig rendered files. - Add unittests for sysconfig rendering of bonds/bridges with mac_address LP: #1701417
2017-07-20sysconfig: enable mtu set per subnet, including ipv6 mtuRyan Harper
Render MTU values if present in subnet and route configurations for v4 and v6. LP: #1702513
2017-07-20sysconfig: handle manual type subnetsRyan Harper
Implement manual control for sysconfig by using ONBOOT=N. This allows an interface to be configured but not brought up. Note that ONBOOT is per-interface not per address. LP: #1687725
2017-07-20sysconfig: fix ipv6 gateway routesRyan Harper
Currently only the subnet is checked for 'ipv6' setting, however, the routes array may include a mix of v4 or v6 configurations, in particular, the gateway in a route may be ipv6, and if so, should export the value via IPV6_DEFAULTGW in the ifcfg-XXXX file. Additionally, if the route is v6, it should rendering a routes6-XXXX file; this is present but missing the 'dev <interface>' scoping. LP: #1694801
2017-07-20sysconfig: fix rendering of bond, bridge and vlan types.Ryan Harper
Previously, virtual types (bond, bridge, vlan) were almost completely broken. They would not get any network configuration (ip addresses or dhcp config) and or routes rendered. This fixes those issues. For bonds we now correctly render BONDING_SLAVE entries. Also add tests for simple bond, bridge and vlan. LP: #1695092
2017-07-19sysconfig: ipv6 and default gateway fixes.Ryan Harper
With this change, entries in IPV6ADDR and IPV6ADDR_SECONDARIES will now always be in format addr/prefix. When a subnet has a gateway will be written. If the gateway is ipv6, use the key IPV6_DEFAULTGW rather than GATEWAY. LP: #1704872