From bb847614445bb755dacc6e908bea26b8c025fbec Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Date: Fri, 13 Sep 2024 17:11:56 -0300 Subject: [PATCH] Support filtering services by ensuring field This change implements an additional filter option to the `openstack share service list` command, following the recently added `ensuring` field in the services entity. Change-Id: Iadffe9307861aba042ed65ea29506ca648437b23 Signed-off-by: Carlos da Silva --- manilaclient/api_versions.py | 2 +- manilaclient/osc/v2/services.py | 17 ++++++++++++++++- ...ng-filter-for-services-eedbead009d3505f.yaml | 5 +++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/add-ensuring-filter-for-services-eedbead009d3505f.yaml diff --git a/manilaclient/api_versions.py b/manilaclient/api_versions.py index 73601af29..de0014b26 100644 --- a/manilaclient/api_versions.py +++ b/manilaclient/api_versions.py @@ -27,7 +27,7 @@ from manilaclient import utils LOG = logging.getLogger(__name__) -MAX_VERSION = '2.92' +MAX_VERSION = '2.93' MIN_VERSION = '2.0' DEPRECATED_VERSION = '1.0' _VERSIONED_METHOD_MAP = {} diff --git a/manilaclient/osc/v2/services.py b/manilaclient/osc/v2/services.py index 4206dcac9..757eeca4f 100644 --- a/manilaclient/osc/v2/services.py +++ b/manilaclient/osc/v2/services.py @@ -138,6 +138,13 @@ class ListShareService(command.Lister): default=None, help=_("Filter services by their availability zone."), ) + parser.add_argument( + "--ensuring", + metavar="", + choices=['True', 'False'], + default=None, + help=_("Filter services running ensure shares or not."), + ) return parser def take_action(self, parsed_args): @@ -150,6 +157,14 @@ class ListShareService(command.Lister): 'state': parsed_args.state, 'zone': parsed_args.zone, } + if parsed_args.ensuring: + if share_client.api_version < api_versions.APIVersion("2.93"): + raise exceptions.CommandError( + "Filtering services whether they are running ensure " + "shares or not is only supported by manila API version " + ">= 2.93" + ) + search_opts['ensuring'] = parsed_args.ensuring services = share_client.services.list(search_opts=search_opts) @@ -164,7 +179,7 @@ class ListShareService(command.Lister): ] if share_client.api_version >= api_versions.APIVersion("2.83"): columns.append('Disabled Reason') - if share_client.api_version >= api_versions.APIVersion("2.86"): + if share_client.api_version >= api_versions.APIVersion("2.93"): columns.append('Ensuring') data = ( diff --git a/releasenotes/notes/add-ensuring-filter-for-services-eedbead009d3505f.yaml b/releasenotes/notes/add-ensuring-filter-for-services-eedbead009d3505f.yaml new file mode 100644 index 000000000..3f560b6c1 --- /dev/null +++ b/releasenotes/notes/add-ensuring-filter-for-services-eedbead009d3505f.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + It is now possible to filter services that have their status set to + `ensuring` with a new option in the `service list` command.