{"language": "Python", "id": 14, "repo_owner": "canonical", "repo_name": "cloud-init", "head_branch": "holman/dhcpcd", "workflow_name": "Lint Tests", "workflow_filename": "check_format.yml", "workflow_path": ".github/workflows/check_format.yml", "contributor": "holmanb", "sha_fail": "4d5898b8a73c93e1ed4434744c2fa7c3f7fbd501", "sha_success": "2bd296ef8983a716a7b8d107571181333f093109", "workflow": "name: Lint Tests\non:\n pull_request:\n push:\n branches:\n - main\n\nconcurrency:\n group: 'ci-${{ github.workflow }}-${{ github.ref }}'\n cancel-in-progress: true\ndefaults:\n run:\n shell: sh -ex {0}\n\njobs:\n check_format:\n strategy:\n fail-fast: false\n matrix:\n env: [ruff, mypy, pylint, black, isort]\n lint-with:\n - {tip-versions: false, os: ubuntu-20.04}\n - {tip-versions: true, os: ubuntu-latest}\n name: Check ${{ matrix.lint-with.tip-versions && 'tip-' || '' }}${{ matrix.env }}\n runs-on: ${{ matrix.lint-with.os }}\n steps:\n - name: \"Checkout #1\"\n uses: actions/checkout@v3.0.0\n\n - name: \"Checkout #2 (for tools/read-version)\"\n run: |\n git fetch --unshallow\n git remote add upstream https://git.launchpad.net/cloud-init\n\n - name: Dependencies\n run: |\n sudo DEBIAN_FRONTEND=noninteractive apt-get -qy update\n sudo DEBIAN_FRONTEND=noninteractive apt-get -qy install tox\n\n - name: Print version\n run: python3 --version\n\n - name: Test\n if: ${{ !matrix.lint-with.tip-versions }}\n env:\n # matrix env: not to be confused w/environment variables or testenv\n TOXENV: ${{ matrix.env }}\n run: tox\n - name: Test (tip versions)\n if: matrix.lint-with.tip-versions\n continue-on-error: true\n env:\n TOXENV: tip-${{ matrix.env }}\n run: tox\n schema-format:\n strategy:\n fail-fast: false\n name: Check json format\n runs-on: ubuntu-22.04\n steps:\n - name: \"Checkout #1\"\n uses: actions/checkout@v3.0.0\n\n - name: \"Test format\"\n run: |\n tools/check_json_format.sh cloudinit/config/schemas/schema-cloud-config-v1.json\n tools/check_json_format.sh cloudinit/config/schemas/schema-network-config-v1.json\n tools/check_json_format.sh cloudinit/config/schemas/versions.schema.cloud-config.json\n\n doc:\n strategy:\n fail-fast: false\n name: Check docs\n runs-on: ubuntu-22.04\n steps:\n - name: \"Checkout #1\"\n uses: actions/checkout@v3.0.0\n\n - name: \"Checkout #2 (for tools/read-version)\"\n run: |\n git fetch --unshallow\n git remote add upstream https://git.launchpad.net/cloud-init\n - name: \"Install Python 3.10\"\n uses: actions/setup-python@v4\n with:\n python-version: '3.10.8'\n - name: \"Install dependencies\"\n run: |\n sudo DEBIAN_FRONTEND=noninteractive apt-get -qy update\n sudo DEBIAN_FRONTEND=noninteractive apt-get -qy install tox\n - name: \"Spellcheck\"\n run: |\n tox\n env:\n TOXENV: doc-spelling\n - name: \"Build docs\"\n env:\n TOXENV: doc\n run: |\n tox\n\n shell-lint:\n name: Shell Lint\n runs-on: ubuntu-22.04\n steps:\n - name: Checkout\n uses: actions/checkout@v3.0.0\n\n - name: Install ShellCheck\n run: |\n sudo apt-get update\n sudo apt install shellcheck\n\n - name: Run ShellCheck\n run: |\n shellcheck ./tools/ds-identify\n\n check-cla-signers:\n runs-on: ubuntu-22.04\n steps:\n - uses: actions/checkout@v3.0.0\n\n - name: Check CLA signers file\n run: tools/check-cla-signers\n", "logs": [{"step_name": "Check pylint/6_Test.txt", "log": "##[group]Run tox\n\u001b[36;1mtox\u001b[0m\nshell: /usr/bin/sh -ex {0}\nenv:\n TOXENV: pylint\n##[endgroup]\n+ tox\nGLOB sdist-make: /home/runner/work/cloud-init/cloud-init/setup.py\npylint create: /home/runner/work/cloud-init/cloud-init/.tox/pylint\npylint installdeps: pylint===2.13.9, -r/home/runner/work/cloud-init/cloud-init/test-requirements.txt, -r/home/runner/work/cloud-init/cloud-init/integration-requirements.txt\npylint inst: /home/runner/work/cloud-init/cloud-init/.tox/.tmp/package/1/cloud-init-23.4+88.g0e8fe220.zip\npylint installed: adal==1.2.7,anyio==4.2.0,appdirs==1.4.4,applicationinsights==0.11.10,argcomplete==3.1.6,astroid==2.11.7,attrs==23.2.0,autopage==0.5.2,azure-cli-core==2.56.0,azure-cli-telemetry==1.1.0,azure-common==1.1.28,azure-core==1.29.6,azure-identity==1.15.0,azure-mgmt-compute==30.4.0,azure-mgmt-core==1.4.0,azure-mgmt-network==25.2.0,azure-mgmt-resource==23.0.1,bcrypt==4.1.2,boto3==1.34.17,botocore==1.34.17,cachetools==5.3.2,certifi==2023.11.17,cffi==1.16.0,charset-normalizer==3.3.2,circuitbreaker==1.4.0,cliff==4.5.0,cloud-init==23.4+88.g0e8fe220,cmd2==2.4.3,configobj==5.0.8,coverage==7.4.0,cryptography==41.0.7,debtcollector==2.5.0,decorator==5.1.1,dill==0.3.7,distro==1.9.0,dogpile.cache==1.3.0,exceptiongroup==1.2.0,google-api-core==2.15.0,google-api-python-client==2.113.0,google-auth==2.26.2,google-auth-httplib2==0.2.0,googleapis-common-protos==1.62.0,httplib2==0.22.0,humanfriendly==10.0,ibm-cloud-sdk-core==3.18.2,ibm-platform-services==0.49.0,ibm-vpc==0.20.0,idna==3.6,importlib-metadata==7.0.1,importlib-resources==6.1.1,iniconfig==2.0.0,iso8601==2.1.0,isodate==0.6.1,isort==5.13.2,Jinja2==3.1.3,jmespath==1.0.1,jsonpatch==1.33,jsonpointer==2.4,jsonschema==4.20.0,jsonschema-specifications==2023.12.1,keystoneauth1==5.5.0,knack==0.11.0,lazy-object-proxy==1.10.0,MarkupSafe==2.1.3,mccabe==0.7.0,msal==1.24.0b2,msal-extensions==1.0.0,msgpack==1.0.7,msrest==0.7.1,msrestazure==0.6.4,netaddr==0.10.1,netifaces==0.11.0,oauthlib==3.2.2,oci==2.118.2,openstacksdk==1.4.0,os-service-types==1.7.0,osc-lib==3.0.0,oslo.config==9.3.0,oslo.i18n==6.2.0,oslo.serialization==5.3.0,oslo.utils==6.3.0,packaging==23.2,paramiko==3.4.0,passlib==1.7.4,pbr==6.0.0,pkginfo==1.9.6,pkgutil-resolve-name==1.3.10,platformdirs==4.1.0,pluggy==1.3.0,portalocker==2.8.2,prettytable==3.9.0,protobuf==3.19.6,psutil==5.9.7,pyasn1==0.5.1,pyasn1-modules==0.3.0,pycloudlib==1!5.12.1,pycparser==2.21,pygments==2.17.2,PyJWT==2.8.0,pylint==2.13.9,PyNaCl==1.5.0,pyOpenSSL==23.3.0,pyparsing==2.4.7,pyperclip==1.8.2,pyserial==3.5,pytest==7.4.4,pytest-cov==4.1.0,pytest-mock==3.12.0,python-cinderclient==9.4.0,python-dateutil==2.8.2,python-keystoneclient==5.3.0,python-novaclient==18.4.0,python-openstackclient==6.4.0,pytz==2023.3.post1,PyYAML==6.0.1,qemu.qmp==0.0.3,referencing==0.32.1,requests==2.31.0,requests-oauthlib==1.3.1,requestsexceptions==1.4.0,responses==0.24.1,rfc3986==2.0.0,rpds-py==0.17.1,rsa==4.9,s3transfer==0.10.0,simplejson==3.19.2,six==1.16.0,sniffio==1.3.0,stevedore==5.1.0,tabulate==0.9.0,toml==0.10.0,tomli==2.0.1,typing-extensions==4.9.0,tzdata==2023.4,uritemplate==4.1.1,urllib3==2.1.0,wcwidth==0.2.13,wrapt==1.16.0,zipp==3.17.0\npylint run-test-pre: PYTHONHASHSEED='1345909868'\npylint run-test: commands[0] | /home/runner/work/cloud-init/cloud-init/.tox/pylint/bin/python -m pylint cloudinit/ tests/ tools/ conftest.py setup.py\n************* Module cloudinit.net.dhcp\ncloudinit/net/dhcp.py:538: [W0235(useless-super-delegation), Dhcpcd.__init__] Useless super delegation in method '__init__'\n\n------------------------------------\nYour code has been rated at 10.00/10\n\nERROR: InvocationError for command /home/runner/work/cloud-init/cloud-init/.tox/pylint/bin/python -m pylint cloudinit/ tests/ tools/ conftest.py setup.py (exited with code 4)\n___________________________________ summary ____________________________________\nERROR: pylint: commands failed\n##[error]Process completed with exit code 1.\n"}], "diff": "diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py\nindex 5c891f26e..c02166ad2 100644\n--- a/cloudinit/distros/__init__.py\n+++ b/cloudinit/distros/__init__.py\n@@ -170,6 +170,7 @@ class Distro(persistence.CloudInitPickleMixin, metaclass=abc.ABCMeta):\n self._runner = helpers.Runners(paths)\n self.package_managers: List[PackageManager] = []\n self._dhcp_client = None\n+ self._fallback_interface = None\n \n def _unpickle(self, ci_pkl_version: int) -> None:\n \"\"\"Perform deserialization fixes for Distro.\"\"\"\n@@ -1274,6 +1275,13 @@ class Distro(persistence.CloudInitPickleMixin, metaclass=abc.ABCMeta):\n \"/bin/true\",\n ] + ([\"-cf\", config_file, interface] if config_file else [interface])\n \n+ @property\n+ def fallback_interface(self):\n+ \"\"\"Determine the network interface used during local network config.\"\"\"\n+ if self._fallback_interface is None:\n+ self._fallback_interface = net.find_fallback_nic()\n+ return self._fallback_interface\n+\n \n def _apply_hostname_transformations_to_url(url: str, transformations: list):\n \"\"\"\ndiff --git a/cloudinit/net/dhcp.py b/cloudinit/net/dhcp.py\nindex 9c94b3f92..7b2d41df1 100644\n--- a/cloudinit/net/dhcp.py\n+++ b/cloudinit/net/dhcp.py\n@@ -19,8 +19,6 @@ import configobj\n \n from cloudinit import subp, temp_utils, util\n from cloudinit.net import (\n- find_fallback_nic,\n- get_devicelist,\n get_ib_interface_hwaddr,\n get_interface_mac,\n is_ib_interface,\n@@ -98,17 +96,8 @@ def maybe_perform_dhcp_discovery(distro, nic=None, dhcp_log_func=None):\n from the dhclient discovery if run, otherwise an empty list is\n returned.\n \"\"\"\n- if nic is None:\n- nic = find_fallback_nic()\n- if nic is None:\n- LOG.debug(\"Skip dhcp_discovery: Unable to find fallback nic.\")\n- raise NoDHCPLeaseInterfaceError()\n- elif nic not in get_devicelist():\n- LOG.debug(\n- \"Skip dhcp_discovery: nic %s not found in get_devicelist.\", nic\n- )\n- raise NoDHCPLeaseInterfaceError()\n- return distro.dhcp_client.dhcp_discovery(nic, dhcp_log_func, distro)\n+ interface = nic or distro.fallback_interface\n+ return distro.dhcp_client.dhcp_discovery(interface, dhcp_log_func, distro)\n \n \n def networkd_parse_lease(content):\n@@ -185,7 +174,7 @@ class DhcpClient(abc.ABC):\n def parse_static_routes(routes: str) -> List[Tuple[str, str]]:\n return []\n \n- def get_newest_lease(self, distro) -> Dict[str, Any]:\n+ def get_newest_lease(self, interface: str) -> Dict[str, Any]:\n return {}\n \n \n@@ -218,15 +207,15 @@ class IscDhclient(DhcpClient):\n dhcp_leases.append(dict(lease_options))\n return dhcp_leases\n \n- def get_newest_lease(self, distro) -> Dict[str, Any]:\n+ def get_newest_lease(self, interface: str) -> Dict[str, Any]:\n \"\"\"Get the most recent lease from the ephemeral phase as a dict.\n \n Return a dict of dhcp options. The dict contains key value\n pairs from the most recent lease.\n \n- @param distro: a distro object - not used in this class, but required\n- for function signature compatibility with other classes\n- that require a distro object\n+ @param interface: an interface string - not used in this class, but\n+ required for function signature compatibility with other classes\n+ that require a distro object\n @raises: InvalidDHCPLeaseFileError on empty or unparseable leasefile\n content.\n \"\"\"\n@@ -355,7 +344,7 @@ class IscDhclient(DhcpClient):\n )\n if dhcp_log_func is not None:\n dhcp_log_func(out, err)\n- lease = self.get_newest_lease(distro)\n+ lease = self.get_newest_lease(interface)\n if lease:\n return lease\n raise InvalidDHCPLeaseFileError()\n@@ -535,9 +524,6 @@ class IscDhclient(DhcpClient):\n class Dhcpcd(DhcpClient):\n client_name = \"dhcpcd\"\n \n- def __init__(self):\n- super().__init__()\n-\n def dhcp_discovery(\n self,\n interface: str,\n@@ -547,12 +533,12 @@ class Dhcpcd(DhcpClient):\n \"\"\"Run dhcpcd on the interface without scripts/filesystem artifacts.\n \n @param interface: Name of the network interface on which to send a\n- dhcp request\n+ dhcp request\n @param dhcp_log_func: A callable accepting the client output and\n- error streams.\n+ error streams.\n @param distro: a distro object for network interface manipulation\n @return: dict of lease options representing the most recent dhcp lease\n- parsed from the dhclient.lease file\n+ parsed from the dhclient.lease file\n \"\"\"\n LOG.debug(\"Performing a dhcp discovery on %s\", interface)\n \n@@ -580,7 +566,7 @@ class Dhcpcd(DhcpClient):\n )\n if dhcp_log_func is not None:\n dhcp_log_func(out, err)\n- lease = self.get_newest_lease(distro)\n+ lease = self.get_newest_lease(interface)\n if lease:\n return lease\n raise NoDHCPLeaseError(\"No lease found\")\n@@ -644,12 +630,10 @@ class Dhcpcd(DhcpClient):\n # for compatibility we still expect a list of leases\n return lease\n \n- def get_newest_lease(self, distro) -> Dict[str, Any]:\n- \"\"\"Return a lease\n-\n- Return a list of dicts of dhcp options. Each dict contains key value\n- pairs a specific lease in order from oldest to newest.\n+ def get_newest_lease(self, interface: str) -> Dict[str, Any]:\n+ \"\"\"Return a dict of dhcp options.\n \n+ @param interface: which interface to dump the lease from\n @raises: InvalidDHCPLeaseFileError on empty or unparseable leasefile\n content.\n \"\"\"\n@@ -659,11 +643,11 @@ class Dhcpcd(DhcpClient):\n [\n \"dhcpcd\",\n \"--dumplease\",\n- distro.fallback_interface,\n+ interface,\n ],\n rcs=[0, 1],\n ).stdout,\n- distro.fallback_interface,\n+ interface,\n )\n \n except subp.ProcessExecutionError as error:\n@@ -781,17 +765,17 @@ class Udhcpc(DhcpClient):\n if dhcp_log_func is not None:\n dhcp_log_func(out, err)\n \n- return self.get_newest_lease(distro)\n+ return self.get_newest_lease(interface)\n \n- def get_newest_lease(self, distro) -> Dict[str, Any]:\n+ def get_newest_lease(self, interface: str) -> Dict[str, Any]:\n \"\"\"Get the most recent lease from the ephemeral phase as a dict.\n \n Return a dict of dhcp options. The dict contains key value\n pairs from the most recent lease.\n \n- @param distro: a distro object - not used in this class, but required\n- for function signature compatibility with other classes\n- that require a distro object\n+ @param interface: an interface name - not used in this class, but\n+ required for function signature compatibility with other classes\n+ that require a distro object\n @raises: InvalidDHCPLeaseFileError on empty or unparseable leasefile\n content.\n \"\"\"\ndiff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py\nindex c207b5ed6..f9650268a 100644\n--- a/cloudinit/sources/__init__.py\n+++ b/cloudinit/sources/__init__.py\n@@ -610,13 +610,11 @@ class DataSource(CloudInitPickleMixin, metaclass=abc.ABCMeta):\n @property\n def fallback_interface(self):\n \"\"\"Determine the network interface used during local network config.\"\"\"\n- if self._fallback_interface is None:\n- self._fallback_interface = net.find_fallback_nic()\n- if self._fallback_interface is None:\n- LOG.warning(\n- \"Did not find a fallback interface on %s.\", self.cloud_name\n- )\n- return self._fallback_interface\n+ if self.distro.fallback_interface is None:\n+ LOG.warning(\n+ \"Did not find a fallback interface on %s.\", self.cloud_name\n+ )\n+ return self.distro.fallback_interface\n \n @property\n def platform_type(self):\ndiff --git a/tests/unittests/net/test_dhcp.py b/tests/unittests/net/test_dhcp.py\nindex ffa3eab17..9af5f93aa 100644\n--- a/tests/unittests/net/test_dhcp.py\n+++ b/tests/unittests/net/test_dhcp.py\n@@ -372,20 +372,7 @@ class TestDHCPDiscoveryClean(CiTestCase):\n with_logs = True\n ib_address_prefix = \"00:00:00:00:00:00:00:00:00:00:00:00\"\n \n- @mock.patch(\"cloudinit.net.dhcp.find_fallback_nic\")\n- def test_no_fallback_nic_found(self, m_fallback_nic):\n- \"\"\"Log and do nothing when nic is absent and no fallback is found.\"\"\"\n- m_fallback_nic.return_value = None # No fallback nic found\n-\n- with pytest.raises(NoDHCPLeaseInterfaceError):\n- maybe_perform_dhcp_discovery(MockDistro())\n-\n- self.assertIn(\n- \"Skip dhcp_discovery: Unable to find fallback nic.\",\n- self.logs.getvalue(),\n- )\n-\n- @mock.patch(\"cloudinit.net.dhcp.find_fallback_nic\", return_value=\"eth9\")\n+ @mock.patch(\"cloudinit.distros.net.find_fallback_nic\", return_value=\"eth9\")\n @mock.patch(\"cloudinit.net.dhcp.os.remove\")\n @mock.patch(\"cloudinit.net.dhcp.subp.subp\")\n @mock.patch(\"cloudinit.net.dhcp.subp.which\")\n@@ -406,7 +393,7 @@ class TestDHCPDiscoveryClean(CiTestCase):\n self.logs.getvalue(),\n )\n \n- @mock.patch(\"cloudinit.net.dhcp.find_fallback_nic\", return_value=\"eth9\")\n+ @mock.patch(\"cloudinit.distros.net.find_fallback_nic\", return_value=\"eth9\")\n @mock.patch(\"cloudinit.net.dhcp.os.remove\")\n @mock.patch(\"cloudinit.net.dhcp.subp.subp\")\n @mock.patch(\"cloudinit.net.dhcp.subp.which\")\n@@ -435,17 +422,6 @@ class TestDHCPDiscoveryClean(CiTestCase):\n self.logs.getvalue(),\n )\n \n- @mock.patch(\"cloudinit.net.dhcp.find_fallback_nic\", return_value=None)\n- def test_provided_nic_does_not_exist(self, m_fallback_nic):\n- \"\"\"When the provided nic doesn't exist, log a message and no-op.\"\"\"\n- with pytest.raises(NoDHCPLeaseInterfaceError):\n- maybe_perform_dhcp_discovery(MockDistro(), \"idontexist\")\n-\n- self.assertIn(\n- \"Skip dhcp_discovery: nic idontexist not found in get_devicelist.\",\n- self.logs.getvalue(),\n- )\n-\n @mock.patch(\"cloudinit.net.dhcp.subp.which\")\n @mock.patch(\"cloudinit.net.dhcp.find_fallback_nic\")\n def test_absent_dhclient_command(self, m_fallback, m_which):\ndiff --git a/tests/unittests/sources/test_cloudstack.py b/tests/unittests/sources/test_cloudstack.py\nindex 8ee04b3e1..b33c5e492 100644\n--- a/tests/unittests/sources/test_cloudstack.py\n+++ b/tests/unittests/sources/test_cloudstack.py\n@@ -244,6 +244,13 @@ class TestCloudStackHostname(CiTestCase):\n )\n )\n \n+ self.patches.enter_context(\n+ mock.patch(\n+ \"cloudinit.distros.net.find_fallback_nic\",\n+ return_value=\"eth0\",\n+ )\n+ )\n+\n self.patches.enter_context(\n mock.patch(\n MOD_PATH\n@@ -304,7 +311,7 @@ class TestCloudStackHostname(CiTestCase):\n )\n \n ds = DataSourceCloudStack(\n- {}, MockDistro(), helpers.Paths({\"run_dir\": self.tmp})\n+ {}, ubuntu.Distro(\"\", {}, {}), helpers.Paths({\"run_dir\": self.tmp})\n )\n ds._fallback_interface = \"eth0\"\n with mock.patch(MOD_PATH + \".util.load_file\"):\ndiff --git a/tests/unittests/sources/test_ec2.py b/tests/unittests/sources/test_ec2.py\nindex 5f60ad737..32fed89da 100644\n--- a/tests/unittests/sources/test_ec2.py\n+++ b/tests/unittests/sources/test_ec2.py\n@@ -10,6 +10,7 @@ import requests\n import responses\n \n from cloudinit import helpers\n+from cloudinit.distros import ubuntu\n from cloudinit.sources import DataSourceEc2 as ec2\n from tests.unittests import helpers as test_helpers\n \n@@ -342,9 +343,11 @@ class TestEc2(test_helpers.ResponsesTestCase):\n p.start()\n self.addCleanup(p.stop)\n \n- def _setup_ds(self, sys_cfg, platform_data, md, md_version=None):\n+ def _setup_ds(\n+ self, sys_cfg, platform_data, md, md_version=None, distro=None\n+ ):\n self.uris = []\n- distro = mock.MagicMock()\n+ distro = distro or mock.MagicMock()\n distro.get_tmp_exec_path = self.tmp_dir\n paths = helpers.Paths({\"run_dir\": self.tmp})\n if sys_cfg is None:\n@@ -846,7 +849,7 @@ class TestEc2(test_helpers.ResponsesTestCase):\n \n @mock.patch(\"cloudinit.net.ephemeral.EphemeralIPv6Network\")\n @mock.patch(\"cloudinit.net.ephemeral.EphemeralIPv4Network\")\n- @mock.patch(\"cloudinit.net.find_fallback_nic\")\n+ @mock.patch(\"cloudinit.distros.net.find_fallback_nic\")\n @mock.patch(\"cloudinit.net.ephemeral.maybe_perform_dhcp_discovery\")\n @mock.patch(\"cloudinit.sources.DataSourceEc2.util.is_FreeBSD\")\n def test_ec2_local_performs_dhcp_on_non_bsd(\n@@ -873,6 +876,7 @@ class TestEc2(test_helpers.ResponsesTestCase):\n platform_data=self.valid_platform_data,\n sys_cfg={\"datasource\": {\"Ec2\": {\"strict_id\": False}}},\n md={\"md\": DEFAULT_METADATA},\n+ distro=ubuntu.Distro(\"\", {}, {}),\n )\n \n ret = ds.get_data()\ndiff --git a/tests/unittests/sources/test_init.py b/tests/unittests/sources/test_init.py\nindex 44d63b816..b3764945d 100644\n--- a/tests/unittests/sources/test_init.py\n+++ b/tests/unittests/sources/test_init.py\n@@ -6,6 +6,7 @@ import os\n import stat\n \n from cloudinit import importer, util\n+from cloudinit.distros import ubuntu\n from cloudinit.event import EventScope, EventType\n from cloudinit.helpers import Paths\n from cloudinit.sources import (\n@@ -73,7 +74,7 @@ class TestDataSource(CiTestCase):\n def setUp(self):\n super(TestDataSource, self).setUp()\n self.sys_cfg = {\"datasource\": {\"_undef\": {\"key1\": False}}}\n- self.distro = \"distrotest\" # generally should be a Distro object\n+ self.distro = ubuntu.Distro(\"\", {}, {})\n self.paths = Paths({})\n self.datasource = DataSource(self.sys_cfg, self.distro, self.paths)\n \n@@ -201,7 +202,7 @@ class TestDataSource(CiTestCase):\n for log in expected_logs:\n self.assertIn(log, logs)\n \n- @mock.patch(\"cloudinit.sources.net.find_fallback_nic\")\n+ @mock.patch(\"cloudinit.distros.net.find_fallback_nic\")\n def test_fallback_interface_is_discovered(self, m_get_fallback_nic):\n \"\"\"The fallback_interface is discovered via find_fallback_nic.\"\"\"\n m_get_fallback_nic.return_value = \"nic9\"\n@@ -221,7 +222,7 @@ class TestDataSource(CiTestCase):\n @mock.patch(\"cloudinit.sources.net.find_fallback_nic\")\n def test_wb_fallback_interface_is_cached(self, m_get_fallback_nic):\n \"\"\"The fallback_interface is cached and won't be rediscovered.\"\"\"\n- self.datasource._fallback_interface = \"nic10\"\n+ self.datasource.distro._fallback_interface = \"nic10\"\n self.assertEqual(\"nic10\", self.datasource.fallback_interface)\n m_get_fallback_nic.assert_not_called()\n \ndiff --git a/tests/unittests/sources/test_openstack.py b/tests/unittests/sources/test_openstack.py\nindex 127123cff..97cc8c94e 100644\n--- a/tests/unittests/sources/test_openstack.py\n+++ b/tests/unittests/sources/test_openstack.py\n@@ -338,7 +338,7 @@ class TestOpenStackDataSource(test_helpers.ResponsesTestCase):\n ds_os_local = ds.DataSourceOpenStackLocal(\n settings.CFG_BUILTIN, distro, helpers.Paths({\"run_dir\": self.tmp})\n )\n- ds_os_local._fallback_interface = \"eth9\" # Monkey patch for dhcp\n+ distro.fallback_interface = \"eth9\" # Monkey patch for dhcp\n m_dhcp.return_value = {\n \"interface\": \"eth9\",\n \"fixed-address\": \"192.168.2.9\",\n", "difficulty": 1, "changed_files": ["cloudinit/distros/__init__.py", "cloudinit/net/dhcp.py", "cloudinit/sources/__init__.py", "tests/unittests/net/test_dhcp.py", "tests/unittests/sources/test_cloudstack.py", "tests/unittests/sources/test_ec2.py", "tests/unittests/sources/test_init.py", "tests/unittests/sources/test_openstack.py"], "commit_link": "https://github.com/canonical/cloud-init/tree/4d5898b8a73c93e1ed4434744c2fa7c3f7fbd501"}