Switch to using cinderclient.

This is practically a transparent switch since it was
copied out of novaclient and maintains API compatibility.

NOTE: this will fail until python-cinderclient is published
to PyPI properly.

Implements blueprint switch-to-cinder-client

Change-Id: Ic8cd6660735e172ff5d3402952265a15dc15f9e5
This commit is contained in:
Gabriel Hurley 2012-08-13 18:28:42 -07:00
parent acb0516548
commit 0cd51d5c28
3 changed files with 13 additions and 5 deletions

View File

@ -27,6 +27,8 @@ import logging
from django.conf import settings
from django.utils.translation import ugettext as _
from cinderclient.v1 import client as cinder_client
from novaclient.v1_1 import client as nova_client
from novaclient.v1_1 import security_group_rules as nova_rules
from novaclient.v1_1.security_groups import SecurityGroup as NovaSecurityGroup
@ -210,11 +212,11 @@ def cinderclient(request):
insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
LOG.debug('cinderclient connection created using token "%s" and url "%s"' %
(request.user.token.id, url_for(request, 'volume')))
c = nova_client.Client(request.user.username,
request.user.token.id,
project_id=request.user.tenant_id,
auth_url=url_for(request, 'volume'),
insecure=insecure)
c = cinder_client.Client(request.user.username,
request.user.token.id,
project_id=request.user.tenant_id,
auth_url=url_for(request, 'volume'),
insecure=insecure)
c.client.auth_token = request.user.token.id
c.client.management_url = url_for(request, 'volume')
return c

View File

@ -18,6 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from cinderclient import exceptions as cinderclient
from glanceclient.common import exceptions as glanceclient
from keystoneclient import exceptions as keystoneclient
from novaclient import exceptions as novaclient
@ -27,6 +28,8 @@ from swiftclient import client as swiftclient
UNAUTHORIZED = (keystoneclient.Unauthorized,
keystoneclient.Forbidden,
cinderclient.Unauthorized,
cinderclient.Forbidden,
novaclient.Unauthorized,
novaclient.Forbidden,
glanceclient.Unauthorized,
@ -34,6 +37,7 @@ UNAUTHORIZED = (keystoneclient.Unauthorized,
quantumclient.Forbidden)
NOT_FOUND = (keystoneclient.NotFound,
cinderclient.NotFound,
novaclient.NotFound,
glanceclient.NotFound,
quantumclient.NetworkNotFoundClient,
@ -43,6 +47,7 @@ NOT_FOUND = (keystoneclient.NotFound,
RECOVERABLE = (keystoneclient.ClientException,
# AuthorizationFailure is raised when Keystone is "unavailable".
keystoneclient.AuthorizationFailure,
cinderclient.ClientException,
novaclient.ClientException,
glanceclient.ClientException,
# NOTE(amotoki): Quantum exceptions other than the first one

View File

@ -2,6 +2,7 @@
Django>=1.4
django_compressor
django_openstack_auth
python-cinderclient
python-glanceclient<2
python-keystoneclient
python-novaclient