~ubuntu-branches/ubuntu/saucy/horizon/saucy-security

« back to all changes in this revision

Viewing changes to openstack_dashboard/api/cinder.py

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2013-09-06 11:59:43 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20130906115943-h3td0l7tp16mb9oc
Tags: 1:2013.2~b3-0ubuntu1
* New upstream release.
* debian/control: Minimum python-openstack-auth version >= 1.1.1.
* debian/control: Add python-troveclient.
* debian/static: Refresh static assets for 2013.2~b3.
* debian/patches: ubuntu_local_settings.patch -> ubuntu_settings.patch, also
  patch location of secret key in openstack_dashboard/settings.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
import logging
26
26
 
27
 
from django.conf import settings
28
 
from django.utils.translation import ugettext_lazy as _
 
27
from django.conf import settings  # noqa
 
28
from django.utils.translation import ugettext_lazy as _  # noqa
29
29
 
30
30
from cinderclient.v1 import client as cinder_client
31
31
 
32
32
from horizon import exceptions
33
33
 
34
 
from openstack_dashboard.api.base import QuotaSet
35
 
from openstack_dashboard.api.base import url_for
 
34
from openstack_dashboard.api import base
36
35
from openstack_dashboard.api import nova
37
36
 
38
37
LOG = logging.getLogger(__name__)
40
39
 
41
40
# API static values
42
41
VOLUME_STATE_AVAILABLE = "available"
 
42
DEFAULT_QUOTA_NAME = 'default'
43
43
 
44
44
 
45
45
def cinderclient(request):
46
46
    insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
 
47
    cacert = getattr(settings, 'OPENSTACK_SSL_CACERT', None)
47
48
    cinder_url = ""
48
49
    try:
49
 
        cinder_url = url_for(request, 'volume')
 
50
        cinder_url = base.url_for(request, 'volume')
50
51
    except exceptions.ServiceCatalogException:
51
52
        LOG.debug('no volume service configured.')
52
53
        return None
57
58
                             project_id=request.user.tenant_id,
58
59
                             auth_url=cinder_url,
59
60
                             insecure=insecure,
 
61
                             cacert=cacert,
60
62
                             http_log_debug=settings.DEBUG)
61
63
    c.client.auth_token = request.user.token.id
62
64
    c.client.management_url = cinder_url
123
125
def tenant_quota_get(request, tenant_id):
124
126
    c_client = cinderclient(request)
125
127
    if c_client is None:
126
 
        return QuotaSet()
127
 
    return QuotaSet(c_client.quotas.get(tenant_id))
 
128
        return base.QuotaSet()
 
129
    return base.QuotaSet(c_client.quotas.get(tenant_id))
128
130
 
129
131
 
130
132
def tenant_quota_update(request, tenant_id, **kwargs):
132
134
 
133
135
 
134
136
def default_quota_get(request, tenant_id):
135
 
    return QuotaSet(cinderclient(request).quotas.defaults(tenant_id))
 
137
    return base.QuotaSet(cinderclient(request).quotas.defaults(tenant_id))
 
138
 
 
139
 
 
140
def default_quota_update(request, **kwargs):
 
141
    cinderclient(request).quota_classes.update(DEFAULT_QUOTA_NAME, **kwargs)
136
142
 
137
143
 
138
144
def volume_type_list(request):