# Path: zaqarclient/auth/base.py
# class AuthBackend(object):
# class NoAuth(AuthBackend):
#     def __init__(self, conf):
#     def authenticate(self, api_version, request):
#     def authenticate(self, api_version, req):
# 
# Path: zaqarclient/errors.py
# class ZaqarError(Exception):
# class DriverLoadFailure(ZaqarError):
# class InvalidOperation(ZaqarError):
# class UnsupportedVersion(ZaqarError):
#     def __init__(self, driver, ex):


import six.moves.urllib.parse as urlparse
from keystoneauth1 import discover
from keystoneauth1 import exceptions as ka_exc
from keystoneauth1.identity import v2 as v2_auth
from keystoneauth1.identity import v3 as v3_auth
from keystoneauth1 import session
from zaqarclient.auth import base
from zaqarclient import errors
        else:
            raise errors.ZaqarError('Unable to determine the Keystone version '
                                    'to authenticate with using the given '
                                    'auth_url.')

        ks_session.auth = auth
        return ks_session

    def _discover_auth_versions(self, session, auth_url):
        # Discover the API versions the server is supporting based on the
        # given URL
        v2_auth_url = None
        v3_auth_url = None
        try:
            ks_discover = discover.Discover(session=session, url=auth_url)
            v2_auth_url = ks_discover.url_for('2.0')
            v3_auth_url = ks_discover.url_for('3.0')
        except ka_exc.DiscoveryFailure:
            raise
        except ka_exc.ClientException:
            # Identity service may not support discovery. In that case,
            # try to determine version from auth_url
            url_parts = urlparse.urlparse(auth_url)
            (scheme, netloc, path, params, query, fragment) = url_parts
            path = path.lower()
            if path.startswith('/v3'):
                v3_auth_url = auth_url
            elif path.startswith('/v2'):
                v2_auth_url = auth_url
            else:

# Path: zaqarclient/auth/base.py
# class AuthBackend(object):
# class NoAuth(AuthBackend):
#     def __init__(self, conf):
#     def authenticate(self, api_version, request):
#     def authenticate(self, api_version, req):
# 
# Path: zaqarclient/errors.py
# class ZaqarError(Exception):
# class DriverLoadFailure(ZaqarError):
# class InvalidOperation(ZaqarError):
# class UnsupportedVersion(ZaqarError):
#     def __init__(self, driver, ex):


# Path: zaqarclient/auth/keystone.py
import six.moves.urllib.parse as urlparse
from keystoneauth1 import discover
from keystoneauth1 import exceptions as ka_exc
from keystoneauth1.identity import v2 as v2_auth
from keystoneauth1.identity import v3 as v3_auth
from keystoneauth1 import session
from zaqarclient.auth import base
from zaqarclient import errors

        else:
            raise errors.ZaqarError('Unable to determine the Keystone version '
                                    'to authenticate with using the given '
                                    'auth_url.')

        ks_session.auth = auth
        return ks_session

    def _discover_auth_versions(self, session, auth_url):
        # Discover the API versions the server is supporting based on the
        # given URL
        v2_auth_url = None
        v3_auth_url = None
        try:
            ks_discover = discover.Discover(session=session, url=auth_url)
            v2_auth_url = ks_discover.url_for('2.0')
            v3_auth_url = ks_discover.url_for('3.0')
        except ka_exc.DiscoveryFailure:
            raise
        except ka_exc.ClientException:
            # Identity service may not support discovery. In that case,
            # try to determine version from auth_url
            url_parts = urlparse.urlparse(auth_url)
            (scheme, netloc, path, params, query, fragment) = url_parts
            path = path.lower()
            if path.startswith('/v3'):
                v3_auth_url = auth_url
            elif path.startswith('/v2'):
                v2_auth_url = auth_url
            else:

                raise errors.ZaqarError('Unable to determine the Keystone '