summaryrefslogtreecommitdiff
path: root/tests/unittests/test_net.py
Commit message (Collapse)AuthorAgeFilesLines
* net: purge blacklist_drivers across net and azure (#2160)Chris Patterson2023-05-101-21/+18
| | | | | | | | | | It was only used by Hyper-V which now has a filtering mechanism that does not require the use of a denylist. This exposed some issues with tests misspelling "hv_netvsc" and using unmatched mac addresses. This fixes those to work with the current filter that does not rely on the driver name. Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
* gce: activate network discovery on every boot (#2128)Alberto Contreras2023-04-271-2/+2
| | | | | | | Google wants to allow users to make changes on nics while the instance is stopped. Activate network discovery on every boot. Additionally, skip the call to `netplan generate` if the rendered config is the same on subsequent boots.
* macs: ignore duplicate MAC for devs with driver driver qmi_wwan (#2090)Chad Smith2023-03-231-12/+28
| | | | | | | | | | | | | Another physical modem which has duplicate MAC addresses. Cloud-init needs to ignore the subordinate devices which are associated with the qmi_wwan driver. Fixes network rendering for the following modems: Quectel EG25 Quectel RM510Q-GLHA Sierra Wireless MC7455 LP: #2008888
* log: Add standardized deprecation tooling (SC-1312) (#2026)Brett Holman2023-02-241-1/+2
| | | | | - Add deprecation log level - Add deprecation utilities for structured format and messaging - Update existing deprecation log sites, add deprecated versions
* Ignore duplicate macs from mscc_felix and fsl_enetcJames Falcon2023-02-021-0/+20
| | | | | | | mscc_felix and fsl_enetc are drivers representing a switch that is expected to have duplicate macs. If we encounter either of these drivers, we should not raise the duplicate mac exception. LP: #1997922
* Fix default route rendering on v2 ipv6 (#1973)James Falcon2023-01-241-1/+1
| | | | | | ::/0 would get rendered as ::/64 rather than ::/0 across all renderers using ipv6 in a v2 config. LP: #2003562
* network/netplan: add gateways as on-link when necessary (#1931)Louis Sautier2023-01-091-0/+38
| | | | | | | | network/netplan: add gateways as on-link when necessary When the gateway isn't part of the subnet's network, the "on-link" flag is required for the route to get added. LP: #2000596
* net: skip duplicate mac check for netvsc nic and its VF (#1853)Anh Vo2022-11-181-0/+25
| | | | | | | | | | | | | | | | When accelerated network is enabled on Azure, the host presents two network interfaces with the same mac address to the VM: a synthetic nic (netvsc) and a VF nic, which is enslaved to the synthetic nic. The net module is already excluding slave nics when enumerating interfaces. However, if cloud-init starts enumerating after the kernel makes the VF visible to userspace, but before the enslaving has finished, cloud-init will see two nics with duplicate mac. This change will skip the duplicate mac error if one of the two nics with duplicate mac is a netvsc nic LP: #1844191
* network: Deprecate gateway{4,6} keys in network config v2 (#1794)Alberto Contreras2022-11-161-22/+320
| | | | | | | - Do not render gateway{4,6} when transforming from network config v1 to v2. - Issue a warning if gateway{4,6} is present in network config v2. This warning is not issued if a passthrough to netplan is performed. LP: #1992512
* Networkd multi-address support/fix (#1685)Teodor Garzdin2022-08-241-0/+1
| | | | | | Fix that given a cloud-init network config with multiple addresses for an interface the networkd backend outputs an invalid networkd service config. According to the `man` page of `systemd-networkd` only one `Address=` field per `[Address]` section is allowed.
* NM ipv6 connection does not work on Azure and Openstack (#1616)Emanuele Giuseppe Esposito2022-08-221-16/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This problem is found after below bug fix, ipv6 is not workable after launching a new instance. [Bug 2056964](https://bugzilla.redhat.com/show_bug.cgi?id=2056964) - [RHEL-9]Rebase cloud-init from Fedora so it can configure networking using NM keyfiles we can see log "Not bringing up newly configured network interfaces" in /var/log/cloud-init.log 2022-06-17 02:15:22,191 - __init__.py[DEBUG]: Selected renderer 'network-manager' from priority list: ['netplan', 'network-manager', 'networkd', 'sysconfig', 'eni'] 2022-06-17 02:15:22,192 - util.py[DEBUG]: Writing to /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnection - wb: [600] 376 bytes 2022-06-17 02:15:22,193 - util.py[DEBUG]: Restoring selinux mode for /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnection (recursive=False) 2022-06-17 02:15:22,194 - util.py[DEBUG]: Restoring selinux mode for /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnection (recursive=False) 2022-06-17 02:15:22,194 - __init__.py[DEBUG]: Not bringing up newly configured network interfaces On Azure, ping6 gets Network is unreachable. $ ping6 ace:cab:deca::fe -c 1 ping6: connect: Network is unreachable # ip -6 route ::1 dev lo proto kernel metric 256 pref medium ace:cab:deca::4 dev eth0 proto kernel metric 100 pref medium fe80::/64 dev eth0 proto kernel metric 1024 pref medium cat /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnection # Generated by cloud-init. Changes will be lost. [connection] id=cloud-init eth0 uuid=1dd9a779-d327-56e1-8454-c65e2556c12c type=ethernet [user] org.freedesktop.NetworkManager.origin=cloud-init [ethernet] mac-address=00:0D:3A:58:0F:B3 [ipv4] method=auto may-fail=false [ipv6] method=dhcp may-fail=false addr-gen-mode=stable-privacy On Openstack, ping6 error is a little bit different, but unreachable either. # ping6 2620:52:0:88:f816:3eff:fe23:e623 -c 1 PING 2620:52:0:88:f816:3eff:fe23:e623(2620:52:0:88:f816:3eff:fe23:e623) 56 data bytes From 2620:52:0:88:ef7e:b597:1cc8:32df icmp_seq=1 Destination unreachable: Address unreachable --- 2620:52:0:88:f816:3eff:fe23:e623 ping statistics --- 1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms $ ip -6 route ::1 dev lo proto kernel metric 256 pref medium 2620:52:0:88::/64 dev eth0 proto ra metric 100 pref medium fe80::/64 dev eth0 proto kernel metric 1024 pref medium default proto static metric 100 pref medium nexthop via 2620:52:0:88::3fe dev eth0 weight 1 nexthop via fe80::4e16:fc01:d8c:98ed dev eth0 weight 1 nexthop via fe80::4e16:fc01:d83:88aa dev eth0 weight 1 cat /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnection # Generated by cloud-init. Changes will be lost. [connection] id=cloud-init eth0 uuid=1dd9a779-d327-56e1-8454-c65e2556c12c type=ethernet [user] org.freedesktop.NetworkManager.origin=cloud-init [ethernet] mtu=1500 mac-address=FA:16:3E:CE:97:C9 [ipv4] method=auto may-fail=false [ipv6] method=auto may-fail=false addr-gen-mode=stable-privacy route1=::/0,2620:52:0:88::3fe dhcp6 mode should be "auto" and addr-gen-mode=stable-privacy should be removed. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> RHBZ: 2098501
* Remove xenial references (#1472)Alberto Contreras2022-06-081-5/+5
| | | | | | - Remove references and dead code to Xenial, Eoan, Python < 3.7 - cc_ubuntu_drivers: Use python3-debconf instead of shell script - add integration test for ubuntu_drivers - bump pycloudlib for OCI subnet/jammy fixes
* Drop mypy excluded files (#1454)Alberto Contreras2022-05-231-3/+3
| | | | | | | | | - Add types to let mypy pass. - Add mypy flags: - detect unused ignores - redundant casts - Drop support of `ConfigParser` in Python 2 - Harden DataSourceLXD.network_config - Convert old-style commented types to proper types.
* Network functions refactor and bugfixes (#1383)Brett Holman2022-04-151-12/+12
| | | | | | | | - replace common functionality with standard library implementations - add is_ip_network() for validating addresses in form: "192.168.1.1/24" - add validation to _normalize_net_keys - fix eni tests that formerly tested invalid ipv6 addresses (caught by stricter validation) - other refactorization and name standardization
* Fix KeyError when rendering sysconfig IPv6 routes (#1380)James Falcon2022-04-141-0/+102
| | | | | | | | Route rendering code was expecting a netmask rather than using the prefix. A prefix is provided to the renderer, but was being hidden from the route rendering code. This commit exposes the prefix and prefers it for IPv6, given how uncommon netmasks are for IPv6. LP: #1958506
* testing: add additional mocks to test_net tests (#1356)yangzz-972022-03-311-0/+8
| | | | | | Tests in tests/unittests/test_net.py::TestGetInterfaces were missing mocks for bond and failover calls. Signed-off-by: yangzz-97 <yangzz-97@1162011203@qq.com>
* Fix sysconfig render when set-name is missing (#1327)Andrew Kutz2022-03-151-2/+79
| | | | | | | This patch addresses an issue where the absence of set-name in a network configuration potentially results in an unintended network configuration. LP: #1855945
* Refactoring helper funcs out of NetworkState (#1336)Andrew Kutz2022-03-151-1/+2
| | | | | | | | | This patch refactors several network, helper functions out of the network_state.py file and into cloudinit.net. This is in relation to LP #1855945 and github.com/canonical/cloud-init/pull/1327. The aforementioned issue requires some refactoring to avoid circular imports, but it was not proper to do that refactoring in *that* pull request. Thus this PR is specific to the refactoring and can be evaluated on its own merits.
* Add native NetworkManager support (#1224)Lubomir Rintel2022-02-251-113/+1121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fedora currently relies on sysconfig/ifcfg renderer. This is not too great, because Fedora (also RHEL since version 8) dropped support for the legacy network service that uses ifcfg files long ago. In turn, Fedora ended up patching cloud-init downstream to utilize NetworkManager's ifcfg compatibility mode [1]. This seems to have worked for a while, nevertheless the NetworkManager's ifcfg backend is reaching the end of its useful life too [2]. [1] https://src.fedoraproject.org/rpms/cloud-init/blob/rawhide/f/cloud-init-21.3-nm-controlled.patch [2] https://fedoraproject.org/wiki/Changes/NoIfcfgFiles Let's not mangle things downstream and make vanilla cloud-init work great on Fedora instead. This also means that the sysconfig compatibility with Network Manager was removed. Firstly, this relies upon the fact that you can get ifcfg support by adding it to NetworkManager.conf. That is not guaranteed and certainly will not be case in future. Secondly, cloud-init always generates configuration with NM_CONTROLLED=no, so the generated ifcfg files are no good for NetworkManager. Fedora patches around this by just removing those lines in their cloud-init package.
* Fix IPv6 netmask format for sysconfig (#1215)Harald2022-02-081-4/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Adopt Black and isort (SC-700) (#1157)James Falcon2021-12-151-1922/+2911
| | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* testing: monkeypatch system_info call in unit tests (SC-533) (#1117)James Falcon2021-11-221-13/+12
| | | | | | | | | | | | | | testing: monkeypatch system_info call in unit tests system_info can make calls that read or write from the filesystem, which should require special mocking. It is also decorated with 'lru_cache', which means test authors often don't realize they need to be mocking. Also, we don't actually want the results from the user's local machine, so monkeypatching it across all tests should be reasonable. Additionally, moved some of 'system_info` into a helper function to reduce the surface area of the monkeypatch, added tests for the new function (and fixed a bug as a result), and removed related mocks that should be no longer needed.
* Add support to accept-ra in networkd renderer (#999)Shreenidhi Shedi2021-08-301-0/+74
| | | Also fix search path in networkd
* Add support for EuroLinux 7 && EuroLinux 8 (#957)Aleksander Baranowski2021-08-051-0/+1
|
* Add new network activators to bring up interfaces (#919)James Falcon2021-07-011-1/+1
| | | | | | | | | | | | 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.
* Removed distro specific network code from Photon (#929)sshedi2021-06-281-0/+4
| | | | | | | | 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>
* Add support for VMware PhotonOS (#909)sshedi2021-06-181-9/+235
| | | | | 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.
* sysconfig: use BONDING_MODULE_OPTS on SUSE (#831)Jens Sandmann2021-04-091-2/+2
| | | | | | 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.
* Fix mis-detecting network configuration in initramfs cmdline (#844)James Falcon2021-03-291-0/+50
| | | | | | | | 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
* net: exclude OVS internal interfaces in get_interfaces (#829)Daniel Watkins2021-03-081-0/+20
| | | | | | | | | | | | | | | | | | | `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
* net: Fix static routes to host in eni renderer (#668)Pavel Abalikhin2021-01-131-0/+7
| | | | Route '-net' parameter is incompatible with /32 IPv4 addresses so we have to use '-host' in that case.
* Missing IPV6_AUTOCONF=no to render sysconfig dhcp6 stateful on RHEL (#753)Eduardo Otubo2021-01-071-0/+1
| | | | | | | | 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>
* Adding BOOTPROTO = dhcp to render sysconfig dhcp6 stateful on RHEL (#685)Eduardo Otubo2020-12-011-1/+1
| | | | | | | | | | | 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>
* Make wakeonlan Network Config v2 setting actually work (#626)dermotbradley2020-11-091-0/+143
| | | | | | | 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.
* Explicit set IPV6_AUTOCONF and IPV6_FORCE_ACCEPT_RA on static6 (#634)Eduardo Otubo2020-10-291-0/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Update network config docs to clarify MAC address quoting (#623)dermotbradley2020-10-271-20/+20
| | | | Also update MAC addresses used in testcases to remove quotes where not required and add single quotes where quotes are required.
* network: Fix type and respect name when rendering vlan in sysconfig. (#541)Eduardo Otubo2020-09-151-4/+0
| | | | | | | | | | | | | | | 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
* Fixes KeyError for bridge with no "parameters:" setting (#423)Brian Candler2020-06-091-0/+10
| | | | | Reason: commit ded1ec8 introduced a regression whereby a bridge with no "parameters:" setting caused a KeyError exception. LP: #1879673
* Move subp into its own module. (#416)Scott Moser2020-06-081-16/+17
| | | | | | | | | | | | | | | | | 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.
* test: fix all flake8 E121 and E123 errors (#404)Joshua Powers2020-06-021-9/+9
| | | | This fixes issues with closing brackets not matching the opening bracket's line and continuation line under-idented for hanging indent.
* test: fix all flake8 E241 (#403)Joshua Powers2020-06-021-2/+2
| | | Remove extra spaces after a ','
* net: ubuntu focal prioritize netplan over eni even if both present (#267)Chad Smith2020-03-301-40/+46
| | | | | | | | | | | | On Focal and later, Ubuntu will prioritize netplan renderer over eni, even if ifupdown and netplan are both installed. ENI on Focal and later is considered an unsupported configuration so cloud-init should generally prefer netplan. On many cloud images, the /etc/network/interfaces config file does not include the dir /etc/network/interfaces.d thereby ignoring cloud-init's /etc/network/interfaces.d/50-cloud-init.cfg file. LP: #1867029
* net: support network-config:disabled on the kernel commandline (#232)Chad Smith2020-03-041-0/+17
| | | | | | | | | | | | | | | | | | Allow disabling cloud-init's network configuration via a plain-text kernel cmdline Cloud-init docs indicate that users can disable cloud-init networking via kernel command line parameter 'network-config=<YAML>'. This does not work unless the <YAML> payload base64 encoded. Document the base64 encoding requirement and add a plain-text value for disabling cloud-init network config: network-config=disabled Also: - Log an error and ignore any plain-text network-config payloads that are not specifically 'network-config=disabled'. - Log a warning if network-config kernel param is invalid yaml but do not raise an exception, allowing boot to continue and use fallback networking. LP: #1862702
* sysconfig: distro-specific config rendering for BOOTPROTO option (#162)Robert Schweikert2020-02-031-237/+359
| | | | | | | | | | | | | | | - 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
* net/cmdline: correctly handle static ip= config (#201)Dimitri John Ledkov2020-01-301-1/+1
| | | | | | | It is proto 'none', not 'static' as was mistakenly implemented in initramfs-tools/cloud-init in the past, yet was never the case in the klibc ipconfig state file output. LP: #1861412
* FreeBSD: fix for get_linux_distro() and lru_cache (#59)Igor Galić2019-11-251-6/+13
| | | | | | | | | | | | | | | | | Since `is_FreeBSD()` is used a lot, which uses `system_info()`, which uses `get_linux_distro()` we add caching, by decorating the following functions with `@lru_cache`: - get_architecture() - _lsb_release() - is_FreeBSD - get_linux_distro - system_info() - _get_cmdline() Since [functools](https://docs.python.org/3/library/functools.html) only exists in Python 3, only python 3 will benefit from this improvement. For python 2, our shim is just a pass-thru. Too bad, but, also… https://pythonclock.org/ The main motivation here was, at first, to cache more, following the style of _lsb_release. That is now consolidated under this very same roof. LP: #1815030
* net: IPv6, accept_ra, slaac, stateless (#51)Harald2019-11-201-3/+235
| | | | | | | | | | | | | | | | | | | | | 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
* azure: support matching dhcp route-metrics for dual-stack ipv4 ipv6Chad Smith2019-11-041-0/+54
| | | | | | | | | | | | | | | 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
* net: fix subnet_is_ipv6() for stateless|statefulHarald Jensås2019-10-311-0/+16
| | | | | | | | | | | Function return false for ipv6_dhcpv6-stateless|stateful, the eni renderer does not add '6' to 'inet' which is incorrect. The subnet_is_ipv6() function is updated to also return true if startswith('ipv6'). LP: #1848690