path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/ubuntu.py # Override def get_dhcp_pid(self): return self._get_dhcp_pid(["pidof", "dhclient3"]) path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/ubuntu.py def get_dhcp_pid(self): return self._get_dhcp_pid(["pidof", "systemd-networkd"]) def start_network(self): path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/default.py def get_dhcp_pid(self): return self._get_dhcp_pid(["pidof", "dhclient"]) def set_hostname(self, hostname): path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/bigip.py def get_dhcp_pid(self): return self._get_dhcp_pid(["/sbin/pidof", "dhclient"]) def set_hostname(self, hostname): path: waagent_2.12.0.2-4/tests/ga/test_env.py assert_warnings(1) with patch("azurelinuxagent.common.osutil.default.shellutil.run_command", side_effect=lambda _: self.shellutil_run_command(["pidof", "non-existing-process"])): # it should log the new error pids = monitor_dhcp_client_restart._get_dhcp_client_pid() path: waagent_2.12.0.2-4/tests/ga/test_env.py def test_get_dhcp_client_pid_should_return_an_empty_list_and_log_a_warning_when_dhcp_client_is_not_running(self): with patch("azurelinuxagent.common.osutil.default.shellutil.run_command", side_effect=lambda _: self.shellutil_run_command(["pidof", "non-existing-process"])): with patch('azurelinuxagent.common.logger.Logger.warn') as mock_warn: pids = MonitorDhcpClientRestart(get_osutil())._get_dhcp_client_pid() path: waagent_2.12.0.2-4/tests/ga/test_env.py self.assertEqual("Dhcp client is not running.", args[0]) with patch("azurelinuxagent.common.osutil.default.shellutil.run_command", side_effect=lambda _: self.shellutil_run_command(["pidof", "non-existing-process"])): # it should log the first error pids = monitor_dhcp_client_restart._get_dhcp_client_pid() path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/openwrt.py def get_dhcp_pid(self): return self._get_dhcp_pid(["pidof", self.dhclient_name]) def get_nic_state(self, as_string=False): path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/alpine.py def get_dhcp_pid(self): return self._get_dhcp_pid(["pidof", "dhcpcd"]) def restart_if(self, ifname, retries=None, wait=None): path: waagent_2.12.0.2-4/tests/common/osutil/test_default.py def mock_run_command(cmd): # pylint: disable=unused-argument return original_run_command(["pidof", "non-existing-process"]) with patch("azurelinuxagent.common.utils.shellutil.run_command", side_effect=mock_run_command): path: waagent_2.12.0.2-4/tests/common/osutil/test_default.py in case there are any basic errors, such as a typos, etc. The test does not verify that the implementation returns the PID for the actual dhcp client; in fact, it uses a mock that invokes pidof to return the PID of an arbitrary process (the pidof process itself). Most implementations of get_dhcp_pid use pidof with the appropriate name for the dhcp client. The test is defined as a global function to make it easily accessible from the test suites for each distro. path: waagent_2.12.0.2-4/tests/common/osutil/test_default.py def mock_run_command(cmd): # pylint: disable=unused-argument return original_run_command(["pidof", "pidof"]) with patch("azurelinuxagent.common.utils.shellutil.run_command", side_effect=mock_run_command): path: waagent_2.12.0.2-4/tests/common/osutil/test_default.py This is a very basic test for osutil.get_dhcp_pid. It is simply meant to exercise the implementation of that method in case there are any basic errors, such as a typos, etc. The test does not verify that the implementation returns the PID for the actual dhcp client; in fact, it uses a mock that invokes pidof to return the PID of an arbitrary process (the pidof process itself). Most implementations of get_dhcp_pid use pidof with the appropriate name for the dhcp client. path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/fedora.py def get_dhcp_pid(self): return self._get_dhcp_pid(["pidof", "dhclient"]) def conf_sshd(self, disable_password): path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/clearlinux.py def get_dhcp_pid(self): return self._get_dhcp_pid(["pidof", "systemd-networkd"]) def conf_sshd(self, disable_password): path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/photonos.py def get_dhcp_pid(self): return self._get_dhcp_pid(['pidof', 'systemd-networkd']) def conf_sshd(self, disable_password): path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/redhat.py # Override def get_dhcp_pid(self): return self._get_dhcp_pid(["pidof", "dhclient"]) def set_hostname(self, hostname): path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/arch.py def get_dhcp_pid(self): return self._get_dhcp_pid(["pidof", "systemd-networkd"]) def conf_sshd(self, disable_password): path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/suse.py def get_dhcp_pid(self): return self._get_dhcp_pid(["pidof", self.dhclient_name]) def is_dhcp_enabled(self): path: waagent_2.12.0.2-4/azurelinuxagent/common/osutil/mariner.py def get_dhcp_pid(self): return self._get_dhcp_pid(["pidof", "systemd-networkd"]) def conf_sshd(self, disable_password):