Allow passing version as '2' as well as '2.0'
Currently python-neutronclient and python-openstackclient have different views of what OS_NETWORK_API_VERSION should be. Rather than fighting a land war, how about we make both things accept both things, since it's generally understandable by humans that '2' and '2.0' are the same thing. Change-Id: Ibf3c14e15b19c1aca696ce5c693588565a73a524
This commit is contained in:

committed by
Akihiro Motoki

parent
88010add39
commit
074fb3d536
@@ -14,14 +14,13 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from neutronclient.common import exceptions
|
|
||||||
from neutronclient.common import utils
|
from neutronclient.common import utils
|
||||||
from neutronclient.i18n import _
|
|
||||||
|
|
||||||
|
|
||||||
API_NAME = 'network'
|
API_NAME = 'network'
|
||||||
API_VERSIONS = {
|
API_VERSIONS = {
|
||||||
'2.0': 'neutronclient.v2_0.client.Client',
|
'2.0': 'neutronclient.v2_0.client.Client',
|
||||||
|
'2': 'neutronclient.v2_0.client.Client',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -35,27 +34,22 @@ def make_client(instance):
|
|||||||
instance.initialize()
|
instance.initialize()
|
||||||
url = instance._url
|
url = instance._url
|
||||||
url = url.rstrip("/")
|
url = url.rstrip("/")
|
||||||
if '2.0' == instance._api_version[API_NAME]:
|
client = neutron_client(username=instance._username,
|
||||||
client = neutron_client(username=instance._username,
|
tenant_name=instance._tenant_name,
|
||||||
tenant_name=instance._tenant_name,
|
password=instance._password,
|
||||||
password=instance._password,
|
region_name=instance._region_name,
|
||||||
region_name=instance._region_name,
|
auth_url=instance._auth_url,
|
||||||
auth_url=instance._auth_url,
|
endpoint_url=url,
|
||||||
endpoint_url=url,
|
endpoint_type=instance._endpoint_type,
|
||||||
endpoint_type=instance._endpoint_type,
|
token=instance._token,
|
||||||
token=instance._token,
|
auth_strategy=instance._auth_strategy,
|
||||||
auth_strategy=instance._auth_strategy,
|
insecure=instance._insecure,
|
||||||
insecure=instance._insecure,
|
ca_cert=instance._ca_cert,
|
||||||
ca_cert=instance._ca_cert,
|
retries=instance._retries,
|
||||||
retries=instance._retries,
|
raise_errors=instance._raise_errors,
|
||||||
raise_errors=instance._raise_errors,
|
session=instance._session,
|
||||||
session=instance._session,
|
auth=instance._auth)
|
||||||
auth=instance._auth)
|
return client
|
||||||
return client
|
|
||||||
else:
|
|
||||||
raise exceptions.UnsupportedVersion(_("API version %s is not "
|
|
||||||
"supported") %
|
|
||||||
instance._api_version[API_NAME])
|
|
||||||
|
|
||||||
|
|
||||||
def Client(api_version, *args, **kwargs):
|
def Client(api_version, *args, **kwargs):
|
||||||
|
Reference in New Issue
Block a user