From d525d7cf5f4e34ec5f4545e93ee3280ddbd331f6 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Fri, 8 Jun 2018 00:46:34 +0100 Subject: [PATCH] os_server: Remove nova_client usage (#40765) The os_server module uses the deprecated nova_client function, and therefore ends up requiring python-novaclient installed. In this patch we switch the ip detachment to make use of a shade function, removing the need for python-novaclient. (cherry picked from commit 055d89cd32385fa891e17a24aadc2c68397f307d) --- lib/ansible/modules/cloud/openstack/os_server.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_server.py b/lib/ansible/modules/cloud/openstack/os_server.py index e939433c321..f605445085f 100644 --- a/lib/ansible/modules/cloud/openstack/os_server.py +++ b/lib/ansible/modules/cloud/openstack/os_server.py @@ -562,10 +562,12 @@ def _update_server(module, cloud, server): return (changed, server) -def _delete_floating_ip_list(cloud, server, extra_ips): +def _detach_ip_list(cloud, server, extra_ips): for ip in extra_ips: - cloud.nova_client.servers.remove_floating_ip( - server=server.id, address=ip) + ip_id = cloud.get_floating_ip( + id=None, filters={'floating_ip_address': ip}) + cloud.detach_ip_from_server( + server_id=server.id, floating_ip_id=ip_id) def _check_ips(module, cloud, server): @@ -606,7 +608,7 @@ def _check_ips(module, cloud, server): if ip not in floating_ips: extra_ips.append(ip) if extra_ips: - _delete_floating_ip_list(cloud, server, extra_ips) + _detach_ip_list(cloud, server, extra_ips) changed = True elif auto_ip: if server['interface_ip']: