# Copyright 2012 OpenStack Foundation.
# 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.
#

from neutronclient.common import exceptions
from neutronclient.common import utils
from neutronclient.i18n import _


API_NAME = 'network'
API_VERSIONS = {
    '2.0': 'neutronclient.v2_0.client.Client',
}


def make_client(instance):
    """Returns an neutron client."""
    neutron_client = utils.get_client_class(
        API_NAME,
        instance._api_version[API_NAME],
        API_VERSIONS,
    )
    instance.initialize()
    url = instance._url
    url = url.rstrip("/")
    if '2.0' == instance._api_version[API_NAME]:
        client = neutron_client(username=instance._username,
                                tenant_name=instance._tenant_name,
                                password=instance._password,
                                region_name=instance._region_name,
                                auth_url=instance._auth_url,
                                endpoint_url=url,
                                endpoint_type=instance._endpoint_type,
                                token=instance._token,
                                auth_strategy=instance._auth_strategy,
                                insecure=instance._insecure,
                                ca_cert=instance._ca_cert,
                                retries=instance._retries,
                                raise_errors=instance._raise_errors,
                                session=instance._session,
                                auth=instance._auth)
        return client
    else:
        raise exceptions.UnsupportedVersion(_("API version %s is not "
                                              "supported") %
                                            instance._api_version[API_NAME])


def Client(api_version, *args, **kwargs):
    """Return an neutron client.

    @param api_version: only 2.0 is supported now
    """
    neutron_client = utils.get_client_class(
        API_NAME,
        api_version,
        API_VERSIONS,
    )
    return neutron_client(*args, **kwargs)

@@ -668,90 +668,13 @@
 ort 
-exceptions%0Afrom neutronclient.common import utils%0Afrom neutronclient.i18n import _
+utils
 %0A%0A%0AA
@@ -757,16 +757,61 @@
 lient',%0A
+    '2': 'neutronclient.v2_0.client.Client',%0A
 %7D%0A%0A%0Adef 
@@ -1082,61 +1082,8 @@
 /%22)%0A
-    if '2.0' == instance._api_version%5BAPI_NAME%5D:%0A    
     
@@ -1163,20 +1163,16 @@
         
-    
 tenant_n
@@ -1226,20 +1226,16 @@
         
-    
 password
@@ -1283,20 +1283,16 @@
         
-  
-  
 region_n
@@ -1342,28 +1342,24 @@
             
-    
 auth_url=ins
@@ -1371,28 +1371,24 @@
 ._auth_url,%0A
-    
             
@@ -1441,36 +1441,32 @@
                 
-    
 endpoint_type=in
@@ -1516,20 +1516,16 @@
         
-    
 token=in
@@ -1563,28 +1563,24 @@
             
-  
-  
 auth_strateg
@@ -1606,20 +1606,16 @@
 rategy,%0A
-    
         
@@ -1691,20 +1691,16 @@
         
-    
 ca_cert=
@@ -1746,20 +1746,16 @@
         
- 
-   
 retries=
@@ -1773,20 +1773,16 @@
 etries,%0A
-    
         
@@ -1866,20 +1866,16 @@
         
-   
- 
 session=
@@ -1917,28 +1917,24 @@
             
-    
 auth=instanc
@@ -1942,20 +1942,16 @@
 ._auth)%0A
-    
     retu
@@ -1964,227 +1964,8 @@
 ent%0A
-    else:%0A        raise exceptions.UnsupportedVersion(_(%22API version %25s is not %22%0A                                              %22supported%22) %25%0A                                            instance._api_version%5BAPI_NAME%5D)%0A
 %0A%0Ade

Allow passing version as '2' as well as '2.0'