From 761d558e17cfd07c17f8457d5b4d66aea0ddc09a Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Thu, 18 Apr 2024 12:27:37 +0200 Subject: [PATCH] Allow filtering BGPVPNs BGPVPNs can be filtered server-side when being listed. The most interesting filters here are for routers, networks and ports, as these allow to filter for a specific association the BGPVPN has, but the other filter options might come in handy as well. route|import|export-target support only exact matches in the BGPVPN API, meaning all entries need to be given in the right order as a comma separated string. As this is quiet counter-intuitive for a user (that might expect they could provide only one or unsorted entries) these attributes have been left out. Change-Id: I355b6584e115cf70a7fd040a24d30f9686555b85 --- openstack/network/v2/bgpvpn.py | 13 +++++++++++++ openstack/tests/unit/network/v2/test_bgpvpn.py | 8 ++++++++ .../notes/bgpvpn-list-filters-e76183a7008c0631.yaml | 7 +++++++ 3 files changed, 28 insertions(+) create mode 100644 releasenotes/notes/bgpvpn-list-filters-e76183a7008c0631.yaml diff --git a/openstack/network/v2/bgpvpn.py b/openstack/network/v2/bgpvpn.py index 98de33208..03478c8e5 100644 --- a/openstack/network/v2/bgpvpn.py +++ b/openstack/network/v2/bgpvpn.py @@ -27,6 +27,19 @@ class BgpVpn(resource.Resource): allow_delete = True allow_list = True + _query_mapping = resource.QueryParameters( + 'name', + 'project_id', + 'local_pref', + 'vni', + 'type', + 'networks', + 'routers', + 'ports', + # NOTE(seba): (route|import|export) targets only support exact matches + # and have therefore been left out + ) + # Properties #: The Id of the BGPVPN id = resource.Body('id') diff --git a/openstack/tests/unit/network/v2/test_bgpvpn.py b/openstack/tests/unit/network/v2/test_bgpvpn.py index c6e4671e0..0aba1fefb 100644 --- a/openstack/tests/unit/network/v2/test_bgpvpn.py +++ b/openstack/tests/unit/network/v2/test_bgpvpn.py @@ -62,6 +62,14 @@ class TestBgpVpn(base.TestCase): { 'limit': 'limit', 'marker': 'marker', + 'local_pref': 'local_pref', + 'name': 'name', + 'networks': 'networks', + 'routers': 'routers', + 'ports': 'ports', + 'project_id': 'project_id', + 'type': 'type', + 'vni': 'vni', }, sot._query_mapping._mapping, ) diff --git a/releasenotes/notes/bgpvpn-list-filters-e76183a7008c0631.yaml b/releasenotes/notes/bgpvpn-list-filters-e76183a7008c0631.yaml new file mode 100644 index 000000000..4eb359e9b --- /dev/null +++ b/releasenotes/notes/bgpvpn-list-filters-e76183a7008c0631.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + ``openstack.network.v2.bgpvpn.BgpVpn`` can now be filtered by its + associations to `networks`, `routers` and `ports. Additionally, + filtering for the attributes `name`, `project_id`, `local_pref`, `vni` + and `type` is now done on server-side.