cFouts 3cd57eb32e Fix client API version to support Manila API
The Manila client's API version is now '2.5' so that it matches the
Manila server's API version.

The client also supports the Manila V2 Keystone endpoint such that it
will only communicate with the Manila V2 API.

Closes-bug: 1494360

Change-Id: I3d011046bbe4f9223d93341f3d3ac09074f52990
2015-09-14 01:07:07 +00:00

50 lines
1.5 KiB
Python

# Copyright 2010 Jacob Kaplan-Moss
# Copyright 2011 OpenStack LLC.
# Copyright 2011 Piston Cloud Computing, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
OpenStack Client interface. Handles the REST calls and responses.
"""
from oslo_utils import importutils
from manilaclient import exceptions
def get_client_class(version):
version_map = {
'1': 'manilaclient.v1.client.Client',
'2': 'manilaclient.v1.client.Client',
}
try:
client_path = version_map[str(version)]
except (KeyError, ValueError):
msg = "Invalid client version '%s'. must be one of: %s" % (
(version, ', '.join(version_map)))
raise exceptions.UnsupportedVersion(msg)
return importutils.import_class(client_path)
def get_major_version(version):
return version.split('.')[0]
def Client(version, *args, **kwargs):
client_class = get_client_class(get_major_version(version))
return client_class(*args, **kwargs)