Silence warnings from openstacksdk

OSC has historically relied on project-specific clients like novaclient
for library bindings. These did not support auto-negotiation of
versions. Instead, users were advised to set the requested microversion
to e.g. '2.latest' to opt into the latest API version supported by the
client.

We're slowly migrating everything to SDK which *does* support
auto-negotiation (well, of sorts). This makes versions like '2.latest'
unecessary and SDK correctly warns the user about this.

  You have a configured API_VERSION with 'latest' in it. In the context
  of openstacksdk this doesn't make any sense.

Unfortunately, we have not yet migrated all commands to SDK, meaning we
have a mix of SDK and legacy client-based commands. So long as there are
any command using the legacy client, we can't insist on users removing
this configuration. This makes the warning both annoying and something
the user can't do anything about. We also don't want to remove the
warning from SDK so instead we opt to filter it out, along with all
other warnings from openstacksdk (which similarly a user can't do
anything about).

Change-Id: If8a7cf9bc876f84864d66f5aed5f2f61c5d0696a
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2023-02-20 17:02:00 +00:00
parent 864f51f427
commit 23da7b73a2

@ -17,6 +17,7 @@
"""Command-line interface to the OpenStack APIs"""
import sys
import warnings
from osc_lib.api import auth
from osc_lib.command import commandmanager
@ -44,6 +45,10 @@ class OpenStackShell(shell.OpenStackShell):
# Assume TLS host certificate verification is enabled
self.verify = True
# ignore warnings from openstacksdk since our users can't do anything
# about them
warnings.filterwarnings('ignore', module='openstack')
def build_option_parser(self, description, version):
parser = super(OpenStackShell, self).build_option_parser(
description,