Skip to content

Commit 3cad254

Browse files
stephenfinSilviaWachira
authored andcommitted
share: Fix nits in client creation
A follow-up to Ibb369de02e2e8de4d8925c3d6d11a8b7006c377f with the following changes: * Add a comment explaining why we're deferring imports * Use the cached API version if available * Reorder imports * Bump the minimum version of manilaclient, allowing us to remove a workaround for single digit version numbers Change-Id: Ief08df571074bbe7f914dd10cb1a292f18daf881 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent e94c73c commit 3cad254

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

openstackclient/share/client.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
import logging
1717
from typing import TYPE_CHECKING, Any
1818

19-
if TYPE_CHECKING:
20-
from manilaclient import client
21-
2219
from osc_lib import exceptions
2320
from osc_lib import utils
2421

2522
from openstackclient.i18n import _
2623

24+
if TYPE_CHECKING:
25+
from manilaclient import client
26+
2727
LOG = logging.getLogger(__name__)
2828

2929
# global variables used when building the shell
@@ -37,16 +37,16 @@
3737

3838
def make_client(instance: Any) -> 'client.Client':
3939
"""Returns a manilaclient.client.Client instance."""
40-
from manilaclient import api_versions
40+
# Defer client imports until we actually need them
4141
from manilaclient import client
4242

43-
check_version = instance._api_version[API_NAME]
44-
if check_version.isdigit():
45-
check_version = f"{check_version}.0"
46-
47-
version = api_versions.get_api_version(check_version)
43+
if _share_api_version is not None:
44+
version = _share_api_version
45+
else:
46+
from manilaclient import api_versions
4847

49-
instance.setup_auth()
48+
check_version = instance._api_version[API_NAME]
49+
version = api_versions.get_api_version(check_version)
5050

5151
LOG.debug('Instantiating Shared File System client: %s', client.Client)
5252
LOG.debug('Shared File System API version: %s', version)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ osc-lib>=4.6.0 # Apache-2.0
1010
oslo.i18n>=3.15.3 # Apache-2.0
1111
python-keystoneclient>=3.22.0 # Apache-2.0
1212
python-cinderclient>=3.3.0 # Apache-2.0
13-
python-manilaclient>=5.7.0 # Apache-2.0
13+
python-manilaclient>=6.0.0 # Apache-2.0
1414
requests>=2.27.0 # Apache-2.0
1515
stevedore>=2.0.1 # Apache-2.0

0 commit comments

Comments
 (0)