Fixes LP bug 872684 -- Use service catalog instead of settings.SWIFT_ENABLED

This commit is contained in:
Gabriel Hurley
2011-10-11 23:16:35 -07:00
parent 601fc1b716
commit 81f540728a
8 changed files with 42 additions and 13 deletions

View File

@@ -36,8 +36,10 @@ def tenants(request):
return {'tenants': []}
def swift(request):
return {'swift_configured': settings.SWIFT_ENABLED}
def object_store(request):
catalog = getattr(request.user, 'service_catalog', [])
object_store = catalog and api.get_service_from_catalog(catalog, 'object-store')
return {'object_store_configured': object_store}
def quantum(request):

View File

@@ -62,7 +62,6 @@ class SelectDateWidget(widgets.Widget):
self.years = range(this_year, this_year + 10)
def render(self, name, value, attrs=None, skip_day_field=True):
print "Render %s %s" % (name, value)
try:
year_val, month_val, day_val = value.year, value.month, value.day
except AttributeError:

View File

@@ -14,13 +14,13 @@
<li><a {% if current_sidebar == "networks" %} class="active" {% endif %} href="{% url dash_networks request.user.tenant_id %}">Networks</a></li>
{% endif %}
</ul>
{% if swift_configured %}
{% if object_store_configured %}
<h3>Manage Object Store</h3>
<ul class='sub_nav'>
<li><a {% if current_sidebar == "containers" %} class="active" {% endif %} href="{% url dash_containers request.user.tenant_id %}">Containers</a></li>
</ul>
{% endif %}
{% dash_sidebar_modules request %}
</div>

View File

@@ -55,7 +55,7 @@ class TestCase(test.TestCase):
"adminURL": "http://glance/glanceapi/admin",
"region": "RegionOne",
"internalURL": "http://glance/glanceapi/internal",
"publicURL": "http://glance/glanceapi/piblic"
"publicURL": "http://glance/glanceapi/public"
}],
"type": "image",
"name": "glance"
@@ -68,6 +68,15 @@ class TestCase(test.TestCase):
}],
"type": "identity",
"name": "identity"
}, {
"endpoints": [{
"adminURL": "http://swift/swiftapi/admin",
"region": "RegionOne",
"internalURL": "http://swift/swiftapi/internal",
"publicURL": "http://swift/swiftapi/public"
}],
"type": "object-store",
"name": "swift"
}]
def setUp(self):

View File

@@ -423,7 +423,7 @@ class AccountApiTests(test.TestCase):
self.mox.ReplayAll()
ret_val = api.tenant_update(self.request, TEST_TENANT_ID,
ret_val = api.tenant_update(self.request, TEST_TENANT_ID,
TEST_TENANT_NAME, DESCRIPTION, ENABLED)
self.assertIsInstance(ret_val, api.Tenant)

View File

@@ -0,0 +1,23 @@
from django_openstack import context_processors, test
class ContextProcessorTests(test.TestCase):
def setUp(self):
super(ContextProcessorTests, self).setUp()
self._prev_catalog = self.request.user.service_catalog
def tearDown(self):
super(ContextProcessorTests, self).tearDown()
self.request.user.service_catalog = self._prev_catalog
def test_object_store(self):
# Returns the object store service data when it's in the catalog
object_store = context_processors.object_store(self.request)
self.assertNotEqual(None, object_store['object_store_configured'])
# Returns None when the object store is not in the catalog
new_catalog = [service for service in self.request.user.service_catalog
if service['type'] != 'object-store']
self.request.user.service_catalog = new_catalog
object_store = context_processors.object_store(self.request)
self.assertEqual(None, object_store['object_store_configured'])

View File

@@ -65,7 +65,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.contrib.messages.context_processors.messages',
'django_openstack.context_processors.swift',
'django_openstack.context_processors.object_store',
'django_openstack.context_processors.tenants',
'django_openstack.context_processors.quantum',
)

View File

@@ -37,10 +37,6 @@ OPENSTACK_KEYSTONE_URL = "http://localhost:5000/v2.0/"
OPENSTACK_KEYSTONE_ADMIN_URL = "http://localhost:35357/v2.0"
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "Member"
# NOTE(tres): Available services should come from the service
# catalog in Keystone.
SWIFT_ENABLED = False
# Configure quantum connection details for networking
QUANTUM_ENABLED = True
QUANTUM_URL = '127.0.0.1'