From 49163f91568c51781eebb6189348476db0e538c7 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Fri, 20 Jan 2023 12:20:35 +0100 Subject: [PATCH] Add support for dhcpcd in the renew_lease method In Cirros 0.6.0 and newer there is dhcpcd client used instead of old udhcpc. This patch adds support to that new client in the remote_client's renew_lease method. Related-Bug: #2003063 Change-Id: I5d5648332e1c84221e708c29a904fcaaffdb451e --- tempest/common/utils/linux/remote_client.py | 9 +++++++-- tempest/config.py | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py index 9d9fab70f2..7c551155e9 100644 --- a/tempest/common/utils/linux/remote_client.py +++ b/tempest/common/utils/linux/remote_client.py @@ -145,15 +145,20 @@ class RemoteClient(remote_client.RemoteClient): cmd = "sudo /sbin/dhclient -r && sudo /sbin/dhclient" self.exec_command(cmd) + def _renew_lease_dhcpcd(self, fixed_ip=None): + """Renews DHCP lease via dhcpcd client. """ + cmd = "sudo /sbin/dhcpcd --rebind" + self.exec_command(cmd) + def renew_lease(self, fixed_ip=None, dhcp_client='udhcpc'): """Wrapper method for renewing DHCP lease via given client Supporting: * udhcpc * dhclient + * dhcpcd """ - # TODO(yfried): add support for dhcpcd - supported_clients = ['udhcpc', 'dhclient'] + supported_clients = ['udhcpc', 'dhclient', 'dhcpcd'] if dhcp_client not in supported_clients: raise tempest.lib.exceptions.InvalidConfiguration( '%s DHCP client unsupported' % dhcp_client) diff --git a/tempest/config.py b/tempest/config.py index d91fca44f0..f1eb6470b7 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -1203,10 +1203,10 @@ ScenarioGroup = [ # TODO(yfried): add support for dhcpcd cfg.StrOpt('dhcp_client', default='udhcpc', - choices=["udhcpc", "dhclient", ""], + choices=["udhcpc", "dhclient", "dhcpcd", ""], help='DHCP client used by images to renew DCHP lease. ' 'If left empty, update operation will be skipped. ' - 'Supported clients: "udhcpc", "dhclient"'), + 'Supported clients: "udhcpc", "dhclient", "dhcpcd"'), cfg.StrOpt('protocol', default='icmp', choices=('icmp', 'tcp', 'udp'),