From 15d63094c696d60dd0b4545d44612e0c627935a4 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Tue, 31 Mar 2020 15:34:30 +0000 Subject: [PATCH] Prevent raising exception if IP address is set in _hotplug_server In "_hotplug_server", when the new interfaces is added to the server, the function tries to configure the Neutron assigned IP address in this new interface. Although the IP addresses are listed before to check that the new port IP is not present, as reported in the bug, sometimes the address is already set when the "ip a add" command is executed. Change-Id: I9594482735b482eb477f342dfd9f265a41eb002d Closes-Bug: #1869899 --- tempest/scenario/test_network_basic_ops.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py index d8584ec88b..f466729b41 100644 --- a/tempest/scenario/test_network_basic_ops.py +++ b/tempest/scenario/test_network_basic_ops.py @@ -297,9 +297,19 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest): ip_mask = CONF.network.project_network_mask_bits # check if the address is not already in use, if not, set it if ' ' + ip_address + '/' + str(ip_mask) not in ip_output: - ssh_client.exec_command("sudo ip addr add %s/%s dev %s" % ( - ip_address, ip_mask, new_nic)) - ssh_client.exec_command("sudo ip link set %s up" % new_nic) + try: + ssh_client.exec_command("sudo ip addr add %s/%s dev %s" % ( + ip_address, ip_mask, new_nic)) + ssh_client.exec_command("sudo ip link set %s up" % new_nic) + except exceptions.SSHExecCommandFailed as exc: + if 'RTNETLINK answers: File exists' in str(exc): + LOG.debug( + 'IP address %(ip_address)s is already set in device ' + '%(device)s\nPrevious "ip a" output: %(ip_output)s', + {'ip_address': ip_address, 'device': new_nic, + 'ip_output': ip_output}) + else: + raise exc def _get_server_nics(self, ssh_client): reg = re.compile(r'(?P\d+): (?P\w+)[@]?.*:')