summaryrefslogtreecommitdiff
path: root/cloudinit/net/eni.py
AgeCommit message (Collapse)Author
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-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.
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-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-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-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-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-03-21net: Fix ipv6 static routes when using eni rendererRaphael Glon
When rendering ipv6 static routes in eni format the post-up/pre down commands were not correct for ipv6. LP: #1818669
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-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-08-06netplan: Correctly render macaddress on a bonds and bridges when provided.Scott Moser
When converting network config v1 to netplan, we were not correctly rendering the 'macaddress' key on a bond. Not that the difference in spelling between v1 'mac_address' and v2 'macaddress' is intentional. Also fixed here is rendering of the macaddress for bridges. LP: #1784699
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
2017-10-05network: bridge_stp value not always correctRyan Harper
Update network_state to store the bridge_stp value as a boolean. The various renderers then can map the boolean value to the correct output as needed; eni uses 'on/off', sysconfig uses 'yes/no' and netplan will use the boolean directly. Update unittest values for sysconfig and netplan. Both contained the network_state string value which resulted in not correctly enable/disable STP in the target system. Update network_state comment (fd -> forward-delay, add stp as boolean) on bridge commands to match the expected format of a netplan bridge command. LP: #1721157
2017-07-20net: eni route rendering missed ipv6 default route configRyan Harper
In some network configurations a network value of '::' and a netmask value of '::' were used to indicate a default IPV6 gateway. Commit d00da2d5 removed ipv6 'netmask' attributes and calculate a prefix length value instead. The eni route rendering failed to update the check to use prefix value of 0 to indicate the presence of an IPV6 default route. A broken ipv6 default route rendered like: post-up route add -net :: netmask :: gw 2001:4800:78ff:1b::1 || true And with this patch, it now renders like: post-up route add -A inet6 default gw 2001:4800:78ff:1b::1 || true LP: #1701097
2017-06-27Azure: Add network-config, Refactor net layer to handle duplicate macs.Ryan Harper
On systems with network devices with duplicate mac addresses, cloud-init will fail to rename the devices according to the specified network configuration. Refactor net layer to search by device driver and device id if available. Azure systems may have duplicate mac addresses by design. Update Azure datasource to run at init-local time and let Azure datasource generate a fallback networking config to handle advanced networking configurations. Lastly, add a 'setup' method to the datasources that is called before userdata/vendordata is processed but after networking is up. That is used here on Azure to interact with the 'fabric'.
2017-06-08net: normalize data in network_state objectScott Moser
The network_state object's network and route keys would have different information depending upon how the network_state object was populated. This change cleans that up. Now: * address will always contain an IP address. * prefix will always include an integer value that is the network_prefix for the address. * netmask will be present only if the address is ipv4, and its value will always correlate to the 'prefix'.
2017-05-31Fix eni rendering for bridge params that require repeated key for values.Ryan Harper
There are a few bridge parameters which require repeating the key with each value in the list when rendering eni. Extend the network unittests to cover all of the known bridge parameters and check we render eni and netplan correctly.
2017-05-31net: remove systemd link file writing from eni rendererRyan Harper
During the network v2 merge, we inadvertently re-enabled rendering systemd .link files. This files are not required as cloud-init already has to do interface renaming due to issues with udevd which may refuse to rename certain interfaces (such as veth devices in a LXD container). As such, removing the code altogether.
2017-03-20cloudinit.net: add network config v2 parsing and renderingRyan Harper
Network configuration version 2 format is implemented in a package called netplan (nplan)[1] which allows consolidated network config for multiple network controllers. - Add a new netplan renderer - Update default policy, placing eni and sysconfig first This requires explicit policy to enable netplan over eni on systems which have both (Yakkety, Zesty, UC16) - Allow any network state (parsed from any format cloud-init supports) to render to v2 if system supports netplan. - Move eni's _subnet_is_ipv6 to common code for use by other renderers - Make sysconfig renderer always emit /etc/syconfig/network configuration - Update cloud-init.service systemd unit to also wait on systemd-networkd-wait-online.service 1. https://lists.ubuntu.com/archives/ubuntu-devel/2016-July/039464.html
2017-03-20net: Fix incorrect call to isfileJoshua Powers
Previous commit introduced a regression by calling os.path.is_file, a non-existent function. This changes that call to use os.path.isfile. LP: #1674317
2017-03-17net: add renderers for automatically selecting the renderer.Scott Moser
Previously, the distro had hard coded which network renderer it would use. This adds support for just picking the right renderer based on what is available. Now, that can be set via a priority in system_info, but should generally work. That config looks like: system_info: network: renderers: ["eni", "sysconfig"] When no renderers are found, a specific RendererNotFoundError is raised. stages.py is modified to catch that and log it at error level. This path should not really be exercised, but could occur if for example an Ubuntu system did not have ifupdown, or a rhel system did not have sysconfig. In such a system previously we would have quietly rendered ENI configuration but that would have been ignored. This is one step better in that we at least log the error.
2017-03-17render_network_state: switch arguments around, do not require targetScott Moser
render_network_state should default to rendering on /. The changes here just make it so render_network_state does not require a target, but defaults to None, and uses target_path to handle that.
2017-03-17support 'loopback' as a device type.Scott Moser
As reported in bug 1671927, sysconfig had an issue with rendering a loopback device. The problem was that some as yet unknown issue was causing the openstack config drive to parse the provided ENI file rather than reading the network_data.json. Parsing an ENI file would add a a 'lo' device of type 'physical', and sysconfig was failing to render that. The change here is: a.) add a 'loopback' type rather than 'physical' for network config. {'name': 'lo', 'type': 'loopback', 'subnets': ['type': 'loopback']} b.) support skipping that type in the eni and sysconfig renderers. c.) make network_state just piggy back on 'physical' renderer for loopback (this was what was happening before). Tests are added for eni and sysconfig renderer.
2017-01-25Fix eni rendering of multiple IPs per interfaceRyan Harper
The iface:alias syntax for eni rendering is brittle with ipv6. Replace it with using multiple iface stanzas with the same iface name which is supported. Side-effect is that one can no longer do 'ifup $iface:$alias' but requires instead use of ip address {add|delete} instead. LP: #1657940
2016-12-22LICENSE: Allow dual licensing GPL-3 or Apache 2.0Jon Grimm
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.
2016-08-23Generate a dummy bond name for OpenStackScott Moser
The OpenStack network_data.json does not provide a name for bond links. This change makes it so a dummy one is generated and used instead to satisfy cloud-init which does require one. In order to write the correct link (underlying 'link' names) for the bonds, we maintain a list of info by ids so we can easily get the right device name. Also: * add a vlan test case that similarly references an id rather than name. * make bond interfaces auto LP: #1605749
2016-07-13merge from trunkScott Moser
2016-07-13merge from trunkScott Moser
2016-07-13merge from trunk.lp1602373Scott Moser
this merges in the render_hwaddress support. newly added tests still run, so hwaddress seems correctly getting in.
2016-07-13ConfigDrive: write 'injected' files and legacy networkingScott Moser
Previous commit disabled the consumption of 'injected' files in configdrive (openstack server boot --file=/target/file=local-file) unless the datasource was in 'pass' mode. The default mode is 'net' so that would never happen. Also here are: a.) a fix for 'links_path_prefix' string from debian, to finally disable the rendering of systemd.link files (LP: #1594546) b.) some comments to apply_network_config c.) implement a backwards compatibility for for distros that do not yet implement apply_network_config by converting the network config into ENI format and calling apply_network. This is required because prior to the previous commit, those distros would have had 'apply_network' called with the openstack provided ENI file. But after this change they will have apply_network_config called by cloudinit's main. d.) a network_state_to_eni helper for converting net config to eni it supports the not-actually-correct 'hwaddress' field in ENI. LP: #1602373
2016-07-13String format requires positions on python 2.6Joshua Harlow
2016-06-21no longer skip 'lo' elements when reading. pass 3rd test.Scott Moser
2016-06-21fix flake8Scott Moser
2016-06-21make 2 of 3 tests passScott Moser
2016-06-21net: fix inet value for subnets, don't add interface attributes to aliasScott Moser
[copied from curtin revno 390] Apply two separate fixes for configuring bonding with ip aliases. Curtin re-used the interface's inet value for each subnet that might be configured. In the case where the configuration included an ipv4 address after an ipv6 one resulted in emitting 'inet6' for ipv4 address which is not correct. Resolve this issue by calculating the inet value independent of the current status of the iface, using the subnet config instead. When rendering a network_config which includes ip alias interfaces do not emit any attributes, like MTU, or bond/bridge options Including these values is almost always wrong or will result in confusing behavior on the target system. LP: #1588547
2016-06-21fix english in commentScott Moser
2016-06-21merge with trunkScott Moser
2016-06-21fix lost per-interface routes, use post-up to bring up interface aliasesScott Moser
Fix the lack of per-interface routes, and add an example to yaml. in revno 394 in curtin, we added post-up for interface aliases. bring that commit here.
2016-06-21sort attributes in sections, change 'mac_address' to 'hwaddress'Scott Moser
2016-06-21minor cleanupScott Moser
2016-06-21make _render_iface return a list of sections rather than one sectionScott Moser
2016-06-20merge with trunk.Scott Moser
test runs to the point where it did, think I got most of the changes incorporated.
2016-06-20add a header to rendered ENI file describing its contentScott Moser
2016-06-15merge with trunkScott Moser
2016-06-15Fix line length issuesJoshua Harlow
2016-06-15Fixup code review commentsJoshua Harlow
2016-06-14fix pep8 failure introduced in recent commit.Scott Moser
The commit 1232 (Refactor a large part of the networking code) broke pep8.
2016-06-13Refactor some of sysconfig changes -> network_state moduleJoshua Harlow