From b3ac8414427646ee930a91fb58aaae8850db265a Mon Sep 17 00:00:00 2001 From: Jakob Meng Date: Tue, 8 Feb 2022 18:39:21 +0100 Subject: [PATCH] Dropped deprecated return values in floating_ip_info and assert remaining fields Attributes such as location and tenant_id are computed by OpenStack SDK. We do not return these fields in floating_ip_info because e.g. tenant_id has been marked as deprecated and is a copy of the project_id field. Ref.: https://opendev.org/openstack/openstacksdk/commit/70a06d99908c9a56cb28715c62e8ebe6f076a87d Added an assertion to CI which checks that all advertised fields are returned by floating_ip_info. This helps with detecting breaking changes in future updates. Change-Id: I62e4681cd57f82054f68efe1dc59be2cca118135 --- ci/roles/floating_ip_info/tasks/main.yml | 10 ++++++++++ plugins/modules/floating_ip_info.py | 12 ++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ci/roles/floating_ip_info/tasks/main.yml b/ci/roles/floating_ip_info/tasks/main.yml index b37d00ee..916c2cb2 100644 --- a/ci/roles/floating_ip_info/tasks/main.yml +++ b/ci/roles/floating_ip_info/tasks/main.yml @@ -9,3 +9,13 @@ that: - fips is success - fips is not changed + +- name: assert fields + when: fips.floating_ips|length > 0 + assert: + that: + # allow new fields to be introduced but prevent fields from being removed + - '["created_at", "description", "dns_domain", "dns_name", "fixed_ip_address", "floating_ip_address", + "floating_network_id", "id", "name", "port_details", "port_id", "project_id", "qos_policy_id", + "revision_number", "router_id", "status", "subnet_id", "tags", "updated_at"]| + difference(fips.floating_ips.0.keys())|length == 0' diff --git a/plugins/modules/floating_ip_info.py b/plugins/modules/floating_ip_info.py index 966cab00..50e7c879 100644 --- a/plugins/modules/floating_ip_info.py +++ b/plugins/modules/floating_ip_info.py @@ -165,7 +165,6 @@ class FloatingIPInfoModule(OpenStackModule): router = self.params['router'] status = self.params['status'] - data = [] query = {} if description: query['description'] = description @@ -194,15 +193,8 @@ class FloatingIPInfoModule(OpenStackModule): if status: query['status'] = status.upper() - for raw in self.conn.network.ips(**query): - dt = raw.to_dict() - dt.pop('location') - data.append(dt) - - self.exit_json( - changed=False, - floating_ips=data - ) + ips = [ip.to_dict(computed=False) for ip in self.conn.network.ips(**query)] + self.exit_json(changed=False, floating_ips=ips) def main():