Fix manila endpoint in catalog not find error

This issue occurs when we list share without add manilav1 endpoint,
there will be "could not find Manila endpoint in catalog".

Since manilav1 has been deprecated for a couple of releases, so there
is no need to add manilav1 endpoint when using manila v2 API.

This change is to fix it without add manilav1 endpoint, we can also
perform manila command with manilav2 endpoint when using manila v2
API.

Change-Id: I68b499e153e1aba3a5a285f07d71e31b6af65bca
Closes-Bug: #1558995
Closes-Bug: #1734016
This commit is contained in:
junboli 2018-02-26 10:32:26 +08:00
parent 244b676bc7
commit caf07cabf3
3 changed files with 20 additions and 4 deletions

View File

@ -42,6 +42,7 @@ from manilaclient.v2 import shell as shell_v2
DEFAULT_OS_SHARE_API_VERSION = api_versions.MAX_VERSION
DEFAULT_MANILA_ENDPOINT_TYPE = 'publicURL'
DEFAULT_MAJOR_OS_SHARE_API_VERSION = "2"
V1_MAJOR_VERSION = '1'
V2_MAJOR_VERSION = '2'
@ -496,7 +497,18 @@ class OpenStackManilaShell(object):
self.do_bash_completion(args)
return 0
if not options.os_share_api_version:
api_version = api_versions.get_api_version(
DEFAULT_MAJOR_OS_SHARE_API_VERSION)
else:
api_version = api_versions.get_api_version(
options.os_share_api_version)
major_version_string = six.text_type(api_version.ver_major)
os_service_type = args.service_type
if not os_service_type:
os_service_type = constants.SERVICE_TYPES[major_version_string]
os_endpoint_type = args.endpoint_type or DEFAULT_MANILA_ENDPOINT_TYPE
client_args = dict(
@ -509,7 +521,7 @@ class OpenStackManilaShell(object):
tenant_id=args.os_project_id or args.os_tenant_id,
endpoint_type=os_endpoint_type,
extensions=self.extensions,
service_type=constants.V1_SERVICE_TYPE,
service_type=os_service_type,
service_name=args.service_name,
retries=options.retries,
http_log_debug=args.debug,

View File

@ -119,7 +119,7 @@ class OpenstackManilaShellTest(utils.TestCase):
tenant_id=env_vars['OS_PROJECT_ID'],
endpoint_type='publicURL',
extensions=mock.ANY,
service_type=constants.V1_SERVICE_TYPE,
service_type=constants.V2_SERVICE_TYPE,
service_name='',
retries=0,
http_log_debug=False,
@ -191,7 +191,7 @@ class OpenstackManilaShellTest(utils.TestCase):
tenant_id="",
endpoint_type="publicURL",
extensions=mock.ANY,
service_type=constants.V1_SERVICE_TYPE,
service_type=constants.V2_SERVICE_TYPE,
service_name="",
retries=0,
http_log_debug=False,
@ -270,7 +270,7 @@ class OpenstackManilaShellTest(utils.TestCase):
tenant_id="",
endpoint_type=expected["os_endpoint_type"],
extensions=mock.ANY,
service_type=constants.V1_SERVICE_TYPE,
service_type=constants.V2_SERVICE_TYPE,
service_name="",
retries=0,
http_log_debug=False,

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Fix endpoint not found error when only the manilav2 endpoint is configured.